Commit 489b6f7c authored by jarin's avatar jarin Committed by Commit bot

[turbofan] Add missing deopt for the assignment in the for-in statement.

BUG=chromium:416359
LOG=n
R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/881303002

Cr-Commit-Position: refs/heads/master@{#26309}
parent d684ece0
...@@ -1260,6 +1260,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { ...@@ -1260,6 +1260,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
// Perform the assignment as if via '='. // Perform the assignment as if via '='.
{ EffectContext context(this); { EffectContext context(this);
EmitAssignment(stmt->each()); EmitAssignment(stmt->each());
PrepareForBailoutForId(stmt->AssignmentId(), NO_REGISTERS);
} }
// Generate code for the body of the loop. // Generate code for the body of the loop.
......
...@@ -1247,6 +1247,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { ...@@ -1247,6 +1247,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
// Perform the assignment as if via '='. // Perform the assignment as if via '='.
{ EffectContext context(this); { EffectContext context(this);
EmitAssignment(stmt->each()); EmitAssignment(stmt->each());
PrepareForBailoutForId(stmt->AssignmentId(), NO_REGISTERS);
} }
// Generate code for the body of the loop. // Generate code for the body of the loop.
......
...@@ -933,11 +933,12 @@ class ForInStatement FINAL : public ForEachStatement { ...@@ -933,11 +933,12 @@ class ForInStatement FINAL : public ForEachStatement {
ForInType for_in_type() const { return for_in_type_; } ForInType for_in_type() const { return for_in_type_; }
void set_for_in_type(ForInType type) { for_in_type_ = type; } void set_for_in_type(ForInType type) { for_in_type_ = type; }
static int num_ids() { return parent_num_ids() + 4; } static int num_ids() { return parent_num_ids() + 5; }
BailoutId BodyId() const { return BailoutId(local_id(0)); } BailoutId BodyId() const { return BailoutId(local_id(0)); }
BailoutId PrepareId() const { return BailoutId(local_id(1)); } BailoutId PrepareId() const { return BailoutId(local_id(1)); }
BailoutId EnumId() const { return BailoutId(local_id(2)); } BailoutId EnumId() const { return BailoutId(local_id(2)); }
BailoutId ToObjectId() const { return BailoutId(local_id(3)); } BailoutId ToObjectId() const { return BailoutId(local_id(3)); }
BailoutId AssignmentId() const { return BailoutId(local_id(4)); }
BailoutId ContinueId() const OVERRIDE { return EntryId(); } BailoutId ContinueId() const OVERRIDE { return EntryId(); }
BailoutId StackCheckId() const OVERRIDE { return BodyId(); } BailoutId StackCheckId() const OVERRIDE { return BodyId(); }
......
...@@ -774,7 +774,7 @@ void AstGraphBuilder::VisitForInStatement(ForInStatement* stmt) { ...@@ -774,7 +774,7 @@ void AstGraphBuilder::VisitForInStatement(ForInStatement* stmt) {
} }
value = environment()->Pop(); value = environment()->Pop();
// Bind value and do loop body. // Bind value and do loop body.
VisitForInAssignment(stmt->each(), value); VisitForInAssignment(stmt->each(), value, stmt->AssignmentId());
VisitIterationBody(stmt, &for_loop, 5); VisitIterationBody(stmt, &for_loop, 5);
for_loop.EndBody(); for_loop.EndBody();
// Inc counter and continue. // Inc counter and continue.
...@@ -1228,7 +1228,8 @@ void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { ...@@ -1228,7 +1228,8 @@ void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
} }
void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value) { void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value,
BailoutId bailout_id) {
DCHECK(expr->IsValidReferenceExpression()); DCHECK(expr->IsValidReferenceExpression());
// Left-hand side can only be a property, a global or a variable slot. // Left-hand side can only be a property, a global or a variable slot.
...@@ -1239,8 +1240,7 @@ void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value) { ...@@ -1239,8 +1240,7 @@ void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value) {
switch (assign_type) { switch (assign_type) {
case VARIABLE: { case VARIABLE: {
Variable* var = expr->AsVariableProxy()->var(); Variable* var = expr->AsVariableProxy()->var();
// TODO(jarin) Fill in the correct bailout id. BuildVariableAssignment(var, value, Token::ASSIGN, bailout_id);
BuildVariableAssignment(var, value, Token::ASSIGN, BailoutId::None());
break; break;
} }
case NAMED_PROPERTY: { case NAMED_PROPERTY: {
...@@ -1252,8 +1252,7 @@ void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value) { ...@@ -1252,8 +1252,7 @@ void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value) {
MakeUnique(property->key()->AsLiteral()->AsPropertyName()); MakeUnique(property->key()->AsLiteral()->AsPropertyName());
Node* store = Node* store =
NewNode(javascript()->StoreNamed(strict_mode(), name), object, value); NewNode(javascript()->StoreNamed(strict_mode(), name), object, value);
// TODO(jarin) Fill in the correct bailout id. PrepareFrameState(store, bailout_id);
PrepareFrameState(store, BailoutId::None());
break; break;
} }
case KEYED_PROPERTY: { case KEYED_PROPERTY: {
...@@ -1265,8 +1264,7 @@ void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value) { ...@@ -1265,8 +1264,7 @@ void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value) {
value = environment()->Pop(); value = environment()->Pop();
Node* store = NewNode(javascript()->StoreProperty(strict_mode()), object, Node* store = NewNode(javascript()->StoreProperty(strict_mode()), object,
key, value); key, value);
// TODO(jarin) Fill in the correct bailout id. PrepareFrameState(store, bailout_id);
PrepareFrameState(store, BailoutId::None());
break; break;
} }
} }
......
...@@ -197,7 +197,8 @@ class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor { ...@@ -197,7 +197,8 @@ class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor {
void VisitArithmeticExpression(BinaryOperation* expr); void VisitArithmeticExpression(BinaryOperation* expr);
// Dispatched from VisitForInStatement. // Dispatched from VisitForInStatement.
void VisitForInAssignment(Expression* expr, Node* value); void VisitForInAssignment(Expression* expr, Node* value,
BailoutId bailout_id);
// Dispatched from VisitClassLiteral. // Dispatched from VisitClassLiteral.
void VisitClassLiteralContents(ClassLiteral* expr); void VisitClassLiteralContents(ClassLiteral* expr);
......
...@@ -1184,6 +1184,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { ...@@ -1184,6 +1184,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
// Perform the assignment as if via '='. // Perform the assignment as if via '='.
{ EffectContext context(this); { EffectContext context(this);
EmitAssignment(stmt->each()); EmitAssignment(stmt->each());
PrepareForBailoutForId(stmt->AssignmentId(), NO_REGISTERS);
} }
// Generate code for the body of the loop. // Generate code for the body of the loop.
......
...@@ -1247,6 +1247,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { ...@@ -1247,6 +1247,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
// Perform the assignment as if via '='. // Perform the assignment as if via '='.
{ EffectContext context(this); { EffectContext context(this);
EmitAssignment(stmt->each()); EmitAssignment(stmt->each());
PrepareForBailoutForId(stmt->AssignmentId(), NO_REGISTERS);
} }
// Generate code for the body of the loop. // Generate code for the body of the loop.
......
...@@ -1242,6 +1242,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { ...@@ -1242,6 +1242,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
// Perform the assignment as if via '='. // Perform the assignment as if via '='.
{ EffectContext context(this); { EffectContext context(this);
EmitAssignment(stmt->each()); EmitAssignment(stmt->each());
PrepareForBailoutForId(stmt->AssignmentId(), NO_REGISTERS);
} }
// Generate code for the body of the loop. // Generate code for the body of the loop.
......
...@@ -1217,6 +1217,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { ...@@ -1217,6 +1217,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
{ {
EffectContext context(this); EffectContext context(this);
EmitAssignment(stmt->each()); EmitAssignment(stmt->each());
PrepareForBailoutForId(stmt->AssignmentId(), NO_REGISTERS);
} }
// Generate code for the body of the loop. // Generate code for the body of the loop.
......
...@@ -1218,6 +1218,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { ...@@ -1218,6 +1218,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
// Perform the assignment as if via '='. // Perform the assignment as if via '='.
{ EffectContext context(this); { EffectContext context(this);
EmitAssignment(stmt->each()); EmitAssignment(stmt->each());
PrepareForBailoutForId(stmt->AssignmentId(), NO_REGISTERS);
} }
// Generate code for the body of the loop. // Generate code for the body of the loop.
......
...@@ -1173,6 +1173,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { ...@@ -1173,6 +1173,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
// Perform the assignment as if via '='. // Perform the assignment as if via '='.
{ EffectContext context(this); { EffectContext context(this);
EmitAssignment(stmt->each()); EmitAssignment(stmt->each());
PrepareForBailoutForId(stmt->AssignmentId(), NO_REGISTERS);
} }
// Generate code for the body of the loop. // Generate code for the body of the loop.
......
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
"use strict"
function f() {
for (x in {a:0});
}
assertThrows(f);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment