| 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" | 5 #include "vm/globals.h" |
| 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/instructions.h" | 9 #include "vm/instructions.h" |
| 10 #include "vm/stub_code.h" | 10 #include "vm/stub_code.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 __ pushq(PP); | 28 __ pushq(PP); |
| 29 __ LoadPoolPointer(); | 29 __ LoadPoolPointer(); |
| 30 prologue_code_size = assembler->CodeSize(); | 30 prologue_code_size = assembler->CodeSize(); |
| 31 __ JmpPatchable(*StubCode::InvokeDartCode_entry(), PP); | 31 __ JmpPatchable(*StubCode::InvokeDartCode_entry(), PP); |
| 32 __ JmpPatchable(*StubCode::AllocateArray_entry(), PP); | 32 __ JmpPatchable(*StubCode::AllocateArray_entry(), PP); |
| 33 __ popq(PP); | 33 __ popq(PP); |
| 34 __ ret(); | 34 __ ret(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 | 37 |
| 38 ASSEMBLER_TEST_RUN(Jump, test) { |
| 39 ASSERT(prologue_code_size != -1); |
| 40 const Code& code = test->code(); |
| 41 const Instructions& instrs = Instructions::Handle(code.instructions()); |
| 42 bool status = |
| 43 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()), |
| 44 instrs.size(), |
| 45 VirtualMemory::kReadWrite); |
| 46 EXPECT(status); |
| 47 JumpPattern jump1(test->entry() + prologue_code_size, test->code()); |
| 48 jump1.IsValid(); |
| 49 EXPECT_EQ(StubCode::InvokeDartCode_entry()->label().address(), |
| 50 jump1.TargetAddress()); |
| 51 JumpPattern jump2((test->entry() + |
| 52 jump1.pattern_length_in_bytes() + prologue_code_size), |
| 53 test->code()); |
| 54 const Code& array_stub = |
| 55 Code::Handle(StubCode::AllocateArray_entry()->code()); |
| 56 EXPECT_EQ(array_stub.EntryPoint(), jump2.TargetAddress()); |
| 57 uword target1 = jump1.TargetAddress(); |
| 58 uword target2 = jump2.TargetAddress(); |
| 59 jump1.SetTargetAddress(target2); |
| 60 jump2.SetTargetAddress(target1); |
| 61 EXPECT_EQ(array_stub.EntryPoint(), jump1.TargetAddress()); |
| 62 EXPECT_EQ(StubCode::InvokeDartCode_entry()->label().address(), |
| 63 jump2.TargetAddress()); |
| 64 } |
| 65 |
| 38 } // namespace dart | 66 } // namespace dart |
| 39 | 67 |
| 40 #endif // defined TARGET_ARCH_X64 | 68 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |