Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1139)

Unified Diff: src/x64/full-codegen-x64.cc

Issue 938443002: [es6] implement spread calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase + clang-format Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/x64/full-codegen-x64.cc
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
index 34fbd81015c9fe70689402cf1ed8cb557f371a63..9c7a41f44906a2e4c326d9b52d40f9fbc496899d 100644
--- a/src/x64/full-codegen-x64.cc
+++ b/src/x64/full-codegen-x64.cc
@@ -3008,6 +3008,21 @@ void FullCodeGenerator::EmitLoadSuperConstructor() {
}
+void FullCodeGenerator::EmitInitializeThisAfterSuper(
+ SuperReference* super_ref) {
+ Variable* this_var = super_ref->this_var()->var();
+ GetVar(rcx, this_var);
+ __ CompareRoot(rcx, Heap::kTheHoleValueRootIndex);
+ Label uninitialized_this;
+ __ j(equal, &uninitialized_this);
+ __ Push(this_var->name());
+ __ CallRuntime(Runtime::kThrowReferenceError, 1);
+ __ bind(&uninitialized_this);
+
+ EmitVariableAssignment(this_var, Token::INIT_CONST);
+}
+
+
void FullCodeGenerator::VisitCall(Call* expr) {
#ifdef DEBUG
// We want to verify that RecordJSReturnSite gets called on all paths
@@ -3222,17 +3237,7 @@ void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) {
RecordJSReturnSite(expr);
- SuperReference* super_ref = expr->expression()->AsSuperReference();
- Variable* this_var = super_ref->this_var()->var();
- GetVar(rcx, this_var);
- __ CompareRoot(rcx, Heap::kTheHoleValueRootIndex);
- Label uninitialized_this;
- __ j(equal, &uninitialized_this);
- __ Push(this_var->name());
- __ CallRuntime(Runtime::kThrowReferenceError, 1);
- __ bind(&uninitialized_this);
-
- EmitVariableAssignment(this_var, Token::INIT_CONST);
+ EmitInitializeThisAfterSuper(expr->expression()->AsSuperReference());
context()->Plug(rax);
}
@@ -4553,26 +4558,80 @@ void FullCodeGenerator::EmitDebugIsActive(CallRuntime* expr) {
}
+void FullCodeGenerator::EmitCallSuperWithSpread(CallRuntime* expr) {
+ // Assert: expr === CallRuntime("ReflectConstruct")
+ CallRuntime* call = expr->arguments()->at(0)->AsCallRuntime();
+ ZoneList<Expression*>* args = call->arguments();
+ DCHECK_EQ(3, args->length());
+
+ SuperReference* super_reference = args->at(0)->AsSuperReference();
+
+ // Load ReflectConstruct function
+ EmitLoadJSRuntimeFunction(call);
+
+ // Push the target function under the receiver.
+ __ Push(Operand(rsp, 0));
+ __ movp(Operand(rsp, kPointerSize), rax);
+
+ // Push super
+ EmitLoadSuperConstructor();
+ __ Push(result_register());
+
+ // Push arguments array
+ VisitForStackValue(args->at(1));
+
+ // Push NewTarget
+ DCHECK(args->at(2)->IsVariableProxy());
+ VisitForStackValue(args->at(2));
+
+ EmitCallJSRuntimeFunction(call);
+
+ // Restore context register.
+ __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
+ context()->DropAndPlug(1, rax);
+
+ EmitInitializeThisAfterSuper(super_reference);
+}
+
+
+void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) {
+ // Push the builtins object as receiver.
+ __ movp(rax, GlobalObjectOperand());
+ __ Push(FieldOperand(rax, GlobalObject::kBuiltinsOffset));
+
+ // Load the function from the receiver.
+ __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0));
+ __ Move(LoadDescriptor::NameRegister(), expr->name());
+ if (FLAG_vector_ics) {
+ __ Move(VectorLoadICDescriptor::SlotRegister(),
+ SmiFromSlot(expr->CallRuntimeFeedbackSlot()));
+ CallLoadIC(NOT_CONTEXTUAL);
+ } else {
+ CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId());
+ }
+}
+
+
+void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) {
+ ZoneList<Expression*>* args = expr->arguments();
+ int arg_count = args->length();
+
+ // Record source position of the IC call.
+ SetSourcePosition(expr->position());
+ CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS);
+ __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize));
+ __ CallStub(&stub);
+}
+
+
void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
ZoneList<Expression*>* args = expr->arguments();
int arg_count = args->length();
if (expr->is_jsruntime()) {
Comment cmnt(masm_, "[ CallRuntime");
- // Push the builtins object as receiver.
- __ movp(rax, GlobalObjectOperand());
- __ Push(FieldOperand(rax, GlobalObject::kBuiltinsOffset));
- // Load the function from the receiver.
- __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0));
- __ Move(LoadDescriptor::NameRegister(), expr->name());
- if (FLAG_vector_ics) {
- __ Move(VectorLoadICDescriptor::SlotRegister(),
- SmiFromSlot(expr->CallRuntimeFeedbackSlot()));
- CallLoadIC(NOT_CONTEXTUAL);
- } else {
- CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId());
- }
+ EmitLoadJSRuntimeFunction(expr);
// Push the target function under the receiver.
__ Push(Operand(rsp, 0));
@@ -4583,11 +4642,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
VisitForStackValue(args->at(i));
}
- // Record source position of the IC call.
- SetSourcePosition(expr->position());
- CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS);
- __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize));
- __ CallStub(&stub);
+ EmitCallJSRuntimeFunction(expr);
// Restore context register.
__ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
« no previous file with comments | « src/typing.cc ('k') | test/cctest/test-parsing.cc » ('j') | test/js-perf-test/JSTests.json » ('J')

Powered by Google App Engine
This is Rietveld 408576698