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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 static_cast<JSDate::FieldIndex>(static_cast<int>(mindex.Value())))), | 125 static_cast<JSDate::FieldIndex>(static_cast<int>(mindex.Value())))), |
126 value, effect, control); | 126 value, effect, control); |
127 } | 127 } |
128 // TODO(turbofan): Optimize more patterns. | 128 // TODO(turbofan): Optimize more patterns. |
129 return NoChange(); | 129 return NoChange(); |
130 } | 130 } |
131 | 131 |
132 | 132 |
133 Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) { | 133 Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) { |
134 if (mode() != kDeoptimizationEnabled) return NoChange(); | 134 if (mode() != kDeoptimizationEnabled) return NoChange(); |
135 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); | 135 Node* frame_state = NodeProperties::GetFrameStateInput(node, 0); |
136 Node* const effect = NodeProperties::GetEffectInput(node); | 136 DCHECK_EQ(frame_state->opcode(), IrOpcode::kFrameState); |
137 Node* const control = NodeProperties::GetControlInput(node); | |
138 | 137 |
139 // TODO(bmeurer): Move MergeControlToEnd() to the AdvancedReducer. | 138 Node* effect = NodeProperties::GetEffectInput(node); |
140 Node* deoptimize = | 139 Node* control = NodeProperties::GetControlInput(node); |
141 graph()->NewNode(common()->Deoptimize(), frame_state, effect, control); | |
142 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); | |
143 | 140 |
144 node->set_op(common()->Dead()); | 141 // We are making the continuation after the call dead. To |
145 node->TrimInputCount(0); | 142 // model this, we generate if (true) statement with deopt |
146 return Changed(node); | 143 // in the true branch and continuation in the false branch. |
| 144 Node* branch = |
| 145 graph()->NewNode(common()->Branch(), jsgraph()->TrueConstant(), control); |
| 146 |
| 147 // False branch - the original continuation. |
| 148 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 149 ReplaceWithValue(node, jsgraph()->UndefinedConstant(), effect, if_false); |
| 150 |
| 151 // True branch: deopt. |
| 152 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 153 Node* deopt = |
| 154 graph()->NewNode(common()->Deoptimize(), frame_state, effect, if_true); |
| 155 |
| 156 // Connect the deopt to the merge exiting the graph. |
| 157 NodeProperties::MergeControlToEnd(graph(), common(), deopt); |
| 158 |
| 159 return Changed(deopt); |
147 } | 160 } |
148 | 161 |
149 | 162 |
150 Reduction JSIntrinsicLowering::ReduceDoubleHi(Node* node) { | 163 Reduction JSIntrinsicLowering::ReduceDoubleHi(Node* node) { |
151 return Change(node, machine()->Float64ExtractHighWord32()); | 164 return Change(node, machine()->Float64ExtractHighWord32()); |
152 } | 165 } |
153 | 166 |
154 | 167 |
155 Reduction JSIntrinsicLowering::ReduceDoubleLo(Node* node) { | 168 Reduction JSIntrinsicLowering::ReduceDoubleLo(Node* node) { |
156 return Change(node, machine()->Float64ExtractLowWord32()); | 169 return Change(node, machine()->Float64ExtractLowWord32()); |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 } | 544 } |
532 | 545 |
533 | 546 |
534 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { | 547 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { |
535 return jsgraph()->machine(); | 548 return jsgraph()->machine(); |
536 } | 549 } |
537 | 550 |
538 } // namespace compiler | 551 } // namespace compiler |
539 } // namespace internal | 552 } // namespace internal |
540 } // namespace v8 | 553 } // namespace v8 |
OLD | NEW |