OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/ast-graph-builder.h" | 5 #include "src/compiler/ast-graph-builder.h" |
6 | 6 |
7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
8 #include "src/compiler/control-builders.h" | 8 #include "src/compiler/control-builders.h" |
9 #include "src/compiler/machine-operator.h" | 9 #include "src/compiler/machine-operator.h" |
10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
(...skipping 199 matching lines...) Loading... |
210 } | 210 } |
211 } | 211 } |
212 } | 212 } |
213 if (should_update) { | 213 if (should_update) { |
214 Operator* op = common()->StateValues(count); | 214 Operator* op = common()->StateValues(count); |
215 (*state_values) = graph()->NewNode(op, count, env_values); | 215 (*state_values) = graph()->NewNode(op, count, env_values); |
216 } | 216 } |
217 } | 217 } |
218 | 218 |
219 | 219 |
220 Node* AstGraphBuilder::Environment::Checkpoint(BailoutId ast_id) { | 220 Node* AstGraphBuilder::Environment::Checkpoint( |
| 221 BailoutId ast_id, OutputFrameStateCombine combine) { |
221 UpdateStateValues(¶meters_node_, 0, parameters_count()); | 222 UpdateStateValues(¶meters_node_, 0, parameters_count()); |
222 UpdateStateValues(&locals_node_, parameters_count(), locals_count()); | 223 UpdateStateValues(&locals_node_, parameters_count(), locals_count()); |
223 UpdateStateValues(&stack_node_, parameters_count() + locals_count(), | 224 UpdateStateValues(&stack_node_, parameters_count() + locals_count(), |
224 stack_height()); | 225 stack_height()); |
225 | 226 |
226 Operator* op = common()->FrameState(ast_id); | 227 Operator* op = common()->FrameState(ast_id, combine); |
227 | 228 |
228 return graph()->NewNode(op, parameters_node_, locals_node_, stack_node_); | 229 return graph()->NewNode(op, parameters_node_, locals_node_, stack_node_, |
| 230 GetContext()); |
229 } | 231 } |
230 | 232 |
231 | 233 |
232 AstGraphBuilder::AstContext::AstContext(AstGraphBuilder* own, | 234 AstGraphBuilder::AstContext::AstContext(AstGraphBuilder* own, |
233 Expression::Context kind) | 235 Expression::Context kind) |
234 : kind_(kind), owner_(own), outer_(own->ast_context()) { | 236 : kind_(kind), owner_(own), outer_(own->ast_context()) { |
235 owner()->set_ast_context(this); // Push. | 237 owner()->set_ast_context(this); // Push. |
236 #ifdef DEBUG | 238 #ifdef DEBUG |
237 original_height_ = environment()->stack_height(); | 239 original_height_ = environment()->stack_height(); |
238 #endif | 240 #endif |
(...skipping 1763 matching lines...) Loading... |
2002 } | 2004 } |
2003 | 2005 |
2004 | 2006 |
2005 void AstGraphBuilder::PrepareFrameState(Node* node, BailoutId ast_id, | 2007 void AstGraphBuilder::PrepareFrameState(Node* node, BailoutId ast_id, |
2006 OutputFrameStateCombine combine) { | 2008 OutputFrameStateCombine combine) { |
2007 if (OperatorProperties::HasFrameStateInput(node->op())) { | 2009 if (OperatorProperties::HasFrameStateInput(node->op())) { |
2008 int frame_state_index = NodeProperties::GetFrameStateIndex(node); | 2010 int frame_state_index = NodeProperties::GetFrameStateIndex(node); |
2009 | 2011 |
2010 DCHECK(node->InputAt(frame_state_index)->op()->opcode() == IrOpcode::kDead); | 2012 DCHECK(node->InputAt(frame_state_index)->op()->opcode() == IrOpcode::kDead); |
2011 | 2013 |
2012 Node* frame_state_node = environment()->Checkpoint(ast_id); | 2014 Node* frame_state_node = environment()->Checkpoint(ast_id, combine); |
2013 node->ReplaceInput(frame_state_index, frame_state_node); | 2015 node->ReplaceInput(frame_state_index, frame_state_node); |
2014 } | 2016 } |
2015 | |
2016 if (OperatorProperties::CanLazilyDeoptimize(node->op())) { | |
2017 // The deopting node should have an outgoing control dependency. | |
2018 DCHECK(environment()->GetControlDependency() == node); | |
2019 | |
2020 StructuredGraphBuilder::Environment* continuation_env = environment(); | |
2021 // Create environment for the deoptimization block, and build the block. | |
2022 StructuredGraphBuilder::Environment* deopt_env = | |
2023 CopyEnvironment(continuation_env); | |
2024 set_environment(deopt_env); | |
2025 | |
2026 if (combine == PUSH_OUTPUT) { | |
2027 environment()->Push(node); | |
2028 } | |
2029 | |
2030 NewNode(common()->LazyDeoptimization()); | |
2031 | |
2032 // TODO(jarin) If ast_id.IsNone(), perhaps we should generate an empty | |
2033 // deopt block and make sure there is no patch entry for this (so | |
2034 // that the deoptimizer dies when trying to deoptimize here). | |
2035 Node* state_node = environment()->Checkpoint(ast_id); | |
2036 Node* deoptimize_node = NewNode(common()->Deoptimize(), state_node); | |
2037 UpdateControlDependencyToLeaveFunction(deoptimize_node); | |
2038 | |
2039 // Continue with the original environment. | |
2040 set_environment(continuation_env); | |
2041 NewNode(common()->Continuation()); | |
2042 } | |
2043 } | 2017 } |
2044 | 2018 |
2045 } | 2019 } |
2046 } | 2020 } |
2047 } // namespace v8::internal::compiler | 2021 } // namespace v8::internal::compiler |
OLD | NEW |