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 "src/compiler/graph-inl.h" | 5 #include "src/compiler/graph-inl.h" |
6 #include "src/compiler/js-typed-lowering.h" | 6 #include "src/compiler/js-typed-lowering.h" |
7 #include "src/compiler/node-aux-data-inl.h" | 7 #include "src/compiler/node-aux-data-inl.h" |
8 #include "src/compiler/node-properties-inl.h" | 8 #include "src/compiler/node-properties-inl.h" |
9 #include "src/types.h" | 9 #include "src/types.h" |
10 | 10 |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
508 if (input_type->Is(Type::Number())) { | 508 if (input_type->Is(Type::Number())) { |
509 // JSToBoolean(number) => BooleanNot(NumberEqual(x, #0)) | 509 // JSToBoolean(number) => BooleanNot(NumberEqual(x, #0)) |
510 Node* cmp = graph()->NewNode(simplified()->NumberEqual(), input, | 510 Node* cmp = graph()->NewNode(simplified()->NumberEqual(), input, |
511 jsgraph()->ZeroConstant()); | 511 jsgraph()->ZeroConstant()); |
512 Node* inv = graph()->NewNode(simplified()->BooleanNot(), cmp); | 512 Node* inv = graph()->NewNode(simplified()->BooleanNot(), cmp); |
513 ReplaceEagerly(input, inv); | 513 ReplaceEagerly(input, inv); |
514 // TODO(titzer): Ugly. ReplaceEagerly smashes all uses. Smash it back here. | 514 // TODO(titzer): Ugly. ReplaceEagerly smashes all uses. Smash it back here. |
515 cmp->ReplaceInput(0, input); | 515 cmp->ReplaceInput(0, input); |
516 return Changed(inv); | 516 return Changed(inv); |
517 } | 517 } |
518 if (input_type->Is(Type::Number())) { | |
rossberg
2014/08/06 13:04:07
Why is this duplicated?
| |
519 // JSToBoolean(number) => BooleanNot(NumberEqual(x, #0)) | |
520 Node* cmp = graph()->NewNode(simplified()->NumberEqual(), input, | |
521 jsgraph()->ZeroConstant()); | |
522 Node* inv = graph()->NewNode(simplified()->BooleanNot(), cmp); | |
523 ReplaceEagerly(input, inv); | |
524 // TODO(titzer): Ugly. ReplaceEagerly() smashes all uses. So smash it back. | |
525 cmp->ReplaceInput(0, input); | |
526 return Changed(inv); | |
527 } | |
518 // TODO(turbofan): js-typed-lowering of ToBoolean(string) | 528 // TODO(turbofan): js-typed-lowering of ToBoolean(string) |
519 return NoChange(); | 529 return NoChange(); |
520 } | 530 } |
521 | 531 |
522 | 532 |
523 static Reduction ReplaceWithReduction(Node* node, Reduction reduction) { | 533 static Reduction ReplaceWithReduction(Node* node, Reduction reduction) { |
524 if (reduction.Changed()) { | 534 if (reduction.Changed()) { |
525 ReplaceUses(node, reduction.replacement(), NULL); | 535 ReplaceUses(node, reduction.replacement(), NULL); |
526 return reduction; | 536 return reduction; |
527 } | 537 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
595 return ReplaceWithReduction(node, | 605 return ReplaceWithReduction(node, |
596 ReduceJSToStringInput(node->InputAt(0))); | 606 ReduceJSToStringInput(node->InputAt(0))); |
597 default: | 607 default: |
598 break; | 608 break; |
599 } | 609 } |
600 return NoChange(); | 610 return NoChange(); |
601 } | 611 } |
602 } | 612 } |
603 } | 613 } |
604 } // namespace v8::internal::compiler | 614 } // namespace v8::internal::compiler |
OLD | NEW |