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

Side by Side Diff: runtime/vm/instructions_ia32_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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_IA32) 6 #if defined(TARGET_ARCH_IA32)
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/object.h" 10 #include "vm/object.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 #include "vm/virtual_memory.h" 13 #include "vm/virtual_memory.h"
14 14
15 namespace dart { 15 namespace dart {
16 16
17 #define __ assembler-> 17 #define __ assembler->
18 18
19 ASSEMBLER_TEST_GENERATE(Call, assembler) { 19 ASSEMBLER_TEST_GENERATE(Call, assembler) {
20 StubCode* stub_code = Isolate::Current()->stub_code(); 20 __ call(&StubCode::InvokeDartCodeLabel());
21 __ call(&stub_code->InvokeDartCodeLabel());
22 __ ret(); 21 __ ret();
23 } 22 }
24 23
25 24
26 ASSEMBLER_TEST_RUN(Call, test) { 25 ASSEMBLER_TEST_RUN(Call, test) {
27 StubCode* stub_code = Isolate::Current()->stub_code();
28 CallPattern call(test->entry()); 26 CallPattern call(test->entry());
29 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(), 27 EXPECT_EQ(StubCode::InvokeDartCodeLabel().address(),
30 call.TargetAddress()); 28 call.TargetAddress());
31 } 29 }
32 30
33 31
34 ASSEMBLER_TEST_GENERATE(Jump, assembler) { 32 ASSEMBLER_TEST_GENERATE(Jump, assembler) {
35 StubCode* stub_code = Isolate::Current()->stub_code(); 33 __ jmp(&StubCode::InvokeDartCodeLabel());
36 __ jmp(&stub_code->InvokeDartCodeLabel()); 34 const ExternalLabel array_label(StubCode::AllocateArrayEntryPoint());
37 const Code& array_stub = Code::Handle(stub_code->GetAllocateArrayStub());
38 const ExternalLabel array_label(array_stub.EntryPoint());
39 __ jmp(&array_label); 35 __ jmp(&array_label);
40 __ ret(); 36 __ ret();
41 } 37 }
42 38
43 39
44 ASSEMBLER_TEST_RUN(Jump, test) { 40 ASSEMBLER_TEST_RUN(Jump, test) {
45 const Code& code = test->code(); 41 const Code& code = test->code();
46 const Instructions& instrs = Instructions::Handle(code.instructions()); 42 const Instructions& instrs = Instructions::Handle(code.instructions());
47 StubCode* stub_code = Isolate::Current()->stub_code();
48 bool status = 43 bool status =
49 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()), 44 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()),
50 instrs.size(), 45 instrs.size(),
51 VirtualMemory::kReadWrite); 46 VirtualMemory::kReadWrite);
52 EXPECT(status); 47 EXPECT(status);
53 JumpPattern jump1(test->entry(), test->code()); 48 JumpPattern jump1(test->entry(), test->code());
54 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(), 49 EXPECT_EQ(StubCode::InvokeDartCodeLabel().address(),
55 jump1.TargetAddress()); 50 jump1.TargetAddress());
56 JumpPattern jump2(test->entry() + jump1.pattern_length_in_bytes(), 51 JumpPattern jump2(test->entry() + jump1.pattern_length_in_bytes(),
57 test->code()); 52 test->code());
58 const Code& array_stub = Code::Handle(stub_code->GetAllocateArrayStub()); 53 const Code& array_stub =
54 Code::Handle(StubCode::AllocateArray_entry()->code());
59 EXPECT_EQ(array_stub.EntryPoint(), 55 EXPECT_EQ(array_stub.EntryPoint(),
60 jump2.TargetAddress()); 56 jump2.TargetAddress());
61 uword target1 = jump1.TargetAddress(); 57 uword target1 = jump1.TargetAddress();
62 uword target2 = jump2.TargetAddress(); 58 uword target2 = jump2.TargetAddress();
63 jump1.SetTargetAddress(target2); 59 jump1.SetTargetAddress(target2);
64 jump2.SetTargetAddress(target1); 60 jump2.SetTargetAddress(target1);
65 EXPECT_EQ(array_stub.EntryPoint(), 61 EXPECT_EQ(array_stub.EntryPoint(),
66 jump1.TargetAddress()); 62 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_IA32 69 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698