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