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

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

Powered by Google App Engine
This is Rietveld 408576698