OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
10 #include "vm/instructions.h" | 10 #include "vm/instructions.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 __ ret(); | 22 __ ret(); |
23 } | 23 } |
24 | 24 |
25 | 25 |
26 ASSEMBLER_TEST_RUN(Call, test) { | 26 ASSEMBLER_TEST_RUN(Call, test) { |
27 // The return address, which must be the address of an instruction contained | 27 // The return address, which must be the address of an instruction contained |
28 // in the code, points to the Ret instruction above, i.e. one instruction | 28 // in the code, points to the Ret instruction above, i.e. one instruction |
29 // before the end of the code buffer. | 29 // before the end of the code buffer. |
30 CallPattern call(test->entry() + test->code().Size() - Instr::kInstrSize, | 30 CallPattern call(test->entry() + test->code().Size() - Instr::kInstrSize, |
31 test->code()); | 31 test->code()); |
32 EXPECT_EQ(StubCode::InvokeDartCode_entry()->label().address(), | 32 EXPECT_EQ(StubCode::InvokeDartCode_entry()->code(), |
33 call.TargetAddress()); | 33 call.TargetCode()); |
34 } | 34 } |
35 | 35 |
36 | 36 |
37 ASSEMBLER_TEST_GENERATE(Jump, assembler) { | |
38 __ BranchPatchable(*StubCode::InvokeDartCode_entry()); | |
39 __ BranchPatchable(*StubCode::AllocateArray_entry()); | |
40 } | |
41 | |
42 | |
43 ASSEMBLER_TEST_RUN(Jump, test) { | |
44 const Code& code = test->code(); | |
45 const Instructions& instrs = Instructions::Handle(code.instructions()); | |
46 bool status = | |
47 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()), | |
48 instrs.size(), | |
49 VirtualMemory::kReadWrite); | |
50 EXPECT(status); | |
51 JumpPattern jump1(test->entry(), test->code()); | |
52 EXPECT_EQ(StubCode::InvokeDartCode_entry()->label().address(), | |
53 jump1.TargetAddress()); | |
54 JumpPattern jump2(test->entry() + jump1.pattern_length_in_bytes(), | |
55 test->code()); | |
56 const Code& array_stub = | |
57 Code::Handle(StubCode::AllocateArray_entry()->code()); | |
58 EXPECT_EQ(array_stub.EntryPoint(), jump2.TargetAddress()); | |
59 uword target1 = jump1.TargetAddress(); | |
60 uword target2 = jump2.TargetAddress(); | |
61 jump1.SetTargetAddress(target2); | |
62 jump2.SetTargetAddress(target1); | |
63 EXPECT_EQ(array_stub.EntryPoint(), jump1.TargetAddress()); | |
64 EXPECT_EQ(StubCode::InvokeDartCode_entry()->label().address(), | |
65 jump2.TargetAddress()); | |
66 } | |
67 | |
68 } // namespace dart | 37 } // namespace dart |
69 | 38 |
70 #endif // defined TARGET_ARCH_ARM64 | 39 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |