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

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

Issue 365983002: Make isolate specific stub code accessors instance methods instead (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/instructions_mips_test.cc ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_X64) 6 #if defined(TARGET_ARCH_X64)
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 __ call(&StubCode::InvokeDartCodeLabel()); 18 StubCode* stub_code = Isolate::Current()->stub_code();
19 __ call(&stub_code->InvokeDartCodeLabel());
19 __ ret(); 20 __ ret();
20 } 21 }
21 22
22 23
23 ASSEMBLER_TEST_RUN(Call, test) { 24 ASSEMBLER_TEST_RUN(Call, test) {
25 StubCode* stub_code = Isolate::Current()->stub_code();
24 CallPattern call(test->entry(), test->code()); 26 CallPattern call(test->entry(), test->code());
25 EXPECT_EQ(StubCode::InvokeDartCodeLabel().address(), 27 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(),
26 call.TargetAddress()); 28 call.TargetAddress());
27 } 29 }
28 30
29 31
30 static intptr_t prologue_code_size = -1; 32 static intptr_t prologue_code_size = -1;
31 33
32 34
33 ASSEMBLER_TEST_GENERATE(Jump, assembler) { 35 ASSEMBLER_TEST_GENERATE(Jump, assembler) {
34 ASSERT(assembler->CodeSize() == 0); 36 ASSERT(assembler->CodeSize() == 0);
35 __ pushq(PP); 37 __ pushq(PP);
36 __ LoadPoolPointer(PP); 38 __ LoadPoolPointer(PP);
37 prologue_code_size = assembler->CodeSize(); 39 prologue_code_size = assembler->CodeSize();
38 __ JmpPatchable(&StubCode::InvokeDartCodeLabel(), PP); 40 StubCode* stub_code = Isolate::Current()->stub_code();
39 __ JmpPatchable(&StubCode::AllocateArrayLabel(), PP); 41 __ JmpPatchable(&stub_code->InvokeDartCodeLabel(), PP);
42 __ JmpPatchable(&stub_code->AllocateArrayLabel(), PP);
40 __ popq(PP); 43 __ popq(PP);
41 __ ret(); 44 __ ret();
42 } 45 }
43 46
44 47
45 ASSEMBLER_TEST_RUN(Jump, test) { 48 ASSEMBLER_TEST_RUN(Jump, test) {
46 ASSERT(prologue_code_size != -1); 49 ASSERT(prologue_code_size != -1);
47 const Code& code = test->code(); 50 const Code& code = test->code();
48 const Instructions& instrs = Instructions::Handle(code.instructions()); 51 const Instructions& instrs = Instructions::Handle(code.instructions());
52 StubCode* stub_code = Isolate::Current()->stub_code();
49 bool status = 53 bool status =
50 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()), 54 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()),
51 instrs.size(), 55 instrs.size(),
52 VirtualMemory::kReadWrite); 56 VirtualMemory::kReadWrite);
53 EXPECT(status); 57 EXPECT(status);
54 JumpPattern jump1(test->entry() + prologue_code_size, test->code()); 58 JumpPattern jump1(test->entry() + prologue_code_size, test->code());
55 jump1.IsValid(); 59 jump1.IsValid();
56 EXPECT_EQ(StubCode::InvokeDartCodeLabel().address(), 60 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(),
57 jump1.TargetAddress()); 61 jump1.TargetAddress());
58 JumpPattern jump2((test->entry() + 62 JumpPattern jump2((test->entry() +
59 jump1.pattern_length_in_bytes() + prologue_code_size), 63 jump1.pattern_length_in_bytes() + prologue_code_size),
60 test->code()); 64 test->code());
61 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), 65 EXPECT_EQ(stub_code->AllocateArrayLabel().address(),
62 jump2.TargetAddress()); 66 jump2.TargetAddress());
63 uword target1 = jump1.TargetAddress(); 67 uword target1 = jump1.TargetAddress();
64 uword target2 = jump2.TargetAddress(); 68 uword target2 = jump2.TargetAddress();
65 jump1.SetTargetAddress(target2); 69 jump1.SetTargetAddress(target2);
66 jump2.SetTargetAddress(target1); 70 jump2.SetTargetAddress(target1);
67 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), 71 EXPECT_EQ(stub_code->AllocateArrayLabel().address(),
68 jump1.TargetAddress()); 72 jump1.TargetAddress());
69 EXPECT_EQ(StubCode::InvokeDartCodeLabel().address(), 73 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(),
70 jump2.TargetAddress()); 74 jump2.TargetAddress());
71 } 75 }
72 76
73 } // namespace dart 77 } // namespace dart
74 78
75 #endif // defined TARGET_ARCH_X64 79 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/instructions_mips_test.cc ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698