Commit 558efe21 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

Add missing BailoutId and FrameState to with statements.

R=bmeurer@chromium.org
TEST=mjsunit/regress/regress-crbug-450642
BUG=chromium:450642
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#26218}
parent 8fb59304
...@@ -291,6 +291,7 @@ void AstNumberingVisitor::VisitCallRuntime(CallRuntime* node) { ...@@ -291,6 +291,7 @@ void AstNumberingVisitor::VisitCallRuntime(CallRuntime* node) {
void AstNumberingVisitor::VisitWithStatement(WithStatement* node) { void AstNumberingVisitor::VisitWithStatement(WithStatement* node) {
IncrementNodeCount(); IncrementNodeCount();
DisableOptimization(kWithStatement); DisableOptimization(kWithStatement);
node->set_base_id(ReserveIdRange(WithStatement::num_ids()));
Visit(node->expression()); Visit(node->expression());
Visit(node->statement()); Visit(node->statement());
} }
......
...@@ -1102,19 +1102,32 @@ class WithStatement FINAL : public Statement { ...@@ -1102,19 +1102,32 @@ class WithStatement FINAL : public Statement {
Expression* expression() const { return expression_; } Expression* expression() const { return expression_; }
Statement* statement() const { return statement_; } Statement* statement() const { return statement_; }
void set_base_id(int id) { base_id_ = id; }
static int num_ids() { return parent_num_ids() + 1; }
BailoutId EntryId() const { return BailoutId(local_id(0)); }
protected: protected:
WithStatement( WithStatement(Zone* zone, Scope* scope, Expression* expression,
Zone* zone, Scope* scope, Statement* statement, int pos)
Expression* expression, Statement* statement, int pos)
: Statement(zone, pos), : Statement(zone, pos),
scope_(scope), scope_(scope),
expression_(expression), expression_(expression),
statement_(statement) { } statement_(statement),
base_id_(BailoutId::None().ToInt()) {}
static int parent_num_ids() { return 0; }
int base_id() const {
DCHECK(!BailoutId(base_id_).IsNone());
return base_id_;
}
private: private:
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
Scope* scope_; Scope* scope_;
Expression* expression_; Expression* expression_;
Statement* statement_; Statement* statement_;
int base_id_;
}; };
......
...@@ -542,6 +542,7 @@ void AstGraphBuilder::VisitWithStatement(WithStatement* stmt) { ...@@ -542,6 +542,7 @@ void AstGraphBuilder::VisitWithStatement(WithStatement* stmt) {
Node* value = environment()->Pop(); Node* value = environment()->Pop();
const Operator* op = javascript()->CreateWithContext(); const Operator* op = javascript()->CreateWithContext();
Node* context = NewNode(op, value, GetFunctionClosure()); Node* context = NewNode(op, value, GetFunctionClosure());
PrepareFrameState(context, stmt->EntryId());
ContextScope scope(this, stmt->scope(), context); ContextScope scope(this, stmt->scope(), context);
Visit(stmt->statement()); Visit(stmt->statement());
} }
...@@ -1083,8 +1084,7 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { ...@@ -1083,8 +1084,7 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
const Operator* op = const Operator* op =
javascript()->CallRuntime(Runtime::kInternalSetPrototype, 2); javascript()->CallRuntime(Runtime::kInternalSetPrototype, 2);
Node* set_prototype = NewNode(op, receiver, value); Node* set_prototype = NewNode(op, receiver, value);
// SetPrototype should not lazy deopt on an object // SetPrototype should not lazy deopt on an object literal.
// literal.
PrepareFrameState(set_prototype, BailoutId::None()); PrepareFrameState(set_prototype, BailoutId::None());
} }
break; break;
......
...@@ -190,6 +190,7 @@ bool Linkage::NeedsFrameState(Runtime::FunctionId function) { ...@@ -190,6 +190,7 @@ bool Linkage::NeedsFrameState(Runtime::FunctionId function) {
case Runtime::kPreventExtensions: case Runtime::kPreventExtensions:
case Runtime::kPromiseRejectEvent: case Runtime::kPromiseRejectEvent:
case Runtime::kPromiseRevokeReject: case Runtime::kPromiseRevokeReject:
case Runtime::kPushWithContext:
case Runtime::kRegExpInitializeAndCompile: case Runtime::kRegExpInitializeAndCompile:
case Runtime::kRegExpExecMultiple: case Runtime::kRegExpExecMultiple:
case Runtime::kResolvePossiblyDirectEval: case Runtime::kResolvePossiblyDirectEval:
......
...@@ -57,22 +57,25 @@ bool OperatorProperties::HasFrameStateInput(const Operator* op) { ...@@ -57,22 +57,25 @@ bool OperatorProperties::HasFrameStateInput(const Operator* op) {
case IrOpcode::kJSBitwiseOr: case IrOpcode::kJSBitwiseOr:
case IrOpcode::kJSBitwiseXor: case IrOpcode::kJSBitwiseXor:
case IrOpcode::kJSDivide: case IrOpcode::kJSDivide:
case IrOpcode::kJSLoadNamed:
case IrOpcode::kJSLoadProperty:
case IrOpcode::kJSModulus: case IrOpcode::kJSModulus:
case IrOpcode::kJSMultiply: case IrOpcode::kJSMultiply:
case IrOpcode::kJSShiftLeft: case IrOpcode::kJSShiftLeft:
case IrOpcode::kJSShiftRight: case IrOpcode::kJSShiftRight:
case IrOpcode::kJSShiftRightLogical: case IrOpcode::kJSShiftRightLogical:
case IrOpcode::kJSStoreNamed:
case IrOpcode::kJSStoreProperty:
case IrOpcode::kJSSubtract: case IrOpcode::kJSSubtract:
// Context operations
case IrOpcode::kJSCreateWithContext:
// Conversions // Conversions
case IrOpcode::kJSToObject: case IrOpcode::kJSToObject:
case IrOpcode::kJSToNumber: case IrOpcode::kJSToNumber:
// Other // Properties
case IrOpcode::kJSLoadNamed:
case IrOpcode::kJSLoadProperty:
case IrOpcode::kJSStoreNamed:
case IrOpcode::kJSStoreProperty:
case IrOpcode::kJSDeleteProperty: case IrOpcode::kJSDeleteProperty:
return true; return true;
......
...@@ -1236,6 +1236,7 @@ void FullCodeGenerator::VisitWithStatement(WithStatement* stmt) { ...@@ -1236,6 +1236,7 @@ void FullCodeGenerator::VisitWithStatement(WithStatement* stmt) {
PushFunctionArgumentForContextAllocation(); PushFunctionArgumentForContextAllocation();
__ CallRuntime(Runtime::kPushWithContext, 2); __ CallRuntime(Runtime::kPushWithContext, 2);
StoreToFrameField(StandardFrameConstants::kContextOffset, context_register()); StoreToFrameField(StandardFrameConstants::kContextOffset, context_register());
PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS);
Scope* saved_scope = scope(); Scope* saved_scope = scope();
scope_ = stmt->scope(); scope_ = stmt->scope();
......
// 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.
assertThrows(function() { with (undefined) {} }, TypeError);
...@@ -77,7 +77,7 @@ const SharedOperator kSharedOperators[] = { ...@@ -77,7 +77,7 @@ const SharedOperator kSharedOperators[] = {
SHARED(InstanceOf, Operator::kNoProperties, 2, 1, 1, 1, 1, 1), SHARED(InstanceOf, Operator::kNoProperties, 2, 1, 1, 1, 1, 1),
SHARED(Debugger, Operator::kNoProperties, 0, 0, 1, 1, 0, 1), SHARED(Debugger, Operator::kNoProperties, 0, 0, 1, 1, 0, 1),
SHARED(CreateFunctionContext, Operator::kNoProperties, 1, 0, 1, 1, 1, 1), SHARED(CreateFunctionContext, Operator::kNoProperties, 1, 0, 1, 1, 1, 1),
SHARED(CreateWithContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1), SHARED(CreateWithContext, Operator::kNoProperties, 2, 1, 1, 1, 1, 1),
SHARED(CreateBlockContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1), SHARED(CreateBlockContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1),
SHARED(CreateModuleContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1), SHARED(CreateModuleContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1),
SHARED(CreateScriptContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1) SHARED(CreateScriptContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1)
......
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