OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/code_generator.h" | 9 #include "vm/code_generator.h" |
10 #include "vm/code_patcher.h" | 10 #include "vm/code_patcher.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 SequenceNode* node_seq = test->node_sequence(); | 40 SequenceNode* node_seq = test->node_sequence(); |
41 ArgumentListNode* arguments = new ArgumentListNode(kPos); | 41 ArgumentListNode* arguments = new ArgumentListNode(kPos); |
42 node_seq->Add(new ReturnNode(kPos, | 42 node_seq->Add(new ReturnNode(kPos, |
43 new StaticCallNode(kPos, function, arguments))); | 43 new StaticCallNode(kPos, function, arguments))); |
44 } | 44 } |
45 | 45 |
46 CODEGEN_TEST2_RUN(PatchStaticCall, NativePatchStaticCall, Instance::null()); | 46 CODEGEN_TEST2_RUN(PatchStaticCall, NativePatchStaticCall, Instance::null()); |
47 | 47 |
48 #define __ assembler-> | 48 #define __ assembler-> |
49 | 49 |
50 ASSEMBLER_TEST_GENERATE(InsertCall, assembler) { | |
51 __ nop(); | |
52 __ nop(); | |
53 __ nop(); | |
54 __ nop(); | |
55 __ nop(); | |
56 __ ret(); | |
57 } | |
58 | |
59 | |
60 ASSEMBLER_TEST_RUN(InsertCall, entry) { | |
61 CodePatcher::InsertCall(entry, &StubCode::MegamorphicLookupLabel()); | |
62 Call call(entry); | |
63 EXPECT_EQ(StubCode::MegamorphicLookupLabel().address(), call.TargetAddress()); | |
64 } | |
65 | |
66 | |
67 ASSEMBLER_TEST_GENERATE(InsertJump, assembler) { | |
68 __ nop(); | |
69 __ nop(); | |
70 __ nop(); | |
71 __ nop(); | |
72 __ nop(); | |
73 __ ret(); | |
74 } | |
75 | |
76 | |
77 ASSEMBLER_TEST_RUN(InsertJump, entry) { | |
78 CodePatcher::InsertJump(entry, &StubCode::MegamorphicLookupLabel()); | |
79 Jump jump(entry); | |
80 EXPECT_EQ(StubCode::MegamorphicLookupLabel().address(), jump.TargetAddress()); | |
81 } | |
82 | |
83 | |
84 ASSEMBLER_TEST_GENERATE(IcDataAccess, assembler) { | 50 ASSEMBLER_TEST_GENERATE(IcDataAccess, assembler) { |
85 const String& function_name = String::Handle(String::New("Vermicelles")); | 51 const String& function_name = String::Handle(String::New("Vermicelles")); |
86 ICData ic_data(function_name, 1); | 52 ICData ic_data(function_name, 1); |
87 EXPECT(!Array::Handle(ic_data.data()).IsNull()); | 53 EXPECT(!Array::Handle(ic_data.data()).IsNull()); |
88 __ LoadObject(ECX, Array::ZoneHandle(ic_data.data())); | 54 __ LoadObject(ECX, Array::ZoneHandle(ic_data.data())); |
89 __ LoadObject(EDX, CodeGenerator::ArgumentsDescriptor(1, Array::Handle())); | 55 __ LoadObject(EDX, CodeGenerator::ArgumentsDescriptor(1, Array::Handle())); |
90 __ call(&StubCode::CallInstanceFunctionLabel()); | 56 ExternalLabel target_label( |
| 57 "InlineCache1", StubCode::InlineCache1EntryPoint()); |
| 58 __ call(&target_label); |
91 __ ret(); | 59 __ ret(); |
92 } | 60 } |
93 | 61 |
94 | 62 |
95 ASSEMBLER_TEST_RUN(IcDataAccess, entry) { | 63 ASSEMBLER_TEST_RUN(IcDataAccess, entry) { |
96 uword return_address = entry + CodePatcher::InstanceCallSizeInBytes(); | 64 uword return_address = entry + CodePatcher::InstanceCallSizeInBytes(); |
97 const Array& array = Array::Handle( | 65 const Array& array = Array::Handle( |
98 CodePatcher::GetInstanceCallIcDataAt(return_address)); | 66 CodePatcher::GetInstanceCallIcDataAt(return_address)); |
99 EXPECT(!array.IsNull()); | 67 EXPECT(!array.IsNull()); |
100 ICData ic_data(array); | 68 ICData ic_data(array); |
101 EXPECT_STREQ("Vermicelles", | 69 EXPECT_STREQ("Vermicelles", |
102 String::Handle(ic_data.FunctionName()).ToCString()); | 70 String::Handle(ic_data.FunctionName()).ToCString()); |
103 EXPECT_EQ(1, ic_data.NumberOfArgumentsChecked()); | 71 EXPECT_EQ(1, ic_data.NumberOfArgumentsChecked()); |
104 EXPECT_EQ(0, ic_data.NumberOfChecks()); | 72 EXPECT_EQ(0, ic_data.NumberOfChecks()); |
105 const String& new_function_name = String::Handle(String::New("Rigi")); | 73 const String& new_function_name = String::Handle(String::New("Rigi")); |
106 ICData new_ic_data(new_function_name, 1); | 74 ICData new_ic_data(new_function_name, 1); |
107 EXPECT_STREQ("Rigi", String::Handle(new_ic_data.FunctionName()).ToCString()); | 75 EXPECT_STREQ("Rigi", String::Handle(new_ic_data.FunctionName()).ToCString()); |
108 CodePatcher::SetInstanceCallIcDataAt(return_address, | 76 CodePatcher::SetInstanceCallIcDataAt(return_address, |
109 Array::ZoneHandle(new_ic_data.data())); | 77 Array::ZoneHandle(new_ic_data.data())); |
110 const Array& new_array = Array::Handle( | 78 const Array& new_array = Array::Handle( |
111 CodePatcher::GetInstanceCallIcDataAt(return_address)); | 79 CodePatcher::GetInstanceCallIcDataAt(return_address)); |
112 ICData test_ic_data(new_array); | 80 ICData test_ic_data(new_array); |
113 EXPECT_STREQ("Rigi", String::Handle(test_ic_data.FunctionName()).ToCString()); | 81 EXPECT_STREQ("Rigi", String::Handle(test_ic_data.FunctionName()).ToCString()); |
114 } | 82 } |
115 | 83 |
116 } // namespace dart | 84 } // namespace dart |
117 | 85 |
118 #endif // TARGET_ARCH_IA32 | 86 #endif // TARGET_ARCH_IA32 |
OLD | NEW |