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

Side by Side Diff: src/x64/full-codegen-x64.cc

Issue 917753002: new classes: implement default constructors. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase to run try jobs Created 5 years, 10 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 2944 matching lines...) Expand 10 before | Expand all | Expand 10 after
2955 __ Push(Smi::FromInt(language_mode())); 2955 __ Push(Smi::FromInt(language_mode()));
2956 2956
2957 // Push the start position of the scope the calls resides in. 2957 // Push the start position of the scope the calls resides in.
2958 __ Push(Smi::FromInt(scope()->start_position())); 2958 __ Push(Smi::FromInt(scope()->start_position()));
2959 2959
2960 // Do the runtime call. 2960 // Do the runtime call.
2961 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); 2961 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6);
2962 } 2962 }
2963 2963
2964 2964
2965 void FullCodeGenerator::EmitLoadSuperConstructor(SuperReference* super_ref) { 2965 void FullCodeGenerator::EmitLoadSuperConstructor() {
2966 DCHECK(super_ref != NULL);
2967 __ Push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 2966 __ Push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
2968 __ CallRuntime(Runtime::kGetPrototype, 1); 2967 __ CallRuntime(Runtime::kGetPrototype, 1);
2969 } 2968 }
2970 2969
2971 2970
2972 void FullCodeGenerator::VisitCall(Call* expr) { 2971 void FullCodeGenerator::VisitCall(Call* expr) {
2973 #ifdef DEBUG 2972 #ifdef DEBUG
2974 // We want to verify that RecordJSReturnSite gets called on all paths 2973 // We want to verify that RecordJSReturnSite gets called on all paths
2975 // through this function. Avoid early returns. 2974 // through this function. Avoid early returns.
2976 expr->return_is_recorded_ = false; 2975 expr->return_is_recorded_ = false;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
3073 if (is_named_call) { 3072 if (is_named_call) {
3074 EmitCallWithLoadIC(expr); 3073 EmitCallWithLoadIC(expr);
3075 } else { 3074 } else {
3076 EmitKeyedCallWithLoadIC(expr, property->key()); 3075 EmitKeyedCallWithLoadIC(expr, property->key());
3077 } 3076 }
3078 } 3077 }
3079 } else if (call_type == Call::SUPER_CALL) { 3078 } else if (call_type == Call::SUPER_CALL) {
3080 if (FLAG_experimental_classes) { 3079 if (FLAG_experimental_classes) {
3081 EmitSuperConstructorCall(expr); 3080 EmitSuperConstructorCall(expr);
3082 } else { 3081 } else {
3082 EmitLoadSuperConstructor();
3083 __ Push(result_register());
3083 SuperReference* super_ref = callee->AsSuperReference(); 3084 SuperReference* super_ref = callee->AsSuperReference();
3084 EmitLoadSuperConstructor(super_ref);
3085 __ Push(result_register());
3086 VisitForStackValue(super_ref->this_var()); 3085 VisitForStackValue(super_ref->this_var());
3087 EmitCall(expr, CallICState::METHOD); 3086 EmitCall(expr, CallICState::METHOD);
3088 } 3087 }
3089 } else { 3088 } else {
3090 DCHECK(call_type == Call::OTHER_CALL); 3089 DCHECK(call_type == Call::OTHER_CALL);
3091 // Call to an arbitrary expression not handled specially above. 3090 // Call to an arbitrary expression not handled specially above.
3092 { PreservePositionScope scope(masm()->positions_recorder()); 3091 { PreservePositionScope scope(masm()->positions_recorder());
3093 VisitForStackValue(callee); 3092 VisitForStackValue(callee);
3094 } 3093 }
3095 __ PushRoot(Heap::kUndefinedValueRootIndex); 3094 __ PushRoot(Heap::kUndefinedValueRootIndex);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3146 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); 3145 PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
3147 context()->Plug(rax); 3146 context()->Plug(rax);
3148 } 3147 }
3149 3148
3150 3149
3151 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { 3150 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) {
3152 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); 3151 Variable* new_target_var = scope()->DeclarationScope()->new_target_var();
3153 GetVar(result_register(), new_target_var); 3152 GetVar(result_register(), new_target_var);
3154 __ Push(result_register()); 3153 __ Push(result_register());
3155 3154
3156 SuperReference* super_ref = expr->expression()->AsSuperReference(); 3155 EmitLoadSuperConstructor();
3157 EmitLoadSuperConstructor(super_ref);
3158 __ Push(result_register()); 3156 __ Push(result_register());
3159 3157
3158 SuperReference* super_ref = expr->expression()->AsSuperReference();
3160 Variable* this_var = super_ref->this_var()->var(); 3159 Variable* this_var = super_ref->this_var()->var();
3161 3160
3162 GetVar(rax, this_var); 3161 GetVar(rax, this_var);
3163 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex); 3162 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
3164 Label uninitialized_this; 3163 Label uninitialized_this;
3165 __ j(equal, &uninitialized_this); 3164 __ j(equal, &uninitialized_this);
3166 __ Push(this_var->name()); 3165 __ Push(this_var->name());
3167 __ CallRuntime(Runtime::kThrowReferenceError, 1); 3166 __ CallRuntime(Runtime::kThrowReferenceError, 1);
3168 __ bind(&uninitialized_this); 3167 __ bind(&uninitialized_this);
3169 3168
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
4064 4063
4065 __ bind(&runtime); 4064 __ bind(&runtime);
4066 __ Push(rax); 4065 __ Push(rax);
4067 __ CallRuntime(Runtime::kCall, args->length()); 4066 __ CallRuntime(Runtime::kCall, args->length());
4068 __ bind(&done); 4067 __ bind(&done);
4069 4068
4070 context()->Plug(rax); 4069 context()->Plug(rax);
4071 } 4070 }
4072 4071
4073 4072
4073 void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) {
4074 Variable* new_target_var = scope()->DeclarationScope()->new_target_var();
4075 GetVar(result_register(), new_target_var);
4076 __ Push(result_register());
4077
4078 EmitLoadSuperConstructor();
4079 __ Push(result_register());
4080
4081 // Check if the calling frame is an arguments adaptor frame.
4082 Label adaptor_frame, args_set_up, runtime;
4083 __ movp(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
4084 __ movp(rcx, Operand(rdx, StandardFrameConstants::kContextOffset));
4085 __ Cmp(rcx, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
4086 __ j(equal, &adaptor_frame);
4087 // default constructor has no arguments, so no adaptor frame means no args.
4088 __ movp(rax, Immediate(0));
4089 __ jmp(&args_set_up);
4090
4091 // Copy arguments from adaptor frame.
4092 {
4093 __ bind(&adaptor_frame);
4094 __ movp(rcx, Operand(rdx, ArgumentsAdaptorFrameConstants::kLengthOffset));
4095 __ SmiToInteger64(rcx, rcx);
4096
4097 // Subtract 1 from arguments count, for new.target.
4098 __ subp(rcx, Immediate(1));
4099 __ movp(rax, rcx);
4100 __ leap(rdx, Operand(rdx, rcx, times_pointer_size,
4101 StandardFrameConstants::kCallerSPOffset));
4102 Label loop;
4103 __ bind(&loop);
4104 __ Push(Operand(rdx, -1 * kPointerSize));
4105 __ subp(rdx, Immediate(kPointerSize));
4106 __ decp(rcx);
4107 __ j(not_zero, &loop);
4108 }
4109
4110 __ bind(&args_set_up);
4111 __ movp(rdi, Operand(rsp, rax, times_pointer_size, 0));
4112
4113 CallConstructStub stub(isolate(), SUPER_CONSTRUCTOR_CALL);
4114 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL);
4115
4116 __ Drop(1);
4117
4118 context()->Plug(result_register());
4119 }
4120
4121
4074 void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) { 4122 void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) {
4075 RegExpConstructResultStub stub(isolate()); 4123 RegExpConstructResultStub stub(isolate());
4076 ZoneList<Expression*>* args = expr->arguments(); 4124 ZoneList<Expression*>* args = expr->arguments();
4077 DCHECK(args->length() == 3); 4125 DCHECK(args->length() == 3);
4078 VisitForStackValue(args->at(0)); 4126 VisitForStackValue(args->at(0));
4079 VisitForStackValue(args->at(1)); 4127 VisitForStackValue(args->at(1));
4080 VisitForAccumulatorValue(args->at(2)); 4128 VisitForAccumulatorValue(args->at(2));
4081 __ Pop(rbx); 4129 __ Pop(rbx);
4082 __ Pop(rcx); 4130 __ Pop(rcx);
4083 __ CallStub(&stub); 4131 __ CallStub(&stub);
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after
5329 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5377 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5330 Assembler::target_address_at(call_target_address, 5378 Assembler::target_address_at(call_target_address,
5331 unoptimized_code)); 5379 unoptimized_code));
5332 return OSR_AFTER_STACK_CHECK; 5380 return OSR_AFTER_STACK_CHECK;
5333 } 5381 }
5334 5382
5335 5383
5336 } } // namespace v8::internal 5384 } } // namespace v8::internal
5337 5385
5338 #endif // V8_TARGET_ARCH_X64 5386 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698