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