Chromium Code Reviews| Index: src/x64/full-codegen-x64.cc |
| diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc |
| index 4b16c690a3329a586b9a80c42aec122de605a8e7..d720e151806af05e7189bf349cdd9f14d8eed59c 100644 |
| --- a/src/x64/full-codegen-x64.cc |
| +++ b/src/x64/full-codegen-x64.cc |
| @@ -3063,11 +3063,15 @@ void FullCodeGenerator::VisitCall(Call* expr) { |
| } |
| } |
| } else if (call_type == Call::SUPER_CALL) { |
| - SuperReference* super_ref = callee->AsSuperReference(); |
| - EmitLoadSuperConstructor(super_ref); |
| - __ Push(result_register()); |
| - VisitForStackValue(super_ref->this_var()); |
| - EmitCall(expr, CallICState::METHOD); |
| + if (FLAG_experimental_classes) { |
| + EmitSuperConstructorCall(expr); |
| + } else { |
| + SuperReference* super_ref = callee->AsSuperReference(); |
| + EmitLoadSuperConstructor(super_ref); |
| + __ Push(result_register()); |
| + VisitForStackValue(super_ref->this_var()); |
| + EmitCall(expr, CallICState::METHOD); |
| + } |
| } else { |
| DCHECK(call_type == Call::OTHER_CALL); |
| // Call to an arbitrary expression not handled specially above. |
| @@ -3134,6 +3138,51 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
| } |
| +void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
| + SuperReference* super_ref = expr->expression()->AsSuperReference(); |
| + EmitLoadSuperConstructor(super_ref); |
| + __ Push(result_register()); |
| + |
| + // Push the arguments ("left-to-right") on the stack. |
| + ZoneList<Expression*>* args = expr->arguments(); |
| + int arg_count = args->length(); |
| + for (int i = 0; i < arg_count; i++) { |
| + VisitForStackValue(args->at(i)); |
| + } |
| + |
| + // Call the construct call builtin that handles allocation and |
| + // constructor invocation. |
| + SetSourcePosition(expr->position()); |
| + |
| + // Load function and argument count into edi and eax. |
| + __ Set(rax, arg_count); |
| + __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); |
| + |
| + // Record call targets in unoptimized code. |
| + if (FLAG_pretenuring_call_new) { |
| + UNREACHABLE(); |
| + /* TODO[dslomov]: support pretenuring. |
|
arv (Not doing code reviews)
2015/01/22 16:20:26
The style guide says to format these as: `TODO(dsl
Dmitry Lomov (no reviews)
2015/01/22 17:00:25
Done (other places too)
|
| + EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); |
| + DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == |
| + expr->CallNewFeedbackSlot().ToInt() + 1); |
| + */ |
| + } |
| + |
| + __ Move(rbx, FeedbackVector()); |
| + __ Move(rdx, SmiFromSlot(expr->CallFeedbackSlot())); |
| + |
| + // TODO(dslomov): use a different stub and propagate new.target. |
| + CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); |
| + __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
| + |
| + RecordJSReturnSite(expr); |
| + |
| + // TODO(dslomov): implement TDZ for `this`. |
| + EmitVariableAssignment(super_ref->this_var()->var(), Token::ASSIGN); |
| + context()->Plug(rax); |
| +} |
| + |
| + |
| void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
| ZoneList<Expression*>* args = expr->arguments(); |
| DCHECK(args->length() == 1); |