Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: runtime/vm/instructions_arm_test.cc

Issue 183803024: Adds support for ARMv6. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Added tests. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/cpu.h"
9 #include "vm/instructions.h" 10 #include "vm/instructions.h"
10 #include "vm/stub_code.h" 11 #include "vm/stub_code.h"
11 #include "vm/unit_test.h" 12 #include "vm/unit_test.h"
12 13
13 namespace dart { 14 namespace dart {
14 15
15 #define __ assembler-> 16 #define __ assembler->
16 17
17 ASSEMBLER_TEST_GENERATE(Call, assembler) { 18 ASSEMBLER_TEST_GENERATE(Call, assembler) {
18 __ BranchLinkPatchable(&StubCode::InstanceFunctionLookupLabel()); 19 __ BranchLinkPatchable(&StubCode::InstanceFunctionLookupLabel());
19 __ Ret(); 20 __ Ret();
20 } 21 }
21 22
22 23
23 ASSEMBLER_TEST_RUN(Call, test) { 24 ASSEMBLER_TEST_RUN(Call, test) {
24 // The return address, which must be the address of an instruction contained 25 // 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 // in the code, points to the Ret instruction above, i.e. one instruction
26 // before the end of the code buffer. 27 // before the end of the code buffer.
27 CallPattern call(test->entry() + test->code().Size() - Instr::kInstrSize, 28 CallPattern call(test->entry() + test->code().Size() - Instr::kInstrSize,
28 test->code()); 29 test->code());
29 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), 30 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(),
30 call.TargetAddress()); 31 call.TargetAddress());
32 // On the simulator, also try the ARMv6 version.
regis 2014/03/06 17:32:11 I do not understand this comment. Are you missing
zra 2014/03/07 19:00:17 Removed. I had a test here that switched to ARMv6
31 } 33 }
32 34
33 35
34 ASSEMBLER_TEST_GENERATE(Jump, assembler) { 36 ASSEMBLER_TEST_GENERATE(Jump, assembler) {
35 __ BranchPatchable(&StubCode::InstanceFunctionLookupLabel()); 37 __ BranchPatchable(&StubCode::InstanceFunctionLookupLabel());
36 __ BranchPatchable(&StubCode::AllocateArrayLabel()); 38 __ BranchPatchable(&StubCode::AllocateArrayLabel());
37 } 39 }
38 40
39 41
40 ASSEMBLER_TEST_RUN(Jump, test) { 42 ASSEMBLER_TEST_RUN(Jump, test) {
(...skipping 14 matching lines...) Expand all
55 uword target1 = jump1.TargetAddress(); 57 uword target1 = jump1.TargetAddress();
56 uword target2 = jump2.TargetAddress(); 58 uword target2 = jump2.TargetAddress();
57 jump1.SetTargetAddress(target2); 59 jump1.SetTargetAddress(target2);
58 jump2.SetTargetAddress(target1); 60 jump2.SetTargetAddress(target1);
59 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), 61 EXPECT_EQ(StubCode::AllocateArrayLabel().address(),
60 jump1.TargetAddress()); 62 jump1.TargetAddress());
61 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), 63 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(),
62 jump2.TargetAddress()); 64 jump2.TargetAddress());
63 } 65 }
64 66
67
68 #if defined(USING_SIMULATOR)
69 ASSEMBLER_TEST_GENERATE(JumpARMv6, assembler) {
70 // ARMv7 is the default.
71 HostCPUFeatures::set_arm_version(ARMv6);
72 __ BranchPatchable(&StubCode::InstanceFunctionLookupLabel());
73 __ BranchPatchable(&StubCode::AllocateArrayLabel());
74 HostCPUFeatures::set_arm_version(ARMv7);
75 }
76
77
78 ASSEMBLER_TEST_RUN(JumpARMv6, test) {
79 HostCPUFeatures::set_arm_version(ARMv6);
80 const Code& code = test->code();
81 const Instructions& instrs = Instructions::Handle(code.instructions());
82 bool status =
83 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()),
84 instrs.size(),
85 VirtualMemory::kReadWrite);
86 EXPECT(status);
87 JumpPattern jump1(test->entry(), test->code());
88 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(),
89 jump1.TargetAddress());
90 JumpPattern jump2(test->entry() + jump1.pattern_length_in_bytes(),
91 test->code());
92 EXPECT_EQ(StubCode::AllocateArrayLabel().address(),
93 jump2.TargetAddress());
94 uword target1 = jump1.TargetAddress();
95 uword target2 = jump2.TargetAddress();
96 jump1.SetTargetAddress(target2);
97 jump2.SetTargetAddress(target1);
98 EXPECT_EQ(StubCode::AllocateArrayLabel().address(),
99 jump1.TargetAddress());
100 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(),
101 jump2.TargetAddress());
102 HostCPUFeatures::set_arm_version(ARMv7);
103 }
104 #endif
105
65 } // namespace dart 106 } // namespace dart
66 107
67 #endif // defined TARGET_ARCH_ARM 108 #endif // defined TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698