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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 } | 217 } |
218 | 218 |
219 Node* ConvertPlainPrimitiveToNumberOrUndefined(Node* node) { | 219 Node* ConvertPlainPrimitiveToNumberOrUndefined(Node* node) { |
220 DCHECK(NodeProperties::GetType(node)->Is(Type::PlainPrimitive())); | 220 DCHECK(NodeProperties::GetType(node)->Is(Type::PlainPrimitive())); |
221 // Avoid inserting too many eager ToNumber() operations. | 221 // Avoid inserting too many eager ToNumber() operations. |
222 Reduction const reduction = lowering_->ReduceJSToNumberInput(node); | 222 Reduction const reduction = lowering_->ReduceJSToNumberInput(node); |
223 if (reduction.Changed()) return reduction.replacement(); | 223 if (reduction.Changed()) return reduction.replacement(); |
224 if (NodeProperties::GetType(node)->Is(Type::NumberOrUndefined())) { | 224 if (NodeProperties::GetType(node)->Is(Type::NumberOrUndefined())) { |
225 return node; | 225 return node; |
226 } | 226 } |
| 227 // TODO(bmeurer): Introduce PlainPrimitiveToNumber here. |
227 return graph()->NewNode( | 228 return graph()->NewNode( |
228 javascript()->ToNumber(), node, jsgraph()->NoContextConstant(), | 229 javascript()->ToNumber(), node, jsgraph()->NoContextConstant(), |
229 jsgraph()->EmptyFrameState(), graph()->start(), graph()->start()); | 230 lowering_->EmptyFrameState(), graph()->start(), graph()->start()); |
230 } | 231 } |
231 | 232 |
232 Node* ConvertSingleInputToNumber(Node* node, Node* frame_state) { | 233 Node* ConvertSingleInputToNumber(Node* node, Node* frame_state) { |
233 DCHECK(!NodeProperties::GetType(node)->Is(Type::PlainPrimitive())); | 234 DCHECK(!NodeProperties::GetType(node)->Is(Type::PlainPrimitive())); |
234 Node* const n = graph()->NewNode(javascript()->ToNumber(), node, context(), | 235 Node* const n = graph()->NewNode(javascript()->ToNumber(), node, context(), |
235 frame_state, effect(), control()); | 236 frame_state, effect(), control()); |
236 Node* const if_success = graph()->NewNode(common()->IfSuccess(), n); | 237 Node* const if_success = graph()->NewNode(common()->IfSuccess(), n); |
237 NodeProperties::ReplaceControlInput(node_, if_success); | 238 NodeProperties::ReplaceControlInput(node_, if_success); |
238 NodeProperties::ReplaceUses(node_, node_, node_, node_, n); | 239 NodeProperties::ReplaceUses(node_, node_, node_, node_, n); |
239 update_effect(n); | 240 update_effect(n); |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 jsgraph()->NoContextConstant() || | 785 jsgraph()->NoContextConstant() || |
785 NodeProperties::GetEffectInput(node) != graph()->start() || | 786 NodeProperties::GetEffectInput(node) != graph()->start() || |
786 NodeProperties::GetControlInput(node) != graph()->start()) { | 787 NodeProperties::GetControlInput(node) != graph()->start()) { |
787 // JSToNumber(x:plain-primitive,context,effect,control) | 788 // JSToNumber(x:plain-primitive,context,effect,control) |
788 // => JSToNumber(x,no-context,start,start) | 789 // => JSToNumber(x,no-context,start,start) |
789 RelaxEffectsAndControls(node); | 790 RelaxEffectsAndControls(node); |
790 NodeProperties::ReplaceContextInput(node, jsgraph()->NoContextConstant()); | 791 NodeProperties::ReplaceContextInput(node, jsgraph()->NoContextConstant()); |
791 NodeProperties::ReplaceControlInput(node, graph()->start()); | 792 NodeProperties::ReplaceControlInput(node, graph()->start()); |
792 NodeProperties::ReplaceEffectInput(node, graph()->start()); | 793 NodeProperties::ReplaceEffectInput(node, graph()->start()); |
793 DCHECK_EQ(1, OperatorProperties::GetFrameStateInputCount(node->op())); | 794 DCHECK_EQ(1, OperatorProperties::GetFrameStateInputCount(node->op())); |
794 NodeProperties::ReplaceFrameStateInput(node, 0, | 795 NodeProperties::ReplaceFrameStateInput(node, 0, EmptyFrameState()); |
795 jsgraph()->EmptyFrameState()); | |
796 return Changed(node); | 796 return Changed(node); |
797 } | 797 } |
798 } | 798 } |
799 return NoChange(); | 799 return NoChange(); |
800 } | 800 } |
801 | 801 |
802 | 802 |
803 Reduction JSTypedLowering::ReduceJSToStringInput(Node* input) { | 803 Reduction JSTypedLowering::ReduceJSToStringInput(Node* input) { |
804 if (input->opcode() == IrOpcode::kJSToString) { | 804 if (input->opcode() == IrOpcode::kJSToString) { |
805 // Recursively try to reduce the input first. | 805 // Recursively try to reduce the input first. |
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1853 return NoChange(); | 1853 return NoChange(); |
1854 } | 1854 } |
1855 | 1855 |
1856 | 1856 |
1857 Node* JSTypedLowering::Word32Shl(Node* const lhs, int32_t const rhs) { | 1857 Node* JSTypedLowering::Word32Shl(Node* const lhs, int32_t const rhs) { |
1858 if (rhs == 0) return lhs; | 1858 if (rhs == 0) return lhs; |
1859 return graph()->NewNode(machine()->Word32Shl(), lhs, | 1859 return graph()->NewNode(machine()->Word32Shl(), lhs, |
1860 jsgraph()->Int32Constant(rhs)); | 1860 jsgraph()->Int32Constant(rhs)); |
1861 } | 1861 } |
1862 | 1862 |
| 1863 Node* JSTypedLowering::EmptyFrameState() { |
| 1864 return graph()->NewNode( |
| 1865 common()->FrameState(BailoutId::None(), OutputFrameStateCombine::Ignore(), |
| 1866 nullptr), |
| 1867 jsgraph()->EmptyStateValues(), jsgraph()->EmptyStateValues(), |
| 1868 jsgraph()->EmptyStateValues(), jsgraph()->NoContextConstant(), |
| 1869 jsgraph()->UndefinedConstant(), graph()->start()); |
| 1870 } |
1863 | 1871 |
1864 Factory* JSTypedLowering::factory() const { return jsgraph()->factory(); } | 1872 Factory* JSTypedLowering::factory() const { return jsgraph()->factory(); } |
1865 | 1873 |
1866 | 1874 |
1867 Graph* JSTypedLowering::graph() const { return jsgraph()->graph(); } | 1875 Graph* JSTypedLowering::graph() const { return jsgraph()->graph(); } |
1868 | 1876 |
1869 | 1877 |
1870 Isolate* JSTypedLowering::isolate() const { return jsgraph()->isolate(); } | 1878 Isolate* JSTypedLowering::isolate() const { return jsgraph()->isolate(); } |
1871 | 1879 |
1872 | 1880 |
(...skipping 17 matching lines...) Expand all Loading... |
1890 } | 1898 } |
1891 | 1899 |
1892 | 1900 |
1893 CompilationDependencies* JSTypedLowering::dependencies() const { | 1901 CompilationDependencies* JSTypedLowering::dependencies() const { |
1894 return dependencies_; | 1902 return dependencies_; |
1895 } | 1903 } |
1896 | 1904 |
1897 } // namespace compiler | 1905 } // namespace compiler |
1898 } // namespace internal | 1906 } // namespace internal |
1899 } // namespace v8 | 1907 } // namespace v8 |
OLD | NEW |