| 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/compiler/access-builder.h" | 9 #include "src/compiler/access-builder.h" |
| 10 #include "src/compiler/js-graph.h" | 10 #include "src/compiler/js-graph.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 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: | 33 case Runtime::kInlineConstructDouble: |
| 34 return ReduceConstructDouble(node); | 34 return ReduceConstructDouble(node); |
| 35 case Runtime::kInlineDateField: |
| 36 return ReduceDateField(node); |
| 35 case Runtime::kInlineDeoptimizeNow: | 37 case Runtime::kInlineDeoptimizeNow: |
| 36 return ReduceDeoptimizeNow(node); | 38 return ReduceDeoptimizeNow(node); |
| 37 case Runtime::kInlineDoubleHi: | 39 case Runtime::kInlineDoubleHi: |
| 38 return ReduceDoubleHi(node); | 40 return ReduceDoubleHi(node); |
| 39 case Runtime::kInlineDoubleLo: | 41 case Runtime::kInlineDoubleLo: |
| 40 return ReduceDoubleLo(node); | 42 return ReduceDoubleLo(node); |
| 41 case Runtime::kInlineHeapObjectGetMap: | 43 case Runtime::kInlineHeapObjectGetMap: |
| 42 return ReduceHeapObjectGetMap(node); | 44 return ReduceHeapObjectGetMap(node); |
| 43 case Runtime::kInlineIncrementStatsCounter: | 45 case Runtime::kInlineIncrementStatsCounter: |
| 44 return ReduceIncrementStatsCounter(node); | 46 return ReduceIncrementStatsCounter(node); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 Node* value = | 101 Node* value = |
| 100 graph()->NewNode(machine()->Float64InsertHighWord32(), | 102 graph()->NewNode(machine()->Float64InsertHighWord32(), |
| 101 graph()->NewNode(machine()->Float64InsertLowWord32(), | 103 graph()->NewNode(machine()->Float64InsertLowWord32(), |
| 102 jsgraph()->Constant(0), low), | 104 jsgraph()->Constant(0), low), |
| 103 high); | 105 high); |
| 104 ReplaceWithValue(node, value); | 106 ReplaceWithValue(node, value); |
| 105 return Replace(value); | 107 return Replace(value); |
| 106 } | 108 } |
| 107 | 109 |
| 108 | 110 |
| 111 Reduction JSIntrinsicLowering::ReduceDateField(Node* node) { |
| 112 Node* const value = NodeProperties::GetValueInput(node, 0); |
| 113 Node* const index = NodeProperties::GetValueInput(node, 1); |
| 114 Node* const effect = NodeProperties::GetEffectInput(node); |
| 115 Node* const control = NodeProperties::GetControlInput(node); |
| 116 NumberMatcher mindex(index); |
| 117 if (mindex.Is(JSDate::kDateValue)) { |
| 118 return Change( |
| 119 node, |
| 120 simplified()->LoadField(AccessBuilder::ForJSDateField( |
| 121 static_cast<JSDate::FieldIndex>(static_cast<int>(mindex.Value())))), |
| 122 value, effect, control); |
| 123 } |
| 124 // TODO(turbofan): Optimize more patterns. |
| 125 return NoChange(); |
| 126 } |
| 127 |
| 128 |
| 109 Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) { | 129 Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) { |
| 110 if (mode() != kDeoptimizationEnabled) return NoChange(); | 130 if (mode() != kDeoptimizationEnabled) return NoChange(); |
| 111 Node* frame_state = NodeProperties::GetFrameStateInput(node, 0); | 131 Node* frame_state = NodeProperties::GetFrameStateInput(node, 0); |
| 112 DCHECK_EQ(frame_state->opcode(), IrOpcode::kFrameState); | 132 DCHECK_EQ(frame_state->opcode(), IrOpcode::kFrameState); |
| 113 | 133 |
| 114 Node* effect = NodeProperties::GetEffectInput(node); | 134 Node* effect = NodeProperties::GetEffectInput(node); |
| 115 Node* control = NodeProperties::GetControlInput(node); | 135 Node* control = NodeProperties::GetControlInput(node); |
| 116 | 136 |
| 117 // We are making the continuation after the call dead. To | 137 // We are making the continuation after the call dead. To |
| 118 // model this, we generate if (true) statement with deopt | 138 // model this, we generate if (true) statement with deopt |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 } | 539 } |
| 520 | 540 |
| 521 | 541 |
| 522 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { | 542 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { |
| 523 return jsgraph()->machine(); | 543 return jsgraph()->machine(); |
| 524 } | 544 } |
| 525 | 545 |
| 526 } // namespace compiler | 546 } // namespace compiler |
| 527 } // namespace internal | 547 } // namespace internal |
| 528 } // namespace v8 | 548 } // namespace v8 |
| OLD | NEW |