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

Side by Side Diff: src/ia32/full-codegen-ia32.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_IA32 7 #if V8_TARGET_ARCH_IA32
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 2938 matching lines...) Expand 10 before | Expand all | Expand 10 after
2949 __ push(Immediate(Smi::FromInt(language_mode()))); 2949 __ push(Immediate(Smi::FromInt(language_mode())));
2950 2950
2951 // Push the start position of the scope the calls resides in. 2951 // Push the start position of the scope the calls resides in.
2952 __ push(Immediate(Smi::FromInt(scope()->start_position()))); 2952 __ push(Immediate(Smi::FromInt(scope()->start_position())));
2953 2953
2954 // Do the runtime call. 2954 // Do the runtime call.
2955 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); 2955 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6);
2956 } 2956 }
2957 2957
2958 2958
2959 void FullCodeGenerator::EmitLoadSuperConstructor(SuperReference* super_ref) { 2959 void FullCodeGenerator::EmitLoadSuperConstructor() {
2960 DCHECK(super_ref != NULL);
2961 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 2960 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
2962 __ CallRuntime(Runtime::kGetPrototype, 1); 2961 __ CallRuntime(Runtime::kGetPrototype, 1);
2963 } 2962 }
2964 2963
2965 2964
2966 void FullCodeGenerator::VisitCall(Call* expr) { 2965 void FullCodeGenerator::VisitCall(Call* expr) {
2967 #ifdef DEBUG 2966 #ifdef DEBUG
2968 // We want to verify that RecordJSReturnSite gets called on all paths 2967 // We want to verify that RecordJSReturnSite gets called on all paths
2969 // through this function. Avoid early returns. 2968 // through this function. Avoid early returns.
2970 expr->return_is_recorded_ = false; 2969 expr->return_is_recorded_ = false;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
3068 EmitCallWithLoadIC(expr); 3067 EmitCallWithLoadIC(expr);
3069 } else { 3068 } else {
3070 EmitKeyedCallWithLoadIC(expr, property->key()); 3069 EmitKeyedCallWithLoadIC(expr, property->key());
3071 } 3070 }
3072 } 3071 }
3073 } else if (call_type == Call::SUPER_CALL) { 3072 } else if (call_type == Call::SUPER_CALL) {
3074 if (FLAG_experimental_classes) { 3073 if (FLAG_experimental_classes) {
3075 EmitSuperConstructorCall(expr); 3074 EmitSuperConstructorCall(expr);
3076 } else { 3075 } else {
3077 SuperReference* super_ref = callee->AsSuperReference(); 3076 SuperReference* super_ref = callee->AsSuperReference();
3078 EmitLoadSuperConstructor(super_ref); 3077 EmitLoadSuperConstructor();
3079 __ push(result_register()); 3078 __ push(result_register());
3080 VisitForStackValue(super_ref->this_var()); 3079 VisitForStackValue(super_ref->this_var());
3081 EmitCall(expr, CallICState::METHOD); 3080 EmitCall(expr, CallICState::METHOD);
3082 } 3081 }
3083 } else { 3082 } else {
3084 DCHECK(call_type == Call::OTHER_CALL); 3083 DCHECK(call_type == Call::OTHER_CALL);
3085 // Call to an arbitrary expression not handled specially above. 3084 // Call to an arbitrary expression not handled specially above.
3086 { PreservePositionScope scope(masm()->positions_recorder()); 3085 { PreservePositionScope scope(masm()->positions_recorder());
3087 VisitForStackValue(callee); 3086 VisitForStackValue(callee);
3088 } 3087 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3141 context()->Plug(eax); 3140 context()->Plug(eax);
3142 } 3141 }
3143 3142
3144 3143
3145 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { 3144 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) {
3146 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); 3145 Variable* new_target_var = scope()->DeclarationScope()->new_target_var();
3147 GetVar(eax, new_target_var); 3146 GetVar(eax, new_target_var);
3148 __ push(eax); 3147 __ push(eax);
3149 3148
3150 SuperReference* super_ref = expr->expression()->AsSuperReference(); 3149 SuperReference* super_ref = expr->expression()->AsSuperReference();
3151 EmitLoadSuperConstructor(super_ref); 3150 EmitLoadSuperConstructor();
3152 __ push(result_register()); 3151 __ push(result_register());
3153 3152
3154 Variable* this_var = super_ref->this_var()->var(); 3153 Variable* this_var = super_ref->this_var()->var();
3155 GetVar(eax, this_var); 3154 GetVar(eax, this_var);
3156 __ cmp(eax, isolate()->factory()->the_hole_value()); 3155 __ cmp(eax, isolate()->factory()->the_hole_value());
3157 Label uninitialized_this; 3156 Label uninitialized_this;
3158 __ j(equal, &uninitialized_this); 3157 __ j(equal, &uninitialized_this);
3159 __ push(Immediate(this_var->name())); 3158 __ push(Immediate(this_var->name()));
3160 __ CallRuntime(Runtime::kThrowReferenceError, 1); 3159 __ CallRuntime(Runtime::kThrowReferenceError, 1);
3161 __ bind(&uninitialized_this); 3160 __ bind(&uninitialized_this);
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
4064 4063
4065 __ bind(&runtime); 4064 __ bind(&runtime);
4066 __ push(eax); 4065 __ push(eax);
4067 __ CallRuntime(Runtime::kCall, args->length()); 4066 __ CallRuntime(Runtime::kCall, args->length());
4068 __ bind(&done); 4067 __ bind(&done);
4069 4068
4070 context()->Plug(eax); 4069 context()->Plug(eax);
4071 } 4070 }
4072 4071
4073 4072
4073 void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) {
4074 Variable* new_target_var = scope()->DeclarationScope()->new_target_var();
4075 GetVar(eax, new_target_var);
4076 __ push(eax);
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 __ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
4084 __ mov(ecx, Operand(edx, StandardFrameConstants::kContextOffset));
4085 __ cmp(ecx, Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
4086 __ j(equal, &adaptor_frame);
4087 // default constructor has no arguments, so no adaptor frame means no args.
4088 __ mov(eax, Immediate(0));
4089 __ jmp(&args_set_up);
4090
4091 // Copy arguments from adaptor frame.
4092 {
4093 __ bind(&adaptor_frame);
4094 __ mov(ecx, Operand(edx, ArgumentsAdaptorFrameConstants::kLengthOffset));
4095 __ SmiUntag(ecx);
4096
4097 // Subtract 1 from arguments count, for new.target.
4098 __ sub(ecx, Immediate(1));
4099 __ mov(eax, ecx);
4100 __ lea(edx, Operand(edx, ecx, times_pointer_size,
4101 StandardFrameConstants::kCallerSPOffset));
4102 Label loop;
4103 __ bind(&loop);
4104 __ push(Operand(edx, -1 * kPointerSize));
4105 __ sub(edx, Immediate(kPointerSize));
4106 __ dec(ecx);
4107 __ j(not_zero, &loop);
4108 }
4109
4110 __ bind(&args_set_up);
4111 __ mov(edi, Operand(esp, eax, 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(eax);
4119 }
4120
4121
4074 void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) { 4122 void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) {
4075 // Load the arguments on the stack and call the stub. 4123 // Load the arguments on the stack and call the stub.
4076 RegExpConstructResultStub stub(isolate()); 4124 RegExpConstructResultStub stub(isolate());
4077 ZoneList<Expression*>* args = expr->arguments(); 4125 ZoneList<Expression*>* args = expr->arguments();
4078 DCHECK(args->length() == 3); 4126 DCHECK(args->length() == 3);
4079 VisitForStackValue(args->at(0)); 4127 VisitForStackValue(args->at(0));
4080 VisitForStackValue(args->at(1)); 4128 VisitForStackValue(args->at(1));
4081 VisitForAccumulatorValue(args->at(2)); 4129 VisitForAccumulatorValue(args->at(2));
4082 __ pop(ebx); 4130 __ pop(ebx);
4083 __ pop(ecx); 4131 __ pop(ecx);
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after
5303 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5351 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5304 Assembler::target_address_at(call_target_address, 5352 Assembler::target_address_at(call_target_address,
5305 unoptimized_code)); 5353 unoptimized_code));
5306 return OSR_AFTER_STACK_CHECK; 5354 return OSR_AFTER_STACK_CHECK;
5307 } 5355 }
5308 5356
5309 5357
5310 } } // namespace v8::internal 5358 } } // namespace v8::internal
5311 5359
5312 #endif // V8_TARGET_ARCH_IA32 5360 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/parser.h » ('j') | src/x64/code-stubs-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698