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

Side by Side Diff: runtime/vm/instructions_mips_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_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
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 StubCode* stub_code = Isolate::Current()->stub_code(); 18 __ BranchLinkPatchable(&StubCode::InvokeDartCodeLabel());
19 __ BranchLinkPatchable(&stub_code->InvokeDartCodeLabel());
20 __ Ret(); 19 __ Ret();
21 } 20 }
22 21
23 22
24 ASSEMBLER_TEST_RUN(Call, test) { 23 ASSEMBLER_TEST_RUN(Call, test) {
25 // The return address, which must be the address of an instruction contained 24 // The return address, which must be the address of an instruction contained
26 // in the code, points to the Ret instruction above, i.e. two instructions 25 // in the code, points to the Ret instruction above, i.e. two instructions
27 // before the end of the code buffer, including the delay slot for the 26 // before the end of the code buffer, including the delay slot for the
28 // return jump. 27 // return jump.
29 CallPattern call(test->entry() + test->code().Size() - (2*Instr::kInstrSize), 28 CallPattern call(test->entry() + test->code().Size() - (2*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_MIPS 69 #endif // defined TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698