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

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

Issue 221173011: Simplify handling of IC and megamorphic cache misses. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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_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::InstanceFunctionLookupLabel()); 18 __ call(&StubCode::InvokeDartCodeLabel());
19 __ ret(); 19 __ ret();
20 } 20 }
21 21
22 22
23 ASSEMBLER_TEST_RUN(Call, test) { 23 ASSEMBLER_TEST_RUN(Call, test) {
24 CallPattern call(test->entry(), test->code()); 24 CallPattern call(test->entry(), test->code());
25 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), 25 EXPECT_EQ(StubCode::InvokeDartCodeLabel().address(),
26 call.TargetAddress()); 26 call.TargetAddress());
27 } 27 }
28 28
29 29
30 static intptr_t prologue_code_size = -1; 30 static intptr_t prologue_code_size = -1;
31 31
32 32
33 ASSEMBLER_TEST_GENERATE(Jump, assembler) { 33 ASSEMBLER_TEST_GENERATE(Jump, assembler) {
34 ASSERT(assembler->CodeSize() == 0); 34 ASSERT(assembler->CodeSize() == 0);
35 __ pushq(PP); 35 __ pushq(PP);
36 __ LoadPoolPointer(PP); 36 __ LoadPoolPointer(PP);
37 prologue_code_size = assembler->CodeSize(); 37 prologue_code_size = assembler->CodeSize();
38 __ JmpPatchable(&StubCode::InstanceFunctionLookupLabel(), PP); 38 __ JmpPatchable(&StubCode::InvokeDartCodeLabel(), PP);
39 __ JmpPatchable(&StubCode::AllocateArrayLabel(), PP); 39 __ JmpPatchable(&StubCode::AllocateArrayLabel(), PP);
40 __ popq(PP); 40 __ popq(PP);
41 __ ret(); 41 __ ret();
42 } 42 }
43 43
44 44
45 ASSEMBLER_TEST_RUN(Jump, test) { 45 ASSEMBLER_TEST_RUN(Jump, test) {
46 ASSERT(prologue_code_size != -1); 46 ASSERT(prologue_code_size != -1);
47 const Code& code = test->code(); 47 const Code& code = test->code();
48 const Instructions& instrs = Instructions::Handle(code.instructions()); 48 const Instructions& instrs = Instructions::Handle(code.instructions());
49 bool status = 49 bool status =
50 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()), 50 VirtualMemory::Protect(reinterpret_cast<void*>(instrs.EntryPoint()),
51 instrs.size(), 51 instrs.size(),
52 VirtualMemory::kReadWrite); 52 VirtualMemory::kReadWrite);
53 EXPECT(status); 53 EXPECT(status);
54 JumpPattern jump1(test->entry() + prologue_code_size, test->code()); 54 JumpPattern jump1(test->entry() + prologue_code_size, test->code());
55 jump1.IsValid(); 55 jump1.IsValid();
56 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), 56 EXPECT_EQ(StubCode::InvokeDartCodeLabel().address(),
57 jump1.TargetAddress()); 57 jump1.TargetAddress());
58 JumpPattern jump2((test->entry() + 58 JumpPattern jump2((test->entry() +
59 jump1.pattern_length_in_bytes() + prologue_code_size), 59 jump1.pattern_length_in_bytes() + prologue_code_size),
60 test->code()); 60 test->code());
61 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), 61 EXPECT_EQ(StubCode::AllocateArrayLabel().address(),
62 jump2.TargetAddress()); 62 jump2.TargetAddress());
63 uword target1 = jump1.TargetAddress(); 63 uword target1 = jump1.TargetAddress();
64 uword target2 = jump2.TargetAddress(); 64 uword target2 = jump2.TargetAddress();
65 jump1.SetTargetAddress(target2); 65 jump1.SetTargetAddress(target2);
66 jump2.SetTargetAddress(target1); 66 jump2.SetTargetAddress(target1);
67 EXPECT_EQ(StubCode::AllocateArrayLabel().address(), 67 EXPECT_EQ(StubCode::AllocateArrayLabel().address(),
68 jump1.TargetAddress()); 68 jump1.TargetAddress());
69 EXPECT_EQ(StubCode::InstanceFunctionLookupLabel().address(), 69 EXPECT_EQ(StubCode::InvokeDartCodeLabel().address(),
70 jump2.TargetAddress()); 70 jump2.TargetAddress());
71 } 71 }
72 72
73 } // namespace dart 73 } // namespace dart
74 74
75 #endif // defined TARGET_ARCH_X64 75 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698