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

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

Issue 2015113002: DBC: Collect type feedback for fastpath smi ops (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add comment Created 4 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
« no previous file with comments | « no previous file | runtime/vm/constants_dbc.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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_DBC) 6 #if defined(TARGET_ARCH_DBC)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/stack_frame.h" 9 #include "vm/stack_frame.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
(...skipping 14 matching lines...) Expand all
25 #define EXECUTE_TEST_CODE_INTPTR(code) \ 25 #define EXECUTE_TEST_CODE_INTPTR(code) \
26 Smi::Value(Smi::RawCast(ExecuteTest(code))) 26 Smi::Value(Smi::RawCast(ExecuteTest(code)))
27 #define EXECUTE_TEST_CODE_BOOL(code) \ 27 #define EXECUTE_TEST_CODE_BOOL(code) \
28 (Bool::RawCast(ExecuteTest(code)) == Bool::True().raw()) 28 (Bool::RawCast(ExecuteTest(code)) == Bool::True().raw())
29 #define EXECUTE_TEST_CODE_OBJECT(code) \ 29 #define EXECUTE_TEST_CODE_OBJECT(code) \
30 Object::Handle(ExecuteTest(code)) 30 Object::Handle(ExecuteTest(code))
31 31
32 #define __ assembler-> 32 #define __ assembler->
33 33
34 34
35 static RawClass* CreateDummyClass(const String& class_name,
36 const Script& script) {
37 const Class& cls = Class::Handle(Class::New(
38 Library::Handle(), class_name, script, TokenPosition::kNoSource));
39 cls.set_is_synthesized_class(); // Dummy class for testing.
40 return cls.raw();
41 }
42
43
44 static RawLibrary* CreateDummyLibrary(const String& library_name) {
45 return Library::New(library_name);
46 }
47
48
49 static RawFunction* CreateFunction(const char* name) {
50 Thread* thread = Thread::Current();
51 const String& class_name = String::Handle(Symbols::New(thread, "ownerClass"));
52 const String& lib_name = String::Handle(Symbols::New(thread, "ownerLibrary"));
53 const Script& script = Script::Handle();
54 const Class& owner_class =
55 Class::Handle(CreateDummyClass(class_name, script));
56 const Library& owner_library =
57 Library::Handle(CreateDummyLibrary(lib_name));
58 owner_class.set_library(owner_library);
59 const String& function_name = String::ZoneHandle(Symbols::New(thread, name));
60 return Function::New(function_name, RawFunction::kRegularFunction,
61 true, false, false, false, false, owner_class,
62 TokenPosition::kMinSource);
63 }
64
65
66 static void GenerateDummyCode(Assembler* assembler, const Object& result) {
67 __ PushConstant(result);
68 __ ReturnTOS();
69 }
70
71
72 static void MakeDummyInstanceCall(Assembler* assembler, const Object& result) {
73 // Make a dummy function.
74 Assembler _assembler_;
75 GenerateDummyCode(&_assembler_, result);
76 const char* dummy_function_name = "dummy_instance_function";
77 const Function& dummy_instance_function =
78 Function::Handle(CreateFunction(dummy_function_name));
79 Code& code =
80 Code::Handle(Code::FinalizeCode(dummy_instance_function, &_assembler_));
81 dummy_instance_function.AttachCode(code);
82
83 // Make a dummy ICData.
84 const Array& dummy_arguments_descriptor =
85 Array::Handle(ArgumentsDescriptor::New(2));
86 const ICData& ic_data = ICData::Handle(ICData::New(
87 dummy_instance_function,
88 String::Handle(dummy_instance_function.name()),
89 dummy_arguments_descriptor,
90 Thread::kNoDeoptId,
91 2));
92
93 // Wire up the Function in the ICData.
94 GrowableArray<intptr_t> cids(2);
95 cids.Add(kSmiCid);
96 cids.Add(kSmiCid);
97 ic_data.AddCheck(cids, dummy_instance_function);
98
99 // For the non-Smi tests.
100 cids[0] = kBigintCid;
101 ic_data.AddCheck(cids, dummy_instance_function);
102 ICData* call_ic_data = &ICData::ZoneHandle(ic_data.Original());
103
104 // Generate the instance call.
105 const intptr_t call_ic_data_kidx = __ AddConstant(*call_ic_data);
106 __ InstanceCall2(2, call_ic_data_kidx);
107 }
108
109
35 ASSEMBLER_TEST_GENERATE(Simple, assembler) { 110 ASSEMBLER_TEST_GENERATE(Simple, assembler) {
36 __ PushConstant(Smi::Handle(Smi::New(42))); 111 __ PushConstant(Smi::Handle(Smi::New(42)));
37 __ ReturnTOS(); 112 __ ReturnTOS();
38 } 113 }
39 114
40 115
41 ASSEMBLER_TEST_RUN(Simple, test) { 116 ASSEMBLER_TEST_RUN(Simple, test) {
42 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 117 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
43 } 118 }
44 119
(...skipping 14 matching lines...) Expand all
59 // GreaterThanTOS; 134 // GreaterThanTOS;
60 // 135 //
61 // Smi fast-path for a corresponding method. Checks if SP[0] and SP[-1] are 136 // Smi fast-path for a corresponding method. Checks if SP[0] and SP[-1] are
62 // both smis and result of SP[0] <op> SP[-1] is a smi - if this is true 137 // both smis and result of SP[0] <op> SP[-1] is a smi - if this is true
63 // then pops operands and pushes result on the stack and skips the next 138 // then pops operands and pushes result on the stack and skips the next
64 // instruction (which implements a slow path fallback). 139 // instruction (which implements a slow path fallback).
65 ASSEMBLER_TEST_GENERATE(AddTOS, assembler) { 140 ASSEMBLER_TEST_GENERATE(AddTOS, assembler) {
66 __ PushConstant(Smi::Handle(Smi::New(-42))); 141 __ PushConstant(Smi::Handle(Smi::New(-42)));
67 __ PushConstant(Smi::Handle(Smi::New(84))); 142 __ PushConstant(Smi::Handle(Smi::New(84)));
68 __ AddTOS(); 143 __ AddTOS();
69 __ PushConstant(Smi::Handle(Smi::New(0))); // Should be skipped. 144 // Should be skipped.
145 MakeDummyInstanceCall(assembler, Smi::Handle(Smi::New(0)));
70 __ ReturnTOS(); 146 __ ReturnTOS();
71 } 147 }
72 148
73 149
74 ASSEMBLER_TEST_RUN(AddTOS, test) { 150 ASSEMBLER_TEST_RUN(AddTOS, test) {
75 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 151 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
76 } 152 }
77 153
78 154
79 ASSEMBLER_TEST_GENERATE(AddTOSOverflow, assembler) { 155 ASSEMBLER_TEST_GENERATE(AddTOSOverflow, assembler) {
80 __ PushConstant(Smi::Handle(Smi::New(Smi::kMaxValue))); 156 __ PushConstant(Smi::Handle(Smi::New(Smi::kMaxValue)));
81 __ PushConstant(Smi::Handle(Smi::New(1))); 157 __ PushConstant(Smi::Handle(Smi::New(1)));
82 __ AddTOS(); 158 __ AddTOS();
83 __ PushConstant(Smi::Handle(Smi::New(42))); // Shouldn't be skipped. 159 // Shouldn't be skipped.
160 MakeDummyInstanceCall(assembler, Smi::Handle(Smi::New(42)));
84 __ ReturnTOS(); 161 __ ReturnTOS();
85 } 162 }
86 163
87 164
88 ASSEMBLER_TEST_RUN(AddTOSOverflow, test) { 165 ASSEMBLER_TEST_RUN(AddTOSOverflow, test) {
89 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 166 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
90 } 167 }
91 168
92 169
93 ASSEMBLER_TEST_GENERATE(AddTOSNonSmi, assembler) { 170 ASSEMBLER_TEST_GENERATE(AddTOSNonSmi, assembler) {
94 const String& numstr = 171 const String& numstr =
95 String::Handle(String::New("98765432198765432100", Heap::kOld)); 172 String::Handle(String::New("98765432198765432100", Heap::kOld));
96 __ PushConstant(Integer::Handle(Integer::New(numstr, Heap::kOld))); 173 __ PushConstant(Integer::Handle(Integer::New(numstr, Heap::kOld)));
97 __ PushConstant(Smi::Handle(Smi::New(1))); 174 __ PushConstant(Smi::Handle(Smi::New(1)));
98 __ AddTOS(); 175 __ AddTOS();
99 __ PushConstant(Smi::Handle(Smi::New(42))); // Shouldn't be skipped. 176 // Shouldn't be skipped.
177 MakeDummyInstanceCall(assembler, Smi::Handle(Smi::New(42)));
100 __ ReturnTOS(); 178 __ ReturnTOS();
101 } 179 }
102 180
103 181
104 ASSEMBLER_TEST_RUN(AddTOSNonSmi, test) { 182 ASSEMBLER_TEST_RUN(AddTOSNonSmi, test) {
105 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 183 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
106 } 184 }
107 185
108 186
109 ASSEMBLER_TEST_GENERATE(SubTOS, assembler) { 187 ASSEMBLER_TEST_GENERATE(SubTOS, assembler) {
110 __ PushConstant(Smi::Handle(Smi::New(30))); 188 __ PushConstant(Smi::Handle(Smi::New(30)));
111 __ PushConstant(Smi::Handle(Smi::New(-12))); 189 __ PushConstant(Smi::Handle(Smi::New(-12)));
112 __ SubTOS(); 190 __ SubTOS();
113 __ PushConstant(Smi::Handle(Smi::New(0))); // Should be skipped. 191 // Should be skipped.
192 MakeDummyInstanceCall(assembler, Smi::Handle(Smi::New(0)));
114 __ ReturnTOS(); 193 __ ReturnTOS();
115 } 194 }
116 195
117 196
118 ASSEMBLER_TEST_RUN(SubTOS, test) { 197 ASSEMBLER_TEST_RUN(SubTOS, test) {
119 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 198 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
120 } 199 }
121 200
122 201
123 ASSEMBLER_TEST_GENERATE(SubTOSOverflow, assembler) { 202 ASSEMBLER_TEST_GENERATE(SubTOSOverflow, assembler) {
124 __ PushConstant(Smi::Handle(Smi::New(Smi::kMinValue))); 203 __ PushConstant(Smi::Handle(Smi::New(Smi::kMinValue)));
125 __ PushConstant(Smi::Handle(Smi::New(1))); 204 __ PushConstant(Smi::Handle(Smi::New(1)));
126 __ SubTOS(); 205 __ SubTOS();
127 __ PushConstant(Smi::Handle(Smi::New(42))); // Shouldn't be skipped. 206 // Shouldn't be skipped.
207 MakeDummyInstanceCall(assembler, Smi::Handle(Smi::New(42)));
128 __ ReturnTOS(); 208 __ ReturnTOS();
129 } 209 }
130 210
131 211
132 ASSEMBLER_TEST_RUN(SubTOSOverflow, test) { 212 ASSEMBLER_TEST_RUN(SubTOSOverflow, test) {
133 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 213 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
134 } 214 }
135 215
136 216
137 ASSEMBLER_TEST_GENERATE(SubTOSNonSmi, assembler) { 217 ASSEMBLER_TEST_GENERATE(SubTOSNonSmi, assembler) {
138 const String& numstr = 218 const String& numstr =
139 String::Handle(String::New("98765432198765432100", Heap::kOld)); 219 String::Handle(String::New("98765432198765432100", Heap::kOld));
140 __ PushConstant(Integer::Handle(Integer::New(numstr, Heap::kOld))); 220 __ PushConstant(Integer::Handle(Integer::New(numstr, Heap::kOld)));
141 __ PushConstant(Smi::Handle(Smi::New(1))); 221 __ PushConstant(Smi::Handle(Smi::New(1)));
142 __ SubTOS(); 222 __ SubTOS();
143 __ PushConstant(Smi::Handle(Smi::New(42))); // Shouldn't be skipped. 223 // Shouldn't be skipped.
224 MakeDummyInstanceCall(assembler, Smi::Handle(Smi::New(42)));
144 __ ReturnTOS(); 225 __ ReturnTOS();
145 } 226 }
146 227
147 228
148 ASSEMBLER_TEST_RUN(SubTOSNonSmi, test) { 229 ASSEMBLER_TEST_RUN(SubTOSNonSmi, test) {
149 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 230 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
150 } 231 }
151 232
152 233
153 ASSEMBLER_TEST_GENERATE(MulTOS, assembler) { 234 ASSEMBLER_TEST_GENERATE(MulTOS, assembler) {
154 __ PushConstant(Smi::Handle(Smi::New(-6))); 235 __ PushConstant(Smi::Handle(Smi::New(-6)));
155 __ PushConstant(Smi::Handle(Smi::New(-7))); 236 __ PushConstant(Smi::Handle(Smi::New(-7)));
156 __ MulTOS(); 237 __ MulTOS();
157 __ PushConstant(Smi::Handle(Smi::New(0))); // Should be skipped. 238 // Should be skipped.
239 MakeDummyInstanceCall(assembler, Smi::Handle(Smi::New(0)));
158 __ ReturnTOS(); 240 __ ReturnTOS();
159 } 241 }
160 242
161 243
162 ASSEMBLER_TEST_RUN(MulTOS, test) { 244 ASSEMBLER_TEST_RUN(MulTOS, test) {
163 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 245 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
164 } 246 }
165 247
166 248
167 ASSEMBLER_TEST_GENERATE(MulTOSOverflow, assembler) { 249 ASSEMBLER_TEST_GENERATE(MulTOSOverflow, assembler) {
168 __ PushConstant(Smi::Handle(Smi::New(Smi::kMaxValue))); 250 __ PushConstant(Smi::Handle(Smi::New(Smi::kMaxValue)));
169 __ PushConstant(Smi::Handle(Smi::New(-8))); 251 __ PushConstant(Smi::Handle(Smi::New(-8)));
170 __ MulTOS(); 252 __ MulTOS();
171 __ PushConstant(Smi::Handle(Smi::New(42))); // Shouldn't be skipped. 253 // Shouldn't be skipped.
254 MakeDummyInstanceCall(assembler, Smi::Handle(Smi::New(42)));
172 __ ReturnTOS(); 255 __ ReturnTOS();
173 } 256 }
174 257
175 258
176 ASSEMBLER_TEST_RUN(MulTOSOverflow, test) { 259 ASSEMBLER_TEST_RUN(MulTOSOverflow, test) {
177 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 260 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
178 } 261 }
179 262
180 263
181 ASSEMBLER_TEST_GENERATE(MulTOSNonSmi, assembler) { 264 ASSEMBLER_TEST_GENERATE(MulTOSNonSmi, assembler) {
182 const String& numstr = 265 const String& numstr =
183 String::Handle(String::New("98765432198765432100", Heap::kOld)); 266 String::Handle(String::New("98765432198765432100", Heap::kOld));
184 __ PushConstant(Integer::Handle(Integer::New(numstr, Heap::kOld))); 267 __ PushConstant(Integer::Handle(Integer::New(numstr, Heap::kOld)));
185 __ PushConstant(Smi::Handle(Smi::New(1))); 268 __ PushConstant(Smi::Handle(Smi::New(1)));
186 __ MulTOS(); 269 __ MulTOS();
187 __ PushConstant(Smi::Handle(Smi::New(42))); // Shouldn't be skipped. 270 // Shouldn't be skipped.
271 MakeDummyInstanceCall(assembler, Smi::Handle(Smi::New(42)));
188 __ ReturnTOS(); 272 __ ReturnTOS();
189 } 273 }
190 274
191 275
192 ASSEMBLER_TEST_RUN(MulTOSNonSmi, test) { 276 ASSEMBLER_TEST_RUN(MulTOSNonSmi, test) {
193 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 277 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
194 } 278 }
195 279
196 280
197 ASSEMBLER_TEST_GENERATE(BitOrTOS, assembler) { 281 ASSEMBLER_TEST_GENERATE(BitOrTOS, assembler) {
198 __ PushConstant(Smi::Handle(Smi::New(0x22))); 282 __ PushConstant(Smi::Handle(Smi::New(0x22)));
199 __ PushConstant(Smi::Handle(Smi::New(0x08))); 283 __ PushConstant(Smi::Handle(Smi::New(0x08)));
200 __ BitOrTOS(); 284 __ BitOrTOS();
201 __ PushConstant(Smi::Handle(Smi::New(0))); // Should be skipped. 285 // Should be skipped.
286 MakeDummyInstanceCall(assembler, Smi::Handle(Smi::New(0)));
202 __ ReturnTOS(); 287 __ ReturnTOS();
203 } 288 }
204 289
205 290
206 ASSEMBLER_TEST_RUN(BitOrTOS, test) { 291 ASSEMBLER_TEST_RUN(BitOrTOS, test) {
207 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 292 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
208 } 293 }
209 294
210 295
211 ASSEMBLER_TEST_GENERATE(BitOrTOSNonSmi, assembler) { 296 ASSEMBLER_TEST_GENERATE(BitOrTOSNonSmi, assembler) {
212 const String& numstr = 297 const String& numstr =
213 String::Handle(String::New("98765432198765432100", Heap::kOld)); 298 String::Handle(String::New("98765432198765432100", Heap::kOld));
214 __ PushConstant(Integer::Handle(Integer::New(numstr, Heap::kOld))); 299 __ PushConstant(Integer::Handle(Integer::New(numstr, Heap::kOld)));
215 __ PushConstant(Smi::Handle(Smi::New(0x08))); 300 __ PushConstant(Smi::Handle(Smi::New(0x08)));
216 __ BitOrTOS(); 301 __ BitOrTOS();
217 __ PushConstant(Smi::Handle(Smi::New(42))); // Shouldn't be skipped. 302 // Shouldn't be skipped.
303 MakeDummyInstanceCall(assembler, Smi::Handle(Smi::New(42)));
218 __ ReturnTOS(); 304 __ ReturnTOS();
219 } 305 }
220 306
221 307
222 ASSEMBLER_TEST_RUN(BitOrTOSNonSmi, test) { 308 ASSEMBLER_TEST_RUN(BitOrTOSNonSmi, test) {
223 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 309 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
224 } 310 }
225 311
226 312
227 ASSEMBLER_TEST_GENERATE(BitAndTOS, assembler) { 313 ASSEMBLER_TEST_GENERATE(BitAndTOS, assembler) {
228 __ PushConstant(Smi::Handle(Smi::New(0x2a))); 314 __ PushConstant(Smi::Handle(Smi::New(0x2a)));
229 __ PushConstant(Smi::Handle(Smi::New(0xaa))); 315 __ PushConstant(Smi::Handle(Smi::New(0xaa)));
230 __ BitAndTOS(); 316 __ BitAndTOS();
231 __ PushConstant(Smi::Handle(Smi::New(0))); // Should be skipped. 317 // Should be skipped.
318 MakeDummyInstanceCall(assembler, Smi::Handle(Smi::New(0)));
232 __ ReturnTOS(); 319 __ ReturnTOS();
233 } 320 }
234 321
235 322
236 ASSEMBLER_TEST_RUN(BitAndTOS, test) { 323 ASSEMBLER_TEST_RUN(BitAndTOS, test) {
237 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 324 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
238 } 325 }
239 326
240 327
241 ASSEMBLER_TEST_GENERATE(BitAndTOSNonSmi, assembler) { 328 ASSEMBLER_TEST_GENERATE(BitAndTOSNonSmi, assembler) {
242 const String& numstr = 329 const String& numstr =
243 String::Handle(String::New("98765432198765432100", Heap::kOld)); 330 String::Handle(String::New("98765432198765432100", Heap::kOld));
244 __ PushConstant(Integer::Handle(Integer::New(numstr, Heap::kOld))); 331 __ PushConstant(Integer::Handle(Integer::New(numstr, Heap::kOld)));
245 __ PushConstant(Smi::Handle(Smi::New(0x08))); 332 __ PushConstant(Smi::Handle(Smi::New(0x08)));
246 __ BitAndTOS(); 333 __ BitAndTOS();
247 __ PushConstant(Smi::Handle(Smi::New(42))); // Shouldn't be skipped. 334 // Shouldn't be skipped.
335 MakeDummyInstanceCall(assembler, Smi::Handle(Smi::New(42)));
248 __ ReturnTOS(); 336 __ ReturnTOS();
249 } 337 }
250 338
251 339
252 ASSEMBLER_TEST_RUN(BitAndTOSNonSmi, test) { 340 ASSEMBLER_TEST_RUN(BitAndTOSNonSmi, test) {
253 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 341 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
254 } 342 }
255 343
256 344
257 ASSEMBLER_TEST_GENERATE(EqualTOSTrue, assembler) { 345 ASSEMBLER_TEST_GENERATE(EqualTOSTrue, assembler) {
258 __ PushConstant(Smi::Handle(Smi::New(42))); 346 __ PushConstant(Smi::Handle(Smi::New(42)));
259 __ PushConstant(Smi::Handle(Smi::New(42))); 347 __ PushConstant(Smi::Handle(Smi::New(42)));
260 __ EqualTOS(); 348 __ EqualTOS();
261 __ PushConstant(Bool::False()); // Should be skipped. 349 // Should be skipped.
350 MakeDummyInstanceCall(assembler, Bool::False());
262 __ ReturnTOS(); 351 __ ReturnTOS();
263 } 352 }
264 353
265 354
266 ASSEMBLER_TEST_RUN(EqualTOSTrue, test) { 355 ASSEMBLER_TEST_RUN(EqualTOSTrue, test) {
267 EXPECT(EXECUTE_TEST_CODE_BOOL(test->code())); 356 EXPECT(EXECUTE_TEST_CODE_BOOL(test->code()));
268 } 357 }
269 358
270 359
271 ASSEMBLER_TEST_GENERATE(EqualTOSFalse, assembler) { 360 ASSEMBLER_TEST_GENERATE(EqualTOSFalse, assembler) {
272 __ PushConstant(Smi::Handle(Smi::New(42))); 361 __ PushConstant(Smi::Handle(Smi::New(42)));
273 __ PushConstant(Smi::Handle(Smi::New(-42))); 362 __ PushConstant(Smi::Handle(Smi::New(-42)));
274 __ EqualTOS(); 363 __ EqualTOS();
275 __ PushConstant(Bool::True()); // Should be skipped. 364 // Should be skipped.
365 MakeDummyInstanceCall(assembler, Bool::True());
276 __ ReturnTOS(); 366 __ ReturnTOS();
277 } 367 }
278 368
279 369
280 ASSEMBLER_TEST_RUN(EqualTOSFalse, test) { 370 ASSEMBLER_TEST_RUN(EqualTOSFalse, test) {
281 EXPECT(!EXECUTE_TEST_CODE_BOOL(test->code())); 371 EXPECT(!EXECUTE_TEST_CODE_BOOL(test->code()));
282 } 372 }
283 373
284 374
285 ASSEMBLER_TEST_GENERATE(EqualTOSNonSmi, assembler) { 375 ASSEMBLER_TEST_GENERATE(EqualTOSNonSmi, assembler) {
286 const String& numstr = 376 const String& numstr =
287 String::Handle(String::New("98765432198765432100", Heap::kOld)); 377 String::Handle(String::New("98765432198765432100", Heap::kOld));
288 __ PushConstant(Integer::Handle(Integer::New(numstr, Heap::kOld))); 378 __ PushConstant(Integer::Handle(Integer::New(numstr, Heap::kOld)));
289 __ PushConstant(Smi::Handle(Smi::New(-42))); 379 __ PushConstant(Smi::Handle(Smi::New(-42)));
290 __ EqualTOS(); 380 __ EqualTOS();
291 __ PushConstant(Bool::True()); // Shouldn't be skipped. 381 // Shouldn't be skipped.
382 MakeDummyInstanceCall(assembler, Bool::True());
292 __ ReturnTOS(); 383 __ ReturnTOS();
293 } 384 }
294 385
295 386
296 ASSEMBLER_TEST_RUN(EqualTOSNonSmi, test) { 387 ASSEMBLER_TEST_RUN(EqualTOSNonSmi, test) {
297 EXPECT(EXECUTE_TEST_CODE_BOOL(test->code())); 388 EXPECT(EXECUTE_TEST_CODE_BOOL(test->code()));
298 } 389 }
299 390
300 391
301 ASSEMBLER_TEST_GENERATE(LessThanTOSTrue, assembler) { 392 ASSEMBLER_TEST_GENERATE(LessThanTOSTrue, assembler) {
302 __ PushConstant(Smi::Handle(Smi::New(-42))); 393 __ PushConstant(Smi::Handle(Smi::New(-42)));
303 __ PushConstant(Smi::Handle(Smi::New(42))); 394 __ PushConstant(Smi::Handle(Smi::New(42)));
304 __ LessThanTOS(); 395 __ LessThanTOS();
305 __ PushConstant(Bool::False()); // Should be skipped. 396 // Should be skipped.
397 MakeDummyInstanceCall(assembler, Bool::False());
306 __ ReturnTOS(); 398 __ ReturnTOS();
307 } 399 }
308 400
309 401
310 ASSEMBLER_TEST_RUN(LessThanTOSTrue, test) { 402 ASSEMBLER_TEST_RUN(LessThanTOSTrue, test) {
311 EXPECT(EXECUTE_TEST_CODE_BOOL(test->code())); 403 EXPECT(EXECUTE_TEST_CODE_BOOL(test->code()));
312 } 404 }
313 405
314 406
315 ASSEMBLER_TEST_GENERATE(LessThanTOSFalse, assembler) { 407 ASSEMBLER_TEST_GENERATE(LessThanTOSFalse, assembler) {
316 __ PushConstant(Smi::Handle(Smi::New(42))); 408 __ PushConstant(Smi::Handle(Smi::New(42)));
317 __ PushConstant(Smi::Handle(Smi::New(-42))); 409 __ PushConstant(Smi::Handle(Smi::New(-42)));
318 __ LessThanTOS(); 410 __ LessThanTOS();
319 __ PushConstant(Bool::False()); // Should be skipped. 411 // Should be skipped.
412 MakeDummyInstanceCall(assembler, Bool::False());
320 __ ReturnTOS(); 413 __ ReturnTOS();
321 } 414 }
322 415
323 416
324 ASSEMBLER_TEST_RUN(LessThanTOSFalse, test) { 417 ASSEMBLER_TEST_RUN(LessThanTOSFalse, test) {
325 EXPECT(!EXECUTE_TEST_CODE_BOOL(test->code())); 418 EXPECT(!EXECUTE_TEST_CODE_BOOL(test->code()));
326 } 419 }
327 420
328 421
329 ASSEMBLER_TEST_GENERATE(LessThanTOSNonSmi, assembler) { 422 ASSEMBLER_TEST_GENERATE(LessThanTOSNonSmi, assembler) {
330 const String& numstr = 423 const String& numstr =
331 String::Handle(String::New("98765432198765432100", Heap::kOld)); 424 String::Handle(String::New("98765432198765432100", Heap::kOld));
332 __ PushConstant(Integer::Handle(Integer::New(numstr, Heap::kOld))); 425 __ PushConstant(Integer::Handle(Integer::New(numstr, Heap::kOld)));
333 __ PushConstant(Smi::Handle(Smi::New(-42))); 426 __ PushConstant(Smi::Handle(Smi::New(-42)));
334 __ LessThanTOS(); 427 __ LessThanTOS();
335 __ PushConstant(Bool::True()); // Shouldn't be skipped. 428 // Shouldn't be skipped.
429 MakeDummyInstanceCall(assembler, Bool::True());
336 __ ReturnTOS(); 430 __ ReturnTOS();
337 } 431 }
338 432
339 433
340 ASSEMBLER_TEST_RUN(LessThanTOSNonSmi, test) { 434 ASSEMBLER_TEST_RUN(LessThanTOSNonSmi, test) {
341 EXPECT(EXECUTE_TEST_CODE_BOOL(test->code())); 435 EXPECT(EXECUTE_TEST_CODE_BOOL(test->code()));
342 } 436 }
343 437
344 438
345 ASSEMBLER_TEST_GENERATE(GreaterThanTOSTrue, assembler) { 439 ASSEMBLER_TEST_GENERATE(GreaterThanTOSTrue, assembler) {
346 __ PushConstant(Smi::Handle(Smi::New(42))); 440 __ PushConstant(Smi::Handle(Smi::New(42)));
347 __ PushConstant(Smi::Handle(Smi::New(-42))); 441 __ PushConstant(Smi::Handle(Smi::New(-42)));
348 __ GreaterThanTOS(); 442 __ GreaterThanTOS();
349 __ PushConstant(Bool::False()); // Should be skipped. 443 // Should be skipped.
444 MakeDummyInstanceCall(assembler, Bool::False());
350 __ ReturnTOS(); 445 __ ReturnTOS();
351 } 446 }
352 447
353 448
354 ASSEMBLER_TEST_RUN(GreaterThanTOSTrue, test) { 449 ASSEMBLER_TEST_RUN(GreaterThanTOSTrue, test) {
355 EXPECT(EXECUTE_TEST_CODE_BOOL(test->code())); 450 EXPECT(EXECUTE_TEST_CODE_BOOL(test->code()));
356 } 451 }
357 452
358 453
359 ASSEMBLER_TEST_GENERATE(GreaterThanTOSFalse, assembler) { 454 ASSEMBLER_TEST_GENERATE(GreaterThanTOSFalse, assembler) {
360 __ PushConstant(Smi::Handle(Smi::New(-42))); 455 __ PushConstant(Smi::Handle(Smi::New(-42)));
361 __ PushConstant(Smi::Handle(Smi::New(42))); 456 __ PushConstant(Smi::Handle(Smi::New(42)));
362 __ GreaterThanTOS(); 457 __ GreaterThanTOS();
363 __ PushConstant(Bool::False()); // Should be skipped. 458 // Should be skipped.
459 MakeDummyInstanceCall(assembler, Bool::False());
364 __ ReturnTOS(); 460 __ ReturnTOS();
365 } 461 }
366 462
367 463
368 ASSEMBLER_TEST_RUN(GreaterThanTOSFalse, test) { 464 ASSEMBLER_TEST_RUN(GreaterThanTOSFalse, test) {
369 EXPECT(!EXECUTE_TEST_CODE_BOOL(test->code())); 465 EXPECT(!EXECUTE_TEST_CODE_BOOL(test->code()));
370 } 466 }
371 467
372 468
373 ASSEMBLER_TEST_GENERATE(GreaterThanTOSNonSmi, assembler) { 469 ASSEMBLER_TEST_GENERATE(GreaterThanTOSNonSmi, assembler) {
374 const String& numstr = 470 const String& numstr =
375 String::Handle(String::New("98765432198765432100", Heap::kOld)); 471 String::Handle(String::New("98765432198765432100", Heap::kOld));
376 __ PushConstant(Integer::Handle(Integer::New(numstr, Heap::kOld))); 472 __ PushConstant(Integer::Handle(Integer::New(numstr, Heap::kOld)));
377 __ PushConstant(Smi::Handle(Smi::New(-42))); 473 __ PushConstant(Smi::Handle(Smi::New(-42)));
378 __ GreaterThanTOS(); 474 __ GreaterThanTOS();
379 __ PushConstant(Bool::True()); // Shouldn't be skipped. 475 // Shouldn't be skipped.
476 MakeDummyInstanceCall(assembler, Bool::True());
380 __ ReturnTOS(); 477 __ ReturnTOS();
381 } 478 }
382 479
383 480
384 ASSEMBLER_TEST_RUN(GreaterThanTOSNonSmi, test) { 481 ASSEMBLER_TEST_RUN(GreaterThanTOSNonSmi, test) {
385 EXPECT(EXECUTE_TEST_CODE_BOOL(test->code())); 482 EXPECT(EXECUTE_TEST_CODE_BOOL(test->code()));
386 } 483 }
387 484
388 485
389 // - IfNeStrictTOS; IfEqStrictTOS; IfNeStrictNumTOS; IfEqStrictNumTOS 486 // - IfNeStrictTOS; IfEqStrictTOS; IfNeStrictNumTOS; IfEqStrictNumTOS
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 __ PushConstant(Smi::Handle(Smi::New(37))); 867 __ PushConstant(Smi::Handle(Smi::New(37)));
771 __ PushConstant(Smi::Handle(Smi::New(37))); 868 __ PushConstant(Smi::Handle(Smi::New(37)));
772 __ PushConstant(Smi::Handle(Smi::New(37))); 869 __ PushConstant(Smi::Handle(Smi::New(37)));
773 __ PushConstant(Smi::Handle(Smi::New(37))); 870 __ PushConstant(Smi::Handle(Smi::New(37)));
774 __ PushConstant(Smi::Handle(Smi::New(37))); 871 __ PushConstant(Smi::Handle(Smi::New(37)));
775 __ PushConstant(Smi::Handle(Smi::New(37))); 872 __ PushConstant(Smi::Handle(Smi::New(37)));
776 __ PushConstant(Smi::Handle(Smi::New(37))); 873 __ PushConstant(Smi::Handle(Smi::New(37)));
777 __ PushConstant(Smi::Handle(Smi::New(41))); 874 __ PushConstant(Smi::Handle(Smi::New(41)));
778 __ DropR(11); 875 __ DropR(11);
779 __ AddTOS(); 876 __ AddTOS();
780 __ PushConstant(Smi::Handle(Smi::New(0))); // Should be skipped. 877 MakeDummyInstanceCall(assembler, Smi::Handle(Smi::New(0)));
781 __ ReturnTOS(); 878 __ ReturnTOS();
782 } 879 }
783 880
784 881
785 ASSEMBLER_TEST_RUN(DropR, test) { 882 ASSEMBLER_TEST_RUN(DropR, test) {
786 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 883 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
787 } 884 }
788 885
789 886
790 // - Frame D 887 // - Frame D
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 930
834 // - StoreLocal rX; PopLocal rX 931 // - StoreLocal rX; PopLocal rX
835 // 932 //
836 // Store top of the stack into FP[rX] and pop it if needed. 933 // Store top of the stack into FP[rX] and pop it if needed.
837 // 934 //
838 // - Push rX 935 // - Push rX
839 // 936 //
840 // Push FP[rX] to the stack. 937 // Push FP[rX] to the stack.
841 ASSEMBLER_TEST_GENERATE(StoreLocalPush, assembler) { 938 ASSEMBLER_TEST_GENERATE(StoreLocalPush, assembler) {
842 __ Frame(1); 939 __ Frame(1);
940 __ PushConstant(Smi::Handle(Smi::New(37)));
843 __ PushConstant(Smi::Handle(Smi::New(21))); 941 __ PushConstant(Smi::Handle(Smi::New(21)));
844 __ StoreLocal(0); 942 __ StoreLocal(0);
845 __ Push(0); 943 __ Push(0);
846 __ AddTOS(); 944 __ AddTOS();
847 __ PushConstant(Smi::Handle(Smi::New(0))); // Should be skipped. 945 // Should be skipped.
946 MakeDummyInstanceCall(assembler, Smi::Handle(Smi::New(0)));
848 __ ReturnTOS(); 947 __ ReturnTOS();
849 } 948 }
850 949
851 950
852 ASSEMBLER_TEST_RUN(StoreLocalPush, test) { 951 ASSEMBLER_TEST_RUN(StoreLocalPush, test) {
853 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 952 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
854 } 953 }
855 954
856 955
857 ASSEMBLER_TEST_GENERATE(PopLocalPush, assembler) { 956 ASSEMBLER_TEST_GENERATE(PopLocalPush, assembler) {
858 __ Frame(1); 957 __ Frame(1);
859 __ PushConstant(Smi::Handle(Smi::New(21))); 958 __ PushConstant(Smi::Handle(Smi::New(21)));
860 __ PopLocal(0); 959 __ PopLocal(0);
861 __ Push(0); 960 __ Push(0);
862 __ Push(0); 961 __ Push(0);
863 __ AddTOS(); 962 __ AddTOS();
864 __ PushConstant(Smi::Handle(Smi::New(0))); // Should be skipped. 963 // Should be skipped.
964 MakeDummyInstanceCall(assembler, Smi::Handle(Smi::New(0)));
865 __ ReturnTOS(); 965 __ ReturnTOS();
866 } 966 }
867 967
868 968
869 ASSEMBLER_TEST_RUN(PopLocalPush, test) { 969 ASSEMBLER_TEST_RUN(PopLocalPush, test) {
870 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 970 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
871 } 971 }
872 972
873 973
874 ASSEMBLER_TEST_GENERATE(LoadConstantPush, assembler) { 974 ASSEMBLER_TEST_GENERATE(LoadConstantPush, assembler) {
875 __ Frame(1); 975 __ Frame(1);
876 __ LoadConstant(0, Smi::Handle(Smi::New(21))); 976 __ LoadConstant(0, Smi::Handle(Smi::New(21)));
877 __ Push(0); 977 __ Push(0);
878 __ Push(0); 978 __ Push(0);
879 __ AddTOS(); 979 __ AddTOS();
880 __ PushConstant(Smi::Handle(Smi::New(0))); // Should be skipped. 980 // Should be skipped.
981 MakeDummyInstanceCall(assembler, Smi::Handle(Smi::New(0)));
881 __ ReturnTOS(); 982 __ ReturnTOS();
882 } 983 }
883 984
884 985
885 ASSEMBLER_TEST_RUN(LoadConstantPush, test) { 986 ASSEMBLER_TEST_RUN(LoadConstantPush, test) {
886 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 987 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
887 } 988 }
888 989
889 990
890 // - Move rA, rX 991 // - Move rA, rX
891 // 992 //
892 // FP[rA] <- FP[rX] 993 // FP[rA] <- FP[rX]
893 // Note: rX is signed so it can be used to address parameters which are 994 // Note: rX is signed so it can be used to address parameters which are
894 // at negative indices with respect to FP. 995 // at negative indices with respect to FP.
895 ASSEMBLER_TEST_GENERATE(MoveLocalLocal, assembler) { 996 ASSEMBLER_TEST_GENERATE(MoveLocalLocal, assembler) {
896 __ Frame(2); 997 __ Frame(2);
897 __ PushConstant(Smi::Handle(Smi::New(21))); 998 __ PushConstant(Smi::Handle(Smi::New(21)));
898 __ PopLocal(0); 999 __ PopLocal(0);
899 __ Move(1, 0); 1000 __ Move(1, 0);
900 __ Push(0); 1001 __ Push(0);
901 __ Push(1); 1002 __ Push(1);
902 __ AddTOS(); 1003 __ AddTOS();
903 __ PushConstant(Smi::Handle(Smi::New(0))); // Should be skipped. 1004 // Should be skipped.
1005 MakeDummyInstanceCall(assembler, Smi::Handle(Smi::New(0)));
904 __ ReturnTOS(); 1006 __ ReturnTOS();
905 } 1007 }
906 1008
907 1009
908 ASSEMBLER_TEST_RUN(MoveLocalLocal, test) { 1010 ASSEMBLER_TEST_RUN(MoveLocalLocal, test) {
909 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 1011 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
910 } 1012 }
911 1013
912 1014
913 // - Return R; ReturnTOS 1015 // - Return R; ReturnTOS
(...skipping 30 matching lines...) Expand all
944 __ Frame(2); 1046 __ Frame(2);
945 __ LoadConstant(0, Smi::Handle(Smi::New(42))); 1047 __ LoadConstant(0, Smi::Handle(Smi::New(42)));
946 __ LoadConstant(1, Smi::Handle(Smi::New(0))); 1048 __ LoadConstant(1, Smi::Handle(Smi::New(0)));
947 1049
948 Label loop_entry, error; 1050 Label loop_entry, error;
949 __ Bind(&loop_entry); 1051 __ Bind(&loop_entry);
950 // Add 1 to FP[1]. 1052 // Add 1 to FP[1].
951 __ PushConstant(Smi::Handle(Smi::New(1))); 1053 __ PushConstant(Smi::Handle(Smi::New(1)));
952 __ Push(1); 1054 __ Push(1);
953 __ AddTOS(); 1055 __ AddTOS();
954 __ Jump(&error); 1056 // Should be skipped.
1057 MakeDummyInstanceCall(assembler, Smi::Handle(Smi::New(-1)));
955 __ PopLocal(1); 1058 __ PopLocal(1);
956 1059
957 // Subtract 1 from FP[0]. 1060 // Subtract 1 from FP[0].
958 __ Push(0); 1061 __ Push(0);
959 __ PushConstant(Smi::Handle(Smi::New(1))); 1062 __ PushConstant(Smi::Handle(Smi::New(1)));
960 __ SubTOS(); 1063 __ SubTOS();
961 __ Jump(&error); 1064 // Should be skipped.
1065 MakeDummyInstanceCall(assembler, Smi::Handle(Smi::New(-1)));
962 1066
963 // Jump to loop_entry if FP[0] != 0. 1067 // Jump to loop_entry if FP[0] != 0.
964 __ StoreLocal(0); 1068 __ StoreLocal(0);
965 __ PushConstant(Smi::Handle(Smi::New(0))); 1069 __ PushConstant(Smi::Handle(Smi::New(0)));
966 __ IfNeStrictNumTOS(); 1070 __ IfNeStrictNumTOS();
967 __ Jump(&loop_entry); 1071 __ Jump(&loop_entry);
968 1072
969 __ Return(1); 1073 __ Return(1);
970 1074
971 __ Bind(&error); 1075 __ Bind(&error);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 const Object& obj = EXECUTE_TEST_CODE_OBJECT(test->code()); 1128 const Object& obj = EXECUTE_TEST_CODE_OBJECT(test->code());
1025 EXPECT(obj.IsArray()); 1129 EXPECT(obj.IsArray());
1026 Array& array = Array::Handle(); 1130 Array& array = Array::Handle();
1027 array ^= obj.raw(); 1131 array ^= obj.raw();
1028 EXPECT_EQ(10, array.Length()); 1132 EXPECT_EQ(10, array.Length());
1029 } 1133 }
1030 1134
1031 } // namespace dart 1135 } // namespace dart
1032 1136
1033 #endif // defined(TARGET_ARCH_DBC) 1137 #endif // defined(TARGET_ARCH_DBC)
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/constants_dbc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698