| 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* frame_state = NodeProperties::GetFrameStateInput(node, 0); | 135 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); |
| 136 DCHECK_EQ(frame_state->opcode(), IrOpcode::kFrameState); | 136 Node* const effect = NodeProperties::GetEffectInput(node); |
| 137 Node* const control = NodeProperties::GetControlInput(node); |
| 137 | 138 |
| 138 Node* effect = NodeProperties::GetEffectInput(node); | 139 // TODO(bmeurer): Move MergeControlToEnd() to the AdvancedReducer. |
| 139 Node* control = NodeProperties::GetControlInput(node); | 140 Node* deoptimize = |
| 141 graph()->NewNode(common()->Deoptimize(), frame_state, effect, control); |
| 142 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); |
| 140 | 143 |
| 141 // We are making the continuation after the call dead. To | 144 node->set_op(common()->Dead()); |
| 142 // model this, we generate if (true) statement with deopt | 145 node->TrimInputCount(0); |
| 143 // in the true branch and continuation in the false branch. | 146 return Changed(node); |
| 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); | |
| 160 } | 147 } |
| 161 | 148 |
| 162 | 149 |
| 163 Reduction JSIntrinsicLowering::ReduceDoubleHi(Node* node) { | 150 Reduction JSIntrinsicLowering::ReduceDoubleHi(Node* node) { |
| 164 return Change(node, machine()->Float64ExtractHighWord32()); | 151 return Change(node, machine()->Float64ExtractHighWord32()); |
| 165 } | 152 } |
| 166 | 153 |
| 167 | 154 |
| 168 Reduction JSIntrinsicLowering::ReduceDoubleLo(Node* node) { | 155 Reduction JSIntrinsicLowering::ReduceDoubleLo(Node* node) { |
| 169 return Change(node, machine()->Float64ExtractLowWord32()); | 156 return Change(node, machine()->Float64ExtractLowWord32()); |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 } | 531 } |
| 545 | 532 |
| 546 | 533 |
| 547 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { | 534 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { |
| 548 return jsgraph()->machine(); | 535 return jsgraph()->machine(); |
| 549 } | 536 } |
| 550 | 537 |
| 551 } // namespace compiler | 538 } // namespace compiler |
| 552 } // namespace internal | 539 } // namespace internal |
| 553 } // namespace v8 | 540 } // namespace v8 |
| OLD | NEW |