| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/js-intrinsic-lowering.h" | 5 #include "src/compiler/js-intrinsic-lowering.h" |
| 6 | 6 |
| 7 #include <stack> | 7 #include <stack> |
| 8 | 8 |
| 9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
| 10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 JSIntrinsicLowering::JSIntrinsicLowering(Editor* editor, JSGraph* jsgraph, | 23 JSIntrinsicLowering::JSIntrinsicLowering(Editor* editor, JSGraph* jsgraph, |
| 24 DeoptimizationMode mode) | 24 DeoptimizationMode mode) |
| 25 : AdvancedReducer(editor), jsgraph_(jsgraph), mode_(mode) {} | 25 : AdvancedReducer(editor), jsgraph_(jsgraph), mode_(mode) {} |
| 26 | 26 |
| 27 Reduction JSIntrinsicLowering::Reduce(Node* node) { | 27 Reduction JSIntrinsicLowering::Reduce(Node* node) { |
| 28 if (node->opcode() != IrOpcode::kJSCallRuntime) return NoChange(); | 28 if (node->opcode() != IrOpcode::kJSCallRuntime) return NoChange(); |
| 29 const Runtime::Function* const f = | 29 const Runtime::Function* const f = |
| 30 Runtime::FunctionForId(CallRuntimeParametersOf(node->op()).id()); | 30 Runtime::FunctionForId(CallRuntimeParametersOf(node->op()).id()); |
| 31 if (f->intrinsic_type != Runtime::IntrinsicType::INLINE) return NoChange(); | 31 if (f->intrinsic_type != Runtime::IntrinsicType::INLINE) return NoChange(); |
| 32 switch (f->function_id) { | 32 switch (f->function_id) { |
| 33 case Runtime::kInlineConstructDouble: | |
| 34 return ReduceConstructDouble(node); | |
| 35 case Runtime::kInlineCreateIterResultObject: | 33 case Runtime::kInlineCreateIterResultObject: |
| 36 return ReduceCreateIterResultObject(node); | 34 return ReduceCreateIterResultObject(node); |
| 37 case Runtime::kInlineDeoptimizeNow: | 35 case Runtime::kInlineDeoptimizeNow: |
| 38 return ReduceDeoptimizeNow(node); | 36 return ReduceDeoptimizeNow(node); |
| 39 case Runtime::kInlineDoubleHi: | 37 case Runtime::kInlineDoubleHi: |
| 40 return ReduceDoubleHi(node); | 38 return ReduceDoubleHi(node); |
| 41 case Runtime::kInlineDoubleLo: | 39 case Runtime::kInlineDoubleLo: |
| 42 return ReduceDoubleLo(node); | 40 return ReduceDoubleLo(node); |
| 43 case Runtime::kInlineGeneratorClose: | 41 case Runtime::kInlineGeneratorClose: |
| 44 return ReduceGeneratorClose(node); | 42 return ReduceGeneratorClose(node); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 Reduction JSIntrinsicLowering::ReduceCreateIterResultObject(Node* node) { | 100 Reduction JSIntrinsicLowering::ReduceCreateIterResultObject(Node* node) { |
| 103 Node* const value = NodeProperties::GetValueInput(node, 0); | 101 Node* const value = NodeProperties::GetValueInput(node, 0); |
| 104 Node* const done = NodeProperties::GetValueInput(node, 1); | 102 Node* const done = NodeProperties::GetValueInput(node, 1); |
| 105 Node* const context = NodeProperties::GetContextInput(node); | 103 Node* const context = NodeProperties::GetContextInput(node); |
| 106 Node* const effect = NodeProperties::GetEffectInput(node); | 104 Node* const effect = NodeProperties::GetEffectInput(node); |
| 107 return Change(node, javascript()->CreateIterResultObject(), value, done, | 105 return Change(node, javascript()->CreateIterResultObject(), value, done, |
| 108 context, effect); | 106 context, effect); |
| 109 } | 107 } |
| 110 | 108 |
| 111 | 109 |
| 112 Reduction JSIntrinsicLowering::ReduceConstructDouble(Node* node) { | |
| 113 Node* high = NodeProperties::GetValueInput(node, 0); | |
| 114 Node* low = NodeProperties::GetValueInput(node, 1); | |
| 115 Node* value = | |
| 116 graph()->NewNode(machine()->Float64InsertHighWord32(), | |
| 117 graph()->NewNode(machine()->Float64InsertLowWord32(), | |
| 118 jsgraph()->Constant(0), low), | |
| 119 high); | |
| 120 ReplaceWithValue(node, value); | |
| 121 return Replace(value); | |
| 122 } | |
| 123 | |
| 124 | |
| 125 Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) { | 110 Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) { |
| 126 if (mode() != kDeoptimizationEnabled) return NoChange(); | 111 if (mode() != kDeoptimizationEnabled) return NoChange(); |
| 127 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); | 112 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); |
| 128 Node* const effect = NodeProperties::GetEffectInput(node); | 113 Node* const effect = NodeProperties::GetEffectInput(node); |
| 129 Node* const control = NodeProperties::GetControlInput(node); | 114 Node* const control = NodeProperties::GetControlInput(node); |
| 130 | 115 |
| 131 // TODO(bmeurer): Move MergeControlToEnd() to the AdvancedReducer. | 116 // TODO(bmeurer): Move MergeControlToEnd() to the AdvancedReducer. |
| 132 Node* deoptimize = | 117 Node* deoptimize = |
| 133 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), | 118 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), |
| 134 frame_state, effect, control); | 119 frame_state, effect, control); |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 } | 501 } |
| 517 | 502 |
| 518 | 503 |
| 519 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { | 504 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { |
| 520 return jsgraph()->simplified(); | 505 return jsgraph()->simplified(); |
| 521 } | 506 } |
| 522 | 507 |
| 523 } // namespace compiler | 508 } // namespace compiler |
| 524 } // namespace internal | 509 } // namespace internal |
| 525 } // namespace v8 | 510 } // namespace v8 |
| OLD | NEW |