Commit 38939ff3 authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: [full-codegen] Eliminate unnecessary hole checks for stores.

  port 231c8ac0 (r40522)

  original commit message:
  Loads already used source position elimination to avoid unnecessary hole checks,
  but for reasons unknown stores did not. This CL corrects that, making full-codegen's
  hole elimination equivalent to ignition's.

  Also introduced a HoleCheckMode enum class to avoid more bool flags and updated
  VariableProxy and BytecodeGenerator appropriately.

BUG=

Review-Url: https://codereview.chromium.org/2444823002
Cr-Commit-Position: refs/heads/master@{#40527}
parent f87d73c7
...@@ -1202,7 +1202,7 @@ void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, ...@@ -1202,7 +1202,7 @@ void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy,
Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable"
: "[ Stack variable"); : "[ Stack variable");
if (proxy->needs_hole_check()) { if (proxy->hole_check_mode() == HoleCheckMode::kRequired) {
// Throw a reference error when using an uninitialized let/const // Throw a reference error when using an uninitialized let/const
// binding in harmony mode. // binding in harmony mode.
Label done; Label done;
...@@ -1635,12 +1635,14 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { ...@@ -1635,12 +1635,14 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) {
// Store the value. // Store the value.
switch (assign_type) { switch (assign_type) {
case VARIABLE: case VARIABLE: {
EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), VariableProxy* proxy = expr->target()->AsVariableProxy();
expr->op(), expr->AssignmentSlot()); EmitVariableAssignment(proxy->var(), expr->op(), expr->AssignmentSlot(),
proxy->hole_check_mode());
PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
context()->Plug(eax); context()->Plug(eax);
break; break;
}
case NAMED_PROPERTY: case NAMED_PROPERTY:
EmitNamedPropertyAssignment(expr); EmitNamedPropertyAssignment(expr);
break; break;
...@@ -1919,9 +1921,10 @@ void FullCodeGenerator::EmitAssignment(Expression* expr, ...@@ -1919,9 +1921,10 @@ void FullCodeGenerator::EmitAssignment(Expression* expr,
switch (assign_type) { switch (assign_type) {
case VARIABLE: { case VARIABLE: {
Variable* var = expr->AsVariableProxy()->var(); VariableProxy* proxy = expr->AsVariableProxy();
EffectContext context(this); EffectContext context(this);
EmitVariableAssignment(var, Token::ASSIGN, slot); EmitVariableAssignment(proxy->var(), Token::ASSIGN, slot,
proxy->hole_check_mode());
break; break;
} }
case NAMED_PROPERTY: { case NAMED_PROPERTY: {
...@@ -1994,9 +1997,9 @@ void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( ...@@ -1994,9 +1997,9 @@ void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot(
} }
} }
void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op,
FeedbackVectorSlot slot) { FeedbackVectorSlot slot,
HoleCheckMode hole_check_mode) {
if (var->IsUnallocated()) { if (var->IsUnallocated()) {
// Global var, const, or let. // Global var, const, or let.
__ mov(StoreDescriptor::ReceiverRegister(), NativeContextOperand()); __ mov(StoreDescriptor::ReceiverRegister(), NativeContextOperand());
...@@ -2010,7 +2013,7 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, ...@@ -2010,7 +2013,7 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op,
DCHECK(var->IsStackAllocated() || var->IsContextSlot()); DCHECK(var->IsStackAllocated() || var->IsContextSlot());
MemOperand location = VarOperand(var, ecx); MemOperand location = VarOperand(var, ecx);
// Perform an initialization check for lexically declared variables. // Perform an initialization check for lexically declared variables.
if (var->binding_needs_init()) { if (hole_check_mode == HoleCheckMode::kRequired) {
Label assign; Label assign;
__ mov(edx, location); __ mov(edx, location);
__ cmp(edx, isolate()->factory()->the_hole_value()); __ cmp(edx, isolate()->factory()->the_hole_value());
...@@ -3076,12 +3079,13 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { ...@@ -3076,12 +3079,13 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
// Store the value returned in eax. // Store the value returned in eax.
switch (assign_type) { switch (assign_type) {
case VARIABLE: case VARIABLE: {
VariableProxy* proxy = expr->expression()->AsVariableProxy();
if (expr->is_postfix()) { if (expr->is_postfix()) {
// Perform the assignment as if via '='. // Perform the assignment as if via '='.
{ EffectContext context(this); { EffectContext context(this);
EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), EmitVariableAssignment(proxy->var(), Token::ASSIGN, expr->CountSlot(),
Token::ASSIGN, expr->CountSlot()); proxy->hole_check_mode());
PrepareForBailoutForId(expr->AssignmentId(), PrepareForBailoutForId(expr->AssignmentId(),
BailoutState::TOS_REGISTER); BailoutState::TOS_REGISTER);
context.Plug(eax); context.Plug(eax);
...@@ -3093,13 +3097,14 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { ...@@ -3093,13 +3097,14 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
} }
} else { } else {
// Perform the assignment as if via '='. // Perform the assignment as if via '='.
EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), EmitVariableAssignment(proxy->var(), Token::ASSIGN, expr->CountSlot(),
Token::ASSIGN, expr->CountSlot()); proxy->hole_check_mode());
PrepareForBailoutForId(expr->AssignmentId(), PrepareForBailoutForId(expr->AssignmentId(),
BailoutState::TOS_REGISTER); BailoutState::TOS_REGISTER);
context()->Plug(eax); context()->Plug(eax);
} }
break; break;
}
case NAMED_PROPERTY: { case NAMED_PROPERTY: {
PopOperand(StoreDescriptor::ReceiverRegister()); PopOperand(StoreDescriptor::ReceiverRegister());
CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value()); CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value());
......
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