OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/code_patcher.h" | 9 #include "vm/code_patcher.h" |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 SwitchableCall(uword return_address, const Code& code) | 200 SwitchableCall(uword return_address, const Code& code) |
201 : start_(return_address - kCallPatternSize), | 201 : start_(return_address - kCallPatternSize), |
202 object_pool_(ObjectPool::Handle(code.GetObjectPool())) { | 202 object_pool_(ObjectPool::Handle(code.GetObjectPool())) { |
203 ASSERT(IsValid()); | 203 ASSERT(IsValid()); |
204 } | 204 } |
205 | 205 |
206 static const int kCallPatternSize = 21; | 206 static const int kCallPatternSize = 21; |
207 | 207 |
208 bool IsValid() const { | 208 bool IsValid() const { |
209 static int16_t pattern[kCallPatternSize] = { | 209 static int16_t pattern[kCallPatternSize] = { |
210 0x49, 0x8b, 0x9f, -1, -1, -1, -1, // movq rbx, [PP + cache_offs] | |
211 0x4d, 0x8b, 0xa7, -1, -1, -1, -1, // movq r12, [PP + code_offs] | 210 0x4d, 0x8b, 0xa7, -1, -1, -1, -1, // movq r12, [PP + code_offs] |
212 0x49, 0x8b, 0x4c, 0x24, 0x0f, // movq rcx, [r12 + entrypoint_off] | 211 0x49, 0x8b, 0x4c, 0x24, 0x0f, // movq rcx, [r12 + entrypoint_off] |
| 212 0x49, 0x8b, 0x9f, -1, -1, -1, -1, // movq rbx, [PP + cache_offs] |
213 0xff, 0xd1, // call rcx | 213 0xff, 0xd1, // call rcx |
214 }; | 214 }; |
215 ASSERT(ARRAY_SIZE(pattern) == kCallPatternSize); | 215 ASSERT(ARRAY_SIZE(pattern) == kCallPatternSize); |
216 return MatchesPattern(start_, pattern, kCallPatternSize); | 216 return MatchesPattern(start_, pattern, kCallPatternSize); |
217 } | 217 } |
218 | 218 |
219 intptr_t data_index() const { | 219 intptr_t data_index() const { |
220 return IndexFromPPLoad(start_ + 3); | 220 return IndexFromPPLoad(start_ + 15); |
221 } | 221 } |
222 intptr_t target_index() const { | 222 intptr_t target_index() const { |
223 return IndexFromPPLoad(start_ + 10); | 223 return IndexFromPPLoad(start_ + 3); |
224 } | 224 } |
225 | 225 |
226 RawObject* data() const { | 226 RawObject* data() const { |
227 return object_pool_.ObjectAt(data_index()); | 227 return object_pool_.ObjectAt(data_index()); |
228 } | 228 } |
229 RawCode* target() const { | 229 RawCode* target() const { |
230 return reinterpret_cast<RawCode*>(object_pool_.ObjectAt(target_index())); | 230 return reinterpret_cast<RawCode*>(object_pool_.ObjectAt(target_index())); |
231 } | 231 } |
232 | 232 |
233 void SetData(const Object& data) const { | 233 void SetData(const Object& data) const { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 NativeFunction* target) { | 354 NativeFunction* target) { |
355 ASSERT(code.ContainsInstructionAt(return_address)); | 355 ASSERT(code.ContainsInstructionAt(return_address)); |
356 NativeCall call(return_address, code); | 356 NativeCall call(return_address, code); |
357 *target = call.native_function(); | 357 *target = call.native_function(); |
358 return call.target(); | 358 return call.target(); |
359 } | 359 } |
360 | 360 |
361 } // namespace dart | 361 } // namespace dart |
362 | 362 |
363 #endif // defined TARGET_ARCH_X64 | 363 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |