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/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 uword CodePatcher::GetNativeCallAt(uword return_address, | 92 uword CodePatcher::GetNativeCallAt(uword return_address, |
93 const Code& code, | 93 const Code& code, |
94 NativeFunction* target) { | 94 NativeFunction* target) { |
95 ASSERT(code.ContainsInstructionAt(return_address)); | 95 ASSERT(code.ContainsInstructionAt(return_address)); |
96 NativeCallPattern call(return_address, code); | 96 NativeCallPattern call(return_address, code); |
97 *target = call.native_function(); | 97 *target = call.native_function(); |
98 return call.target(); | 98 return call.target(); |
99 } | 99 } |
100 | 100 |
101 | |
102 // This class pattern matches on a load from the object pool. Loading on | |
103 // ARM is complicated because it can take four possible different forms. We | |
104 // match backwards from the end of the sequence so we can reuse the code for | |
105 // matching object pool loads at calls. | |
106 class EdgeCounter : public ValueObject { | |
107 public: | |
108 EdgeCounter(uword pc, const Code& code) | |
109 : end_(pc - FlowGraphCompiler::EdgeCounterIncrementSizeInBytes()), | |
110 object_pool_(ObjectPool::Handle(code.GetObjectPool())) { | |
111 // An IsValid predicate is complicated and duplicates the code in the | |
112 // decoding function. Instead we rely on decoding the pattern which | |
113 // will assert partial validity. | |
114 } | |
115 | |
116 RawObject* edge_counter() const { | |
117 Register ignored; | |
118 intptr_t index; | |
119 InstructionPattern::DecodeLoadWordFromPool(end_, &ignored, &index); | |
120 ASSERT(ignored == R0); | |
121 return object_pool_.ObjectAt(index); | |
122 } | |
123 | |
124 private: | |
125 // The object pool load is followed by the fixed-size edge counter | |
126 // incrementing code: | |
127 // ldr ip, [r0, #+11] | |
128 // adds ip, ip, #2 | |
129 // str ip, [r0, #+11] | |
130 static const intptr_t kAdjust = 3 * Instr::kInstrSize; | |
131 | |
132 uword end_; | |
133 const ObjectPool& object_pool_; | |
134 }; | |
135 | |
136 | |
137 RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) { | |
138 ASSERT(code.ContainsInstructionAt(pc)); | |
139 EdgeCounter counter(pc, code); | |
140 return counter.edge_counter(); | |
141 } | |
142 | |
143 } // namespace dart | 101 } // namespace dart |
144 | 102 |
145 #endif // defined TARGET_ARCH_ARM | 103 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |