Commit 93ad996e authored by neis's avatar neis Committed by Commit bot

[interpreter] Simplify hole check condition for variable assignments.

There's no need to check IsLexicalVariableMode since it's subsumed
by binding_needs_init.

Drive-by change: in VisitVariableLoad, move SetResultInAccumulator
out of switch cases.

BUG=

Review-Url: https://codereview.chromium.org/2232313002
Cr-Commit-Position: refs/heads/master@{#38590}
parent 63f311ad
...@@ -1868,7 +1868,6 @@ void BytecodeGenerator::VisitVariableLoad(Variable* variable, ...@@ -1868,7 +1868,6 @@ void BytecodeGenerator::VisitVariableLoad(Variable* variable,
Register source(Register(variable->index())); Register source(Register(variable->index()));
builder()->LoadAccumulatorWithRegister(source); builder()->LoadAccumulatorWithRegister(source);
BuildHoleCheckForVariableLoad(variable); BuildHoleCheckForVariableLoad(variable);
execution_result()->SetResultInAccumulator();
break; break;
} }
case VariableLocation::PARAMETER: { case VariableLocation::PARAMETER: {
...@@ -1877,13 +1876,11 @@ void BytecodeGenerator::VisitVariableLoad(Variable* variable, ...@@ -1877,13 +1876,11 @@ void BytecodeGenerator::VisitVariableLoad(Variable* variable,
Register source = builder()->Parameter(variable->index() + 1); Register source = builder()->Parameter(variable->index() + 1);
builder()->LoadAccumulatorWithRegister(source); builder()->LoadAccumulatorWithRegister(source);
BuildHoleCheckForVariableLoad(variable); BuildHoleCheckForVariableLoad(variable);
execution_result()->SetResultInAccumulator();
break; break;
} }
case VariableLocation::GLOBAL: case VariableLocation::GLOBAL:
case VariableLocation::UNALLOCATED: { case VariableLocation::UNALLOCATED: {
builder()->LoadGlobal(feedback_index(slot), typeof_mode); builder()->LoadGlobal(feedback_index(slot), typeof_mode);
execution_result()->SetResultInAccumulator();
break; break;
} }
case VariableLocation::CONTEXT: { case VariableLocation::CONTEXT: {
...@@ -1911,17 +1908,16 @@ void BytecodeGenerator::VisitVariableLoad(Variable* variable, ...@@ -1911,17 +1908,16 @@ void BytecodeGenerator::VisitVariableLoad(Variable* variable,
builder()->LoadContextSlot(context_reg, variable->index()); builder()->LoadContextSlot(context_reg, variable->index());
BuildHoleCheckForVariableLoad(variable); BuildHoleCheckForVariableLoad(variable);
execution_result()->SetResultInAccumulator();
break; break;
} }
case VariableLocation::LOOKUP: { case VariableLocation::LOOKUP: {
builder()->LoadLookupSlot(variable->name(), typeof_mode); builder()->LoadLookupSlot(variable->name(), typeof_mode);
execution_result()->SetResultInAccumulator();
break; break;
} }
case VariableLocation::MODULE: case VariableLocation::MODULE:
UNREACHABLE(); UNREACHABLE();
} }
execution_result()->SetResultInAccumulator();
} }
void BytecodeGenerator::VisitVariableLoadForAccumulatorValue( void BytecodeGenerator::VisitVariableLoadForAccumulatorValue(
...@@ -2035,8 +2031,7 @@ void BytecodeGenerator::VisitVariableAssignment(Variable* variable, ...@@ -2035,8 +2031,7 @@ void BytecodeGenerator::VisitVariableAssignment(Variable* variable,
BytecodeLabel end_label; BytecodeLabel end_label;
bool hole_check_required = bool hole_check_required =
variable->binding_needs_init() && variable->binding_needs_init() &&
((IsLexicalVariableMode(mode) && op != Token::INIT) || (op != Token::INIT || (mode == CONST && variable->is_this()));
(mode == CONST && op == Token::INIT && variable->is_this()));
switch (variable->location()) { switch (variable->location()) {
case VariableLocation::PARAMETER: case VariableLocation::PARAMETER:
case VariableLocation::LOCAL: { case VariableLocation::LOCAL: {
......
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