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/code_patcher.h" | 8 #include "vm/code_patcher.h" |
9 | 9 |
10 #include "vm/instructions.h" | 10 #include "vm/instructions.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 ASSERT(code.ContainsInstructionAt(return_address)); | 77 ASSERT(code.ContainsInstructionAt(return_address)); |
78 CallPattern static_call(return_address, code); | 78 CallPattern static_call(return_address, code); |
79 ICData& ic_data = ICData::Handle(); | 79 ICData& ic_data = ICData::Handle(); |
80 ic_data ^= static_call.IcData(); | 80 ic_data ^= static_call.IcData(); |
81 if (ic_data_result != NULL) { | 81 if (ic_data_result != NULL) { |
82 *ic_data_result = ic_data.raw(); | 82 *ic_data_result = ic_data.raw(); |
83 } | 83 } |
84 return ic_data.GetTargetAt(0); | 84 return ic_data.GetTargetAt(0); |
85 } | 85 } |
86 | 86 |
| 87 |
| 88 // This class pattern matches on a load from the object pool. Loading on |
| 89 // MIPS is complicated because it can take four possible different forms. |
| 90 // We match backwards from the end of the sequence so we can reuse the code |
| 91 // for matching object pool loads at calls. |
| 92 class EdgeCounter : public ValueObject { |
| 93 public: |
| 94 EdgeCounter(uword pc, const Code& code) |
| 95 : end_(pc - kAdjust), object_pool_(Array::Handle(code.ObjectPool())) { |
| 96 // An IsValid predicate is complicated and duplicates the code in the |
| 97 // decoding function. Instead we rely on decoding the pattern which |
| 98 // will assert partial validity. |
| 99 } |
| 100 |
| 101 RawObject* edge_counter() const { |
| 102 Register ignored; |
| 103 intptr_t index; |
| 104 InstructionPattern::DecodeLoadWordFromPool(end_, &ignored, &index); |
| 105 ASSERT(ignored == T0); |
| 106 return object_pool_.At(index); |
| 107 } |
| 108 |
| 109 private: |
| 110 // The object pool load is followed by the fixed-size edge counter |
| 111 // incrementing code: |
| 112 // lw r9, 11(r8) |
| 113 // addiu r9, r9, 2 |
| 114 // sw r9, 11(r8) |
| 115 static const intptr_t kAdjust = 3 * Instr::kInstrSize; |
| 116 |
| 117 uword end_; |
| 118 const Array& object_pool_; |
| 119 }; |
| 120 |
| 121 |
| 122 RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) { |
| 123 ASSERT(code.ContainsInstructionAt(pc)); |
| 124 EdgeCounter counter(pc, code); |
| 125 return counter.edge_counter(); |
| 126 } |
| 127 |
87 } // namespace dart | 128 } // namespace dart |
88 | 129 |
89 #endif // defined TARGET_ARCH_MIPS | 130 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |