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

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

Issue 600243002: Patchable AllocateArray stub, like instance allocation stubs. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 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
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"
(...skipping 16 matching lines...) Expand all
27 StubCode* stub_code = Isolate::Current()->stub_code(); 27 StubCode* stub_code = Isolate::Current()->stub_code();
28 CallPattern call(test->entry()); 28 CallPattern call(test->entry());
29 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(), 29 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(),
30 call.TargetAddress()); 30 call.TargetAddress());
31 } 31 }
32 32
33 33
34 ASSEMBLER_TEST_GENERATE(Jump, assembler) { 34 ASSEMBLER_TEST_GENERATE(Jump, assembler) {
35 StubCode* stub_code = Isolate::Current()->stub_code(); 35 StubCode* stub_code = Isolate::Current()->stub_code();
36 __ jmp(&stub_code->InvokeDartCodeLabel()); 36 __ jmp(&stub_code->InvokeDartCodeLabel());
37 __ jmp(&stub_code->AllocateArrayLabel()); 37 const Code& array_stub = Code::Handle(stub_code->GetAllocateArrayStub());
38 const ExternalLabel array_label(array_stub.EntryPoint());
39 __ jmp(&array_label);
38 __ ret(); 40 __ ret();
39 } 41 }
40 42
41 43
42 ASSEMBLER_TEST_RUN(Jump, test) { 44 ASSEMBLER_TEST_RUN(Jump, test) {
43 const Code& code = test->code(); 45 const Code& code = test->code();
44 const Instructions& instrs = Instructions::Handle(code.instructions()); 46 const Instructions& instrs = Instructions::Handle(code.instructions());
45 StubCode* stub_code = Isolate::Current()->stub_code(); 47 StubCode* stub_code = Isolate::Current()->stub_code();
46 bool status = 48 bool status =
47 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()), 49 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()),
48 instrs.size(), 50 instrs.size(),
49 VirtualMemory::kReadWrite); 51 VirtualMemory::kReadWrite);
50 EXPECT(status); 52 EXPECT(status);
51 JumpPattern jump1(test->entry(), test->code()); 53 JumpPattern jump1(test->entry(), test->code());
52 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(), 54 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(),
53 jump1.TargetAddress()); 55 jump1.TargetAddress());
54 JumpPattern jump2(test->entry() + jump1.pattern_length_in_bytes(), 56 JumpPattern jump2(test->entry() + jump1.pattern_length_in_bytes(),
55 test->code()); 57 test->code());
56 EXPECT_EQ(stub_code->AllocateArrayLabel().address(), 58 const Code& array_stub = Code::Handle(stub_code->GetAllocateArrayStub());
59 EXPECT_EQ(array_stub.EntryPoint(),
57 jump2.TargetAddress()); 60 jump2.TargetAddress());
58 uword target1 = jump1.TargetAddress(); 61 uword target1 = jump1.TargetAddress();
59 uword target2 = jump2.TargetAddress(); 62 uword target2 = jump2.TargetAddress();
60 jump1.SetTargetAddress(target2); 63 jump1.SetTargetAddress(target2);
61 jump2.SetTargetAddress(target1); 64 jump2.SetTargetAddress(target1);
62 EXPECT_EQ(stub_code->AllocateArrayLabel().address(), 65 EXPECT_EQ(array_stub.EntryPoint(),
63 jump1.TargetAddress()); 66 jump1.TargetAddress());
64 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(), 67 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(),
65 jump2.TargetAddress()); 68 jump2.TargetAddress());
66 } 69 }
67 70
68 } // namespace dart 71 } // namespace dart
69 72
70 #endif // defined TARGET_ARCH_IA32 73 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698