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

Side by Side 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: Remove --harmony-spread flag Created 5 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_X64 7 #if V8_TARGET_ARCH_X64
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 3006 matching lines...) Expand 10 before | Expand all | Expand 10 after
3017 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); 3017 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6);
3018 } 3018 }
3019 3019
3020 3020
3021 void FullCodeGenerator::EmitLoadSuperConstructor() { 3021 void FullCodeGenerator::EmitLoadSuperConstructor() {
3022 __ Push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 3022 __ Push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
3023 __ CallRuntime(Runtime::kGetPrototype, 1); 3023 __ CallRuntime(Runtime::kGetPrototype, 1);
3024 } 3024 }
3025 3025
3026 3026
3027 void FullCodeGenerator::EmitInitializeThisAfterSuper(
3028 SuperReference* super_ref) {
3029 Variable* this_var = super_ref->this_var()->var();
3030 GetVar(rcx, this_var);
3031 __ CompareRoot(rcx, Heap::kTheHoleValueRootIndex);
3032 Label uninitialized_this;
3033 __ j(equal, &uninitialized_this);
3034 __ Push(this_var->name());
3035 __ CallRuntime(Runtime::kThrowReferenceError, 1);
3036 __ bind(&uninitialized_this);
3037
3038 EmitVariableAssignment(this_var, Token::INIT_CONST);
3039 }
3040
3041
3027 void FullCodeGenerator::VisitCall(Call* expr) { 3042 void FullCodeGenerator::VisitCall(Call* expr) {
3028 #ifdef DEBUG 3043 #ifdef DEBUG
3029 // We want to verify that RecordJSReturnSite gets called on all paths 3044 // We want to verify that RecordJSReturnSite gets called on all paths
3030 // through this function. Avoid early returns. 3045 // through this function. Avoid early returns.
3031 expr->return_is_recorded_ = false; 3046 expr->return_is_recorded_ = false;
3032 #endif 3047 #endif
3033 3048
3034 Comment cmnt(masm_, "[ Call"); 3049 Comment cmnt(masm_, "[ Call");
3035 Expression* callee = expr->expression(); 3050 Expression* callee = expr->expression();
3036 Call::CallType call_type = expr->GetCallType(isolate()); 3051 Call::CallType call_type = expr->GetCallType(isolate());
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
3231 __ Move(rbx, FeedbackVector()); 3246 __ Move(rbx, FeedbackVector());
3232 __ Move(rdx, SmiFromSlot(expr->CallFeedbackSlot())); 3247 __ Move(rdx, SmiFromSlot(expr->CallFeedbackSlot()));
3233 3248
3234 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); 3249 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET);
3235 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); 3250 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL);
3236 3251
3237 __ Drop(1); 3252 __ Drop(1);
3238 3253
3239 RecordJSReturnSite(expr); 3254 RecordJSReturnSite(expr);
3240 3255
3241 SuperReference* super_ref = expr->expression()->AsSuperReference(); 3256 EmitInitializeThisAfterSuper(expr->expression()->AsSuperReference());
3242 Variable* this_var = super_ref->this_var()->var();
3243 GetVar(rcx, this_var);
3244 __ CompareRoot(rcx, Heap::kTheHoleValueRootIndex);
3245 Label uninitialized_this;
3246 __ j(equal, &uninitialized_this);
3247 __ Push(this_var->name());
3248 __ CallRuntime(Runtime::kThrowReferenceError, 1);
3249 __ bind(&uninitialized_this);
3250
3251 EmitVariableAssignment(this_var, Token::INIT_CONST);
3252 context()->Plug(rax); 3257 context()->Plug(rax);
3253 } 3258 }
3254 3259
3255 3260
3256 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { 3261 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) {
3257 ZoneList<Expression*>* args = expr->arguments(); 3262 ZoneList<Expression*>* args = expr->arguments();
3258 DCHECK(args->length() == 1); 3263 DCHECK(args->length() == 1);
3259 3264
3260 VisitForAccumulatorValue(args->at(0)); 3265 VisitForAccumulatorValue(args->at(0));
3261 3266
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after
4589 } else { 4594 } else {
4590 CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId()); 4595 CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId());
4591 } 4596 }
4592 4597
4593 // Push the target function under the receiver. 4598 // Push the target function under the receiver.
4594 __ Push(Operand(rsp, 0)); 4599 __ Push(Operand(rsp, 0));
4595 __ movp(Operand(rsp, kPointerSize), rax); 4600 __ movp(Operand(rsp, kPointerSize), rax);
4596 4601
4597 // Push the arguments ("left-to-right"). 4602 // Push the arguments ("left-to-right").
4598 for (int i = 0; i < arg_count; i++) { 4603 for (int i = 0; i < arg_count; i++) {
4599 VisitForStackValue(args->at(i)); 4604 VisitForStackValue(args->at(i), true);
4600 } 4605 }
4601 4606
4602 // Record source position of the IC call. 4607 // Record source position of the IC call.
4603 SetSourcePosition(expr->position()); 4608 SetSourcePosition(expr->position());
4604 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); 4609 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS);
4605 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); 4610 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize));
4606 __ CallStub(&stub); 4611 __ CallStub(&stub);
4607 4612
4608 // Restore context register. 4613 // Restore context register.
4609 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); 4614 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
4610 context()->DropAndPlug(1, rax); 4615 context()->DropAndPlug(1, rax);
4611 4616 if (expr->IsSuperCall()) {
arv (Not doing code reviews) 2015/03/30 22:19:49 This is a bit strange/hacky. I assume this comes f
caitp (gmail) 2015/03/30 22:38:12 it's kind of a hack, yeah... but, without it, `thi
Dmitry Lomov (no reviews) 2015/03/31 10:09:42 IsSuperCall flag on CallRuntime node is super-hack
4617 EmitInitializeThisAfterSuper(args->at(0)->AsSuperReference());
4618 }
4612 } else { 4619 } else {
4613 const Runtime::Function* function = expr->function(); 4620 const Runtime::Function* function = expr->function();
4614 switch (function->function_id) { 4621 switch (function->function_id) {
4615 #define CALL_INTRINSIC_GENERATOR(Name) \ 4622 #define CALL_INTRINSIC_GENERATOR(Name) \
4616 case Runtime::kInline##Name: { \ 4623 case Runtime::kInline##Name: { \
4617 Comment cmnt(masm_, "[ Inline" #Name); \ 4624 Comment cmnt(masm_, "[ Inline" #Name); \
4618 return Emit##Name(expr); \ 4625 return Emit##Name(expr); \
4619 } 4626 }
4620 FOR_EACH_FULL_CODE_INTRINSIC(CALL_INTRINSIC_GENERATOR) 4627 FOR_EACH_FULL_CODE_INTRINSIC(CALL_INTRINSIC_GENERATOR)
4621 #undef CALL_INTRINSIC_GENERATOR 4628 #undef CALL_INTRINSIC_GENERATOR
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
5406 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5413 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5407 Assembler::target_address_at(call_target_address, 5414 Assembler::target_address_at(call_target_address,
5408 unoptimized_code)); 5415 unoptimized_code));
5409 return OSR_AFTER_STACK_CHECK; 5416 return OSR_AFTER_STACK_CHECK;
5410 } 5417 }
5411 5418
5412 5419
5413 } } // namespace v8::internal 5420 } } // namespace v8::internal
5414 5421
5415 #endif // V8_TARGET_ARCH_X64 5422 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698