| Index: src/x64/full-codegen-x64.cc
|
| diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
|
| index 0e2f6c9fdb6b0651b65a11fc4c9c03c5b9740ca2..dcd4e96a1e8ebc48607cb6e759aebfbce4a0429d 100644
|
| --- a/src/x64/full-codegen-x64.cc
|
| +++ b/src/x64/full-codegen-x64.cc
|
| @@ -234,6 +234,24 @@ void FullCodeGenerator::Generate() {
|
| }
|
| }
|
|
|
| + // 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, rdi, rbx, rdx);
|
| + }
|
| +
|
| + 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 + kFPOnStackSize + kPCOnStackSize +
|
| + (info_->scope()->num_parameters() - 1) * kPointerSize;
|
| + __ movp(rax, Operand(rbp, offset));
|
| + SetVar(new_target_var, rax, rbx, rdx);
|
| + }
|
| +
|
| Variable* home_object_var = scope()->home_object_var();
|
| if (home_object_var != nullptr) {
|
| __ Push(rdi);
|
| @@ -307,7 +325,6 @@ void FullCodeGenerator::Generate() {
|
| }
|
|
|
| // Possibly set up a local binding to the [[HomeObject]].
|
| - // Variable* home_object_var = scope()->home_object_var();
|
| if (home_object_var != nullptr) {
|
| Comment cmnt(masm_, "[ Home object");
|
| __ Pop(LoadDescriptor::ReceiverRegister());
|
| @@ -1960,9 +1977,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()) {
|
| __ Push(MemOperand(rsp, kPointerSize));
|
| @@ -1970,9 +1988,10 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) {
|
| }
|
| break;
|
| case KEYED_SUPER_PROPERTY:
|
| - VisitForStackValue(property->obj()->AsSuperReference()->this_var());
|
| VisitForStackValue(
|
| - property->obj()->AsSuperReference()->home_object_var());
|
| + property->obj()->AsSuperPropertyReference()->this_var());
|
| + VisitForStackValue(
|
| + property->obj()->AsSuperPropertyReference()->home_object_var());
|
| VisitForAccumulatorValue(property->key());
|
| __ Push(result_register());
|
| if (expr->is_compound()) {
|
| @@ -2564,9 +2583,9 @@ void FullCodeGenerator::EmitAssignment(Expression* expr,
|
| }
|
| case NAMED_SUPER_PROPERTY: {
|
| __ Push(rax);
|
| - 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; rax: home_object
|
| Register scratch = rcx;
|
| Register scratch2 = rdx;
|
| @@ -2581,8 +2600,9 @@ void FullCodeGenerator::EmitAssignment(Expression* expr,
|
| }
|
| case KEYED_SUPER_PROPERTY: {
|
| __ Push(rax);
|
| - 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 = rcx;
|
| Register scratch2 = rdx;
|
| @@ -2801,8 +2821,9 @@ void FullCodeGenerator::VisitProperty(Property* expr) {
|
| __ movp(LoadDescriptor::ReceiverRegister(), rax);
|
| 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 {
|
| @@ -2813,8 +2834,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);
|
| }
|
| @@ -2872,7 +2894,7 @@ void FullCodeGenerator::EmitSuperCallWithLoadIC(Call* expr) {
|
| Literal* key = prop->key()->AsLiteral();
|
| DCHECK(!key->value()->IsSmi());
|
| // Load the function from the receiver.
|
| - SuperReference* super_ref = prop->obj()->AsSuperReference();
|
| + SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference();
|
| VisitForStackValue(super_ref->home_object_var());
|
| VisitForAccumulatorValue(super_ref->this_var());
|
| __ Push(rax);
|
| @@ -2929,7 +2951,7 @@ void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) {
|
|
|
| SetSourcePosition(prop->position());
|
| // Load the function from the receiver.
|
| - SuperReference* super_ref = prop->obj()->AsSuperReference();
|
| + SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference();
|
| VisitForStackValue(super_ref->home_object_var());
|
| VisitForAccumulatorValue(super_ref->this_var());
|
| __ Push(rax);
|
| @@ -3010,14 +3032,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitLoadSuperConstructor() {
|
| - __ Push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
|
| - __ 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(rcx, this_var);
|
| __ CompareRoot(rcx, Heap::kTheHoleValueRootIndex);
|
| @@ -3167,7 +3183,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.
|
| @@ -3203,11 +3219,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);
|
|
|
| - EmitLoadSuperConstructor();
|
| + VariableProxy* new_target_proxy = super_call_ref->new_target_var();
|
| + VisitForStackValue(new_target_proxy);
|
| +
|
| + EmitLoadSuperConstructor(super_call_ref);
|
| __ Push(result_register());
|
|
|
| // Push the arguments ("left-to-right") on the stack.
|
| @@ -3245,8 +3264,7 @@ void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) {
|
|
|
| RecordJSReturnSite(expr);
|
|
|
| - EmitInitializeThisAfterSuper(expr->expression()->AsSuperReference(),
|
| - expr->CallFeedbackICSlot());
|
| + EmitInitializeThisAfterSuper(super_call_ref, expr->CallFeedbackICSlot());
|
| context()->Plug(rax);
|
| }
|
|
|
| @@ -4113,11 +4131,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);
|
| +
|
| + // new.target
|
| + VisitForStackValue(args->at(0));
|
|
|
| - EmitLoadSuperConstructor();
|
| + // .this_function
|
| + VisitForStackValue(args->at(1));
|
| + __ CallRuntime(Runtime::kGetPrototype, 1);
|
| __ Push(result_register());
|
|
|
| // Check if the calling frame is an arguments adaptor frame.
|
| @@ -4573,7 +4595,8 @@ void FullCodeGenerator::EmitCallSuperWithSpread(CallRuntime* expr) {
|
| 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);
|
| @@ -4582,8 +4605,8 @@ void FullCodeGenerator::EmitCallSuperWithSpread(CallRuntime* expr) {
|
| __ Push(Operand(rsp, 0));
|
| __ movp(Operand(rsp, kPointerSize), rax);
|
|
|
| - // Push super
|
| - EmitLoadSuperConstructor();
|
| + // Push super constructor
|
| + EmitLoadSuperConstructor(super_call_ref);
|
| __ Push(result_register());
|
|
|
| // Push arguments array
|
| @@ -4600,7 +4623,7 @@ void FullCodeGenerator::EmitCallSuperWithSpread(CallRuntime* expr) {
|
| context()->DropAndPlug(1, rax);
|
|
|
| // TODO(mvstanton): with FLAG_vector_stores this needs a slot id.
|
| - EmitInitializeThisAfterSuper(super_reference);
|
| + EmitInitializeThisAfterSuper(super_call_ref);
|
| }
|
|
|
|
|
| @@ -4825,9 +4848,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());
|
| __ Push(MemOperand(rsp, kPointerSize));
|
| __ Push(result_register());
|
| @@ -4836,8 +4859,9 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
|
| }
|
|
|
| case KEYED_SUPER_PROPERTY: {
|
| - 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());
|
| __ Push(result_register());
|
| __ Push(MemOperand(rsp, 2 * kPointerSize));
|
|
|