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 26 matching lines...) Expand all Loading... |
37 prologue_code_size = assembler->CodeSize(); | 37 prologue_code_size = assembler->CodeSize(); |
38 __ JmpPatchable(&StubCode::InstanceFunctionLookupLabel(), PP); | 38 __ JmpPatchable(&StubCode::InstanceFunctionLookupLabel(), PP); |
39 __ JmpPatchable(&StubCode::AllocateArrayLabel(), PP); | 39 __ JmpPatchable(&StubCode::AllocateArrayLabel(), PP); |
40 __ popq(PP); | 40 __ popq(PP); |
41 __ ret(); | 41 __ ret(); |
42 } | 42 } |
43 | 43 |
44 | 44 |
45 ASSEMBLER_TEST_RUN(Jump, test) { | 45 ASSEMBLER_TEST_RUN(Jump, test) { |
46 ASSERT(prologue_code_size != -1); | 46 ASSERT(prologue_code_size != -1); |
| 47 const Code& code = test->code(); |
| 48 const Instructions& instrs = Instructions::Handle(code.instructions()); |
| 49 bool status = |
| 50 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()), |
| 51 instrs.size(), |
| 52 VirtualMemory::kReadWrite); |
| 53 EXPECT(status); |
47 JumpPattern jump1(test->entry() + prologue_code_size, test->code()); | 54 JumpPattern jump1(test->entry() + prologue_code_size, test->code()); |
48 jump1.IsValid(); | 55 jump1.IsValid(); |
49 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), | 56 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), |
50 jump1.TargetAddress()); | 57 jump1.TargetAddress()); |
51 JumpPattern jump2((test->entry() + | 58 JumpPattern jump2((test->entry() + |
52 jump1.pattern_length_in_bytes() + prologue_code_size), | 59 jump1.pattern_length_in_bytes() + prologue_code_size), |
53 test->code()); | 60 test->code()); |
54 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), | 61 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), |
55 jump2.TargetAddress()); | 62 jump2.TargetAddress()); |
56 uword target1 = jump1.TargetAddress(); | 63 uword target1 = jump1.TargetAddress(); |
57 uword target2 = jump2.TargetAddress(); | 64 uword target2 = jump2.TargetAddress(); |
58 jump1.SetTargetAddress(target2); | 65 jump1.SetTargetAddress(target2); |
59 jump2.SetTargetAddress(target1); | 66 jump2.SetTargetAddress(target1); |
60 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), | 67 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), |
61 jump1.TargetAddress()); | 68 jump1.TargetAddress()); |
62 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), | 69 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), |
63 jump2.TargetAddress()); | 70 jump2.TargetAddress()); |
64 } | 71 } |
65 | 72 |
66 } // namespace dart | 73 } // namespace dart |
67 | 74 |
68 #endif // defined TARGET_ARCH_X64 | 75 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |