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 21 matching lines...) Expand all Loading... |
32 Reduction JSIntrinsicLowering::Reduce(Node* node) { | 32 Reduction JSIntrinsicLowering::Reduce(Node* node) { |
33 if (node->opcode() != IrOpcode::kJSCallRuntime) return NoChange(); | 33 if (node->opcode() != IrOpcode::kJSCallRuntime) return NoChange(); |
34 const Runtime::Function* const f = | 34 const Runtime::Function* const f = |
35 Runtime::FunctionForId(CallRuntimeParametersOf(node->op()).id()); | 35 Runtime::FunctionForId(CallRuntimeParametersOf(node->op()).id()); |
36 if (f->intrinsic_type != Runtime::IntrinsicType::INLINE) return NoChange(); | 36 if (f->intrinsic_type != Runtime::IntrinsicType::INLINE) return NoChange(); |
37 switch (f->function_id) { | 37 switch (f->function_id) { |
38 case Runtime::kInlineConstructDouble: | 38 case Runtime::kInlineConstructDouble: |
39 return ReduceConstructDouble(node); | 39 return ReduceConstructDouble(node); |
40 case Runtime::kInlineCreateIterResultObject: | 40 case Runtime::kInlineCreateIterResultObject: |
41 return ReduceCreateIterResultObject(node); | 41 return ReduceCreateIterResultObject(node); |
| 42 case Runtime::kInlineDateField: |
| 43 return ReduceDateField(node); |
42 case Runtime::kInlineDeoptimizeNow: | 44 case Runtime::kInlineDeoptimizeNow: |
43 return ReduceDeoptimizeNow(node); | 45 return ReduceDeoptimizeNow(node); |
44 case Runtime::kInlineDoubleHi: | 46 case Runtime::kInlineDoubleHi: |
45 return ReduceDoubleHi(node); | 47 return ReduceDoubleHi(node); |
46 case Runtime::kInlineDoubleLo: | 48 case Runtime::kInlineDoubleLo: |
47 return ReduceDoubleLo(node); | 49 return ReduceDoubleLo(node); |
48 case Runtime::kInlineIncrementStatsCounter: | 50 case Runtime::kInlineIncrementStatsCounter: |
49 return ReduceIncrementStatsCounter(node); | 51 return ReduceIncrementStatsCounter(node); |
50 case Runtime::kInlineIsArray: | 52 case Runtime::kInlineIsArray: |
51 return ReduceIsInstanceType(node, JS_ARRAY_TYPE); | 53 return ReduceIsInstanceType(node, JS_ARRAY_TYPE); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 case Runtime::kInlineToName: | 96 case Runtime::kInlineToName: |
95 return ReduceToName(node); | 97 return ReduceToName(node); |
96 case Runtime::kInlineToNumber: | 98 case Runtime::kInlineToNumber: |
97 return ReduceToNumber(node); | 99 return ReduceToNumber(node); |
98 case Runtime::kInlineToObject: | 100 case Runtime::kInlineToObject: |
99 return ReduceToObject(node); | 101 return ReduceToObject(node); |
100 case Runtime::kInlineToPrimitive: | 102 case Runtime::kInlineToPrimitive: |
101 return ReduceToPrimitive(node); | 103 return ReduceToPrimitive(node); |
102 case Runtime::kInlineToString: | 104 case Runtime::kInlineToString: |
103 return ReduceToString(node); | 105 return ReduceToString(node); |
| 106 case Runtime::kInlineThrowNotDateError: |
| 107 return ReduceThrowNotDateError(node); |
104 case Runtime::kInlineCall: | 108 case Runtime::kInlineCall: |
105 return ReduceCall(node); | 109 return ReduceCall(node); |
106 case Runtime::kInlineTailCall: | 110 case Runtime::kInlineTailCall: |
107 return ReduceTailCall(node); | 111 return ReduceTailCall(node); |
108 case Runtime::kInlineGetSuperConstructor: | 112 case Runtime::kInlineGetSuperConstructor: |
109 return ReduceGetSuperConstructor(node); | 113 return ReduceGetSuperConstructor(node); |
110 default: | 114 default: |
111 break; | 115 break; |
112 } | 116 } |
113 return NoChange(); | 117 return NoChange(); |
(...skipping 16 matching lines...) Expand all Loading... |
130 Node* value = | 134 Node* value = |
131 graph()->NewNode(machine()->Float64InsertHighWord32(), | 135 graph()->NewNode(machine()->Float64InsertHighWord32(), |
132 graph()->NewNode(machine()->Float64InsertLowWord32(), | 136 graph()->NewNode(machine()->Float64InsertLowWord32(), |
133 jsgraph()->Constant(0), low), | 137 jsgraph()->Constant(0), low), |
134 high); | 138 high); |
135 ReplaceWithValue(node, value); | 139 ReplaceWithValue(node, value); |
136 return Replace(value); | 140 return Replace(value); |
137 } | 141 } |
138 | 142 |
139 | 143 |
| 144 Reduction JSIntrinsicLowering::ReduceDateField(Node* node) { |
| 145 Node* const value = NodeProperties::GetValueInput(node, 0); |
| 146 Node* const index = NodeProperties::GetValueInput(node, 1); |
| 147 Node* const effect = NodeProperties::GetEffectInput(node); |
| 148 Node* const control = NodeProperties::GetControlInput(node); |
| 149 NumberMatcher mindex(index); |
| 150 if (mindex.Is(JSDate::kDateValue)) { |
| 151 return Change( |
| 152 node, |
| 153 simplified()->LoadField(AccessBuilder::ForJSDateField( |
| 154 static_cast<JSDate::FieldIndex>(static_cast<int>(mindex.Value())))), |
| 155 value, effect, control); |
| 156 } |
| 157 // TODO(turbofan): Optimize more patterns. |
| 158 return NoChange(); |
| 159 } |
| 160 |
| 161 |
140 Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) { | 162 Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) { |
141 if (mode() != kDeoptimizationEnabled) return NoChange(); | 163 if (mode() != kDeoptimizationEnabled) return NoChange(); |
142 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); | 164 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); |
143 Node* const effect = NodeProperties::GetEffectInput(node); | 165 Node* const effect = NodeProperties::GetEffectInput(node); |
144 Node* const control = NodeProperties::GetControlInput(node); | 166 Node* const control = NodeProperties::GetControlInput(node); |
145 | 167 |
146 // TODO(bmeurer): Move MergeControlToEnd() to the AdvancedReducer. | 168 // TODO(bmeurer): Move MergeControlToEnd() to the AdvancedReducer. |
147 Node* deoptimize = | 169 Node* deoptimize = |
148 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), | 170 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), |
149 frame_state, effect, control); | 171 frame_state, effect, control); |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 simplified()->LoadField(AccessBuilder::ForJSRegExpSource()); | 520 simplified()->LoadField(AccessBuilder::ForJSRegExpSource()); |
499 return Change(node, op, receiver, effect, control); | 521 return Change(node, op, receiver, effect, control); |
500 } | 522 } |
501 | 523 |
502 | 524 |
503 Reduction JSIntrinsicLowering::ReduceSubString(Node* node) { | 525 Reduction JSIntrinsicLowering::ReduceSubString(Node* node) { |
504 return Change(node, CodeFactory::SubString(isolate()), 3); | 526 return Change(node, CodeFactory::SubString(isolate()), 3); |
505 } | 527 } |
506 | 528 |
507 | 529 |
| 530 Reduction JSIntrinsicLowering::ReduceThrowNotDateError(Node* node) { |
| 531 if (mode() != kDeoptimizationEnabled) return NoChange(); |
| 532 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 1); |
| 533 Node* const effect = NodeProperties::GetEffectInput(node); |
| 534 Node* const control = NodeProperties::GetControlInput(node); |
| 535 |
| 536 // TODO(bmeurer): Move MergeControlToEnd() to the AdvancedReducer. |
| 537 Node* deoptimize = |
| 538 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), |
| 539 frame_state, effect, control); |
| 540 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); |
| 541 |
| 542 node->TrimInputCount(0); |
| 543 NodeProperties::ChangeOp(node, common()->Dead()); |
| 544 return Changed(node); |
| 545 } |
| 546 |
| 547 |
508 Reduction JSIntrinsicLowering::ReduceToInteger(Node* node) { | 548 Reduction JSIntrinsicLowering::ReduceToInteger(Node* node) { |
509 Node* value = NodeProperties::GetValueInput(node, 0); | 549 Node* value = NodeProperties::GetValueInput(node, 0); |
510 Type* value_type = NodeProperties::GetType(value); | 550 Type* value_type = NodeProperties::GetType(value); |
511 if (value_type->Is(type_cache().kIntegerOrMinusZero)) { | 551 if (value_type->Is(type_cache().kIntegerOrMinusZero)) { |
512 ReplaceWithValue(node, value); | 552 ReplaceWithValue(node, value); |
513 return Replace(value); | 553 return Replace(value); |
514 } | 554 } |
515 return NoChange(); | 555 return NoChange(); |
516 } | 556 } |
517 | 557 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 } | 733 } |
694 | 734 |
695 | 735 |
696 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { | 736 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { |
697 return jsgraph()->simplified(); | 737 return jsgraph()->simplified(); |
698 } | 738 } |
699 | 739 |
700 } // namespace compiler | 740 } // namespace compiler |
701 } // namespace internal | 741 } // namespace internal |
702 } // namespace v8 | 742 } // namespace v8 |
OLD | NEW |