OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <functional> | 5 #include <functional> |
6 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/compiler/generic-node-inl.h" | 9 #include "src/compiler/generic-node-inl.h" |
10 #include "test/cctest/cctest.h" | 10 #include "test/cctest/cctest.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 m.Goto(&header); | 202 m.Goto(&header); |
203 m.Bind(&exit); | 203 m.Bind(&exit); |
204 m.Return(m.Int32Constant(constant)); | 204 m.Return(m.Int32Constant(constant)); |
205 | 205 |
206 CHECK_EQ(constant, m.Call()); | 206 CHECK_EQ(constant, m.Call()); |
207 } | 207 } |
208 | 208 |
209 | 209 |
210 template <typename R> | 210 template <typename R> |
211 static void BuildDiamondPhi(RawMachineAssemblerTester<R>* m, Node* cond_node, | 211 static void BuildDiamondPhi(RawMachineAssemblerTester<R>* m, Node* cond_node, |
212 Node* true_node, Node* false_node) { | 212 MachineType type, Node* true_node, |
| 213 Node* false_node) { |
213 MLabel blocka, blockb; | 214 MLabel blocka, blockb; |
214 MLabel* end = m->Exit(); | 215 MLabel* end = m->Exit(); |
215 m->Branch(cond_node, &blocka, &blockb); | 216 m->Branch(cond_node, &blocka, &blockb); |
216 m->Bind(&blocka); | 217 m->Bind(&blocka); |
217 m->Goto(end); | 218 m->Goto(end); |
218 m->Bind(&blockb); | 219 m->Bind(&blockb); |
219 m->Goto(end); | 220 m->Goto(end); |
220 | 221 |
221 m->Bind(end); | 222 m->Bind(end); |
222 Node* phi = m->Phi(true_node, false_node); | 223 Node* phi = m->Phi(type, true_node, false_node); |
223 m->Return(phi); | 224 m->Return(phi); |
224 } | 225 } |
225 | 226 |
226 | 227 |
227 TEST(RunDiamondPhiConst) { | 228 TEST(RunDiamondPhiConst) { |
228 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 229 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
229 int false_val = 0xFF666; | 230 int false_val = 0xFF666; |
230 int true_val = 0x00DDD; | 231 int true_val = 0x00DDD; |
231 Node* true_node = m.Int32Constant(true_val); | 232 Node* true_node = m.Int32Constant(true_val); |
232 Node* false_node = m.Int32Constant(false_val); | 233 Node* false_node = m.Int32Constant(false_val); |
233 BuildDiamondPhi(&m, m.Parameter(0), true_node, false_node); | 234 BuildDiamondPhi(&m, m.Parameter(0), kMachInt32, true_node, false_node); |
234 CHECK_EQ(false_val, m.Call(0)); | 235 CHECK_EQ(false_val, m.Call(0)); |
235 CHECK_EQ(true_val, m.Call(1)); | 236 CHECK_EQ(true_val, m.Call(1)); |
236 } | 237 } |
237 | 238 |
238 | 239 |
239 TEST(RunDiamondPhiNumber) { | 240 TEST(RunDiamondPhiNumber) { |
240 RawMachineAssemblerTester<Object*> m(kMachInt32); | 241 RawMachineAssemblerTester<Object*> m(kMachInt32); |
241 double false_val = -11.1; | 242 double false_val = -11.1; |
242 double true_val = 200.1; | 243 double true_val = 200.1; |
243 Node* true_node = m.NumberConstant(true_val); | 244 Node* true_node = m.NumberConstant(true_val); |
244 Node* false_node = m.NumberConstant(false_val); | 245 Node* false_node = m.NumberConstant(false_val); |
245 BuildDiamondPhi(&m, m.Parameter(0), true_node, false_node); | 246 BuildDiamondPhi(&m, m.Parameter(0), kMachAnyTagged, true_node, false_node); |
246 m.CheckNumber(false_val, m.Call(0)); | 247 m.CheckNumber(false_val, m.Call(0)); |
247 m.CheckNumber(true_val, m.Call(1)); | 248 m.CheckNumber(true_val, m.Call(1)); |
248 } | 249 } |
249 | 250 |
250 | 251 |
251 TEST(RunDiamondPhiString) { | 252 TEST(RunDiamondPhiString) { |
252 RawMachineAssemblerTester<Object*> m(kMachInt32); | 253 RawMachineAssemblerTester<Object*> m(kMachInt32); |
253 const char* false_val = "false"; | 254 const char* false_val = "false"; |
254 const char* true_val = "true"; | 255 const char* true_val = "true"; |
255 Node* true_node = m.StringConstant(true_val); | 256 Node* true_node = m.StringConstant(true_val); |
256 Node* false_node = m.StringConstant(false_val); | 257 Node* false_node = m.StringConstant(false_val); |
257 BuildDiamondPhi(&m, m.Parameter(0), true_node, false_node); | 258 BuildDiamondPhi(&m, m.Parameter(0), kMachAnyTagged, true_node, false_node); |
258 m.CheckString(false_val, m.Call(0)); | 259 m.CheckString(false_val, m.Call(0)); |
259 m.CheckString(true_val, m.Call(1)); | 260 m.CheckString(true_val, m.Call(1)); |
260 } | 261 } |
261 | 262 |
262 | 263 |
263 TEST(RunDiamondPhiParam) { | 264 TEST(RunDiamondPhiParam) { |
264 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); | 265 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); |
265 BuildDiamondPhi(&m, m.Parameter(0), m.Parameter(1), m.Parameter(2)); | 266 BuildDiamondPhi(&m, m.Parameter(0), kMachInt32, m.Parameter(1), |
| 267 m.Parameter(2)); |
266 int32_t c1 = 0x260cb75a; | 268 int32_t c1 = 0x260cb75a; |
267 int32_t c2 = 0xcd3e9c8b; | 269 int32_t c2 = 0xcd3e9c8b; |
268 int result = m.Call(0, c1, c2); | 270 int result = m.Call(0, c1, c2); |
269 CHECK_EQ(c2, result); | 271 CHECK_EQ(c2, result); |
270 result = m.Call(1, c1, c2); | 272 result = m.Call(1, c1, c2); |
271 CHECK_EQ(c1, result); | 273 CHECK_EQ(c1, result); |
272 } | 274 } |
273 | 275 |
274 | 276 |
275 TEST(RunLoopPhiConst) { | 277 TEST(RunLoopPhiConst) { |
276 RawMachineAssemblerTester<int32_t> m; | 278 RawMachineAssemblerTester<int32_t> m; |
277 int true_val = 0x44000; | 279 int true_val = 0x44000; |
278 int false_val = 0x00888; | 280 int false_val = 0x00888; |
279 | 281 |
280 Node* cond_node = m.Int32Constant(0); | 282 Node* cond_node = m.Int32Constant(0); |
281 Node* true_node = m.Int32Constant(true_val); | 283 Node* true_node = m.Int32Constant(true_val); |
282 Node* false_node = m.Int32Constant(false_val); | 284 Node* false_node = m.Int32Constant(false_val); |
283 | 285 |
284 // x = false_val; while(false) { x = true_val; } return x; | 286 // x = false_val; while(false) { x = true_val; } return x; |
285 MLabel body, header; | 287 MLabel body, header; |
286 MLabel* end = m.Exit(); | 288 MLabel* end = m.Exit(); |
287 | 289 |
288 m.Goto(&header); | 290 m.Goto(&header); |
289 m.Bind(&header); | 291 m.Bind(&header); |
290 Node* phi = m.Phi(false_node, true_node); | 292 Node* phi = m.Phi(kMachInt32, false_node, true_node); |
291 m.Branch(cond_node, &body, end); | 293 m.Branch(cond_node, &body, end); |
292 m.Bind(&body); | 294 m.Bind(&body); |
293 m.Goto(&header); | 295 m.Goto(&header); |
294 m.Bind(end); | 296 m.Bind(end); |
295 m.Return(phi); | 297 m.Return(phi); |
296 | 298 |
297 CHECK_EQ(false_val, m.Call()); | 299 CHECK_EQ(false_val, m.Call()); |
298 } | 300 } |
299 | 301 |
300 | 302 |
301 TEST(RunLoopPhiParam) { | 303 TEST(RunLoopPhiParam) { |
302 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); | 304 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); |
303 | 305 |
304 MLabel blocka, blockb; | 306 MLabel blocka, blockb; |
305 MLabel* end = m.Exit(); | 307 MLabel* end = m.Exit(); |
306 | 308 |
307 m.Goto(&blocka); | 309 m.Goto(&blocka); |
308 | 310 |
309 m.Bind(&blocka); | 311 m.Bind(&blocka); |
310 Node* phi = m.Phi(m.Parameter(1), m.Parameter(2)); | 312 Node* phi = m.Phi(kMachInt32, m.Parameter(1), m.Parameter(2)); |
311 Node* cond = m.Phi(m.Parameter(0), m.Int32Constant(0)); | 313 Node* cond = m.Phi(kMachInt32, m.Parameter(0), m.Int32Constant(0)); |
312 m.Branch(cond, &blockb, end); | 314 m.Branch(cond, &blockb, end); |
313 | 315 |
314 m.Bind(&blockb); | 316 m.Bind(&blockb); |
315 m.Goto(&blocka); | 317 m.Goto(&blocka); |
316 | 318 |
317 m.Bind(end); | 319 m.Bind(end); |
318 m.Return(phi); | 320 m.Return(phi); |
319 | 321 |
320 int32_t c1 = 0xa81903b4; | 322 int32_t c1 = 0xa81903b4; |
321 int32_t c2 = 0x5a1207da; | 323 int32_t c2 = 0x5a1207da; |
(...skipping 10 matching lines...) Expand all Loading... |
332 int false_val = 0x10777; | 334 int false_val = 0x10777; |
333 | 335 |
334 // x = false_val; while(false) { x++; } return x; | 336 // x = false_val; while(false) { x++; } return x; |
335 MLabel header, body; | 337 MLabel header, body; |
336 MLabel* end = m.Exit(); | 338 MLabel* end = m.Exit(); |
337 Node* false_node = m.Int32Constant(false_val); | 339 Node* false_node = m.Int32Constant(false_val); |
338 | 340 |
339 m.Goto(&header); | 341 m.Goto(&header); |
340 | 342 |
341 m.Bind(&header); | 343 m.Bind(&header); |
342 Node* phi = m.Phi(false_node, false_node); | 344 Node* phi = m.Phi(kMachInt32, false_node, false_node); |
343 m.Branch(m.Int32Constant(0), &body, end); | 345 m.Branch(m.Int32Constant(0), &body, end); |
344 | 346 |
345 m.Bind(&body); | 347 m.Bind(&body); |
346 Node* add = m.Int32Add(phi, m.Int32Constant(1)); | 348 Node* add = m.Int32Add(phi, m.Int32Constant(1)); |
347 phi->ReplaceInput(1, add); | 349 phi->ReplaceInput(1, add); |
348 m.Goto(&header); | 350 m.Goto(&header); |
349 | 351 |
350 m.Bind(end); | 352 m.Bind(end); |
351 m.Return(phi); | 353 m.Return(phi); |
352 | 354 |
353 CHECK_EQ(false_val, m.Call()); | 355 CHECK_EQ(false_val, m.Call()); |
354 } | 356 } |
355 | 357 |
356 | 358 |
357 TEST(RunLoopIncrement) { | 359 TEST(RunLoopIncrement) { |
358 RawMachineAssemblerTester<int32_t> m; | 360 RawMachineAssemblerTester<int32_t> m; |
359 Int32BinopTester bt(&m); | 361 Int32BinopTester bt(&m); |
360 | 362 |
361 // x = 0; while(x ^ param) { x++; } return x; | 363 // x = 0; while(x ^ param) { x++; } return x; |
362 MLabel header, body; | 364 MLabel header, body; |
363 MLabel* end = m.Exit(); | 365 MLabel* end = m.Exit(); |
364 Node* zero = m.Int32Constant(0); | 366 Node* zero = m.Int32Constant(0); |
365 | 367 |
366 m.Goto(&header); | 368 m.Goto(&header); |
367 | 369 |
368 m.Bind(&header); | 370 m.Bind(&header); |
369 Node* phi = m.Phi(zero, zero); | 371 Node* phi = m.Phi(kMachInt32, zero, zero); |
370 m.Branch(m.WordXor(phi, bt.param0), &body, end); | 372 m.Branch(m.WordXor(phi, bt.param0), &body, end); |
371 | 373 |
372 m.Bind(&body); | 374 m.Bind(&body); |
373 phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); | 375 phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); |
374 m.Goto(&header); | 376 m.Goto(&header); |
375 | 377 |
376 m.Bind(end); | 378 m.Bind(end); |
377 bt.AddReturn(phi); | 379 bt.AddReturn(phi); |
378 | 380 |
379 CHECK_EQ(11, bt.call(11, 0)); | 381 CHECK_EQ(11, bt.call(11, 0)); |
380 CHECK_EQ(110, bt.call(110, 0)); | 382 CHECK_EQ(110, bt.call(110, 0)); |
381 CHECK_EQ(176, bt.call(176, 0)); | 383 CHECK_EQ(176, bt.call(176, 0)); |
382 } | 384 } |
383 | 385 |
384 | 386 |
385 TEST(RunLoopIncrement2) { | 387 TEST(RunLoopIncrement2) { |
386 RawMachineAssemblerTester<int32_t> m; | 388 RawMachineAssemblerTester<int32_t> m; |
387 Int32BinopTester bt(&m); | 389 Int32BinopTester bt(&m); |
388 | 390 |
389 // x = 0; while(x < param) { x++; } return x; | 391 // x = 0; while(x < param) { x++; } return x; |
390 MLabel header, body; | 392 MLabel header, body; |
391 MLabel* end = m.Exit(); | 393 MLabel* end = m.Exit(); |
392 Node* zero = m.Int32Constant(0); | 394 Node* zero = m.Int32Constant(0); |
393 | 395 |
394 m.Goto(&header); | 396 m.Goto(&header); |
395 | 397 |
396 m.Bind(&header); | 398 m.Bind(&header); |
397 Node* phi = m.Phi(zero, zero); | 399 Node* phi = m.Phi(kMachInt32, zero, zero); |
398 m.Branch(m.Int32LessThan(phi, bt.param0), &body, end); | 400 m.Branch(m.Int32LessThan(phi, bt.param0), &body, end); |
399 | 401 |
400 m.Bind(&body); | 402 m.Bind(&body); |
401 phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); | 403 phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); |
402 m.Goto(&header); | 404 m.Goto(&header); |
403 | 405 |
404 m.Bind(end); | 406 m.Bind(end); |
405 bt.AddReturn(phi); | 407 bt.AddReturn(phi); |
406 | 408 |
407 CHECK_EQ(11, bt.call(11, 0)); | 409 CHECK_EQ(11, bt.call(11, 0)); |
408 CHECK_EQ(110, bt.call(110, 0)); | 410 CHECK_EQ(110, bt.call(110, 0)); |
409 CHECK_EQ(176, bt.call(176, 0)); | 411 CHECK_EQ(176, bt.call(176, 0)); |
410 CHECK_EQ(0, bt.call(-200, 0)); | 412 CHECK_EQ(0, bt.call(-200, 0)); |
411 } | 413 } |
412 | 414 |
413 | 415 |
414 TEST(RunLoopIncrement3) { | 416 TEST(RunLoopIncrement3) { |
415 RawMachineAssemblerTester<int32_t> m; | 417 RawMachineAssemblerTester<int32_t> m; |
416 Int32BinopTester bt(&m); | 418 Int32BinopTester bt(&m); |
417 | 419 |
418 // x = 0; while(x < param) { x++; } return x; | 420 // x = 0; while(x < param) { x++; } return x; |
419 MLabel header, body; | 421 MLabel header, body; |
420 MLabel* end = m.Exit(); | 422 MLabel* end = m.Exit(); |
421 Node* zero = m.Int32Constant(0); | 423 Node* zero = m.Int32Constant(0); |
422 | 424 |
423 m.Goto(&header); | 425 m.Goto(&header); |
424 | 426 |
425 m.Bind(&header); | 427 m.Bind(&header); |
426 Node* phi = m.Phi(zero, zero); | 428 Node* phi = m.Phi(kMachInt32, zero, zero); |
427 m.Branch(m.Uint32LessThan(phi, bt.param0), &body, end); | 429 m.Branch(m.Uint32LessThan(phi, bt.param0), &body, end); |
428 | 430 |
429 m.Bind(&body); | 431 m.Bind(&body); |
430 phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); | 432 phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); |
431 m.Goto(&header); | 433 m.Goto(&header); |
432 | 434 |
433 m.Bind(end); | 435 m.Bind(end); |
434 bt.AddReturn(phi); | 436 bt.AddReturn(phi); |
435 | 437 |
436 CHECK_EQ(11, bt.call(11, 0)); | 438 CHECK_EQ(11, bt.call(11, 0)); |
437 CHECK_EQ(110, bt.call(110, 0)); | 439 CHECK_EQ(110, bt.call(110, 0)); |
438 CHECK_EQ(176, bt.call(176, 0)); | 440 CHECK_EQ(176, bt.call(176, 0)); |
439 CHECK_EQ(200, bt.call(200, 0)); | 441 CHECK_EQ(200, bt.call(200, 0)); |
440 } | 442 } |
441 | 443 |
442 | 444 |
443 TEST(RunLoopDecrement) { | 445 TEST(RunLoopDecrement) { |
444 RawMachineAssemblerTester<int32_t> m; | 446 RawMachineAssemblerTester<int32_t> m; |
445 Int32BinopTester bt(&m); | 447 Int32BinopTester bt(&m); |
446 | 448 |
447 // x = param; while(x) { x--; } return x; | 449 // x = param; while(x) { x--; } return x; |
448 MLabel header, body; | 450 MLabel header, body; |
449 MLabel* end = m.Exit(); | 451 MLabel* end = m.Exit(); |
450 | 452 |
451 m.Goto(&header); | 453 m.Goto(&header); |
452 | 454 |
453 m.Bind(&header); | 455 m.Bind(&header); |
454 Node* phi = m.Phi(bt.param0, m.Int32Constant(0)); | 456 Node* phi = m.Phi(kMachInt32, bt.param0, m.Int32Constant(0)); |
455 m.Branch(phi, &body, end); | 457 m.Branch(phi, &body, end); |
456 | 458 |
457 m.Bind(&body); | 459 m.Bind(&body); |
458 phi->ReplaceInput(1, m.Int32Sub(phi, m.Int32Constant(1))); | 460 phi->ReplaceInput(1, m.Int32Sub(phi, m.Int32Constant(1))); |
459 m.Goto(&header); | 461 m.Goto(&header); |
460 | 462 |
461 m.Bind(end); | 463 m.Bind(end); |
462 bt.AddReturn(phi); | 464 bt.AddReturn(phi); |
463 | 465 |
464 CHECK_EQ(0, bt.call(11, 0)); | 466 CHECK_EQ(0, bt.call(11, 0)); |
465 CHECK_EQ(0, bt.call(110, 0)); | 467 CHECK_EQ(0, bt.call(110, 0)); |
466 CHECK_EQ(0, bt.call(197, 0)); | 468 CHECK_EQ(0, bt.call(197, 0)); |
467 } | 469 } |
468 | 470 |
469 | 471 |
470 TEST(RunLoopIncrementFloat64) { | 472 TEST(RunLoopIncrementFloat64) { |
471 RawMachineAssemblerTester<int32_t> m; | 473 RawMachineAssemblerTester<int32_t> m; |
472 | 474 |
473 // x = -3.0; while(x < 10) { x = x + 0.5; } return (int) x; | 475 // x = -3.0; while(x < 10) { x = x + 0.5; } return (int) x; |
474 MLabel header, body; | 476 MLabel header, body; |
475 MLabel* end = m.Exit(); | 477 MLabel* end = m.Exit(); |
476 Node* minus_3 = m.Float64Constant(-3.0); | 478 Node* minus_3 = m.Float64Constant(-3.0); |
477 Node* ten = m.Float64Constant(10.0); | 479 Node* ten = m.Float64Constant(10.0); |
478 | 480 |
479 m.Goto(&header); | 481 m.Goto(&header); |
480 | 482 |
481 m.Bind(&header); | 483 m.Bind(&header); |
482 Node* phi = m.Phi(minus_3, ten); | 484 Node* phi = m.Phi(kMachFloat64, minus_3, ten); |
483 m.Branch(m.Float64LessThan(phi, ten), &body, end); | 485 m.Branch(m.Float64LessThan(phi, ten), &body, end); |
484 | 486 |
485 m.Bind(&body); | 487 m.Bind(&body); |
486 phi->ReplaceInput(1, m.Float64Add(phi, m.Float64Constant(0.5))); | 488 phi->ReplaceInput(1, m.Float64Add(phi, m.Float64Constant(0.5))); |
487 m.Goto(&header); | 489 m.Goto(&header); |
488 | 490 |
489 m.Bind(end); | 491 m.Bind(end); |
490 m.Return(m.ChangeFloat64ToInt32(phi)); | 492 m.Return(m.ChangeFloat64ToInt32(phi)); |
491 | 493 |
492 CHECK_EQ(10, m.Call()); | 494 CHECK_EQ(10, m.Call()); |
(...skipping 2751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3244 TEST(RunLoopPhiInduction2) { | 3246 TEST(RunLoopPhiInduction2) { |
3245 RawMachineAssemblerTester<int32_t> m; | 3247 RawMachineAssemblerTester<int32_t> m; |
3246 | 3248 |
3247 int false_val = 0x10777; | 3249 int false_val = 0x10777; |
3248 | 3250 |
3249 // x = false_val; while(false) { x++; } return x; | 3251 // x = false_val; while(false) { x++; } return x; |
3250 MLabel header, body, end; | 3252 MLabel header, body, end; |
3251 Node* false_node = m.Int32Constant(false_val); | 3253 Node* false_node = m.Int32Constant(false_val); |
3252 m.Goto(&header); | 3254 m.Goto(&header); |
3253 m.Bind(&header); | 3255 m.Bind(&header); |
3254 Node* phi = m.Phi(false_node, false_node); | 3256 Node* phi = m.Phi(kMachInt32, false_node, false_node); |
3255 m.Branch(m.Int32Constant(0), &body, &end); | 3257 m.Branch(m.Int32Constant(0), &body, &end); |
3256 m.Bind(&body); | 3258 m.Bind(&body); |
3257 Node* add = m.Int32Add(phi, m.Int32Constant(1)); | 3259 Node* add = m.Int32Add(phi, m.Int32Constant(1)); |
3258 phi->ReplaceInput(1, add); | 3260 phi->ReplaceInput(1, add); |
3259 m.Goto(&header); | 3261 m.Goto(&header); |
3260 m.Bind(&end); | 3262 m.Bind(&end); |
3261 m.Return(phi); | 3263 m.Return(phi); |
3262 | 3264 |
3263 CHECK_EQ(false_val, m.Call()); | 3265 CHECK_EQ(false_val, m.Call()); |
3264 } | 3266 } |
3265 | 3267 |
3266 | 3268 |
3267 TEST(RunDoubleDiamond) { | 3269 TEST(RunDoubleDiamond) { |
3268 RawMachineAssemblerTester<int32_t> m; | 3270 RawMachineAssemblerTester<int32_t> m; |
3269 | 3271 |
3270 const int magic = 99645; | 3272 const int magic = 99645; |
3271 double buffer = 0.1; | 3273 double buffer = 0.1; |
3272 double constant = 99.99; | 3274 double constant = 99.99; |
3273 | 3275 |
3274 MLabel blocka, blockb, end; | 3276 MLabel blocka, blockb, end; |
3275 Node* k1 = m.Float64Constant(constant); | 3277 Node* k1 = m.Float64Constant(constant); |
3276 Node* k2 = m.Float64Constant(0 - constant); | 3278 Node* k2 = m.Float64Constant(0 - constant); |
3277 m.Branch(m.Int32Constant(0), &blocka, &blockb); | 3279 m.Branch(m.Int32Constant(0), &blocka, &blockb); |
3278 m.Bind(&blocka); | 3280 m.Bind(&blocka); |
3279 m.Goto(&end); | 3281 m.Goto(&end); |
3280 m.Bind(&blockb); | 3282 m.Bind(&blockb); |
3281 m.Goto(&end); | 3283 m.Goto(&end); |
3282 m.Bind(&end); | 3284 m.Bind(&end); |
3283 Node* phi = m.Phi(k2, k1); | 3285 Node* phi = m.Phi(kMachFloat64, k2, k1); |
3284 m.Store(kMachFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi); | 3286 m.Store(kMachFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi); |
3285 m.Return(m.Int32Constant(magic)); | 3287 m.Return(m.Int32Constant(magic)); |
3286 | 3288 |
3287 CHECK_EQ(magic, m.Call()); | 3289 CHECK_EQ(magic, m.Call()); |
3288 CHECK_EQ(constant, buffer); | 3290 CHECK_EQ(constant, buffer); |
3289 } | 3291 } |
3290 | 3292 |
3291 | 3293 |
3292 TEST(RunRefDiamond) { | 3294 TEST(RunRefDiamond) { |
3293 RawMachineAssemblerTester<int32_t> m; | 3295 RawMachineAssemblerTester<int32_t> m; |
3294 | 3296 |
3295 const int magic = 99644; | 3297 const int magic = 99644; |
3296 Handle<String> rexpected = | 3298 Handle<String> rexpected = |
3297 CcTest::i_isolate()->factory()->InternalizeUtf8String("A"); | 3299 CcTest::i_isolate()->factory()->InternalizeUtf8String("A"); |
3298 String* buffer; | 3300 String* buffer; |
3299 | 3301 |
3300 MLabel blocka, blockb, end; | 3302 MLabel blocka, blockb, end; |
3301 Node* k1 = m.StringConstant("A"); | 3303 Node* k1 = m.StringConstant("A"); |
3302 Node* k2 = m.StringConstant("B"); | 3304 Node* k2 = m.StringConstant("B"); |
3303 m.Branch(m.Int32Constant(0), &blocka, &blockb); | 3305 m.Branch(m.Int32Constant(0), &blocka, &blockb); |
3304 m.Bind(&blocka); | 3306 m.Bind(&blocka); |
3305 m.Goto(&end); | 3307 m.Goto(&end); |
3306 m.Bind(&blockb); | 3308 m.Bind(&blockb); |
3307 m.Goto(&end); | 3309 m.Goto(&end); |
3308 m.Bind(&end); | 3310 m.Bind(&end); |
3309 Node* phi = m.Phi(k2, k1); | 3311 Node* phi = m.Phi(kMachAnyTagged, k2, k1); |
3310 m.Store(kMachAnyTagged, m.PointerConstant(&buffer), m.Int32Constant(0), phi); | 3312 m.Store(kMachAnyTagged, m.PointerConstant(&buffer), m.Int32Constant(0), phi); |
3311 m.Return(m.Int32Constant(magic)); | 3313 m.Return(m.Int32Constant(magic)); |
3312 | 3314 |
3313 CHECK_EQ(magic, m.Call()); | 3315 CHECK_EQ(magic, m.Call()); |
3314 CHECK(rexpected->SameValue(buffer)); | 3316 CHECK(rexpected->SameValue(buffer)); |
3315 } | 3317 } |
3316 | 3318 |
3317 | 3319 |
3318 TEST(RunDoubleRefDiamond) { | 3320 TEST(RunDoubleRefDiamond) { |
3319 RawMachineAssemblerTester<int32_t> m; | 3321 RawMachineAssemblerTester<int32_t> m; |
3320 | 3322 |
3321 const int magic = 99648; | 3323 const int magic = 99648; |
3322 double dbuffer = 0.1; | 3324 double dbuffer = 0.1; |
3323 double dconstant = 99.99; | 3325 double dconstant = 99.99; |
3324 Handle<String> rexpected = | 3326 Handle<String> rexpected = |
3325 CcTest::i_isolate()->factory()->InternalizeUtf8String("AX"); | 3327 CcTest::i_isolate()->factory()->InternalizeUtf8String("AX"); |
3326 String* rbuffer; | 3328 String* rbuffer; |
3327 | 3329 |
3328 MLabel blocka, blockb, end; | 3330 MLabel blocka, blockb, end; |
3329 Node* d1 = m.Float64Constant(dconstant); | 3331 Node* d1 = m.Float64Constant(dconstant); |
3330 Node* d2 = m.Float64Constant(0 - dconstant); | 3332 Node* d2 = m.Float64Constant(0 - dconstant); |
3331 Node* r1 = m.StringConstant("AX"); | 3333 Node* r1 = m.StringConstant("AX"); |
3332 Node* r2 = m.StringConstant("BX"); | 3334 Node* r2 = m.StringConstant("BX"); |
3333 m.Branch(m.Int32Constant(0), &blocka, &blockb); | 3335 m.Branch(m.Int32Constant(0), &blocka, &blockb); |
3334 m.Bind(&blocka); | 3336 m.Bind(&blocka); |
3335 m.Goto(&end); | 3337 m.Goto(&end); |
3336 m.Bind(&blockb); | 3338 m.Bind(&blockb); |
3337 m.Goto(&end); | 3339 m.Goto(&end); |
3338 m.Bind(&end); | 3340 m.Bind(&end); |
3339 Node* dphi = m.Phi(d2, d1); | 3341 Node* dphi = m.Phi(kMachFloat64, d2, d1); |
3340 Node* rphi = m.Phi(r2, r1); | 3342 Node* rphi = m.Phi(kMachAnyTagged, r2, r1); |
3341 m.Store(kMachFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi); | 3343 m.Store(kMachFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi); |
3342 m.Store(kMachAnyTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), | 3344 m.Store(kMachAnyTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), |
3343 rphi); | 3345 rphi); |
3344 m.Return(m.Int32Constant(magic)); | 3346 m.Return(m.Int32Constant(magic)); |
3345 | 3347 |
3346 CHECK_EQ(magic, m.Call()); | 3348 CHECK_EQ(magic, m.Call()); |
3347 CHECK_EQ(dconstant, dbuffer); | 3349 CHECK_EQ(dconstant, dbuffer); |
3348 CHECK(rexpected->SameValue(rbuffer)); | 3350 CHECK(rexpected->SameValue(rbuffer)); |
3349 } | 3351 } |
3350 | 3352 |
(...skipping 12 matching lines...) Expand all Loading... |
3363 Node* d1 = m.Float64Constant(dconstant); | 3365 Node* d1 = m.Float64Constant(dconstant); |
3364 Node* d2 = m.Float64Constant(0 - dconstant); | 3366 Node* d2 = m.Float64Constant(0 - dconstant); |
3365 Node* r1 = m.StringConstant("AD"); | 3367 Node* r1 = m.StringConstant("AD"); |
3366 Node* r2 = m.StringConstant("BD"); | 3368 Node* r2 = m.StringConstant("BD"); |
3367 m.Branch(m.Int32Constant(0), &blocka, &blockb); | 3369 m.Branch(m.Int32Constant(0), &blocka, &blockb); |
3368 m.Bind(&blocka); | 3370 m.Bind(&blocka); |
3369 m.Goto(&mid); | 3371 m.Goto(&mid); |
3370 m.Bind(&blockb); | 3372 m.Bind(&blockb); |
3371 m.Goto(&mid); | 3373 m.Goto(&mid); |
3372 m.Bind(&mid); | 3374 m.Bind(&mid); |
3373 Node* dphi1 = m.Phi(d2, d1); | 3375 Node* dphi1 = m.Phi(kMachFloat64, d2, d1); |
3374 Node* rphi1 = m.Phi(r2, r1); | 3376 Node* rphi1 = m.Phi(kMachAnyTagged, r2, r1); |
3375 m.Branch(m.Int32Constant(0), &blockd, &blocke); | 3377 m.Branch(m.Int32Constant(0), &blockd, &blocke); |
3376 | 3378 |
3377 m.Bind(&blockd); | 3379 m.Bind(&blockd); |
3378 m.Goto(&end); | 3380 m.Goto(&end); |
3379 m.Bind(&blocke); | 3381 m.Bind(&blocke); |
3380 m.Goto(&end); | 3382 m.Goto(&end); |
3381 m.Bind(&end); | 3383 m.Bind(&end); |
3382 Node* dphi2 = m.Phi(d1, dphi1); | 3384 Node* dphi2 = m.Phi(kMachFloat64, d1, dphi1); |
3383 Node* rphi2 = m.Phi(r1, rphi1); | 3385 Node* rphi2 = m.Phi(kMachAnyTagged, r1, rphi1); |
3384 | 3386 |
3385 m.Store(kMachFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi2); | 3387 m.Store(kMachFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi2); |
3386 m.Store(kMachAnyTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), | 3388 m.Store(kMachAnyTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), |
3387 rphi2); | 3389 rphi2); |
3388 m.Return(m.Int32Constant(magic)); | 3390 m.Return(m.Int32Constant(magic)); |
3389 | 3391 |
3390 CHECK_EQ(magic, m.Call()); | 3392 CHECK_EQ(magic, m.Call()); |
3391 CHECK_EQ(dconstant, dbuffer); | 3393 CHECK_EQ(dconstant, dbuffer); |
3392 CHECK(rexpected->SameValue(rbuffer)); | 3394 CHECK(rexpected->SameValue(rbuffer)); |
3393 } | 3395 } |
3394 | 3396 |
3395 | 3397 |
3396 TEST(RunDoubleLoopPhi) { | 3398 TEST(RunDoubleLoopPhi) { |
3397 RawMachineAssemblerTester<int32_t> m; | 3399 RawMachineAssemblerTester<int32_t> m; |
3398 MLabel header, body, end; | 3400 MLabel header, body, end; |
3399 | 3401 |
3400 int magic = 99773; | 3402 int magic = 99773; |
3401 double buffer = 0.99; | 3403 double buffer = 0.99; |
3402 double dconstant = 777.1; | 3404 double dconstant = 777.1; |
3403 | 3405 |
3404 Node* zero = m.Int32Constant(0); | 3406 Node* zero = m.Int32Constant(0); |
3405 Node* dk = m.Float64Constant(dconstant); | 3407 Node* dk = m.Float64Constant(dconstant); |
3406 | 3408 |
3407 m.Goto(&header); | 3409 m.Goto(&header); |
3408 m.Bind(&header); | 3410 m.Bind(&header); |
3409 Node* phi = m.Phi(dk, dk); | 3411 Node* phi = m.Phi(kMachFloat64, dk, dk); |
3410 phi->ReplaceInput(1, phi); | 3412 phi->ReplaceInput(1, phi); |
3411 m.Branch(zero, &body, &end); | 3413 m.Branch(zero, &body, &end); |
3412 m.Bind(&body); | 3414 m.Bind(&body); |
3413 m.Goto(&header); | 3415 m.Goto(&header); |
3414 m.Bind(&end); | 3416 m.Bind(&end); |
3415 m.Store(kMachFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi); | 3417 m.Store(kMachFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi); |
3416 m.Return(m.Int32Constant(magic)); | 3418 m.Return(m.Int32Constant(magic)); |
3417 | 3419 |
3418 CHECK_EQ(magic, m.Call()); | 3420 CHECK_EQ(magic, m.Call()); |
3419 } | 3421 } |
3420 | 3422 |
3421 | 3423 |
3422 TEST(RunCountToTenAccRaw) { | 3424 TEST(RunCountToTenAccRaw) { |
3423 RawMachineAssemblerTester<int32_t> m; | 3425 RawMachineAssemblerTester<int32_t> m; |
3424 | 3426 |
3425 Node* zero = m.Int32Constant(0); | 3427 Node* zero = m.Int32Constant(0); |
3426 Node* ten = m.Int32Constant(10); | 3428 Node* ten = m.Int32Constant(10); |
3427 Node* one = m.Int32Constant(1); | 3429 Node* one = m.Int32Constant(1); |
3428 | 3430 |
3429 MLabel header, body, body_cont, end; | 3431 MLabel header, body, body_cont, end; |
3430 | 3432 |
3431 m.Goto(&header); | 3433 m.Goto(&header); |
3432 | 3434 |
3433 m.Bind(&header); | 3435 m.Bind(&header); |
3434 Node* i = m.Phi(zero, zero); | 3436 Node* i = m.Phi(kMachInt32, zero, zero); |
3435 Node* j = m.Phi(zero, zero); | 3437 Node* j = m.Phi(kMachInt32, zero, zero); |
3436 m.Goto(&body); | 3438 m.Goto(&body); |
3437 | 3439 |
3438 m.Bind(&body); | 3440 m.Bind(&body); |
3439 Node* next_i = m.Int32Add(i, one); | 3441 Node* next_i = m.Int32Add(i, one); |
3440 Node* next_j = m.Int32Add(j, one); | 3442 Node* next_j = m.Int32Add(j, one); |
3441 m.Branch(m.Word32Equal(next_i, ten), &end, &body_cont); | 3443 m.Branch(m.Word32Equal(next_i, ten), &end, &body_cont); |
3442 | 3444 |
3443 m.Bind(&body_cont); | 3445 m.Bind(&body_cont); |
3444 i->ReplaceInput(1, next_i); | 3446 i->ReplaceInput(1, next_i); |
3445 j->ReplaceInput(1, next_j); | 3447 j->ReplaceInput(1, next_j); |
(...skipping 11 matching lines...) Expand all Loading... |
3457 | 3459 |
3458 Node* zero = m.Int32Constant(0); | 3460 Node* zero = m.Int32Constant(0); |
3459 Node* ten = m.Int32Constant(10); | 3461 Node* ten = m.Int32Constant(10); |
3460 Node* one = m.Int32Constant(1); | 3462 Node* one = m.Int32Constant(1); |
3461 | 3463 |
3462 MLabel header, body, body_cont, end; | 3464 MLabel header, body, body_cont, end; |
3463 | 3465 |
3464 m.Goto(&header); | 3466 m.Goto(&header); |
3465 | 3467 |
3466 m.Bind(&header); | 3468 m.Bind(&header); |
3467 Node* i = m.Phi(zero, zero); | 3469 Node* i = m.Phi(kMachInt32, zero, zero); |
3468 Node* j = m.Phi(zero, zero); | 3470 Node* j = m.Phi(kMachInt32, zero, zero); |
3469 Node* k = m.Phi(zero, zero); | 3471 Node* k = m.Phi(kMachInt32, zero, zero); |
3470 m.Goto(&body); | 3472 m.Goto(&body); |
3471 | 3473 |
3472 m.Bind(&body); | 3474 m.Bind(&body); |
3473 Node* next_i = m.Int32Add(i, one); | 3475 Node* next_i = m.Int32Add(i, one); |
3474 Node* next_j = m.Int32Add(j, one); | 3476 Node* next_j = m.Int32Add(j, one); |
3475 Node* next_k = m.Int32Add(j, one); | 3477 Node* next_k = m.Int32Add(j, one); |
3476 m.Branch(m.Word32Equal(next_i, ten), &end, &body_cont); | 3478 m.Branch(m.Word32Equal(next_i, ten), &end, &body_cont); |
3477 | 3479 |
3478 m.Bind(&body_cont); | 3480 m.Bind(&body_cont); |
3479 i->ReplaceInput(1, next_i); | 3481 i->ReplaceInput(1, next_i); |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3966 Node* false_node = m.HeapConstant(false_val); | 3968 Node* false_node = m.HeapConstant(false_val); |
3967 | 3969 |
3968 MLabel blocka, blockb, end; | 3970 MLabel blocka, blockb, end; |
3969 m.Branch(m.Parameter(0), &blocka, &blockb); | 3971 m.Branch(m.Parameter(0), &blocka, &blockb); |
3970 m.Bind(&blocka); | 3972 m.Bind(&blocka); |
3971 m.Goto(&end); | 3973 m.Goto(&end); |
3972 m.Bind(&blockb); | 3974 m.Bind(&blockb); |
3973 m.Goto(&end); | 3975 m.Goto(&end); |
3974 | 3976 |
3975 m.Bind(&end); | 3977 m.Bind(&end); |
3976 Node* phi = m.Phi(true_node, false_node); | 3978 Node* phi = m.Phi(kMachAnyTagged, true_node, false_node); |
3977 m.Return(phi); | 3979 m.Return(phi); |
3978 | 3980 |
3979 CHECK_EQ(*false_val, m.Call(0)); | 3981 CHECK_EQ(*false_val, m.Call(0)); |
3980 CHECK_EQ(*true_val, m.Call(1)); | 3982 CHECK_EQ(*true_val, m.Call(1)); |
3981 } | 3983 } |
3982 | 3984 |
3983 | 3985 |
3984 #if MACHINE_ASSEMBLER_SUPPORTS_CALL_C | 3986 #if MACHINE_ASSEMBLER_SUPPORTS_CALL_C |
3985 | 3987 |
3986 TEST(RunSpillLotsOfThingsWithCall) { | 3988 TEST(RunSpillLotsOfThingsWithCall) { |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4312 RawMachineAssemblerTester<int32_t> m; | 4314 RawMachineAssemblerTester<int32_t> m; |
4313 m.Return(m.TruncateFloat64ToInt32(m.LoadFromPointer(&input, kMachFloat64))); | 4315 m.Return(m.TruncateFloat64ToInt32(m.LoadFromPointer(&input, kMachFloat64))); |
4314 for (size_t i = 0; i < arraysize(kValues); ++i) { | 4316 for (size_t i = 0; i < arraysize(kValues); ++i) { |
4315 input = kValues[i].from; | 4317 input = kValues[i].from; |
4316 uint64_t expected = static_cast<int64_t>(kValues[i].raw); | 4318 uint64_t expected = static_cast<int64_t>(kValues[i].raw); |
4317 CHECK_EQ(static_cast<int>(expected), m.Call()); | 4319 CHECK_EQ(static_cast<int>(expected), m.Call()); |
4318 } | 4320 } |
4319 } | 4321 } |
4320 | 4322 |
4321 #endif // V8_TURBOFAN_TARGET | 4323 #endif // V8_TURBOFAN_TARGET |
OLD | NEW |