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

Side by Side Diff: test/cctest/compiler/test-js-typed-lowering.cc

Issue 565493003: Fix typed lowering of ToBoolean on NaN input. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments. Created 6 years, 3 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
« no previous file with comments | « src/types.h ('k') | test/mozilla/mozilla.status » ('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 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 "src/v8.h" 5 #include "src/v8.h"
6 #include "test/cctest/cctest.h" 6 #include "test/cctest/cctest.h"
7 7
8 #include "src/compiler/graph-inl.h" 8 #include "src/compiler/graph-inl.h"
9 #include "src/compiler/js-typed-lowering.h" 9 #include "src/compiler/js-typed-lowering.h"
10 #include "src/compiler/node-properties-inl.h" 10 #include "src/compiler/node-properties-inl.h"
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 { // ToBoolean(null) 466 { // ToBoolean(null)
467 Node* r = R.ReduceUnop(op, Type::Null()); 467 Node* r = R.ReduceUnop(op, Type::Null());
468 R.CheckFalse(r); 468 R.CheckFalse(r);
469 } 469 }
470 470
471 { // ToBoolean(boolean) 471 { // ToBoolean(boolean)
472 Node* r = R.ReduceUnop(op, Type::Boolean()); 472 Node* r = R.ReduceUnop(op, Type::Boolean());
473 CHECK_EQ(IrOpcode::kParameter, r->opcode()); 473 CHECK_EQ(IrOpcode::kParameter, r->opcode());
474 } 474 }
475 475
476 { // ToBoolean(number) 476 { // ToBoolean(ordered-number)
477 Node* r = R.ReduceUnop(op, Type::Number()); 477 Node* r = R.ReduceUnop(op, Type::OrderedNumber());
478 CHECK_EQ(IrOpcode::kBooleanNot, r->opcode()); 478 CHECK_EQ(IrOpcode::kBooleanNot, r->opcode());
479 Node* i = r->InputAt(0); 479 Node* i = r->InputAt(0);
480 CHECK_EQ(IrOpcode::kNumberEqual, i->opcode()); 480 CHECK_EQ(IrOpcode::kNumberEqual, i->opcode());
481 // ToBoolean(number) => BooleanNot(NumberEqual(x, #0)) 481 // ToBoolean(x:number) => BooleanNot(NumberEqual(x, #0))
482 } 482 }
483 483
484 { // ToBoolean(string) 484 { // ToBoolean(string)
485 Node* r = R.ReduceUnop(op, Type::String()); 485 Node* r = R.ReduceUnop(op, Type::String());
486 // TODO(titzer): test will break with better js-typed-lowering 486 // TODO(titzer): test will break with better js-typed-lowering
487 CHECK_EQ(IrOpcode::kJSToBoolean, r->opcode()); 487 CHECK_EQ(IrOpcode::kJSToBoolean, r->opcode());
488 } 488 }
489 489
490 { // ToBoolean(object) 490 { // ToBoolean(object)
491 Node* r = R.ReduceUnop(op, Type::DetectableObject()); 491 Node* r = R.ReduceUnop(op, Type::DetectableObject());
492 R.CheckTrue(r); 492 R.CheckTrue(r);
493 } 493 }
494 494
495 { // ToBoolean(undetectable) 495 { // ToBoolean(undetectable)
496 Node* r = R.ReduceUnop(op, Type::Undetectable()); 496 Node* r = R.ReduceUnop(op, Type::Undetectable());
497 R.CheckFalse(r); 497 R.CheckFalse(r);
498 } 498 }
499 499
500 { // ToBoolean(object) 500 { // ToBoolean(object)
501 Node* r = R.ReduceUnop(op, Type::Object()); 501 Node* r = R.ReduceUnop(op, Type::Object());
502 CHECK_EQ(IrOpcode::kJSToBoolean, r->opcode()); 502 CHECK_EQ(IrOpcode::kJSToBoolean, r->opcode());
503 } 503 }
504 } 504 }
505 505
506 506
507 TEST(JSToBoolean_replacement) { 507 TEST(JSToBoolean_replacement) {
508 JSTypedLoweringTester R; 508 JSTypedLoweringTester R;
509 509
510 Type* types[] = {Type::Null(), Type::Undefined(), 510 Type* types[] = {Type::Null(), Type::Undefined(),
511 Type::Boolean(), Type::Number(), 511 Type::Boolean(), Type::OrderedNumber(),
512 Type::DetectableObject(), Type::Undetectable()}; 512 Type::DetectableObject(), Type::Undetectable()};
513 513
514 for (size_t i = 0; i < arraysize(types); i++) { 514 for (size_t i = 0; i < arraysize(types); i++) {
515 Node* n = R.Parameter(types[i]); 515 Node* n = R.Parameter(types[i]);
516 Node* c = R.graph.NewNode(R.javascript.ToBoolean(), n, R.context(), 516 Node* c = R.graph.NewNode(R.javascript.ToBoolean(), n, R.context(),
517 R.start(), R.start()); 517 R.start(), R.start());
518 Node* effect_use = R.UseForEffect(c); 518 Node* effect_use = R.UseForEffect(c);
519 Node* add = R.graph.NewNode(R.simplified.ReferenceEqual(Type::Any()), n, c); 519 Node* add = R.graph.NewNode(R.simplified.ReferenceEqual(Type::Any()), n, c);
520 520
521 R.CheckEffectInput(c, effect_use); 521 R.CheckEffectInput(c, effect_use);
522 Node* r = R.reduce(c); 522 Node* r = R.reduce(c);
523 523
524 if (types[i]->Is(Type::Boolean())) { 524 if (types[i]->Is(Type::Boolean())) {
525 CHECK_EQ(n, r); 525 CHECK_EQ(n, r);
526 } else if (types[i]->Is(Type::Number())) { 526 } else if (types[i]->Is(Type::OrderedNumber())) {
527 CHECK_EQ(IrOpcode::kBooleanNot, r->opcode()); 527 CHECK_EQ(IrOpcode::kBooleanNot, r->opcode());
528 } else { 528 } else {
529 CHECK_EQ(IrOpcode::kHeapConstant, r->opcode()); 529 CHECK_EQ(IrOpcode::kHeapConstant, r->opcode());
530 } 530 }
531 531
532 CHECK_EQ(n, add->InputAt(0)); 532 CHECK_EQ(n, add->InputAt(0));
533 CHECK_EQ(r, add->InputAt(1)); 533 CHECK_EQ(r, add->InputAt(1));
534 R.CheckEffectInput(R.start(), effect_use); 534 R.CheckEffectInput(R.start(), effect_use);
535 } 535 }
536 } 536 }
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 CHECK_EQ(p1, r->InputAt(0)); 1344 CHECK_EQ(p1, r->InputAt(0));
1345 CHECK_EQ(p0, r->InputAt(1)); 1345 CHECK_EQ(p0, r->InputAt(1));
1346 } else { 1346 } else {
1347 CHECK_EQ(p0, r->InputAt(0)); 1347 CHECK_EQ(p0, r->InputAt(0));
1348 CHECK_EQ(p1, r->InputAt(1)); 1348 CHECK_EQ(p1, r->InputAt(1));
1349 } 1349 }
1350 } 1350 }
1351 } 1351 }
1352 } 1352 }
1353 } 1353 }
OLDNEW
« no previous file with comments | « src/types.h ('k') | test/mozilla/mozilla.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698