Index: src/mips64/full-codegen-mips64.cc |
diff --git a/src/mips64/full-codegen-mips64.cc b/src/mips64/full-codegen-mips64.cc |
index 29caab4adf4a2a8174c147d30ff43f8dd0a35e79..2508933ca3d8c546f7caa1a93109f10e5c9e4cf9 100644 |
--- a/src/mips64/full-codegen-mips64.cc |
+++ b/src/mips64/full-codegen-mips64.cc |
@@ -253,6 +253,24 @@ void FullCodeGenerator::Generate() { |
__ Push(a1); |
} |
+ // Possibly set up a local binding to the this function which is used in |
+ // derived constructors with super calls. |
+ Variable* this_function_var = scope()->this_function_var(); |
+ if (this_function_var != nullptr) { |
+ Comment cmnt(masm_, "[ This function"); |
+ SetVar(this_function_var, a1, a2, a3); |
+ } |
+ |
+ Variable* new_target_var = scope()->new_target_var(); |
+ if (new_target_var != nullptr) { |
+ Comment cmnt(masm_, "[ new.target"); |
+ // new.target is parameter -2. |
+ int offset = 2 * kPointerSize + |
+ (info_->scope()->num_parameters() + 1) * kPointerSize; |
+ __ lw(v0, MemOperand(fp, offset)); |
+ SetVar(new_target_var, v0, a2, a3); |
+ } |
+ |
ArgumentsAccessStub::HasNewTarget has_new_target = |
IsSubclassConstructor(info->function()->kind()) |
? ArgumentsAccessStub::HAS_NEW_TARGET |
@@ -1987,9 +2005,10 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { |
} |
break; |
case NAMED_SUPER_PROPERTY: |
- VisitForStackValue(property->obj()->AsSuperReference()->this_var()); |
+ VisitForStackValue( |
+ property->obj()->AsSuperPropertyReference()->this_var()); |
VisitForAccumulatorValue( |
- property->obj()->AsSuperReference()->home_object_var()); |
+ property->obj()->AsSuperPropertyReference()->home_object_var()); |
__ Push(result_register()); |
if (expr->is_compound()) { |
const Register scratch = a1; |
@@ -1999,9 +2018,10 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { |
break; |
case KEYED_SUPER_PROPERTY: { |
const Register scratch = a1; |
- VisitForStackValue(property->obj()->AsSuperReference()->this_var()); |
+ VisitForStackValue( |
+ property->obj()->AsSuperPropertyReference()->this_var()); |
VisitForAccumulatorValue( |
- property->obj()->AsSuperReference()->home_object_var()); |
+ property->obj()->AsSuperPropertyReference()->home_object_var()); |
__ Move(scratch, result_register()); |
VisitForAccumulatorValue(property->key()); |
__ Push(scratch, result_register()); |
@@ -2635,9 +2655,9 @@ void FullCodeGenerator::EmitAssignment(Expression* expr, |
} |
case NAMED_SUPER_PROPERTY: { |
__ Push(v0); |
- VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); |
+ VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
VisitForAccumulatorValue( |
- prop->obj()->AsSuperReference()->home_object_var()); |
+ prop->obj()->AsSuperPropertyReference()->home_object_var()); |
// stack: value, this; v0: home_object |
Register scratch = a2; |
Register scratch2 = a3; |
@@ -2652,8 +2672,9 @@ void FullCodeGenerator::EmitAssignment(Expression* expr, |
} |
case KEYED_SUPER_PROPERTY: { |
__ Push(v0); |
- VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); |
- VisitForStackValue(prop->obj()->AsSuperReference()->home_object_var()); |
+ VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
+ VisitForStackValue( |
+ prop->obj()->AsSuperPropertyReference()->home_object_var()); |
VisitForAccumulatorValue(prop->key()); |
Register scratch = a2; |
Register scratch2 = a3; |
@@ -2886,8 +2907,9 @@ void FullCodeGenerator::VisitProperty(Property* expr) { |
__ Move(LoadDescriptor::ReceiverRegister(), v0); |
EmitNamedPropertyLoad(expr); |
} else { |
- VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); |
- VisitForStackValue(expr->obj()->AsSuperReference()->home_object_var()); |
+ VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var()); |
+ VisitForStackValue( |
+ expr->obj()->AsSuperPropertyReference()->home_object_var()); |
EmitNamedSuperPropertyLoad(expr); |
} |
} else { |
@@ -2898,8 +2920,9 @@ void FullCodeGenerator::VisitProperty(Property* expr) { |
__ pop(LoadDescriptor::ReceiverRegister()); |
EmitKeyedPropertyLoad(expr); |
} else { |
- VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); |
- VisitForStackValue(expr->obj()->AsSuperReference()->home_object_var()); |
+ VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var()); |
+ VisitForStackValue( |
+ expr->obj()->AsSuperPropertyReference()->home_object_var()); |
VisitForStackValue(expr->key()); |
EmitKeyedSuperPropertyLoad(expr); |
} |
@@ -2961,7 +2984,7 @@ void FullCodeGenerator::EmitSuperCallWithLoadIC(Call* expr) { |
DCHECK(!key->value()->IsSmi()); |
// Load the function from the receiver. |
const Register scratch = a1; |
- SuperReference* super_ref = prop->obj()->AsSuperReference(); |
+ SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference(); |
VisitForAccumulatorValue(super_ref->home_object_var()); |
__ mov(scratch, v0); |
VisitForAccumulatorValue(super_ref->this_var()); |
@@ -3019,7 +3042,7 @@ void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { |
SetSourcePosition(prop->position()); |
// Load the function from the receiver. |
const Register scratch = a1; |
- SuperReference* super_ref = prop->obj()->AsSuperReference(); |
+ SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference(); |
VisitForAccumulatorValue(super_ref->home_object_var()); |
__ Move(scratch, v0); |
VisitForAccumulatorValue(super_ref->this_var()); |
@@ -3098,15 +3121,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { |
} |
-void FullCodeGenerator::EmitLoadSuperConstructor() { |
- __ ld(a0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
- __ Push(a0); |
- __ CallRuntime(Runtime::kGetPrototype, 1); |
-} |
- |
- |
void FullCodeGenerator::EmitInitializeThisAfterSuper( |
- SuperReference* super_ref, FeedbackVectorICSlot slot) { |
+ SuperCallReference* super_ref, FeedbackVectorICSlot slot) { |
Variable* this_var = super_ref->this_var()->var(); |
GetVar(a1, this_var); |
__ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
@@ -3264,7 +3280,7 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
// Push constructor on the stack. If it's not a function it's used as |
// receiver for CALL_NON_FUNCTION, otherwise the value on the stack is |
// ignored. |
- DCHECK(!expr->expression()->IsSuperReference()); |
+ DCHECK(!expr->expression()->IsSuperPropertyReference()); |
VisitForStackValue(expr->expression()); |
// Push the arguments ("left-to-right") on the stack. |
@@ -3300,11 +3316,14 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
- Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); |
- GetVar(result_register(), new_target_var); |
- __ Push(result_register()); |
+ SuperCallReference* super_call_ref = |
+ expr->expression()->AsSuperCallReference(); |
+ DCHECK_NOT_NULL(super_call_ref); |
+ |
+ VariableProxy* new_target_proxy = super_call_ref->new_target_var(); |
+ VisitForStackValue(new_target_proxy); |
- EmitLoadSuperConstructor(); |
+ EmitLoadSuperConstructor(super_call_ref); |
__ push(result_register()); |
// Push the arguments ("left-to-right") on the stack. |
@@ -3342,8 +3361,7 @@ void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
RecordJSReturnSite(expr); |
- EmitInitializeThisAfterSuper(expr->expression()->AsSuperReference(), |
- expr->CallFeedbackICSlot()); |
+ EmitInitializeThisAfterSuper(super_call_ref, expr->CallFeedbackICSlot()); |
context()->Plug(v0); |
} |
@@ -4231,11 +4249,15 @@ void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { |
void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { |
- Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); |
- GetVar(result_register(), new_target_var); |
- __ Push(result_register()); |
+ ZoneList<Expression*>* args = expr->arguments(); |
+ DCHECK(args->length() == 2); |
- EmitLoadSuperConstructor(); |
+ // new.target |
+ VisitForStackValue(args->at(0)); |
+ |
+ // .this_function |
+ VisitForStackValue(args->at(1)); |
+ __ CallRuntime(Runtime::kGetPrototype, 1); |
__ Push(result_register()); |
// Check if the calling frame is an arguments adaptor frame. |
@@ -4637,11 +4659,14 @@ void FullCodeGenerator::EmitDebugIsActive(CallRuntime* expr) { |
void FullCodeGenerator::EmitCallSuperWithSpread(CallRuntime* expr) { |
// Assert: expr === CallRuntime("ReflectConstruct") |
+ DCHECK_EQ(1, expr->arguments()->length()); |
CallRuntime* call = expr->arguments()->at(0)->AsCallRuntime(); |
+ |
ZoneList<Expression*>* args = call->arguments(); |
DCHECK_EQ(3, args->length()); |
- SuperReference* super_reference = args->at(0)->AsSuperReference(); |
+ SuperCallReference* super_call_ref = args->at(0)->AsSuperCallReference(); |
+ DCHECK_NOT_NULL(super_call_ref); |
// Load ReflectConstruct function |
EmitLoadJSRuntimeFunction(call); |
@@ -4651,8 +4676,8 @@ void FullCodeGenerator::EmitCallSuperWithSpread(CallRuntime* expr) { |
__ push(at); |
__ sd(v0, MemOperand(sp, kPointerSize)); |
- // Push super |
- EmitLoadSuperConstructor(); |
+ // Push super constructor |
+ EmitLoadSuperConstructor(super_call_ref); |
__ Push(result_register()); |
// Push arguments array |
@@ -4669,7 +4694,7 @@ void FullCodeGenerator::EmitCallSuperWithSpread(CallRuntime* expr) { |
context()->DropAndPlug(1, v0); |
// TODO(mvstanton): with FLAG_vector_stores this needs a slot id. |
- EmitInitializeThisAfterSuper(super_reference); |
+ EmitInitializeThisAfterSuper(super_call_ref); |
} |
@@ -4893,9 +4918,9 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
} |
case NAMED_SUPER_PROPERTY: { |
- VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); |
+ VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
VisitForAccumulatorValue( |
- prop->obj()->AsSuperReference()->home_object_var()); |
+ prop->obj()->AsSuperPropertyReference()->home_object_var()); |
__ Push(result_register()); |
const Register scratch = a1; |
__ ld(scratch, MemOperand(sp, kPointerSize)); |
@@ -4905,9 +4930,9 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
} |
case KEYED_SUPER_PROPERTY: { |
- VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); |
+ VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
VisitForAccumulatorValue( |
- prop->obj()->AsSuperReference()->home_object_var()); |
+ prop->obj()->AsSuperPropertyReference()->home_object_var()); |
const Register scratch = a1; |
const Register scratch1 = a4; |
__ Move(scratch, result_register()); |