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/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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 return Changed(input); | 437 return Changed(input); |
438 } | 438 } |
439 if (input_type->Is(Type::Undefined())) { | 439 if (input_type->Is(Type::Undefined())) { |
440 // JSToNumber(undefined) => #NaN | 440 // JSToNumber(undefined) => #NaN |
441 return ReplaceWith(jsgraph()->NaNConstant()); | 441 return ReplaceWith(jsgraph()->NaNConstant()); |
442 } | 442 } |
443 if (input_type->Is(Type::Null())) { | 443 if (input_type->Is(Type::Null())) { |
444 // JSToNumber(null) => #0 | 444 // JSToNumber(null) => #0 |
445 return ReplaceWith(jsgraph()->ZeroConstant()); | 445 return ReplaceWith(jsgraph()->ZeroConstant()); |
446 } | 446 } |
447 // TODO(turbofan): js-typed-lowering of ToNumber(x:boolean) | 447 if (input_type->Is(Type::Boolean())) { |
| 448 // JSToNumber(x:boolean) => BooleanToNumber(x) |
| 449 return ReplaceWith( |
| 450 graph()->NewNode(simplified()->BooleanToNumber(), input)); |
| 451 } |
448 // TODO(turbofan): js-typed-lowering of ToNumber(x:string) | 452 // TODO(turbofan): js-typed-lowering of ToNumber(x:string) |
449 return NoChange(); | 453 return NoChange(); |
450 } | 454 } |
451 | 455 |
452 | 456 |
453 Reduction JSTypedLowering::ReduceJSToStringInput(Node* input) { | 457 Reduction JSTypedLowering::ReduceJSToStringInput(Node* input) { |
454 if (input->opcode() == IrOpcode::kJSToString) { | 458 if (input->opcode() == IrOpcode::kJSToString) { |
455 // Recursively try to reduce the input first. | 459 // Recursively try to reduce the input first. |
456 Reduction result = ReduceJSToStringInput(input->InputAt(0)); | 460 Reduction result = ReduceJSToStringInput(input->InputAt(0)); |
457 if (result.Changed()) { | 461 if (result.Changed()) { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 return ReduceJSStoreProperty(node); | 680 return ReduceJSStoreProperty(node); |
677 default: | 681 default: |
678 break; | 682 break; |
679 } | 683 } |
680 return NoChange(); | 684 return NoChange(); |
681 } | 685 } |
682 | 686 |
683 } // namespace compiler | 687 } // namespace compiler |
684 } // namespace internal | 688 } // namespace internal |
685 } // namespace v8 | 689 } // namespace v8 |
OLD | NEW |