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

Side by Side Diff: runtime/vm/instructions_ia32_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_arm_test.cc ('k') | runtime/vm/instructions_mips_test.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_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 __ call(&StubCode::InvokeDartCodeLabel()); 20 StubCode* stub_code = Isolate::Current()->stub_code();
21 __ call(&stub_code->InvokeDartCodeLabel());
21 __ ret(); 22 __ ret();
22 } 23 }
23 24
24 25
25 ASSEMBLER_TEST_RUN(Call, test) { 26 ASSEMBLER_TEST_RUN(Call, test) {
27 StubCode* stub_code = Isolate::Current()->stub_code();
26 CallPattern call(test->entry()); 28 CallPattern call(test->entry());
27 EXPECT_EQ(StubCode::InvokeDartCodeLabel().address(), 29 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(),
28 call.TargetAddress()); 30 call.TargetAddress());
29 } 31 }
30 32
31 33
32 ASSEMBLER_TEST_GENERATE(Jump, assembler) { 34 ASSEMBLER_TEST_GENERATE(Jump, assembler) {
33 __ jmp(&StubCode::InvokeDartCodeLabel()); 35 StubCode* stub_code = Isolate::Current()->stub_code();
34 __ jmp(&StubCode::AllocateArrayLabel()); 36 __ jmp(&stub_code->InvokeDartCodeLabel());
37 __ jmp(&stub_code->AllocateArrayLabel());
35 __ ret(); 38 __ ret();
36 } 39 }
37 40
38 41
39 ASSEMBLER_TEST_RUN(Jump, test) { 42 ASSEMBLER_TEST_RUN(Jump, test) {
40 const Code& code = test->code(); 43 const Code& code = test->code();
41 const Instructions& instrs = Instructions::Handle(code.instructions()); 44 const Instructions& instrs = Instructions::Handle(code.instructions());
45 StubCode* stub_code = Isolate::Current()->stub_code();
42 bool status = 46 bool status =
43 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()), 47 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()),
44 instrs.size(), 48 instrs.size(),
45 VirtualMemory::kReadWrite); 49 VirtualMemory::kReadWrite);
46 EXPECT(status); 50 EXPECT(status);
47 JumpPattern jump1(test->entry(), test->code()); 51 JumpPattern jump1(test->entry(), test->code());
48 EXPECT_EQ(StubCode::InvokeDartCodeLabel().address(), 52 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(),
49 jump1.TargetAddress()); 53 jump1.TargetAddress());
50 JumpPattern jump2(test->entry() + jump1.pattern_length_in_bytes(), 54 JumpPattern jump2(test->entry() + jump1.pattern_length_in_bytes(),
51 test->code()); 55 test->code());
52 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), 56 EXPECT_EQ(stub_code->AllocateArrayLabel().address(),
53 jump2.TargetAddress()); 57 jump2.TargetAddress());
54 uword target1 = jump1.TargetAddress(); 58 uword target1 = jump1.TargetAddress();
55 uword target2 = jump2.TargetAddress(); 59 uword target2 = jump2.TargetAddress();
56 jump1.SetTargetAddress(target2); 60 jump1.SetTargetAddress(target2);
57 jump2.SetTargetAddress(target1); 61 jump2.SetTargetAddress(target1);
58 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), 62 EXPECT_EQ(stub_code->AllocateArrayLabel().address(),
59 jump1.TargetAddress()); 63 jump1.TargetAddress());
60 EXPECT_EQ(StubCode::InvokeDartCodeLabel().address(), 64 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(),
61 jump2.TargetAddress()); 65 jump2.TargetAddress());
62 } 66 }
63 67
64 } // namespace dart 68 } // namespace dart
65 69
66 #endif // defined TARGET_ARCH_IA32 70 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/instructions_arm_test.cc ('k') | runtime/vm/instructions_mips_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698