Commit e39a7c71 authored by ziyang's avatar ziyang Committed by Commit bot

PPC/s390: [full-codegen] Eliminate unnecessary hole checks for stores

Port 231c8ac0

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.

R=adamk@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, bjaideep@ca.ibm.com, michael_dawson@ca.ibm.com, mbrandy@us.ibm.com
BUG=

Review-Url: https://codereview.chromium.org/2449473002
Cr-Commit-Position: refs/heads/master@{#40538}
parent 3107fd07
...@@ -1257,7 +1257,7 @@ void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, ...@@ -1257,7 +1257,7 @@ void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy,
DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode);
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;
...@@ -1696,12 +1696,14 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { ...@@ -1696,12 +1696,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(r3); context()->Plug(r3);
break; break;
}
case NAMED_PROPERTY: case NAMED_PROPERTY:
EmitNamedPropertyAssignment(expr); EmitNamedPropertyAssignment(expr);
break; break;
...@@ -2029,9 +2031,10 @@ void FullCodeGenerator::EmitAssignment(Expression* expr, ...@@ -2029,9 +2031,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: {
...@@ -2106,9 +2109,9 @@ void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( ...@@ -2106,9 +2109,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.
__ LoadGlobalObject(StoreDescriptor::ReceiverRegister()); __ LoadGlobalObject(StoreDescriptor::ReceiverRegister());
...@@ -2119,7 +2122,7 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, ...@@ -2119,7 +2122,7 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op,
DCHECK(var->IsStackAllocated() || var->IsContextSlot()); DCHECK(var->IsStackAllocated() || var->IsContextSlot());
MemOperand location = VarOperand(var, r4); MemOperand location = VarOperand(var, r4);
// 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;
__ LoadP(r6, location); __ LoadP(r6, location);
__ CompareRoot(r6, Heap::kTheHoleValueRootIndex); __ CompareRoot(r6, Heap::kTheHoleValueRootIndex);
...@@ -3187,12 +3190,13 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { ...@@ -3187,12 +3190,13 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
// Store the value returned in r3. // Store the value returned in r3.
switch (assign_type) { switch (assign_type) {
case VARIABLE: case VARIABLE: {
VariableProxy* proxy = expr->expression()->AsVariableProxy();
if (expr->is_postfix()) { if (expr->is_postfix()) {
{ {
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(r3); context.Plug(r3);
...@@ -3203,13 +3207,14 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { ...@@ -3203,13 +3207,14 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
context()->PlugTOS(); context()->PlugTOS();
} }
} else { } else {
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(r3); context()->Plug(r3);
} }
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());
......
...@@ -1221,7 +1221,7 @@ void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, ...@@ -1221,7 +1221,7 @@ void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy,
DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode);
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;
...@@ -1656,12 +1656,14 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { ...@@ -1656,12 +1656,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(r2); context()->Plug(r2);
break; break;
}
case NAMED_PROPERTY: case NAMED_PROPERTY:
EmitNamedPropertyAssignment(expr); EmitNamedPropertyAssignment(expr);
break; break;
...@@ -1986,9 +1988,10 @@ void FullCodeGenerator::EmitAssignment(Expression* expr, ...@@ -1986,9 +1988,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: {
...@@ -2063,7 +2066,8 @@ void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( ...@@ -2063,7 +2066,8 @@ 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.
__ LoadGlobalObject(StoreDescriptor::ReceiverRegister()); __ LoadGlobalObject(StoreDescriptor::ReceiverRegister());
...@@ -2075,7 +2079,7 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, ...@@ -2075,7 +2079,7 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op,
DCHECK(var->IsStackAllocated() || var->IsContextSlot()); DCHECK(var->IsStackAllocated() || var->IsContextSlot());
MemOperand location = VarOperand(var, r3); MemOperand location = VarOperand(var, r3);
// 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;
__ LoadP(r5, location); __ LoadP(r5, location);
__ CompareRoot(r5, Heap::kTheHoleValueRootIndex); __ CompareRoot(r5, Heap::kTheHoleValueRootIndex);
...@@ -3113,12 +3117,13 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { ...@@ -3113,12 +3117,13 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
// Store the value returned in r2. // Store the value returned in r2.
switch (assign_type) { switch (assign_type) {
case VARIABLE: case VARIABLE: {
VariableProxy* proxy = expr->expression()->AsVariableProxy();
if (expr->is_postfix()) { if (expr->is_postfix()) {
{ {
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(r2); context.Plug(r2);
...@@ -3129,13 +3134,14 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { ...@@ -3129,13 +3134,14 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
context()->PlugTOS(); context()->PlugTOS();
} }
} else { } else {
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(r2); context()->Plug(r2);
} }
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