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_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
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/object.h" | 10 #include "vm/object.h" |
11 #include "vm/stub_code.h" | 11 #include "vm/stub_code.h" |
12 #include "vm/unit_test.h" | 12 #include "vm/unit_test.h" |
13 #include "vm/virtual_memory.h" | 13 #include "vm/virtual_memory.h" |
14 | 14 |
15 namespace dart { | 15 namespace dart { |
16 | 16 |
17 #define __ assembler-> | 17 #define __ assembler-> |
18 | 18 |
19 ASSEMBLER_TEST_GENERATE(Call, assembler) { | 19 ASSEMBLER_TEST_GENERATE(Call, assembler) { |
20 __ call(&StubCode::InvokeDartCodeLabel()); | 20 __ Call(*StubCode::InvokeDartCode_entry()); |
21 __ ret(); | 21 __ ret(); |
22 } | 22 } |
23 | 23 |
24 | 24 |
25 ASSEMBLER_TEST_RUN(Call, test) { | 25 ASSEMBLER_TEST_RUN(Call, test) { |
26 CallPattern call(test->entry()); | 26 CallPattern call(test->entry()); |
27 EXPECT_EQ(StubCode::InvokeDartCodeLabel().address(), | 27 EXPECT_EQ(StubCode::InvokeDartCode_entry()->EntryPoint(), |
28 call.TargetAddress()); | 28 call.TargetAddress()); |
29 } | 29 } |
30 | 30 |
31 | 31 |
32 ASSEMBLER_TEST_GENERATE(Jump, assembler) { | 32 ASSEMBLER_TEST_GENERATE(Jump, assembler) { |
33 __ jmp(&StubCode::InvokeDartCodeLabel()); | 33 __ Jmp(*StubCode::InvokeDartCode_entry()); |
34 const ExternalLabel array_label(StubCode::AllocateArrayEntryPoint()); | 34 const ExternalLabel label(StubCode::AllocateArray_entry()->EntryPoint()); |
35 __ jmp(&array_label); | 35 __ jmp(&label); |
36 __ ret(); | 36 __ ret(); |
37 } | 37 } |
38 | 38 |
39 | 39 |
40 ASSEMBLER_TEST_RUN(Jump, test) { | 40 ASSEMBLER_TEST_RUN(Jump, test) { |
41 const Code& code = test->code(); | 41 const Code& code = test->code(); |
42 const Instructions& instrs = Instructions::Handle(code.instructions()); | 42 const Instructions& instrs = Instructions::Handle(code.instructions()); |
43 bool status = | 43 bool status = |
44 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()), | 44 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()), |
45 instrs.size(), | 45 instrs.size(), |
46 VirtualMemory::kReadWrite); | 46 VirtualMemory::kReadWrite); |
47 EXPECT(status); | 47 EXPECT(status); |
48 JumpPattern jump1(test->entry(), test->code()); | 48 JumpPattern jump1(test->entry(), test->code()); |
49 EXPECT_EQ(StubCode::InvokeDartCodeLabel().address(), | 49 EXPECT_EQ(StubCode::InvokeDartCode_entry()->EntryPoint(), |
50 jump1.TargetAddress()); | 50 jump1.TargetAddress()); |
51 JumpPattern jump2(test->entry() + jump1.pattern_length_in_bytes(), | 51 JumpPattern jump2(test->entry() + jump1.pattern_length_in_bytes(), |
52 test->code()); | 52 test->code()); |
53 const Code& array_stub = | 53 const Code& array_stub = |
54 Code::Handle(StubCode::AllocateArray_entry()->code()); | 54 Code::Handle(StubCode::AllocateArray_entry()->code()); |
55 EXPECT_EQ(array_stub.EntryPoint(), | 55 EXPECT_EQ(array_stub.EntryPoint(), |
56 jump2.TargetAddress()); | 56 jump2.TargetAddress()); |
57 uword target1 = jump1.TargetAddress(); | 57 uword target1 = jump1.TargetAddress(); |
58 uword target2 = jump2.TargetAddress(); | 58 uword target2 = jump2.TargetAddress(); |
59 jump1.SetTargetAddress(target2); | 59 jump1.SetTargetAddress(target2); |
60 jump2.SetTargetAddress(target1); | 60 jump2.SetTargetAddress(target1); |
61 EXPECT_EQ(array_stub.EntryPoint(), | 61 EXPECT_EQ(array_stub.EntryPoint(), |
62 jump1.TargetAddress()); | 62 jump1.TargetAddress()); |
63 EXPECT_EQ(StubCode::InvokeDartCodeLabel().address(), | 63 EXPECT_EQ(StubCode::InvokeDartCode_entry()->EntryPoint(), |
64 jump2.TargetAddress()); | 64 jump2.TargetAddress()); |
65 } | 65 } |
66 | 66 |
67 } // namespace dart | 67 } // namespace dart |
68 | 68 |
69 #endif // defined TARGET_ARCH_IA32 | 69 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |