Chromium Code Reviews| 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_ARM. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
| 6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
| 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 // ARM is complicated because it can take four possible different forms. We | |
| 90 // match backwards from the end of the sequence so we can reuse the code for | |
| 91 // matching object pool loads at calls. | |
| 92 class EdgeCounter : public ValueObject { | |
| 93 public: | |
| 94 EdgeCounter(uword end, const Code& code) | |
| 95 : end_(end - 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 partial validity. | |
|
Florian Schneider
2013/09/30 08:55:38
missing verb in this comment?
| |
| 99 } | |
| 100 | |
| 101 RawObject* edge_counter() const { | |
| 102 Register ignored; | |
| 103 intptr_t index; | |
| 104 InstructionPattern::DecodeLoadWordFromPool( | |
| 105 reinterpret_cast<const uword*>(end_), | |
| 106 &ignored, | |
| 107 &index); | |
| 108 ASSERT(ignored == R0); | |
| 109 return object_pool_.At(index); | |
| 110 } | |
| 111 | |
| 112 private: | |
| 113 // The object pool load is followed by the fixed-size edge counter | |
| 114 // incrementing code: | |
| 115 // ldr ip, [r0, #+11] | |
| 116 // adds ip, ip, #2 | |
| 117 // mvnvs ip, #-2147483647 | |
| 118 // str ip, [r0, #+11] | |
| 119 static const intptr_t kAdjust = 4 * Instr::kInstrSize; | |
| 120 | |
| 121 uword end_; | |
| 122 const Array& object_pool_; | |
| 123 }; | |
| 124 | |
| 125 | |
| 126 RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) { | |
| 127 ASSERT(code.ContainsInstructionAt(pc)); | |
| 128 EdgeCounter counter(pc, code); | |
| 129 return counter.edge_counter(); | |
| 130 } | |
| 131 | |
| 87 } // namespace dart | 132 } // namespace dart |
| 88 | 133 |
| 89 #endif // defined TARGET_ARCH_ARM | 134 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |