OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. |
6 #if defined(TARGET_ARCH_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
7 | 7 |
8 #include "vm/constants_mips.h" | 8 #include "vm/constants_mips.h" |
9 #include "vm/instructions.h" | 9 #include "vm/instructions.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
11 | 11 |
12 namespace dart { | 12 namespace dart { |
13 | 13 |
14 CallPattern::CallPattern(uword pc, const Code& code) | 14 CallPattern::CallPattern(uword pc, const Code& code) |
15 : end_(reinterpret_cast<uword*>(pc)), | 15 : end_(reinterpret_cast<uword*>(pc)), |
16 pool_index_(DecodePoolIndex()), | 16 target_address_pool_index_(-1), |
17 object_pool_(Array::Handle(code.ObjectPool())) { } | 17 args_desc_load_end_(-1), |
| 18 args_desc_pool_index_(-1), |
| 19 ic_data_load_end_(-1), |
| 20 ic_data_pool_index_(-1), |
| 21 object_pool_(Array::Handle(code.ObjectPool())) { |
| 22 ASSERT(code.ContainsInstructionAt(pc)); |
| 23 ASSERT(Back(2) == 0x0020f809); // Last instruction: jalr RA, TMP(=R1) |
| 24 Register reg; |
| 25 // First end is 0 so that we begin from the delay slot of the jalr. |
| 26 args_desc_load_end_ = |
| 27 DecodeLoadWordFromPool(2, ®, &target_address_pool_index_); |
| 28 ASSERT(reg == TMP); |
| 29 } |
18 | 30 |
19 | 31 |
20 uword CallPattern::Back(int n) const { | 32 uword CallPattern::Back(int n) const { |
21 ASSERT(n > 0); | 33 ASSERT(n > 0); |
22 return *(end_ - n); | 34 return *(end_ - n); |
23 } | 35 } |
24 | 36 |
25 | 37 |
26 int CallPattern::DecodePoolIndex() { | 38 int CallPattern::DecodeLoadWordFromPool(int end, Register* reg, int* index) { |
| 39 ASSERT(end > 0); |
| 40 uword i = Back(++end); |
| 41 Instr* instr = Instr::At(reinterpret_cast<uword>(&i)); |
| 42 int offset = 0; |
| 43 if ((instr->OpcodeField() == LW) && (instr->RsField() == PP)) { |
| 44 offset = instr->SImmField(); |
| 45 *reg = instr->RtField(); |
| 46 } else { |
| 47 ASSERT(instr->OpcodeField() == LW); |
| 48 offset = instr->SImmField(); |
| 49 *reg = instr->RtField(); |
| 50 |
| 51 i = Back(++end); |
| 52 instr = Instr::At(reinterpret_cast<uword>(&i)); |
| 53 ASSERT(instr->OpcodeField() == SPECIAL); |
| 54 ASSERT(instr->FunctionField() == ADDU); |
| 55 ASSERT(instr->RdField() == *reg); |
| 56 ASSERT(instr->RsField() == *reg); |
| 57 ASSERT(instr->RtField() == PP); |
| 58 |
| 59 i = Back(++end); |
| 60 instr = Instr::At(reinterpret_cast<uword>(&i)); |
| 61 if (instr->OpcodeField() == LUI) { |
| 62 ASSERT(instr->RtField() == *reg); |
| 63 offset |= (instr->UImmField() << 16); |
| 64 } else { |
| 65 ASSERT(instr->OpcodeField() == ORI); |
| 66 ASSERT(instr->RtField() == *reg); |
| 67 offset |= instr->UImmField(); |
| 68 |
| 69 if (instr->RsField() != ZR) { |
| 70 ASSERT(instr->RsField() == *reg); |
| 71 i = Back(++end); |
| 72 instr = Instr::At(reinterpret_cast<uword>(&i)); |
| 73 ASSERT(instr->OpcodeField() == LUI); |
| 74 ASSERT(instr->RtField() == *reg); |
| 75 offset |= (instr->UImmField() << 16); |
| 76 } |
| 77 } |
| 78 } |
| 79 offset += kHeapObjectTag; |
| 80 ASSERT(Utils::IsAligned(offset, 4)); |
| 81 *index = (offset - Array::data_offset())/4; |
| 82 return end; |
| 83 } |
| 84 |
| 85 |
| 86 RawICData* CallPattern::IcData() { |
27 UNIMPLEMENTED(); | 87 UNIMPLEMENTED(); |
28 return 0; | 88 return NULL; |
| 89 } |
| 90 |
| 91 |
| 92 RawArray* CallPattern::ArgumentsDescriptor() { |
| 93 UNIMPLEMENTED(); |
| 94 return NULL; |
29 } | 95 } |
30 | 96 |
31 | 97 |
32 uword CallPattern::TargetAddress() const { | 98 uword CallPattern::TargetAddress() const { |
33 UNIMPLEMENTED(); | 99 ASSERT(target_address_pool_index_ >= 0); |
34 return 0; | 100 const Object& target_address = |
| 101 Object::Handle(object_pool_.At(target_address_pool_index_)); |
| 102 ASSERT(target_address.IsSmi()); |
| 103 // The address is stored in the object array as a RawSmi. |
| 104 return reinterpret_cast<uword>(target_address.raw()); |
35 } | 105 } |
36 | 106 |
37 | 107 |
38 void CallPattern::SetTargetAddress(uword target_address) const { | 108 void CallPattern::SetTargetAddress(uword target_address) const { |
39 UNIMPLEMENTED(); | 109 UNIMPLEMENTED(); |
40 } | 110 } |
41 | 111 |
42 | 112 |
43 JumpPattern::JumpPattern(uword pc) : pc_(pc) { } | 113 JumpPattern::JumpPattern(uword pc) : pc_(pc) { } |
44 | 114 |
(...skipping 11 matching lines...) Expand all Loading... |
56 | 126 |
57 | 127 |
58 void JumpPattern::SetTargetAddress(uword target_address) const { | 128 void JumpPattern::SetTargetAddress(uword target_address) const { |
59 UNIMPLEMENTED(); | 129 UNIMPLEMENTED(); |
60 } | 130 } |
61 | 131 |
62 } // namespace dart | 132 } // namespace dart |
63 | 133 |
64 #endif // defined TARGET_ARCH_MIPS | 134 #endif // defined TARGET_ARCH_MIPS |
65 | 135 |
OLD | NEW |