Commit 398ee1ce authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[interpreter] Reduce overhead in bytecode generator

- Directly use VisitFunctionLiteral where possible
- Take shortcut for StringLiterals in BuildLoadPropertyKey

Change-Id: Ib5c3de3d2bdd354acbfeb607415854ba90622e89
Reviewed-on: https://chromium-review.googlesource.com/c/1382750Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58595}
parent 1099a5ff
...@@ -1259,13 +1259,13 @@ void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) { ...@@ -1259,13 +1259,13 @@ void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) {
} }
case VariableLocation::PARAMETER: case VariableLocation::PARAMETER:
case VariableLocation::LOCAL: { case VariableLocation::LOCAL: {
VisitForAccumulatorValue(decl->fun()); VisitFunctionLiteral(decl->fun());
BuildVariableAssignment(variable, Token::INIT, HoleCheckMode::kElided); BuildVariableAssignment(variable, Token::INIT, HoleCheckMode::kElided);
break; break;
} }
case VariableLocation::CONTEXT: { case VariableLocation::CONTEXT: {
DCHECK_EQ(0, execution_context()->ContextChainDepth(variable->scope())); DCHECK_EQ(0, execution_context()->ContextChainDepth(variable->scope()));
VisitForAccumulatorValue(decl->fun()); VisitFunctionLiteral(decl->fun());
builder()->StoreContextSlot(execution_context()->reg(), variable->index(), builder()->StoreContextSlot(execution_context()->reg(), variable->index(),
0); 0);
break; break;
...@@ -1275,7 +1275,7 @@ void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) { ...@@ -1275,7 +1275,7 @@ void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) {
builder() builder()
->LoadLiteral(variable->raw_name()) ->LoadLiteral(variable->raw_name())
.StoreAccumulatorInRegister(args[0]); .StoreAccumulatorInRegister(args[0]);
VisitForAccumulatorValue(decl->fun()); VisitFunctionLiteral(decl->fun());
builder()->StoreAccumulatorInRegister(args[1]).CallRuntime( builder()->StoreAccumulatorInRegister(args[1]).CallRuntime(
Runtime::kDeclareEvalFunction, args); Runtime::kDeclareEvalFunction, args);
break; break;
...@@ -5531,7 +5531,9 @@ void BytecodeGenerator::BuildPushUndefinedIntoRegisterList( ...@@ -5531,7 +5531,9 @@ void BytecodeGenerator::BuildPushUndefinedIntoRegisterList(
void BytecodeGenerator::BuildLoadPropertyKey(LiteralProperty* property, void BytecodeGenerator::BuildLoadPropertyKey(LiteralProperty* property,
Register out_reg) { Register out_reg) {
if (property->key()->IsStringLiteral()) { if (property->key()->IsStringLiteral()) {
VisitForRegisterValue(property->key(), out_reg); builder()
->LoadLiteral(property->key()->AsLiteral()->AsRawString())
.StoreAccumulatorInRegister(out_reg);
} else { } else {
VisitForAccumulatorValue(property->key()); VisitForAccumulatorValue(property->key());
builder()->ToName(out_reg); builder()->ToName(out_reg);
......
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