| 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 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 | 22 |
| 23 ASSEMBLER_TEST_RUN(Call, test) { | 23 ASSEMBLER_TEST_RUN(Call, test) { |
| 24 CallPattern call(test->entry(), test->code()); | 24 CallPattern call(test->entry(), test->code()); |
| 25 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), | 25 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), |
| 26 call.TargetAddress()); | 26 call.TargetAddress()); |
| 27 } | 27 } |
| 28 | 28 |
| 29 | 29 |
| 30 ASSEMBLER_TEST_GENERATE(Jump, assembler) { | 30 ASSEMBLER_TEST_GENERATE(Jump, assembler) { |
| 31 __ EnterDartFrame(0); // 20 bytes | 31 __ pushq(PP); // Save caller's pool pointer and load a new one here. |
| 32 __ LoadPoolPointer(PP); |
| 32 __ JmpPatchable(&StubCode::InstanceFunctionLookupLabel(), PP); | 33 __ JmpPatchable(&StubCode::InstanceFunctionLookupLabel(), PP); |
| 33 __ JmpPatchable(&StubCode::AllocateArrayLabel(), PP); | 34 __ JmpPatchable(&StubCode::AllocateArrayLabel(), PP); |
| 34 __ LeaveFrameWithPP(); | 35 __ popq(PP); // Restore caller's pool pointer. |
| 35 __ ret(); | 36 __ ret(); |
| 36 } | 37 } |
| 37 | 38 |
| 38 | 39 |
| 39 ASSEMBLER_TEST_RUN(Jump, test) { | 40 ASSEMBLER_TEST_RUN(Jump, test) { |
| 40 JumpPattern jump1(test->entry() + 20, test->code()); | 41 JumpPattern jump1(test->entry() + 20, test->code()); |
| 41 jump1.IsValid(); | 42 jump1.IsValid(); |
| 42 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), | 43 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), |
| 43 jump1.TargetAddress()); | 44 jump1.TargetAddress()); |
| 44 JumpPattern jump2(test->entry() + jump1.pattern_length_in_bytes() + 20, | 45 JumpPattern jump2(test->entry() + jump1.pattern_length_in_bytes() + 20, |
| 45 test->code()); | 46 test->code()); |
| 46 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), | 47 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), |
| 47 jump2.TargetAddress()); | 48 jump2.TargetAddress()); |
| 48 uword target1 = jump1.TargetAddress(); | 49 uword target1 = jump1.TargetAddress(); |
| 49 uword target2 = jump2.TargetAddress(); | 50 uword target2 = jump2.TargetAddress(); |
| 50 jump1.SetTargetAddress(target2); | 51 jump1.SetTargetAddress(target2); |
| 51 jump2.SetTargetAddress(target1); | 52 jump2.SetTargetAddress(target1); |
| 52 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), | 53 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), |
| 53 jump1.TargetAddress()); | 54 jump1.TargetAddress()); |
| 54 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), | 55 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), |
| 55 jump2.TargetAddress()); | 56 jump2.TargetAddress()); |
| 56 } | 57 } |
| 57 | 58 |
| 58 } // namespace dart | 59 } // namespace dart |
| 59 | 60 |
| 60 #endif // defined TARGET_ARCH_X64 | 61 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |