| Index: src/compiler/ast-graph-builder.cc
|
| diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
|
| index 49a67157c7a96866fbd12045e1070ee59c76aace..c9ea02f4e4b12a0da9633f614030d0e82ddd56e1 100644
|
| --- a/src/compiler/ast-graph-builder.cc
|
| +++ b/src/compiler/ast-graph-builder.cc
|
| @@ -238,12 +238,8 @@ Node* AstGraphBuilder::Environment::Checkpoint(BailoutId ast_id) {
|
|
|
|
|
| AstGraphBuilder::AstContext::AstContext(AstGraphBuilder* own,
|
| - Expression::Context kind,
|
| - BailoutId bailout_id)
|
| - : bailout_id_(bailout_id),
|
| - kind_(kind),
|
| - owner_(own),
|
| - outer_(own->ast_context()) {
|
| + Expression::Context kind)
|
| + : kind_(kind), owner_(own), outer_(own->ast_context()) {
|
| owner()->set_ast_context(this); // Push.
|
| #ifdef DEBUG
|
| original_height_ = environment()->stack_height();
|
| @@ -271,28 +267,6 @@ AstGraphBuilder::AstTestContext::~AstTestContext() {
|
| }
|
|
|
|
|
| -void AstGraphBuilder::AstEffectContext::ProduceValueWithLazyBailout(
|
| - Node* value) {
|
| - ProduceValue(value);
|
| - owner()->BuildLazyBailout(value, bailout_id_);
|
| -}
|
| -
|
| -
|
| -void AstGraphBuilder::AstValueContext::ProduceValueWithLazyBailout(
|
| - Node* value) {
|
| - ProduceValue(value);
|
| - owner()->BuildLazyBailout(value, bailout_id_);
|
| -}
|
| -
|
| -
|
| -void AstGraphBuilder::AstTestContext::ProduceValueWithLazyBailout(Node* value) {
|
| - environment()->Push(value);
|
| - owner()->BuildLazyBailout(value, bailout_id_);
|
| - environment()->Pop();
|
| - ProduceValue(value);
|
| -}
|
| -
|
| -
|
| void AstGraphBuilder::AstEffectContext::ProduceValue(Node* value) {
|
| // The value is ignored.
|
| }
|
| @@ -359,7 +333,7 @@ void AstGraphBuilder::VisitForValues(ZoneList<Expression*>* exprs) {
|
|
|
|
|
| void AstGraphBuilder::VisitForValue(Expression* expr) {
|
| - AstValueContext for_value(this, expr->id());
|
| + AstValueContext for_value(this);
|
| if (!HasStackOverflow()) {
|
| expr->Accept(this);
|
| }
|
| @@ -367,7 +341,7 @@ void AstGraphBuilder::VisitForValue(Expression* expr) {
|
|
|
|
|
| void AstGraphBuilder::VisitForEffect(Expression* expr) {
|
| - AstEffectContext for_effect(this, expr->id());
|
| + AstEffectContext for_effect(this);
|
| if (!HasStackOverflow()) {
|
| expr->Accept(this);
|
| }
|
| @@ -375,7 +349,7 @@ void AstGraphBuilder::VisitForEffect(Expression* expr) {
|
|
|
|
|
| void AstGraphBuilder::VisitForTest(Expression* expr) {
|
| - AstTestContext for_condition(this, expr->id());
|
| + AstTestContext for_condition(this);
|
| if (!HasStackOverflow()) {
|
| expr->Accept(this);
|
| }
|
| @@ -1112,14 +1086,14 @@ void AstGraphBuilder::VisitAssignment(Assignment* expr) {
|
| PrintableUnique<Name> name =
|
| MakeUnique(property->key()->AsLiteral()->AsPropertyName());
|
| old_value = NewNode(javascript()->LoadNamed(name), object);
|
| - BuildLazyBailoutWithPushedNode(old_value, property->LoadId());
|
| + BuildLazyBailout(old_value, property->LoadId(), PUSH_OUTPUT);
|
| break;
|
| }
|
| case KEYED_PROPERTY: {
|
| Node* key = environment()->Top();
|
| Node* object = environment()->Peek(1);
|
| old_value = NewNode(javascript()->LoadProperty(), object, key);
|
| - BuildLazyBailoutWithPushedNode(old_value, property->LoadId());
|
| + BuildLazyBailout(old_value, property->LoadId(), PUSH_OUTPUT);
|
| break;
|
| }
|
| }
|
| @@ -1198,7 +1172,8 @@ void AstGraphBuilder::VisitProperty(Property* expr) {
|
| Node* object = environment()->Pop();
|
| value = NewNode(javascript()->LoadProperty(), object, key);
|
| }
|
| - ast_context()->ProduceValueWithLazyBailout(value);
|
| + BuildLazyBailout(value, expr->id(), StateCombineFromAstContext());
|
| + ast_context()->ProduceValue(value);
|
| }
|
|
|
|
|
| @@ -1242,7 +1217,7 @@ void AstGraphBuilder::VisitCall(Call* expr) {
|
| Node* key = environment()->Pop();
|
| callee_value = NewNode(javascript()->LoadProperty(), object, key);
|
| }
|
| - BuildLazyBailoutWithPushedNode(callee_value, property->LoadId());
|
| + BuildLazyBailout(callee_value, property->LoadId(), PUSH_OUTPUT);
|
| receiver_value = environment()->Pop();
|
| // Note that a PROPERTY_CALL requires the receiver to be wrapped into an
|
| // object for sloppy callees. This could also be modeled explicitly here,
|
| @@ -1297,7 +1272,8 @@ void AstGraphBuilder::VisitCall(Call* expr) {
|
| // Create node to perform the function call.
|
| Operator* call = javascript()->Call(args->length() + 2, flags);
|
| Node* value = ProcessArguments(call, args->length() + 2);
|
| - ast_context()->ProduceValueWithLazyBailout(value);
|
| + BuildLazyBailout(value, expr->id(), StateCombineFromAstContext());
|
| + ast_context()->ProduceValue(value);
|
| }
|
|
|
|
|
| @@ -1311,7 +1287,8 @@ void AstGraphBuilder::VisitCallNew(CallNew* expr) {
|
| // Create node to perform the construct call.
|
| Operator* call = javascript()->CallNew(args->length() + 1);
|
| Node* value = ProcessArguments(call, args->length() + 1);
|
| - ast_context()->ProduceValueWithLazyBailout(value);
|
| + BuildLazyBailout(value, expr->id(), StateCombineFromAstContext());
|
| + ast_context()->ProduceValue(value);
|
| }
|
|
|
|
|
| @@ -1337,7 +1314,8 @@ void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) {
|
| // Create node to perform the JS runtime call.
|
| Operator* call = javascript()->Call(args->length() + 2, flags);
|
| Node* value = ProcessArguments(call, args->length() + 2);
|
| - ast_context()->ProduceValueWithLazyBailout(value);
|
| + BuildLazyBailout(value, expr->id(), StateCombineFromAstContext());
|
| + ast_context()->ProduceValue(value);
|
| }
|
|
|
|
|
| @@ -1359,7 +1337,8 @@ void AstGraphBuilder::VisitCallRuntime(CallRuntime* expr) {
|
| Runtime::FunctionId functionId = function->function_id;
|
| Operator* call = javascript()->Runtime(functionId, args->length());
|
| Node* value = ProcessArguments(call, args->length());
|
| - ast_context()->ProduceValueWithLazyBailout(value);
|
| + BuildLazyBailout(value, expr->id(), StateCombineFromAstContext());
|
| + ast_context()->ProduceValue(value);
|
| }
|
|
|
|
|
| @@ -1406,7 +1385,7 @@ void AstGraphBuilder::VisitCountOperation(CountOperation* expr) {
|
| PrintableUnique<Name> name =
|
| MakeUnique(property->key()->AsLiteral()->AsPropertyName());
|
| old_value = NewNode(javascript()->LoadNamed(name), object);
|
| - BuildLazyBailoutWithPushedNode(old_value, property->LoadId());
|
| + BuildLazyBailout(old_value, property->LoadId(), PUSH_OUTPUT);
|
| stack_depth = 1;
|
| break;
|
| }
|
| @@ -1416,7 +1395,7 @@ void AstGraphBuilder::VisitCountOperation(CountOperation* expr) {
|
| Node* key = environment()->Top();
|
| Node* object = environment()->Peek(1);
|
| old_value = NewNode(javascript()->LoadProperty(), object, key);
|
| - BuildLazyBailoutWithPushedNode(old_value, property->LoadId());
|
| + BuildLazyBailout(old_value, property->LoadId(), PUSH_OUTPUT);
|
| stack_depth = 2;
|
| break;
|
| }
|
| @@ -1480,7 +1459,8 @@ void AstGraphBuilder::VisitBinaryOperation(BinaryOperation* expr) {
|
| Node* right = environment()->Pop();
|
| Node* left = environment()->Pop();
|
| Node* value = BuildBinaryOp(left, right, expr->op());
|
| - ast_context()->ProduceValueWithLazyBailout(value);
|
| + BuildLazyBailout(value, expr->id(), StateCombineFromAstContext());
|
| + ast_context()->ProduceValue(value);
|
| }
|
| }
|
| }
|
| @@ -1760,7 +1740,7 @@ Node* AstGraphBuilder::BuildVariableLoad(Variable* variable,
|
| PrintableUnique<Name> name = MakeUnique(variable->name());
|
| Operator* op = javascript()->LoadNamed(name, contextual_mode);
|
| Node* node = NewNode(op, global);
|
| - BuildLazyBailoutWithPushedNode(node, bailout_id);
|
| + BuildLazyBailout(node, bailout_id, PUSH_OUTPUT);
|
| return node;
|
| }
|
| case Variable::PARAMETER:
|
| @@ -2013,11 +1993,16 @@ Node* AstGraphBuilder::BuildBinaryOp(Node* left, Node* right, Token::Value op) {
|
| }
|
|
|
|
|
| -void AstGraphBuilder::BuildLazyBailout(Node* node, BailoutId ast_id) {
|
| +void AstGraphBuilder::BuildLazyBailout(Node* node, BailoutId ast_id,
|
| + OutputFrameStateCombine combine) {
|
| if (OperatorProperties::CanLazilyDeoptimize(node->op())) {
|
| // The deopting node should have an outgoing control dependency.
|
| DCHECK(environment()->GetControlDependency() == node);
|
|
|
| + if (combine == PUSH_OUTPUT) {
|
| + environment()->Push(node);
|
| + }
|
| +
|
| StructuredGraphBuilder::Environment* continuation_env = environment();
|
| // Create environment for the deoptimization block, and build the block.
|
| StructuredGraphBuilder::Environment* deopt_env =
|
| @@ -2039,16 +2024,18 @@ void AstGraphBuilder::BuildLazyBailout(Node* node, BailoutId ast_id) {
|
| // Continue with the original environment.
|
| set_environment(continuation_env);
|
|
|
| + if (combine == PUSH_OUTPUT) {
|
| + environment()->Pop();
|
| + }
|
| +
|
| NewNode(common()->Continuation());
|
| }
|
| }
|
|
|
|
|
| -void AstGraphBuilder::BuildLazyBailoutWithPushedNode(Node* node,
|
| - BailoutId ast_id) {
|
| - environment()->Push(node);
|
| - BuildLazyBailout(node, ast_id);
|
| - environment()->Pop();
|
| +AstGraphBuilder::OutputFrameStateCombine
|
| +AstGraphBuilder::StateCombineFromAstContext() {
|
| + return ast_context()->IsEffect() ? IGNORE_OUTPUT : PUSH_OUTPUT;
|
| }
|
| }
|
| }
|
|
|