Commit 957f3f10 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[fullcodegen] Remove with-statement support.

This removes support for dynamic scoping via with-statement constructs
from the {FullCodeGenerator}. Consequently optimized code containing
such constructs must use the {BytecodeGraphBuilder} and can no longer
use the {AstGraphBuilder} for graph building.

R=rmcilroy@chromium.org
BUG=v8:5657

Review-Url: https://codereview.chromium.org/2533283002
Cr-Commit-Position: refs/heads/master@{#41365}
parent c44008b0
......@@ -284,7 +284,6 @@ void AstNumberingVisitor::VisitCallRuntime(CallRuntime* node) {
void AstNumberingVisitor::VisitWithStatement(WithStatement* node) {
IncrementNodeCount();
DisableFullCodegenAndCrankshaft(kWithStatement);
node->set_base_id(ReserveIdRange(WithStatement::num_ids()));
Visit(node->expression());
Visit(node->statement());
}
......
......@@ -922,30 +922,16 @@ class WithStatement final : public Statement {
Statement* statement() const { return statement_; }
void set_statement(Statement* s) { statement_ = s; }
void set_base_id(int id) { base_id_ = id; }
static int num_ids() { return parent_num_ids() + 2; }
BailoutId ToObjectId() const { return BailoutId(local_id(0)); }
BailoutId EntryId() const { return BailoutId(local_id(1)); }
private:
friend class AstNodeFactory;
WithStatement(Scope* scope, Expression* expression, Statement* statement,
int pos)
: Statement(pos, kWithStatement),
base_id_(BailoutId::None().ToInt()),
scope_(scope),
expression_(expression),
statement_(statement) {}
static int parent_num_ids() { return 0; }
int base_id() const {
DCHECK(!BailoutId(base_id_).IsNone());
return base_id_;
}
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
int base_id_;
Scope* scope_;
Expression* expression_;
Statement* statement_;
......
......@@ -1061,14 +1061,8 @@ void AstGraphBuilder::VisitReturnStatement(ReturnStatement* stmt) {
void AstGraphBuilder::VisitWithStatement(WithStatement* stmt) {
VisitForValue(stmt->expression());
Node* value = environment()->Pop();
Node* object = BuildToObject(value, stmt->ToObjectId());
Handle<ScopeInfo> scope_info = stmt->scope()->scope_info();
const Operator* op = javascript()->CreateWithContext(scope_info);
Node* context = NewNode(op, object, GetFunctionClosureForContext());
PrepareFrameState(context, stmt->EntryId());
VisitInScope(stmt->statement(), stmt->scope(), context);
// Dynamic scoping is supported only by going through Ignition first.
UNREACHABLE();
}
......@@ -2475,12 +2469,6 @@ void AstGraphBuilder::VisitIfNotNull(Statement* stmt) {
}
void AstGraphBuilder::VisitInScope(Statement* stmt, Scope* s, Node* context) {
ContextScope scope(this, s, context);
DCHECK(s->declarations()->is_empty());
Visit(stmt);
}
void AstGraphBuilder::VisitIterationBody(IterationStatement* stmt,
LoopBuilder* loop,
BailoutId stack_check_id) {
......
......@@ -364,7 +364,6 @@ class AstGraphBuilder : public AstVisitor<AstGraphBuilder> {
// Visit statements.
void VisitIfNotNull(Statement* stmt);
void VisitInScope(Statement* stmt, Scope* scope, Node* context);
// Visit expressions.
void Visit(Expression* expr);
......
......@@ -1114,33 +1114,8 @@ void FullCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) {
void FullCodeGenerator::VisitWithStatement(WithStatement* stmt) {
Comment cmnt(masm_, "[ WithStatement");
SetStatementPosition(stmt);
VisitForAccumulatorValue(stmt->expression());
Callable callable = CodeFactory::ToObject(isolate());
__ Move(callable.descriptor().GetRegisterParameter(0), result_register());
__ Call(callable.code(), RelocInfo::CODE_TARGET);
RestoreContext();
PrepareForBailoutForId(stmt->ToObjectId(), BailoutState::TOS_REGISTER);
PushOperand(result_register());
PushOperand(stmt->scope()->scope_info());
PushFunctionArgumentForContextAllocation();
CallRuntimeWithOperands(Runtime::kPushWithContext);
StoreToFrameField(StandardFrameConstants::kContextOffset, context_register());
PrepareForBailoutForId(stmt->EntryId(), BailoutState::NO_REGISTERS);
Scope* saved_scope = scope();
scope_ = stmt->scope();
{ WithOrCatch body(this);
Visit(stmt->statement());
}
scope_ = saved_scope;
// Pop context.
LoadContextField(context_register(), Context::PREVIOUS_INDEX);
// Update local stack frame context field.
StoreToFrameField(StandardFrameConstants::kContextOffset, context_register());
// Dynamic scoping is not supported.
UNREACHABLE();
}
......
......@@ -182,19 +182,6 @@ class FullCodeGenerator final : public AstVisitor<FullCodeGenerator> {
}
};
// The body of a with or catch.
class WithOrCatch : public NestedStatement {
public:
explicit WithOrCatch(FullCodeGenerator* codegen)
: NestedStatement(codegen) {
}
NestedStatement* Exit(int* context_length) override {
++(*context_length);
return previous_;
}
};
// A platform-specific utility to overwrite the accumulator register
// with a GC-safe value.
void ClearAccumulator();
......
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