| 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" |
| 11 #include "vm/unit_test.h" | 11 #include "vm/unit_test.h" |
| 12 | 12 |
| 13 namespace dart { | 13 namespace dart { |
| 14 | 14 |
| 15 #define __ assembler-> | 15 #define __ assembler-> |
| 16 | 16 |
| 17 ASSEMBLER_TEST_GENERATE(Call, assembler) { | 17 ASSEMBLER_TEST_GENERATE(Call, assembler) { |
| 18 __ BranchLinkPatchable(&StubCode::InstanceFunctionLookupLabel()); | 18 __ BranchLinkPatchable(&StubCode::InstanceFunctionLookupLabel()); |
| 19 // Do not emit any code after the call above, since we decode backwards | 19 __ Ret(); |
| 20 // starting from the return address, i.e. from the end of this code buffer. | |
| 21 } | 20 } |
| 22 | 21 |
| 23 | 22 |
| 24 ASSEMBLER_TEST_RUN(Call, test) { | 23 ASSEMBLER_TEST_RUN(Call, test) { |
| 25 CallPattern call(test->entry() + test->code().Size(), test->code()); | 24 // The return address, which must be the address of an instruction contained |
| 25 // in the code, points to the Ret instruction above, i.e. one instruction |
| 26 // before the end of the code buffer. |
| 27 CallPattern call(test->entry() + test->code().Size() - Instr::kInstrSize, |
| 28 test->code()); |
| 26 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), | 29 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), |
| 27 call.TargetAddress()); | 30 call.TargetAddress()); |
| 28 } | 31 } |
| 29 | 32 |
| 30 | 33 |
| 31 ASSEMBLER_TEST_GENERATE(Jump, assembler) { | 34 ASSEMBLER_TEST_GENERATE(Jump, assembler) { |
| 32 __ BranchPatchable(&StubCode::InstanceFunctionLookupLabel()); | 35 __ BranchPatchable(&StubCode::InstanceFunctionLookupLabel()); |
| 33 __ BranchPatchable(&StubCode::AllocateArrayLabel()); | 36 __ BranchPatchable(&StubCode::AllocateArrayLabel()); |
| 34 } | 37 } |
| 35 | 38 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 47 jump2.SetTargetAddress(target1); | 50 jump2.SetTargetAddress(target1); |
| 48 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), | 51 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), |
| 49 jump1.TargetAddress()); | 52 jump1.TargetAddress()); |
| 50 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), | 53 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), |
| 51 jump2.TargetAddress()); | 54 jump2.TargetAddress()); |
| 52 } | 55 } |
| 53 | 56 |
| 54 } // namespace dart | 57 } // namespace dart |
| 55 | 58 |
| 56 #endif // defined TARGET_ARCH_ARM | 59 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |