| 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 "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/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 namespace compiler { | 13 namespace compiler { |
| 14 | 14 |
| 15 JSIntrinsicLowering::JSIntrinsicLowering(JSGraph* jsgraph) | 15 JSIntrinsicLowering::JSIntrinsicLowering(JSGraph* jsgraph) |
| 16 : jsgraph_(jsgraph), simplified_(jsgraph->zone()) {} | 16 : jsgraph_(jsgraph), simplified_(jsgraph->zone()) {} |
| 17 | 17 |
| 18 | 18 |
| 19 Reduction JSIntrinsicLowering::Reduce(Node* node) { | 19 Reduction JSIntrinsicLowering::Reduce(Node* node) { |
| 20 if (node->opcode() != IrOpcode::kJSCallRuntime) return NoChange(); | 20 if (node->opcode() != IrOpcode::kJSCallRuntime) return NoChange(); |
| 21 const Runtime::Function* const f = | 21 const Runtime::Function* const f = |
| 22 Runtime::FunctionForId(CallRuntimeParametersOf(node->op()).id()); | 22 Runtime::FunctionForId(CallRuntimeParametersOf(node->op()).id()); |
| 23 if (f->intrinsic_type != Runtime::IntrinsicType::INLINE) return NoChange(); |
| 23 switch (f->function_id) { | 24 switch (f->function_id) { |
| 24 case Runtime::kDeoptimizeNow: | 25 case Runtime::kInlineDeoptimizeNow: |
| 25 return ReduceDeoptimizeNow(node); | 26 return ReduceInlineDeoptimizeNow(node); |
| 26 case Runtime::kInlineIsSmi: | 27 case Runtime::kInlineIsSmi: |
| 27 return ReduceInlineIsSmi(node); | 28 return ReduceInlineIsSmi(node); |
| 28 case Runtime::kInlineIsNonNegativeSmi: | 29 case Runtime::kInlineIsNonNegativeSmi: |
| 29 return ReduceInlineIsNonNegativeSmi(node); | 30 return ReduceInlineIsNonNegativeSmi(node); |
| 30 case Runtime::kInlineIsArray: | 31 case Runtime::kInlineIsArray: |
| 31 return ReduceInlineIsInstanceType(node, JS_ARRAY_TYPE); | 32 return ReduceInlineIsInstanceType(node, JS_ARRAY_TYPE); |
| 32 case Runtime::kInlineIsFunction: | 33 case Runtime::kInlineIsFunction: |
| 33 return ReduceInlineIsInstanceType(node, JS_FUNCTION_TYPE); | 34 return ReduceInlineIsInstanceType(node, JS_FUNCTION_TYPE); |
| 34 case Runtime::kInlineConstructDouble: | 35 case Runtime::kInlineConstructDouble: |
| 35 return ReduceInlineConstructDouble(node); | 36 return ReduceInlineConstructDouble(node); |
| 36 case Runtime::kInlineDoubleLo: | 37 case Runtime::kInlineDoubleLo: |
| 37 return ReduceInlineDoubleLo(node); | 38 return ReduceInlineDoubleLo(node); |
| 38 case Runtime::kInlineDoubleHi: | 39 case Runtime::kInlineDoubleHi: |
| 39 return ReduceInlineDoubleHi(node); | 40 return ReduceInlineDoubleHi(node); |
| 40 case Runtime::kInlineIsRegExp: | 41 case Runtime::kInlineIsRegExp: |
| 41 return ReduceInlineIsInstanceType(node, JS_REGEXP_TYPE); | 42 return ReduceInlineIsInstanceType(node, JS_REGEXP_TYPE); |
| 42 case Runtime::kInlineValueOf: | 43 case Runtime::kInlineValueOf: |
| 43 return ReduceInlineValueOf(node); | 44 return ReduceInlineValueOf(node); |
| 44 default: | 45 default: |
| 45 break; | 46 break; |
| 46 } | 47 } |
| 47 return NoChange(); | 48 return NoChange(); |
| 48 } | 49 } |
| 49 | 50 |
| 50 | 51 |
| 51 Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) { | 52 Reduction JSIntrinsicLowering::ReduceInlineDeoptimizeNow(Node* node) { |
| 52 if (!FLAG_turbo_deoptimization) return NoChange(); | 53 if (!FLAG_turbo_deoptimization) return NoChange(); |
| 53 | 54 |
| 54 Node* frame_state = NodeProperties::GetFrameStateInput(node, 0); | 55 Node* frame_state = NodeProperties::GetFrameStateInput(node, 0); |
| 55 DCHECK_EQ(frame_state->opcode(), IrOpcode::kFrameState); | 56 DCHECK_EQ(frame_state->opcode(), IrOpcode::kFrameState); |
| 56 | 57 |
| 57 Node* effect = NodeProperties::GetEffectInput(node); | 58 Node* effect = NodeProperties::GetEffectInput(node); |
| 58 Node* control = NodeProperties::GetControlInput(node); | 59 Node* control = NodeProperties::GetControlInput(node); |
| 59 | 60 |
| 60 // We are making the continuation after the call dead. To | 61 // We are making the continuation after the call dead. To |
| 61 // model this, we generate if (true) statement with deopt | 62 // model this, we generate if (true) statement with deopt |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 255 } |
| 255 | 256 |
| 256 | 257 |
| 257 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { | 258 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { |
| 258 return jsgraph()->machine(); | 259 return jsgraph()->machine(); |
| 259 } | 260 } |
| 260 | 261 |
| 261 } // namespace compiler | 262 } // namespace compiler |
| 262 } // namespace internal | 263 } // namespace internal |
| 263 } // namespace v8 | 264 } // namespace v8 |
| OLD | NEW |