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

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

Issue 1247783002: Make array allocation stub shared between isolates. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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
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/cpu.h"
10 #include "vm/instructions.h" 10 #include "vm/instructions.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 13
14 namespace dart { 14 namespace dart {
15 15
16 #define __ assembler-> 16 #define __ assembler->
17 17
18 ASSEMBLER_TEST_GENERATE(Call, assembler) { 18 ASSEMBLER_TEST_GENERATE(Call, assembler) {
19 StubCode* stub_code = Isolate::Current()->stub_code(); 19 __ BranchLinkPatchable(&StubCode::InvokeDartCodeLabel());
20 __ BranchLinkPatchable(&stub_code->InvokeDartCodeLabel());
21 __ Ret(); 20 __ Ret();
22 } 21 }
23 22
24 23
25 ASSEMBLER_TEST_RUN(Call, test) { 24 ASSEMBLER_TEST_RUN(Call, test) {
26 // 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
27 // 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
28 // before the end of the code buffer. 27 // before the end of the code buffer.
29 CallPattern call(test->entry() + test->code().Size() - Instr::kInstrSize, 28 CallPattern call(test->entry() + test->code().Size() - Instr::kInstrSize,
30 test->code()); 29 test->code());
31 StubCode* stub_code = Isolate::Current()->stub_code(); 30 EXPECT_EQ(StubCode::InvokeDartCodeLabel().address(),
32 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(),
33 call.TargetAddress()); 31 call.TargetAddress());
34 } 32 }
35 33
36 34
37 ASSEMBLER_TEST_GENERATE(Jump, assembler) { 35 ASSEMBLER_TEST_GENERATE(Jump, assembler) {
38 StubCode* stub_code = Isolate::Current()->stub_code(); 36 __ BranchPatchable(&StubCode::InvokeDartCodeLabel());
39 __ BranchPatchable(&stub_code->InvokeDartCodeLabel()); 37 const ExternalLabel array_label(StubCode::AllocateArrayEntryPoint());
40 const Code& array_stub = Code::Handle(stub_code->GetAllocateArrayStub());
41 const ExternalLabel array_label(array_stub.EntryPoint());
42 __ BranchPatchable(&array_label); 38 __ BranchPatchable(&array_label);
43 } 39 }
44 40
45 41
46 ASSEMBLER_TEST_RUN(Jump, test) { 42 ASSEMBLER_TEST_RUN(Jump, test) {
47 const Code& code = test->code(); 43 const Code& code = test->code();
48 const Instructions& instrs = Instructions::Handle(code.instructions()); 44 const Instructions& instrs = Instructions::Handle(code.instructions());
49 bool status = 45 bool status =
50 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()), 46 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()),
51 instrs.size(), 47 instrs.size(),
52 VirtualMemory::kReadWrite); 48 VirtualMemory::kReadWrite);
53 StubCode* stub_code = Isolate::Current()->stub_code();
54 EXPECT(status); 49 EXPECT(status);
55 JumpPattern jump1(test->entry(), test->code()); 50 JumpPattern jump1(test->entry(), test->code());
56 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(), 51 EXPECT_EQ(StubCode::InvokeDartCodeLabel().address(),
57 jump1.TargetAddress()); 52 jump1.TargetAddress());
58 JumpPattern jump2(test->entry() + jump1.pattern_length_in_bytes(), 53 JumpPattern jump2(test->entry() + jump1.pattern_length_in_bytes(),
59 test->code()); 54 test->code());
60 const Code& array_stub = Code::Handle(stub_code->GetAllocateArrayStub()); 55 const Code& array_stub =
56 Code::Handle(StubCode::AllocateArray_entry()->code());
61 EXPECT_EQ(array_stub.EntryPoint(), jump2.TargetAddress()); 57 EXPECT_EQ(array_stub.EntryPoint(), jump2.TargetAddress());
62 uword target1 = jump1.TargetAddress(); 58 uword target1 = jump1.TargetAddress();
63 uword target2 = jump2.TargetAddress(); 59 uword target2 = jump2.TargetAddress();
64 jump1.SetTargetAddress(target2); 60 jump1.SetTargetAddress(target2);
65 jump2.SetTargetAddress(target1); 61 jump2.SetTargetAddress(target1);
66 EXPECT_EQ(array_stub.EntryPoint(), jump1.TargetAddress()); 62 EXPECT_EQ(array_stub.EntryPoint(), jump1.TargetAddress());
67 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(), 63 EXPECT_EQ(StubCode::InvokeDartCodeLabel().address(),
68 jump2.TargetAddress()); 64 jump2.TargetAddress());
69 } 65 }
70 66
71 67
72 #if defined(USING_SIMULATOR) 68 #if defined(USING_SIMULATOR)
73 ASSEMBLER_TEST_GENERATE(JumpARMv6, assembler) { 69 ASSEMBLER_TEST_GENERATE(JumpARMv6, assembler) {
74 // ARMv7 is the default. 70 // ARMv7 is the default.
75 StubCode* stub_code = Isolate::Current()->stub_code();
76 HostCPUFeatures::set_arm_version(ARMv6); 71 HostCPUFeatures::set_arm_version(ARMv6);
77 __ BranchPatchable(&stub_code->InvokeDartCodeLabel()); 72 __ BranchPatchable(&StubCode::InvokeDartCodeLabel());
78 const Code& array_stub = Code::Handle(stub_code->GetAllocateArrayStub()); 73 const ExternalLabel array_label(StubCode::AllocateArrayEntryPoint());
79 const ExternalLabel array_label(array_stub.EntryPoint());
80 __ BranchPatchable(&array_label); 74 __ BranchPatchable(&array_label);
81 HostCPUFeatures::set_arm_version(ARMv7); 75 HostCPUFeatures::set_arm_version(ARMv7);
82 } 76 }
83 77
84 78
85 ASSEMBLER_TEST_RUN(JumpARMv6, test) { 79 ASSEMBLER_TEST_RUN(JumpARMv6, test) {
86 HostCPUFeatures::set_arm_version(ARMv6); 80 HostCPUFeatures::set_arm_version(ARMv6);
87 const Code& code = test->code(); 81 const Code& code = test->code();
88 const Instructions& instrs = Instructions::Handle(code.instructions()); 82 const Instructions& instrs = Instructions::Handle(code.instructions());
89 bool status = 83 bool status =
90 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()), 84 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()),
91 instrs.size(), 85 instrs.size(),
92 VirtualMemory::kReadWrite); 86 VirtualMemory::kReadWrite);
93 StubCode* stub_code = Isolate::Current()->stub_code();
94 EXPECT(status); 87 EXPECT(status);
95 JumpPattern jump1(test->entry(), test->code()); 88 JumpPattern jump1(test->entry(), test->code());
96 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(), 89 EXPECT_EQ(StubCode::InvokeDartCodeLabel().address(),
97 jump1.TargetAddress()); 90 jump1.TargetAddress());
98 JumpPattern jump2(test->entry() + jump1.pattern_length_in_bytes(), 91 JumpPattern jump2(test->entry() + jump1.pattern_length_in_bytes(),
99 test->code()); 92 test->code());
100 const Code& array_stub = Code::Handle(stub_code->GetAllocateArrayStub()); 93 const Code& array_stub =
94 Code::Handle(StubCode::AllocateArray_entry()->code());
101 EXPECT_EQ(array_stub.EntryPoint(), jump2.TargetAddress()); 95 EXPECT_EQ(array_stub.EntryPoint(), jump2.TargetAddress());
102 uword target1 = jump1.TargetAddress(); 96 uword target1 = jump1.TargetAddress();
103 uword target2 = jump2.TargetAddress(); 97 uword target2 = jump2.TargetAddress();
104 jump1.SetTargetAddress(target2); 98 jump1.SetTargetAddress(target2);
105 jump2.SetTargetAddress(target1); 99 jump2.SetTargetAddress(target1);
106 EXPECT_EQ(array_stub.EntryPoint(), jump1.TargetAddress()); 100 EXPECT_EQ(array_stub.EntryPoint(), jump1.TargetAddress());
107 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(), 101 EXPECT_EQ(StubCode::InvokeDartCodeLabel().address(),
108 jump2.TargetAddress()); 102 jump2.TargetAddress());
109 HostCPUFeatures::set_arm_version(ARMv7); 103 HostCPUFeatures::set_arm_version(ARMv7);
110 } 104 }
111 #endif 105 #endif
112 106
113 } // namespace dart 107 } // namespace dart
114 108
115 #endif // defined TARGET_ARCH_ARM 109 #endif // defined TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698