From: balazs.kilvady@imgtec.com Date: Thu, 9 Oct 2014 15:33:10 +0000 (+0000) Subject: MIPS: Keyed stores to super where key is a name. X-Git-Tag: upstream/4.7.83~6456 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=69cc49ce4668790b85f826ba0cd023b061201041;p=platform%2Fupstream%2Fv8.git MIPS: Keyed stores to super where key is a name. Port r24490 (839f44c) BUG=v:3330 LOG=N R=paul.lind@imgtec.com Review URL: https://codereview.chromium.org/641093002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24501 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc index 91572da..eb84015 100644 --- a/src/mips/full-codegen-mips.cc +++ b/src/mips/full-codegen-mips.cc @@ -1878,22 +1878,8 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { Comment cmnt(masm_, "[ Assignment"); - // Left-hand side can only be a property, a global or a (parameter or local) - // slot. - enum LhsKind { - VARIABLE, - NAMED_PROPERTY, - KEYED_PROPERTY, - NAMED_SUPER_PROPERTY - }; - LhsKind assign_type = VARIABLE; Property* property = expr->target()->AsProperty(); - if (property != NULL) { - assign_type = (property->key()->IsPropertyName()) - ? (property->IsSuperAccess() ? NAMED_SUPER_PROPERTY - : NAMED_PROPERTY) - : KEYED_PROPERTY; - } + LhsKind assign_type = GetAssignType(property); // Evaluate LHS expression. switch (assign_type) { @@ -1919,6 +1905,20 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { __ Push(scratch, result_register()); } break; + case KEYED_SUPER_PROPERTY: { + const Register scratch = a1; + VisitForStackValue(property->obj()->AsSuperReference()->this_var()); + EmitLoadHomeObject(property->obj()->AsSuperReference()); + __ Move(scratch, result_register()); + VisitForAccumulatorValue(property->key()); + __ Push(scratch, result_register()); + if (expr->is_compound()) { + const Register scratch1 = t0; + __ lw(scratch1, MemOperand(sp, 2 * kPointerSize)); + __ Push(scratch1, scratch, result_register()); + } + break; + } case KEYED_PROPERTY: // We need the key and receiver on both the stack and in v0 and a1. if (expr->is_compound()) { @@ -1951,6 +1951,10 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { EmitNamedSuperPropertyLoad(property); PrepareForBailoutForId(property->LoadId(), TOS_REG); break; + case KEYED_SUPER_PROPERTY: + EmitKeyedSuperPropertyLoad(property); + PrepareForBailoutForId(property->LoadId(), TOS_REG); + break; case KEYED_PROPERTY: EmitKeyedPropertyLoad(property); PrepareForBailoutForId(property->LoadId(), TOS_REG); @@ -2001,6 +2005,10 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { EmitNamedSuperPropertyStore(property); context()->Plug(v0); break; + case KEYED_SUPER_PROPERTY: + EmitKeyedSuperPropertyStore(property); + context()->Plug(v0); + break; case KEYED_PROPERTY: EmitKeyedPropertyAssignment(expr); break; @@ -2636,14 +2644,27 @@ void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) { Literal* key = prop->key()->AsLiteral(); DCHECK(key != NULL); - __ Push(v0); __ Push(key->value()); + __ Push(v0); __ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreToSuper_Strict : Runtime::kStoreToSuper_Sloppy), 4); } +void FullCodeGenerator::EmitKeyedSuperPropertyStore(Property* prop) { + // Assignment to named property of super. + // v0 : value + // stack : receiver ('this'), home_object, key + DCHECK(prop != NULL); + + __ Push(v0); + __ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreKeyedToSuper_Strict + : Runtime::kStoreKeyedToSuper_Sloppy), + 4); +} + + void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { // Assignment to a property, using a keyed store IC. @@ -4441,24 +4462,8 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { Comment cmnt(masm_, "[ CountOperation"); SetSourcePosition(expr->position()); - // Expression can only be a property, a global or a (parameter or local) - // slot. - enum LhsKind { - VARIABLE, - NAMED_PROPERTY, - KEYED_PROPERTY, - NAMED_SUPER_PROPERTY - }; - LhsKind assign_type = VARIABLE; Property* prop = expr->expression()->AsProperty(); - // In case of a property we use the uninitialized expression context - // of the key to detect a named property. - if (prop != NULL) { - assign_type = - (prop->key()->IsPropertyName()) - ? (prop->IsSuperAccess() ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY) - : KEYED_PROPERTY; - } + LhsKind assign_type = GetAssignType(prop); // Evaluate expression and get value. if (assign_type == VARIABLE) { @@ -4471,26 +4476,51 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { __ li(at, Operand(Smi::FromInt(0))); __ push(at); } - if (assign_type == NAMED_PROPERTY) { - // Put the object both on the stack and in the register. - VisitForStackValue(prop->obj()); - __ lw(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); - EmitNamedPropertyLoad(prop); - } else if (assign_type == NAMED_SUPER_PROPERTY) { - VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); - EmitLoadHomeObject(prop->obj()->AsSuperReference()); - __ Push(result_register()); - const Register scratch = a1; - __ lw(scratch, MemOperand(sp, kPointerSize)); - __ Push(scratch, result_register()); - EmitNamedSuperPropertyLoad(prop); - } else { - VisitForStackValue(prop->obj()); - VisitForStackValue(prop->key()); - __ lw(LoadDescriptor::ReceiverRegister(), - MemOperand(sp, 1 * kPointerSize)); - __ lw(LoadDescriptor::NameRegister(), MemOperand(sp, 0)); - EmitKeyedPropertyLoad(prop); + switch (assign_type) { + case NAMED_PROPERTY: { + // Put the object both on the stack and in the register. + VisitForStackValue(prop->obj()); + __ lw(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); + EmitNamedPropertyLoad(prop); + break; + } + + case NAMED_SUPER_PROPERTY: { + VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); + EmitLoadHomeObject(prop->obj()->AsSuperReference()); + __ Push(result_register()); + const Register scratch = a1; + __ lw(scratch, MemOperand(sp, kPointerSize)); + __ Push(scratch, result_register()); + EmitNamedSuperPropertyLoad(prop); + break; + } + + case KEYED_SUPER_PROPERTY: { + VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); + EmitLoadHomeObject(prop->obj()->AsSuperReference()); + const Register scratch = a1; + const Register scratch1 = t0; + __ Move(scratch, result_register()); + VisitForAccumulatorValue(prop->key()); + __ Push(scratch, result_register()); + __ lw(scratch1, MemOperand(sp, 2 * kPointerSize)); + __ Push(scratch1, scratch, result_register()); + EmitKeyedSuperPropertyLoad(prop); + break; + } + + case KEYED_PROPERTY: { + VisitForStackValue(prop->obj()); + VisitForStackValue(prop->key()); + __ lw(LoadDescriptor::ReceiverRegister(), + MemOperand(sp, 1 * kPointerSize)); + __ lw(LoadDescriptor::NameRegister(), MemOperand(sp, 0)); + EmitKeyedPropertyLoad(prop); + } + + case VARIABLE: + UNREACHABLE(); } } @@ -4531,6 +4561,9 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { case KEYED_PROPERTY: __ sw(v0, MemOperand(sp, 2 * kPointerSize)); break; + case KEYED_SUPER_PROPERTY: + __ sw(v0, MemOperand(sp, 3 * kPointerSize)); + break; } } } @@ -4567,6 +4600,9 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { case KEYED_PROPERTY: __ sw(v0, MemOperand(sp, 2 * kPointerSize)); break; + case KEYED_SUPER_PROPERTY: + __ sw(v0, MemOperand(sp, 3 * kPointerSize)); + break; } } } @@ -4633,6 +4669,17 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { } break; } + case KEYED_SUPER_PROPERTY: { + EmitKeyedSuperPropertyStore(prop); + if (expr->is_postfix()) { + if (!context()->IsEffect()) { + context()->PlugTOS(); + } + } else { + context()->Plug(v0); + } + break; + } case KEYED_PROPERTY: { __ mov(StoreDescriptor::ValueRegister(), result_register()); __ Pop(StoreDescriptor::ReceiverRegister(), diff --git a/src/mips64/full-codegen-mips64.cc b/src/mips64/full-codegen-mips64.cc index 7430c8e..3879887 100644 --- a/src/mips64/full-codegen-mips64.cc +++ b/src/mips64/full-codegen-mips64.cc @@ -1875,22 +1875,8 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { Comment cmnt(masm_, "[ Assignment"); - // Left-hand side can only be a property, a global or a (parameter or local) - // slot. - enum LhsKind { - VARIABLE, - NAMED_PROPERTY, - KEYED_PROPERTY, - NAMED_SUPER_PROPERTY - }; - LhsKind assign_type = VARIABLE; Property* property = expr->target()->AsProperty(); - if (property != NULL) { - assign_type = (property->key()->IsPropertyName()) - ? (property->IsSuperAccess() ? NAMED_SUPER_PROPERTY - : NAMED_PROPERTY) - : KEYED_PROPERTY; - } + LhsKind assign_type = GetAssignType(property); // Evaluate LHS expression. switch (assign_type) { @@ -1916,6 +1902,20 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { __ Push(scratch, result_register()); } break; + case KEYED_SUPER_PROPERTY: { + const Register scratch = a1; + VisitForStackValue(property->obj()->AsSuperReference()->this_var()); + EmitLoadHomeObject(property->obj()->AsSuperReference()); + __ Move(scratch, result_register()); + VisitForAccumulatorValue(property->key()); + __ Push(scratch, result_register()); + if (expr->is_compound()) { + const Register scratch1 = a4; + __ ld(scratch1, MemOperand(sp, 2 * kPointerSize)); + __ Push(scratch1, scratch, result_register()); + } + break; + } case KEYED_PROPERTY: // We need the key and receiver on both the stack and in v0 and a1. if (expr->is_compound()) { @@ -1948,6 +1948,10 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { EmitNamedSuperPropertyLoad(property); PrepareForBailoutForId(property->LoadId(), TOS_REG); break; + case KEYED_SUPER_PROPERTY: + EmitKeyedSuperPropertyLoad(property); + PrepareForBailoutForId(property->LoadId(), TOS_REG); + break; case KEYED_PROPERTY: EmitKeyedPropertyLoad(property); PrepareForBailoutForId(property->LoadId(), TOS_REG); @@ -1998,6 +2002,10 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { EmitNamedSuperPropertyStore(property); context()->Plug(v0); break; + case KEYED_SUPER_PROPERTY: + EmitKeyedSuperPropertyStore(property); + context()->Plug(v0); + break; case KEYED_PROPERTY: EmitKeyedPropertyAssignment(expr); break; @@ -2636,14 +2644,27 @@ void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) { Literal* key = prop->key()->AsLiteral(); DCHECK(key != NULL); - __ Push(v0); __ Push(key->value()); + __ Push(v0); __ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreToSuper_Strict : Runtime::kStoreToSuper_Sloppy), 4); } +void FullCodeGenerator::EmitKeyedSuperPropertyStore(Property* prop) { + // Assignment to named property of super. + // v0 : value + // stack : receiver ('this'), home_object, key + DCHECK(prop != NULL); + + __ Push(v0); + __ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreKeyedToSuper_Strict + : Runtime::kStoreKeyedToSuper_Sloppy), + 4); +} + + void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { // Assignment to a property, using a keyed store IC. @@ -4441,24 +4462,8 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { Comment cmnt(masm_, "[ CountOperation"); SetSourcePosition(expr->position()); - // Expression can only be a property, a global or a (parameter or local) - // slot. - enum LhsKind { - VARIABLE, - NAMED_PROPERTY, - KEYED_PROPERTY, - NAMED_SUPER_PROPERTY - }; - LhsKind assign_type = VARIABLE; Property* prop = expr->expression()->AsProperty(); - // In case of a property we use the uninitialized expression context - // of the key to detect a named property. - if (prop != NULL) { - assign_type = - (prop->key()->IsPropertyName()) - ? (prop->IsSuperAccess() ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY) - : KEYED_PROPERTY; - } + LhsKind assign_type = GetAssignType(prop); // Evaluate expression and get value. if (assign_type == VARIABLE) { @@ -4471,26 +4476,51 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { __ li(at, Operand(Smi::FromInt(0))); __ push(at); } - if (assign_type == NAMED_PROPERTY) { - // Put the object both on the stack and in the register. - VisitForStackValue(prop->obj()); - __ ld(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); - EmitNamedPropertyLoad(prop); - } else if (assign_type == NAMED_SUPER_PROPERTY) { - VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); - EmitLoadHomeObject(prop->obj()->AsSuperReference()); - __ Push(result_register()); - const Register scratch = a1; - __ ld(scratch, MemOperand(sp, kPointerSize)); - __ Push(scratch, result_register()); - EmitNamedSuperPropertyLoad(prop); - } else { - VisitForStackValue(prop->obj()); - VisitForStackValue(prop->key()); - __ ld(LoadDescriptor::ReceiverRegister(), - MemOperand(sp, 1 * kPointerSize)); - __ ld(LoadDescriptor::NameRegister(), MemOperand(sp, 0)); - EmitKeyedPropertyLoad(prop); + switch (assign_type) { + case NAMED_PROPERTY: { + // Put the object both on the stack and in the register. + VisitForStackValue(prop->obj()); + __ ld(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); + EmitNamedPropertyLoad(prop); + break; + } + + case NAMED_SUPER_PROPERTY: { + VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); + EmitLoadHomeObject(prop->obj()->AsSuperReference()); + __ Push(result_register()); + const Register scratch = a1; + __ ld(scratch, MemOperand(sp, kPointerSize)); + __ Push(scratch, result_register()); + EmitNamedSuperPropertyLoad(prop); + break; + } + + case KEYED_SUPER_PROPERTY: { + VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); + EmitLoadHomeObject(prop->obj()->AsSuperReference()); + const Register scratch = a1; + const Register scratch1 = a4; + __ Move(scratch, result_register()); + VisitForAccumulatorValue(prop->key()); + __ Push(scratch, result_register()); + __ ld(scratch1, MemOperand(sp, 2 * kPointerSize)); + __ Push(scratch1, scratch, result_register()); + EmitKeyedSuperPropertyLoad(prop); + break; + } + + case KEYED_PROPERTY: { + VisitForStackValue(prop->obj()); + VisitForStackValue(prop->key()); + __ ld(LoadDescriptor::ReceiverRegister(), + MemOperand(sp, 1 * kPointerSize)); + __ ld(LoadDescriptor::NameRegister(), MemOperand(sp, 0)); + EmitKeyedPropertyLoad(prop); + } + + case VARIABLE: + UNREACHABLE(); } } @@ -4531,6 +4561,9 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { case KEYED_PROPERTY: __ sd(v0, MemOperand(sp, 2 * kPointerSize)); break; + case KEYED_SUPER_PROPERTY: + __ sd(v0, MemOperand(sp, 3 * kPointerSize)); + break; } } } @@ -4567,6 +4600,9 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { case KEYED_PROPERTY: __ sd(v0, MemOperand(sp, 2 * kPointerSize)); break; + case KEYED_SUPER_PROPERTY: + __ sd(v0, MemOperand(sp, 3 * kPointerSize)); + break; } } } @@ -4633,6 +4669,17 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { } break; } + case KEYED_SUPER_PROPERTY: { + EmitKeyedSuperPropertyStore(prop); + if (expr->is_postfix()) { + if (!context()->IsEffect()) { + context()->PlugTOS(); + } + } else { + context()->Plug(v0); + } + break; + } case KEYED_PROPERTY: { __ mov(StoreDescriptor::ValueRegister(), result_register()); __ Pop(StoreDescriptor::ReceiverRegister(),