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

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

Issue 1192103004: VM: New calling convention for generated code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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_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"
(...skipping 12 matching lines...) Expand all
23 23
24 static intptr_t prologue_code_size = -1; 24 static intptr_t prologue_code_size = -1;
25 25
26 26
27 ASSEMBLER_TEST_GENERATE(Jump, assembler) { 27 ASSEMBLER_TEST_GENERATE(Jump, assembler) {
28 ASSERT(assembler->CodeSize() == 0); 28 ASSERT(assembler->CodeSize() == 0);
29 __ pushq(PP); 29 __ pushq(PP);
30 __ LoadPoolPointer(PP); 30 __ LoadPoolPointer(PP);
31 prologue_code_size = assembler->CodeSize(); 31 prologue_code_size = assembler->CodeSize();
32 StubCode* stub_code = Isolate::Current()->stub_code(); 32 StubCode* stub_code = Isolate::Current()->stub_code();
33 __ JmpPatchable(&stub_code->InvokeDartCodeLabel(), PP); 33 __ JmpPatchable(Code::Handle(stub_code->InvokeDartCodeCode()), PP);
34 const Code& array_stub = Code::Handle(stub_code->GetAllocateArrayStub()); 34 __ JmpPatchable(Code::Handle(stub_code->GetAllocateArrayStub()), PP);
35 const ExternalLabel array_label(array_stub.EntryPoint());
36 __ JmpPatchable(&array_label, PP);
37 __ popq(PP); 35 __ popq(PP);
38 __ ret(); 36 __ ret();
39 } 37 }
40 38
41 39
42 ASSEMBLER_TEST_RUN(Jump, test) { 40 ASSEMBLER_TEST_RUN(Jump, test) {
43 ASSERT(prologue_code_size != -1); 41 ASSERT(prologue_code_size != -1);
44 const Code& code = test->code(); 42 const Code& code = test->code();
45 const Instructions& instrs = Instructions::Handle(code.instructions()); 43 const Instructions& instrs = Instructions::Handle(code.instructions());
46 StubCode* stub_code = Isolate::Current()->stub_code(); 44 StubCode* stub_code = Isolate::Current()->stub_code();
47 bool status = 45 bool status =
48 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()), 46 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()),
49 instrs.size(), 47 instrs.size(),
50 VirtualMemory::kReadWrite); 48 VirtualMemory::kReadWrite);
51 EXPECT(status); 49 EXPECT(status);
52 JumpPattern jump1(test->entry() + prologue_code_size, test->code()); 50 JumpPattern jump1(test->entry() + prologue_code_size, test->code());
53 jump1.IsValid(); 51 jump1.IsValid();
54 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(), 52 EXPECT_EQ(stub_code->InvokeDartCodeCode(), jump1.TargetCode());
55 jump1.TargetAddress());
56 JumpPattern jump2((test->entry() + 53 JumpPattern jump2((test->entry() +
57 jump1.pattern_length_in_bytes() + prologue_code_size), 54 jump1.pattern_length_in_bytes() + prologue_code_size),
58 test->code()); 55 test->code());
59 const Code& array_stub = Code::Handle(stub_code->GetAllocateArrayStub()); 56 const Code& array_stub = Code::Handle(stub_code->GetAllocateArrayStub());
60 EXPECT_EQ(array_stub.EntryPoint(), jump2.TargetAddress()); 57 EXPECT_EQ(array_stub.raw(), jump2.TargetCode());
61 uword target1 = jump1.TargetAddress(); 58 const Code& target1 = Code::Handle(jump1.TargetCode());
62 uword target2 = jump2.TargetAddress(); 59 const Code& target2 = Code::Handle(jump2.TargetCode());
63 jump1.SetTargetAddress(target2); 60 jump1.SetTargetCode(target2);
64 jump2.SetTargetAddress(target1); 61 jump2.SetTargetCode(target1);
65 EXPECT_EQ(array_stub.EntryPoint(), jump1.TargetAddress()); 62 EXPECT_EQ(array_stub.raw(), jump1.TargetCode());
66 EXPECT_EQ(stub_code->InvokeDartCodeLabel().address(), 63 EXPECT_EQ(stub_code->InvokeDartCodeCode(), jump2.TargetCode());
67 jump2.TargetAddress());
68 } 64 }
69 65
70 } // namespace dart 66 } // namespace dart
71 67
72 #endif // defined TARGET_ARCH_X64 68 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698