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" | 5 #include "vm/globals.h" |
6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
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 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 | 32 |
33 | 33 |
34 ASSEMBLER_TEST_GENERATE(Jump, assembler) { | 34 ASSEMBLER_TEST_GENERATE(Jump, assembler) { |
35 __ BranchPatchable(&StubCode::InstanceFunctionLookupLabel()); | 35 __ BranchPatchable(&StubCode::InstanceFunctionLookupLabel()); |
36 __ BranchPatchable(&StubCode::AllocateArrayLabel()); | 36 __ BranchPatchable(&StubCode::AllocateArrayLabel()); |
37 } | 37 } |
38 | 38 |
39 | 39 |
40 ASSEMBLER_TEST_RUN(Jump, test) { | 40 ASSEMBLER_TEST_RUN(Jump, test) { |
| 41 const Code& code = test->code(); |
| 42 const Instructions& instrs = Instructions::Handle(code.instructions()); |
| 43 bool status = |
| 44 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()), |
| 45 instrs.size(), |
| 46 VirtualMemory::kReadWriteExecute); |
| 47 EXPECT(status); |
41 JumpPattern jump1(test->entry(), test->code()); | 48 JumpPattern jump1(test->entry(), test->code()); |
42 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), | 49 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), |
43 jump1.TargetAddress()); | 50 jump1.TargetAddress()); |
44 JumpPattern jump2(test->entry() + jump1.pattern_length_in_bytes(), | 51 JumpPattern jump2(test->entry() + jump1.pattern_length_in_bytes(), |
45 test->code()); | 52 test->code()); |
46 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), | 53 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), |
47 jump2.TargetAddress()); | 54 jump2.TargetAddress()); |
48 uword target1 = jump1.TargetAddress(); | 55 uword target1 = jump1.TargetAddress(); |
49 uword target2 = jump2.TargetAddress(); | 56 uword target2 = jump2.TargetAddress(); |
50 jump1.SetTargetAddress(target2); | 57 jump1.SetTargetAddress(target2); |
51 jump2.SetTargetAddress(target1); | 58 jump2.SetTargetAddress(target1); |
52 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), | 59 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), |
53 jump1.TargetAddress()); | 60 jump1.TargetAddress()); |
54 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), | 61 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), |
55 jump2.TargetAddress()); | 62 jump2.TargetAddress()); |
56 } | 63 } |
57 | 64 |
58 } // namespace dart | 65 } // namespace dart |
59 | 66 |
60 #endif // defined TARGET_ARCH_ARM | 67 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |