Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Unified Diff: src/interpreter/bytecode-generator.cc

Issue 2035813002: [Interpreter] Move jump processing to bytecode array writer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_fix_bytecode
Patch Set: Address comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | src/interpreter/bytecode-label.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-generator.cc
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc
index 656bd8b78652f4f721617004bbcd9673afb9e176..f4ee9f49f5d98c6f36f8f0fa4ef3bd284acc962c 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -17,7 +17,6 @@ namespace v8 {
namespace internal {
namespace interpreter {
-
// Scoped class tracking context objects created by the visitor. Represents
// mutations of the context chain within the function body, allowing pushing and
// popping of the current {context_register} during visitation.
@@ -88,7 +87,6 @@ class BytecodeGenerator::ContextScope BASE_EMBEDDED {
bool should_pop_context_;
};
-
// Scoped class for tracking control statements entered by the
// visitor. The pattern derives AstGraphBuilder::ControlScope.
class BytecodeGenerator::ControlScope BASE_EMBEDDED {
@@ -124,7 +122,6 @@ class BytecodeGenerator::ControlScope BASE_EMBEDDED {
DISALLOW_COPY_AND_ASSIGN(ControlScope);
};
-
// Helper class for a try-finally control scope. It can record intercepted
// control-flow commands that cause entry into a finally-block, and re-apply
// them after again leaving that block. Special tokens are used to identify
@@ -203,7 +200,6 @@ class BytecodeGenerator::ControlScope::DeferredCommands final {
Register result_register_;
};
-
// Scoped class for dealing with control flow reaching the function level.
class BytecodeGenerator::ControlScopeForTopLevel final
: public BytecodeGenerator::ControlScope {
@@ -229,7 +225,6 @@ class BytecodeGenerator::ControlScopeForTopLevel final
}
};
-
// Scoped class for enabling break inside blocks and switch blocks.
class BytecodeGenerator::ControlScopeForBreakable final
: public BytecodeGenerator::ControlScope {
@@ -261,7 +256,6 @@ class BytecodeGenerator::ControlScopeForBreakable final
BreakableControlFlowBuilder* control_builder_;
};
-
// Scoped class for enabling 'break' and 'continue' in iteration
// constructs, e.g. do...while, while..., for...
class BytecodeGenerator::ControlScopeForIteration final
@@ -296,7 +290,6 @@ class BytecodeGenerator::ControlScopeForIteration final
LoopBuilder* loop_builder_;
};
-
// Scoped class for enabling 'throw' in try-catch constructs.
class BytecodeGenerator::ControlScopeForTryCatch final
: public BytecodeGenerator::ControlScope {
@@ -325,7 +318,6 @@ class BytecodeGenerator::ControlScopeForTryCatch final
}
};
-
// Scoped class for enabling control flow through try-finally constructs.
class BytecodeGenerator::ControlScopeForTryFinally final
: public BytecodeGenerator::ControlScope {
@@ -361,7 +353,6 @@ class BytecodeGenerator::ControlScopeForTryFinally final
DeferredCommands* commands_;
};
-
void BytecodeGenerator::ControlScope::PerformCommand(Command command,
Statement* statement) {
ControlScope* current = this;
@@ -384,7 +375,6 @@ void BytecodeGenerator::ControlScope::PerformCommand(Command command,
UNREACHABLE();
}
-
class BytecodeGenerator::RegisterAllocationScope {
public:
explicit RegisterAllocationScope(BytecodeGenerator* generator)
@@ -442,7 +432,6 @@ class BytecodeGenerator::RegisterAllocationScope {
DISALLOW_COPY_AND_ASSIGN(RegisterAllocationScope);
};
-
// Scoped base class for determining where the result of an expression
// is stored.
class BytecodeGenerator::ExpressionResultScope {
@@ -490,7 +479,6 @@ class BytecodeGenerator::ExpressionResultScope {
DISALLOW_COPY_AND_ASSIGN(ExpressionResultScope);
};
-
// Scoped class used when the result of the current expression is not
// expected to produce a result.
class BytecodeGenerator::EffectResultScope final
@@ -505,7 +493,6 @@ class BytecodeGenerator::EffectResultScope final
virtual void SetResultInRegister(Register reg) {}
};
-
// Scoped class used when the result of the current expression to be
// evaluated should go into the interpreter's accumulator register.
class BytecodeGenerator::AccumulatorResultScope final
@@ -522,7 +509,6 @@ class BytecodeGenerator::AccumulatorResultScope final
}
};
-
// Scoped class used when the result of the current expression to be
// evaluated should go into an interpreter register.
class BytecodeGenerator::RegisterResultScope final
@@ -614,7 +600,6 @@ Handle<BytecodeArray> BytecodeGenerator::MakeBytecode() {
return builder()->ToBytecodeArray();
}
-
void BytecodeGenerator::MakeBytecodeBody() {
// Build the arguments object if it is used.
VisitArgumentsObject(scope()->arguments());
@@ -729,7 +714,6 @@ void BytecodeGenerator::VisitBlock(Block* stmt) {
}
}
-
void BytecodeGenerator::VisitBlockDeclarationsAndStatements(Block* stmt) {
BlockBuilder block_builder(builder());
ControlScopeForBreakable execution_control(this, stmt, &block_builder);
@@ -740,7 +724,6 @@ void BytecodeGenerator::VisitBlockDeclarationsAndStatements(Block* stmt) {
if (stmt->labels() != nullptr) block_builder.EndBlock();
}
-
void BytecodeGenerator::VisitVariableDeclaration(VariableDeclaration* decl) {
Variable* variable = decl->proxy()->var();
VariableMode mode = decl->mode();
@@ -802,7 +785,6 @@ void BytecodeGenerator::VisitVariableDeclaration(VariableDeclaration* decl) {
}
}
-
void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) {
Variable* variable = decl->proxy()->var();
switch (variable->location()) {
@@ -849,17 +831,14 @@ void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) {
}
}
-
void BytecodeGenerator::VisitImportDeclaration(ImportDeclaration* decl) {
UNIMPLEMENTED();
}
-
void BytecodeGenerator::VisitExportDeclaration(ExportDeclaration* decl) {
UNIMPLEMENTED();
}
-
void BytecodeGenerator::VisitDeclarations(
ZoneList<Declaration*>* declarations) {
RegisterAllocationScope register_scope(this);
@@ -888,7 +867,6 @@ void BytecodeGenerator::VisitDeclarations(
globals()->clear();
}
-
void BytecodeGenerator::VisitStatements(ZoneList<Statement*>* statements) {
for (int i = 0; i < statements->length(); i++) {
// Allocate an outer register allocations scope for the statement.
@@ -899,17 +877,14 @@ void BytecodeGenerator::VisitStatements(ZoneList<Statement*>* statements) {
}
}
-
void BytecodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) {
builder()->SetStatementPosition(stmt);
VisitForEffect(stmt->expression());
}
-
void BytecodeGenerator::VisitEmptyStatement(EmptyStatement* stmt) {
}
-
void BytecodeGenerator::VisitIfStatement(IfStatement* stmt) {
builder()->SetStatementPosition(stmt);
BytecodeLabel else_label, end_label;
@@ -939,32 +914,27 @@ void BytecodeGenerator::VisitIfStatement(IfStatement* stmt) {
}
}
-
void BytecodeGenerator::VisitSloppyBlockFunctionStatement(
SloppyBlockFunctionStatement* stmt) {
Visit(stmt->statement());
}
-
void BytecodeGenerator::VisitContinueStatement(ContinueStatement* stmt) {
builder()->SetStatementPosition(stmt);
execution_control()->Continue(stmt->target());
}
-
void BytecodeGenerator::VisitBreakStatement(BreakStatement* stmt) {
builder()->SetStatementPosition(stmt);
execution_control()->Break(stmt->target());
}
-
void BytecodeGenerator::VisitReturnStatement(ReturnStatement* stmt) {
builder()->SetStatementPosition(stmt);
VisitForAccumulatorValue(stmt->expression());
execution_control()->ReturnAccumulator();
}
-
void BytecodeGenerator::VisitWithStatement(WithStatement* stmt) {
builder()->SetStatementPosition(stmt);
VisitForAccumulatorValue(stmt->expression());
@@ -973,7 +943,6 @@ void BytecodeGenerator::VisitWithStatement(WithStatement* stmt) {
VisitInScope(stmt->statement(), stmt->scope());
}
-
void BytecodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) {
// We need this scope because we visit for register values. We have to
// maintain a execution result scope where registers can be allocated.
@@ -1024,7 +993,6 @@ void BytecodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) {
switch_builder.SetBreakTarget(done_label);
}
-
void BytecodeGenerator::VisitCaseClause(CaseClause* clause) {
// Handled entirely in VisitSwitchStatement.
UNREACHABLE();
@@ -1073,7 +1041,6 @@ void BytecodeGenerator::VisitWhileStatement(WhileStatement* stmt) {
loop_builder.EndLoop();
}
-
void BytecodeGenerator::VisitForStatement(ForStatement* stmt) {
if (stmt->init() != nullptr) {
Visit(stmt->init());
@@ -1100,7 +1067,6 @@ void BytecodeGenerator::VisitForStatement(ForStatement* stmt) {
loop_builder.EndLoop();
}
-
void BytecodeGenerator::VisitForInAssignment(Expression* expr,
FeedbackVectorSlot slot) {
DCHECK(expr->IsValidReferenceExpression());
@@ -1174,7 +1140,6 @@ void BytecodeGenerator::VisitForInAssignment(Expression* expr,
}
}
-
void BytecodeGenerator::VisitForInStatement(ForInStatement* stmt) {
if (stmt->subject()->IsNullLiteral() ||
stmt->subject()->IsUndefinedLiteral()) {
@@ -1226,7 +1191,6 @@ void BytecodeGenerator::VisitForInStatement(ForInStatement* stmt) {
builder()->Bind(&subject_undefined_label);
}
-
void BytecodeGenerator::VisitForOfStatement(ForOfStatement* stmt) {
LoopBuilder loop_builder(builder());
ControlScopeForIteration control_scope(this, stmt, &loop_builder);
@@ -1246,7 +1210,6 @@ void BytecodeGenerator::VisitForOfStatement(ForOfStatement* stmt) {
loop_builder.EndLoop();
}
-
void BytecodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) {
TryCatchBuilder try_control_builder(builder());
Register no_reg;
@@ -1283,7 +1246,6 @@ void BytecodeGenerator::VisitTryCatchStatement(TryCatchStatement* stmt) {
try_control_builder.EndCatch();
}
-
void BytecodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
TryFinallyBuilder try_control_builder(builder(), IsInsideTryCatch());
Register no_reg;
@@ -1348,13 +1310,11 @@ void BytecodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
commands.ApplyDeferredCommands();
}
-
void BytecodeGenerator::VisitDebuggerStatement(DebuggerStatement* stmt) {
builder()->SetStatementPosition(stmt);
builder()->Debugger();
}
-
void BytecodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) {
// Find or build a shared function info.
Handle<SharedFunctionInfo> shared_info =
@@ -1367,7 +1327,6 @@ void BytecodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) {
execution_result()->SetResultInAccumulator();
}
-
void BytecodeGenerator::VisitClassLiteral(ClassLiteral* expr) {
if (expr->scope()->ContextLocalCount() > 0) {
VisitNewLocalBlockContext(expr->scope());
@@ -1525,13 +1484,11 @@ void BytecodeGenerator::VisitNativeFunctionLiteral(
execution_result()->SetResultInAccumulator();
}
-
void BytecodeGenerator::VisitDoExpression(DoExpression* expr) {
VisitBlock(expr->block());
VisitVariableProxy(expr->result());
}
-
void BytecodeGenerator::VisitConditional(Conditional* expr) {
// TODO(rmcilroy): Spot easy cases where there code would not need to
// emit the then block or the else block, e.g. condition is
@@ -1552,7 +1509,6 @@ void BytecodeGenerator::VisitConditional(Conditional* expr) {
execution_result()->SetResultInAccumulator();
}
-
void BytecodeGenerator::VisitLiteral(Literal* expr) {
if (!execution_result()->IsEffect()) {
Handle<Object> value = expr->value();
@@ -1575,7 +1531,6 @@ void BytecodeGenerator::VisitLiteral(Literal* expr) {
}
}
-
void BytecodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
// Materialize a regular expression literal.
builder()->CreateRegExpLiteral(expr->pattern(), expr->literal_index(),
@@ -1583,7 +1538,6 @@ void BytecodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
execution_result()->SetResultInAccumulator();
}
-
void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
// Copy the literal boilerplate.
int fast_clone_properties_count = 0;
@@ -1787,7 +1741,6 @@ void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
execution_result()->SetResultInRegister(literal);
}
-
void BytecodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
// Deep-copy the literal boilerplate.
builder()->CreateArrayLiteral(expr->constant_elements(),
@@ -1827,7 +1780,6 @@ void BytecodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
execution_result()->SetResultInAccumulator();
}
-
void BytecodeGenerator::VisitVariableProxy(VariableProxy* proxy) {
builder()->SetExpressionPosition(proxy);
VisitVariableLoad(proxy->var(), proxy->VariableFeedbackSlot());
@@ -2129,7 +2081,6 @@ void BytecodeGenerator::VisitVariableAssignment(Variable* variable,
}
}
-
void BytecodeGenerator::VisitAssignment(Assignment* expr) {
DCHECK(expr->target()->IsValidReferenceExpressionOrThis());
Register object, key, home_object, value;
@@ -2357,7 +2308,6 @@ void BytecodeGenerator::VisitThrow(Throw* expr) {
execution_result()->SetResultInAccumulator();
}
-
void BytecodeGenerator::VisitPropertyLoad(Register obj, Property* expr) {
LhsKind property_kind = Property::GetAssignType(expr);
FeedbackVectorSlot slot = expr->PropertyFeedbackSlot();
@@ -2651,7 +2601,6 @@ void BytecodeGenerator::VisitCallNew(CallNew* expr) {
execution_result()->SetResultInAccumulator();
}
-
void BytecodeGenerator::VisitCallRuntime(CallRuntime* expr) {
ZoneList<Expression*>* args = expr->arguments();
if (expr->is_jsruntime()) {
@@ -2672,14 +2621,12 @@ void BytecodeGenerator::VisitCallRuntime(CallRuntime* expr) {
execution_result()->SetResultInAccumulator();
}
-
void BytecodeGenerator::VisitVoid(UnaryOperation* expr) {
VisitForEffect(expr->expression());
builder()->LoadUndefined();
execution_result()->SetResultInAccumulator();
}
-
void BytecodeGenerator::VisitTypeOf(UnaryOperation* expr) {
if (expr->expression()->IsVariableProxy()) {
// Typeof does not throw a reference error on global variables, hence we
@@ -2694,14 +2641,12 @@ void BytecodeGenerator::VisitTypeOf(UnaryOperation* expr) {
execution_result()->SetResultInAccumulator();
}
-
void BytecodeGenerator::VisitNot(UnaryOperation* expr) {
VisitForAccumulatorValue(expr->expression());
builder()->LogicalNot();
execution_result()->SetResultInAccumulator();
}
-
void BytecodeGenerator::VisitUnaryOperation(UnaryOperation* expr) {
switch (expr->op()) {
case Token::Value::NOT:
@@ -2727,7 +2672,6 @@ void BytecodeGenerator::VisitUnaryOperation(UnaryOperation* expr) {
}
}
-
void BytecodeGenerator::VisitDelete(UnaryOperation* expr) {
if (expr->expression()->IsProperty()) {
// Delete of an object property is allowed both in sloppy
@@ -2789,7 +2733,6 @@ void BytecodeGenerator::VisitDelete(UnaryOperation* expr) {
execution_result()->SetResultInAccumulator();
}
-
void BytecodeGenerator::VisitCountOperation(CountOperation* expr) {
DCHECK(expr->expression()->IsValidReferenceExpressionOrThis());
@@ -2911,7 +2854,6 @@ void BytecodeGenerator::VisitCountOperation(CountOperation* expr) {
}
}
-
void BytecodeGenerator::VisitBinaryOperation(BinaryOperation* binop) {
switch (binop->op()) {
case Token::COMMA:
@@ -2929,7 +2871,6 @@ void BytecodeGenerator::VisitBinaryOperation(BinaryOperation* binop) {
}
}
-
void BytecodeGenerator::VisitCompareOperation(CompareOperation* expr) {
Register lhs = VisitForRegisterValue(expr->left());
VisitForAccumulatorValue(expr->right());
@@ -2938,7 +2879,6 @@ void BytecodeGenerator::VisitCompareOperation(CompareOperation* expr) {
execution_result()->SetResultInAccumulator();
}
-
void BytecodeGenerator::VisitArithmeticExpression(BinaryOperation* expr) {
Register lhs = VisitForRegisterValue(expr->left());
VisitForAccumulatorValue(expr->right());
@@ -2946,39 +2886,32 @@ void BytecodeGenerator::VisitArithmeticExpression(BinaryOperation* expr) {
execution_result()->SetResultInAccumulator();
}
-
void BytecodeGenerator::VisitSpread(Spread* expr) { UNREACHABLE(); }
-
void BytecodeGenerator::VisitEmptyParentheses(EmptyParentheses* expr) {
UNREACHABLE();
}
-
void BytecodeGenerator::VisitThisFunction(ThisFunction* expr) {
execution_result()->SetResultInRegister(Register::function_closure());
}
-
void BytecodeGenerator::VisitSuperCallReference(SuperCallReference* expr) {
// Handled by VisitCall().
UNREACHABLE();
}
-
void BytecodeGenerator::VisitSuperPropertyReference(
SuperPropertyReference* expr) {
builder()->CallRuntime(Runtime::kThrowUnsupportedSuperError, Register(0), 0);
execution_result()->SetResultInAccumulator();
}
-
void BytecodeGenerator::VisitCommaExpression(BinaryOperation* binop) {
VisitForEffect(binop->left());
Visit(binop->right());
}
-
void BytecodeGenerator::VisitLogicalOrExpression(BinaryOperation* binop) {
Expression* left = binop->left();
Expression* right = binop->right();
@@ -2997,7 +2930,6 @@ void BytecodeGenerator::VisitLogicalOrExpression(BinaryOperation* binop) {
execution_result()->SetResultInAccumulator();
}
-
void BytecodeGenerator::VisitLogicalAndExpression(BinaryOperation* binop) {
Expression* left = binop->left();
Expression* right = binop->right();
@@ -3016,12 +2948,10 @@ void BytecodeGenerator::VisitLogicalAndExpression(BinaryOperation* binop) {
execution_result()->SetResultInAccumulator();
}
-
void BytecodeGenerator::VisitRewritableExpression(RewritableExpression* expr) {
Visit(expr->expression());
}
-
void BytecodeGenerator::VisitNewLocalFunctionContext() {
AccumulatorResultScope accumulator_execution_result(this);
Scope* scope = this->scope();
@@ -3045,7 +2975,6 @@ void BytecodeGenerator::VisitNewLocalFunctionContext() {
execution_result()->SetResultInAccumulator();
}
-
void BytecodeGenerator::VisitBuildLocalActivationContext() {
Scope* scope = this->scope();
@@ -3074,7 +3003,6 @@ void BytecodeGenerator::VisitBuildLocalActivationContext() {
}
}
-
void BytecodeGenerator::VisitNewLocalBlockContext(Scope* scope) {
AccumulatorResultScope accumulator_execution_result(this);
DCHECK(scope->is_block_scope());
@@ -3128,7 +3056,6 @@ void BytecodeGenerator::VisitNewLocalCatchContext(Variable* variable) {
execution_result()->SetResultInAccumulator();
}
-
void BytecodeGenerator::VisitObjectLiteralAccessor(
Register home_object, ObjectLiteralProperty* property, Register value_out) {
// TODO(rmcilroy): Replace value_out with VisitForRegister();
@@ -3154,7 +3081,6 @@ void BytecodeGenerator::VisitSetHomeObject(Register value, Register home_object,
}
}
-
void BytecodeGenerator::VisitArgumentsObject(Variable* variable) {
if (variable == nullptr) return;
@@ -3189,7 +3115,6 @@ void BytecodeGenerator::VisitThisFunctionVariable(Variable* variable) {
VisitVariableAssignment(variable, Token::INIT, FeedbackVectorSlot::Invalid());
}
-
void BytecodeGenerator::VisitNewTargetVariable(Variable* variable) {
if (variable == nullptr) return;
@@ -3198,7 +3123,6 @@ void BytecodeGenerator::VisitNewTargetVariable(Variable* variable) {
VisitVariableAssignment(variable, Token::INIT, FeedbackVectorSlot::Invalid());
}
-
void BytecodeGenerator::VisitFunctionClosureForContext() {
AccumulatorResultScope accumulator_execution_result(this);
Scope* closure_scope = execution_context()->scope()->ClosureScope();
@@ -3225,7 +3149,6 @@ void BytecodeGenerator::VisitFunctionClosureForContext() {
execution_result()->SetResultInAccumulator();
}
-
// Visits the expression |expr| and places the result in the accumulator.
void BytecodeGenerator::VisitForAccumulatorValue(Expression* expr) {
AccumulatorResultScope accumulator_scope(this);
@@ -3246,7 +3169,6 @@ void BytecodeGenerator::VisitForEffect(Expression* expr) {
Visit(expr);
}
-
// Visits the expression |expr| and returns the register containing
// the expression result.
Register BytecodeGenerator::VisitForRegisterValue(Expression* expr) {
@@ -3270,12 +3192,10 @@ void BytecodeGenerator::VisitInScope(Statement* stmt, Scope* scope) {
Visit(stmt);
}
-
LanguageMode BytecodeGenerator::language_mode() const {
return execution_context()->scope()->language_mode();
}
-
int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
return TypeFeedbackVector::GetIndex(slot);
}
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | src/interpreter/bytecode-label.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698