Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | |
| 3 | #include "context_arm.h" |
| 4 | |
| 5 | #include "object.h" |
Brian Carlstrom | 6f495f2 | 2011-10-10 15:05:03 -0700 | [diff] [blame] | 6 | #include "runtime_support.h" |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 7 | |
| 8 | namespace art { |
| 9 | namespace arm { |
| 10 | |
| 11 | ArmContext::ArmContext() { |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 12 | #ifndef NDEBUG |
Ian Rogers | ad42e13 | 2011-09-17 20:23:33 -0700 | [diff] [blame] | 13 | // Initialize registers with easy to spot debug values |
Elliott Hughes | 362f9bc | 2011-10-17 18:56:41 -0700 | [diff] [blame^] | 14 | for (int i = 0; i < 16; i++) { |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 15 | gprs_[i] = 0xEBAD6070+i; |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 16 | } |
Elliott Hughes | 362f9bc | 2011-10-17 18:56:41 -0700 | [diff] [blame^] | 17 | for (int i = 0; i < 32; i++) { |
Ian Rogers | 15fdb8c | 2011-09-25 15:45:07 -0700 | [diff] [blame] | 18 | fprs_[i] = 0xEBAD8070+i; |
| 19 | } |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 20 | #endif |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | void ArmContext::FillCalleeSaves(const Frame& fr) { |
| 24 | Method* method = fr.GetMethod(); |
| 25 | uint32_t core_spills = method->GetCoreSpillMask(); |
Ian Rogers | 15fdb8c | 2011-09-25 15:45:07 -0700 | [diff] [blame] | 26 | uint32_t fp_core_spills = method->GetFpSpillMask(); |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 27 | size_t spill_count = __builtin_popcount(core_spills); |
Ian Rogers | 15fdb8c | 2011-09-25 15:45:07 -0700 | [diff] [blame] | 28 | size_t fp_spill_count = __builtin_popcount(fp_core_spills); |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 29 | if (spill_count > 0) { |
| 30 | // Lowest number spill is furthest away, walk registers and fill into context |
| 31 | int j = 1; |
Elliott Hughes | 362f9bc | 2011-10-17 18:56:41 -0700 | [diff] [blame^] | 32 | for (int i = 0; i < 16; i++) { |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 33 | if (((core_spills >> i) & 1) != 0) { |
| 34 | gprs_[i] = fr.LoadCalleeSave(spill_count - j); |
| 35 | j++; |
| 36 | } |
| 37 | } |
| 38 | } |
Ian Rogers | 15fdb8c | 2011-09-25 15:45:07 -0700 | [diff] [blame] | 39 | if (fp_spill_count > 0) { |
| 40 | // Lowest number spill is furthest away, walk registers and fill into context |
| 41 | int j = 1; |
Elliott Hughes | 362f9bc | 2011-10-17 18:56:41 -0700 | [diff] [blame^] | 42 | for (int i = 0; i < 32; i++) { |
Ian Rogers | 15fdb8c | 2011-09-25 15:45:07 -0700 | [diff] [blame] | 43 | if (((fp_core_spills >> i) & 1) != 0) { |
| 44 | fprs_[i] = fr.LoadCalleeSave(spill_count + fp_spill_count - j); |
| 45 | j++; |
| 46 | } |
| 47 | } |
| 48 | } |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | void ArmContext::DoLongJump() { |
Elliott Hughes | 85d1545 | 2011-09-16 17:33:01 -0700 | [diff] [blame] | 52 | #if defined(__arm__) |
Brian Carlstrom | 6f495f2 | 2011-10-10 15:05:03 -0700 | [diff] [blame] | 53 | art_do_long_jump(&gprs_[0], &fprs_[S0]); |
Elliott Hughes | 85d1545 | 2011-09-16 17:33:01 -0700 | [diff] [blame] | 54 | #else |
| 55 | UNIMPLEMENTED(FATAL); |
| 56 | #endif |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | } // namespace arm |
| 60 | } // namespace art |