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

Side by Side Diff: src/compiler/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: 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 | « no previous file | src/types.h » ('j') | src/types.h » ('J')
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/compiler/access-builder.h" 5 #include "src/compiler/access-builder.h"
6 #include "src/compiler/graph-inl.h" 6 #include "src/compiler/graph-inl.h"
7 #include "src/compiler/js-typed-lowering.h" 7 #include "src/compiler/js-typed-lowering.h"
8 #include "src/compiler/node-aux-data-inl.h" 8 #include "src/compiler/node-aux-data-inl.h"
9 #include "src/compiler/node-properties-inl.h" 9 #include "src/compiler/node-properties-inl.h"
10 #include "src/types.h" 10 #include "src/types.h"
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 // Recursively try to reduce the input first. 466 // Recursively try to reduce the input first.
467 Reduction result = ReduceJSToBooleanInput(input->InputAt(0)); 467 Reduction result = ReduceJSToBooleanInput(input->InputAt(0));
468 if (result.Changed()) { 468 if (result.Changed()) {
469 RelaxEffects(input); 469 RelaxEffects(input);
470 return result; 470 return result;
471 } 471 }
472 return Changed(input); // JSToBoolean(JSToBoolean(x)) => JSToBoolean(x) 472 return Changed(input); // JSToBoolean(JSToBoolean(x)) => JSToBoolean(x)
473 } 473 }
474 Type* input_type = NodeProperties::GetBounds(input).upper; 474 Type* input_type = NodeProperties::GetBounds(input).upper;
475 if (input_type->Is(Type::Boolean())) { 475 if (input_type->Is(Type::Boolean())) {
476 return Changed(input); // JSToBoolean(boolean) => x 476 return Changed(input); // JSToBoolean(boolean) => x
rossberg 2014/09/11 12:17:50 s/x/boolean/
Michael Starzinger 2014/09/11 12:35:59 Done, but with a slightly different notation as pe
477 } 477 }
478 if (input_type->Is(Type::Undefined())) { 478 if (input_type->Is(Type::Undefined())) {
479 // JSToBoolean(undefined) => #false 479 // JSToBoolean(undefined) => #false
480 return ReplaceWith(jsgraph()->FalseConstant()); 480 return ReplaceWith(jsgraph()->FalseConstant());
481 } 481 }
482 if (input_type->Is(Type::Null())) { 482 if (input_type->Is(Type::Null())) {
483 // JSToBoolean(null) => #false 483 // JSToBoolean(null) => #false
484 return ReplaceWith(jsgraph()->FalseConstant()); 484 return ReplaceWith(jsgraph()->FalseConstant());
485 } 485 }
486 if (input_type->Is(Type::DetectableReceiver())) { 486 if (input_type->Is(Type::DetectableReceiver())) {
487 // JSToBoolean(detectable) => #true 487 // JSToBoolean(detectable) => #true
488 return ReplaceWith(jsgraph()->TrueConstant()); 488 return ReplaceWith(jsgraph()->TrueConstant());
489 } 489 }
490 if (input_type->Is(Type::Undetectable())) { 490 if (input_type->Is(Type::Undetectable())) {
491 // JSToBoolean(undetectable) => #false 491 // JSToBoolean(undetectable) => #false
492 return ReplaceWith(jsgraph()->FalseConstant()); 492 return ReplaceWith(jsgraph()->FalseConstant());
493 } 493 }
494 if (input_type->Is(Type::Number())) { 494 if (input_type->Is(Type::OrderedNumber())) {
495 // JSToBoolean(number) => BooleanNot(NumberEqual(x, #0)) 495 // JSToBoolean(ordered-number) => BooleanNot(NumberEqual(x, #0))
rossberg 2014/09/11 12:17:50 s/x/ordered-number/
Michael Starzinger 2014/09/11 12:35:59 Done.
496 Node* cmp = graph()->NewNode(simplified()->NumberEqual(), input, 496 Node* cmp = graph()->NewNode(simplified()->NumberEqual(), input,
497 jsgraph()->ZeroConstant()); 497 jsgraph()->ZeroConstant());
498 Node* inv = graph()->NewNode(simplified()->BooleanNot(), cmp); 498 Node* inv = graph()->NewNode(simplified()->BooleanNot(), cmp);
499 return ReplaceWith(inv); 499 return ReplaceWith(inv);
500 } 500 }
501 // TODO(turbofan): js-typed-lowering of ToBoolean(string) 501 // TODO(turbofan): js-typed-lowering of ToBoolean(string)
502 return NoChange(); 502 return NoChange();
503 } 503 }
504 504
505 505
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 case IrOpcode::kJSMultiply: 622 case IrOpcode::kJSMultiply:
623 return ReduceNumberBinop(node, simplified()->NumberMultiply()); 623 return ReduceNumberBinop(node, simplified()->NumberMultiply());
624 case IrOpcode::kJSDivide: 624 case IrOpcode::kJSDivide:
625 return ReduceNumberBinop(node, simplified()->NumberDivide()); 625 return ReduceNumberBinop(node, simplified()->NumberDivide());
626 case IrOpcode::kJSModulus: 626 case IrOpcode::kJSModulus:
627 return ReduceNumberBinop(node, simplified()->NumberModulus()); 627 return ReduceNumberBinop(node, simplified()->NumberModulus());
628 case IrOpcode::kJSUnaryNot: { 628 case IrOpcode::kJSUnaryNot: {
629 Reduction result = ReduceJSToBooleanInput(node->InputAt(0)); 629 Reduction result = ReduceJSToBooleanInput(node->InputAt(0));
630 Node* value; 630 Node* value;
631 if (result.Changed()) { 631 if (result.Changed()) {
632 // JSUnaryNot(x) => BooleanNot(x) 632 // JSUnaryNot(boolean) => BooleanNot(x)
rossberg 2014/09/11 12:17:50 s/x/boolean/
Michael Starzinger 2014/09/11 12:35:59 Done.
633 value = 633 value =
634 graph()->NewNode(simplified()->BooleanNot(), result.replacement()); 634 graph()->NewNode(simplified()->BooleanNot(), result.replacement());
635 NodeProperties::ReplaceWithValue(node, value); 635 NodeProperties::ReplaceWithValue(node, value);
636 return Changed(value); 636 return Changed(value);
637 } else { 637 } else {
638 // JSUnaryNot(x) => BooleanNot(JSToBoolean(x)) 638 // JSUnaryNot(x) => BooleanNot(JSToBoolean(x))
639 value = graph()->NewNode(simplified()->BooleanNot(), node); 639 value = graph()->NewNode(simplified()->BooleanNot(), node);
640 node->set_op(javascript()->ToBoolean()); 640 node->set_op(javascript()->ToBoolean());
641 NodeProperties::ReplaceWithValue(node, value, node); 641 NodeProperties::ReplaceWithValue(node, value, node);
642 // Note: ReplaceUses() smashes all uses, so smash it back here. 642 // Note: ReplaceUses() smashes all uses, so smash it back here.
(...skipping 16 matching lines...) Expand all
659 return ReduceJSStoreProperty(node); 659 return ReduceJSStoreProperty(node);
660 default: 660 default:
661 break; 661 break;
662 } 662 }
663 return NoChange(); 663 return NoChange();
664 } 664 }
665 665
666 } // namespace compiler 666 } // namespace compiler
667 } // namespace internal 667 } // namespace internal
668 } // namespace v8 668 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/types.h » ('j') | src/types.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698