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

Side by Side Diff: runtime/vm/instructions_arm64_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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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_ARM64) 6 #if defined(TARGET_ARCH_ARM64)
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 } // namespace dart 67 } // namespace dart
72 68
73 #endif // defined TARGET_ARCH_ARM64 69 #endif // defined TARGET_ARCH_ARM64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698