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/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/compilation-dependencies.h" | 6 #include "src/compilation-dependencies.h" |
7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 } | 740 } |
741 | 741 |
742 | 742 |
743 Reduction JSTypedLowering::ReduceJSToNumberInput(Node* input) { | 743 Reduction JSTypedLowering::ReduceJSToNumberInput(Node* input) { |
744 if (input->opcode() == IrOpcode::kJSToNumber) { | 744 if (input->opcode() == IrOpcode::kJSToNumber) { |
745 // Recursively try to reduce the input first. | 745 // Recursively try to reduce the input first. |
746 Reduction result = ReduceJSToNumber(input); | 746 Reduction result = ReduceJSToNumber(input); |
747 if (result.Changed()) return result; | 747 if (result.Changed()) return result; |
748 return Changed(input); // JSToNumber(JSToNumber(x)) => JSToNumber(x) | 748 return Changed(input); // JSToNumber(JSToNumber(x)) => JSToNumber(x) |
749 } | 749 } |
| 750 // Check for ToNumber truncation of signaling NaN to undefined mapping. |
| 751 if (input->opcode() == IrOpcode::kSelect) { |
| 752 Node* check = NodeProperties::GetValueInput(input, 0); |
| 753 Node* vtrue = NodeProperties::GetValueInput(input, 1); |
| 754 Type* vtrue_type = NodeProperties::GetType(vtrue); |
| 755 Node* vfalse = NodeProperties::GetValueInput(input, 2); |
| 756 Type* vfalse_type = NodeProperties::GetType(vfalse); |
| 757 if (vtrue_type->Is(Type::Undefined()) && vfalse_type->Is(Type::Number())) { |
| 758 if (check->opcode() == IrOpcode::kNumberIsHoleNaN && |
| 759 check->InputAt(0) == vfalse) { |
| 760 // JSToNumber(Select(NumberIsHoleNaN(x), y:undefined, x:number)) => x |
| 761 return Replace(vfalse); |
| 762 } |
| 763 } |
| 764 } |
750 // Check if we have a cached conversion. | 765 // Check if we have a cached conversion. |
751 Type* input_type = NodeProperties::GetType(input); | 766 Type* input_type = NodeProperties::GetType(input); |
752 if (input_type->Is(Type::Number())) { | 767 if (input_type->Is(Type::Number())) { |
753 // JSToNumber(x:number) => x | 768 // JSToNumber(x:number) => x |
754 return Changed(input); | 769 return Changed(input); |
755 } | 770 } |
756 if (input_type->Is(Type::Undefined())) { | 771 if (input_type->Is(Type::Undefined())) { |
757 // JSToNumber(undefined) => #NaN | 772 // JSToNumber(undefined) => #NaN |
758 return Replace(jsgraph()->NaNConstant()); | 773 return Replace(jsgraph()->NaNConstant()); |
759 } | 774 } |
(...skipping 1608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2368 } | 2383 } |
2369 | 2384 |
2370 | 2385 |
2371 CompilationDependencies* JSTypedLowering::dependencies() const { | 2386 CompilationDependencies* JSTypedLowering::dependencies() const { |
2372 return dependencies_; | 2387 return dependencies_; |
2373 } | 2388 } |
2374 | 2389 |
2375 } // namespace compiler | 2390 } // namespace compiler |
2376 } // namespace internal | 2391 } // namespace internal |
2377 } // namespace v8 | 2392 } // namespace v8 |
OLD | NEW |