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

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: 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
« no previous file with comments | « src/hydrogen.cc ('k') | src/parser.h » ('j') | src/parser.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2937 matching lines...) Expand 10 before | Expand all | Expand 10 after
2948 __ push(Immediate(Smi::FromInt(language_mode()))); 2948 __ push(Immediate(Smi::FromInt(language_mode())));
2949 2949
2950 // Push the start position of the scope the calls resides in. 2950 // Push the start position of the scope the calls resides in.
2951 __ push(Immediate(Smi::FromInt(scope()->start_position()))); 2951 __ push(Immediate(Smi::FromInt(scope()->start_position())));
2952 2952
2953 // Do the runtime call. 2953 // Do the runtime call.
2954 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); 2954 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6);
2955 } 2955 }
2956 2956
2957 2957
2958 void FullCodeGenerator::EmitLoadSuperConstructor(SuperReference* super_ref) { 2958 void FullCodeGenerator::EmitLoadSuperConstructor() {
2959 DCHECK(super_ref != NULL);
2960 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 2959 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
2961 __ CallRuntime(Runtime::kGetPrototype, 1); 2960 __ CallRuntime(Runtime::kGetPrototype, 1);
2962 } 2961 }
2963 2962
2964 2963
2965 void FullCodeGenerator::VisitCall(Call* expr) { 2964 void FullCodeGenerator::VisitCall(Call* expr) {
2966 #ifdef DEBUG 2965 #ifdef DEBUG
2967 // We want to verify that RecordJSReturnSite gets called on all paths 2966 // We want to verify that RecordJSReturnSite gets called on all paths
2968 // through this function. Avoid early returns. 2967 // through this function. Avoid early returns.
2969 expr->return_is_recorded_ = false; 2968 expr->return_is_recorded_ = false;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
3067 EmitCallWithLoadIC(expr); 3066 EmitCallWithLoadIC(expr);
3068 } else { 3067 } else {
3069 EmitKeyedCallWithLoadIC(expr, property->key()); 3068 EmitKeyedCallWithLoadIC(expr, property->key());
3070 } 3069 }
3071 } 3070 }
3072 } else if (call_type == Call::SUPER_CALL) { 3071 } else if (call_type == Call::SUPER_CALL) {
3073 if (FLAG_experimental_classes) { 3072 if (FLAG_experimental_classes) {
3074 EmitSuperConstructorCall(expr); 3073 EmitSuperConstructorCall(expr);
3075 } else { 3074 } else {
3076 SuperReference* super_ref = callee->AsSuperReference(); 3075 SuperReference* super_ref = callee->AsSuperReference();
3077 EmitLoadSuperConstructor(super_ref); 3076 EmitLoadSuperConstructor();
3078 __ push(result_register()); 3077 __ push(result_register());
3079 VisitForStackValue(super_ref->this_var()); 3078 VisitForStackValue(super_ref->this_var());
3080 EmitCall(expr, CallICState::METHOD); 3079 EmitCall(expr, CallICState::METHOD);
3081 } 3080 }
3082 } else { 3081 } else {
3083 DCHECK(call_type == Call::OTHER_CALL); 3082 DCHECK(call_type == Call::OTHER_CALL);
3084 // Call to an arbitrary expression not handled specially above. 3083 // Call to an arbitrary expression not handled specially above.
3085 { PreservePositionScope scope(masm()->positions_recorder()); 3084 { PreservePositionScope scope(masm()->positions_recorder());
3086 VisitForStackValue(callee); 3085 VisitForStackValue(callee);
3087 } 3086 }
(...skipping 11 matching lines...) Expand all
3099 3098
3100 void FullCodeGenerator::VisitCallNew(CallNew* expr) { 3099 void FullCodeGenerator::VisitCallNew(CallNew* expr) {
3101 Comment cmnt(masm_, "[ CallNew"); 3100 Comment cmnt(masm_, "[ CallNew");
3102 // According to ECMA-262, section 11.2.2, page 44, the function 3101 // According to ECMA-262, section 11.2.2, page 44, the function
3103 // expression in new calls must be evaluated before the 3102 // expression in new calls must be evaluated before the
3104 // arguments. 3103 // arguments.
3105 3104
3106 // Push constructor on the stack. If it's not a function it's used as 3105 // Push constructor on the stack. If it's not a function it's used as
3107 // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is 3106 // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is
3108 // ignored. 3107 // ignored.
3109 if (expr->expression()->IsSuperReference()) { 3108 if (expr->expression()->IsSuperReference()) {
arv (Not doing code reviews) 2015/02/11 14:53:48 This is dead code... see https://codereview.chromi
Dmitry Lomov (no reviews) 2015/02/11 16:29:36 Will rebase
3110 EmitLoadSuperConstructor(expr->expression()->AsSuperReference()); 3109 EmitLoadSuperConstructor();
3111 __ push(result_register()); 3110 __ push(result_register());
3112 } else { 3111 } else {
3113 VisitForStackValue(expr->expression()); 3112 VisitForStackValue(expr->expression());
3114 } 3113 }
3115 3114
3116 // Push the arguments ("left-to-right") on the stack. 3115 // Push the arguments ("left-to-right") on the stack.
3117 ZoneList<Expression*>* args = expr->arguments(); 3116 ZoneList<Expression*>* args = expr->arguments();
3118 int arg_count = args->length(); 3117 int arg_count = args->length();
3119 for (int i = 0; i < arg_count; i++) { 3118 for (int i = 0; i < arg_count; i++) {
3120 VisitForStackValue(args->at(i)); 3119 VisitForStackValue(args->at(i));
(...skipping 23 matching lines...) Expand all
3144 context()->Plug(eax); 3143 context()->Plug(eax);
3145 } 3144 }
3146 3145
3147 3146
3148 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { 3147 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) {
3149 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); 3148 Variable* new_target_var = scope()->DeclarationScope()->new_target_var();
3150 GetVar(eax, new_target_var); 3149 GetVar(eax, new_target_var);
3151 __ push(eax); 3150 __ push(eax);
3152 3151
3153 SuperReference* super_ref = expr->expression()->AsSuperReference(); 3152 SuperReference* super_ref = expr->expression()->AsSuperReference();
3154 EmitLoadSuperConstructor(super_ref); 3153 EmitLoadSuperConstructor();
3155 __ push(result_register()); 3154 __ push(result_register());
3156 3155
3157 Variable* this_var = super_ref->this_var()->var(); 3156 Variable* this_var = super_ref->this_var()->var();
3158 GetVar(eax, this_var); 3157 GetVar(eax, this_var);
3159 __ cmp(eax, isolate()->factory()->the_hole_value()); 3158 __ cmp(eax, isolate()->factory()->the_hole_value());
3160 Label uninitialized_this; 3159 Label uninitialized_this;
3161 __ j(equal, &uninitialized_this); 3160 __ j(equal, &uninitialized_this);
3162 __ push(Immediate(this_var->name())); 3161 __ push(Immediate(this_var->name()));
3163 __ CallRuntime(Runtime::kThrowReferenceError, 1); 3162 __ CallRuntime(Runtime::kThrowReferenceError, 1);
3164 __ bind(&uninitialized_this); 3163 __ bind(&uninitialized_this);
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
4067 4066
4068 __ bind(&runtime); 4067 __ bind(&runtime);
4069 __ push(eax); 4068 __ push(eax);
4070 __ CallRuntime(Runtime::kCall, args->length()); 4069 __ CallRuntime(Runtime::kCall, args->length());
4071 __ bind(&done); 4070 __ bind(&done);
4072 4071
4073 context()->Plug(eax); 4072 context()->Plug(eax);
4074 } 4073 }
4075 4074
4076 4075
4076 void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) {
4077 Variable* new_target_var = scope()->DeclarationScope()->new_target_var();
4078 GetVar(eax, new_target_var);
4079 __ push(eax);
4080
4081 EmitLoadSuperConstructor();
4082 __ push(result_register());
4083
4084
arv (Not doing code reviews) 2015/02/11 14:53:48 remove empty line
Dmitry Lomov (no reviews) 2015/02/11 16:29:36 Done.
4085 // Check if the calling frame is an arguments adaptor frame.
4086 Label adaptor_frame, args_set_up, runtime;
4087 __ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
4088 __ mov(ecx, Operand(edx, StandardFrameConstants::kContextOffset));
4089 __ cmp(ecx, Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
4090 __ j(equal, &adaptor_frame);
4091 // default constructor has no arguments, so no adaptor frame means no args.
4092 __ mov(eax, Immediate(0));
4093 __ jmp(&args_set_up);
4094
4095 // Copy arguments from adaptor frame.
4096 {
4097 __ bind(&adaptor_frame);
4098 __ mov(ecx, Operand(edx, ArgumentsAdaptorFrameConstants::kLengthOffset));
4099 __ SmiUntag(ecx);
4100
4101 // Subtract 1 from smi-tagged arguments count, for new.target.
4102 __ sub(ecx, Immediate(1));
4103 __ mov(eax, ecx);
4104 __ lea(edx, Operand(edx, ecx, times_pointer_size,
4105 StandardFrameConstants::kCallerSPOffset));
4106 Label loop;
4107 __ bind(&loop);
4108 __ push(Operand(edx, -1 * kPointerSize));
4109 __ sub(edx, Immediate(kPointerSize));
4110 __ dec(ecx);
4111 __ j(not_zero, &loop);
4112 }
4113
4114 __ bind(&args_set_up);
4115 __ mov(edi, Operand(esp, eax, times_pointer_size, 0));
4116
4117 CallConstructStub stub(isolate(), SUPER_CONSTRUCTOR_CALL);
4118 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL);
4119
4120 __ Drop(1);
4121
4122 context()->Plug(eax);
4123 }
4124
4125
4077 void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) { 4126 void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) {
4078 // Load the arguments on the stack and call the stub. 4127 // Load the arguments on the stack and call the stub.
4079 RegExpConstructResultStub stub(isolate()); 4128 RegExpConstructResultStub stub(isolate());
4080 ZoneList<Expression*>* args = expr->arguments(); 4129 ZoneList<Expression*>* args = expr->arguments();
4081 DCHECK(args->length() == 3); 4130 DCHECK(args->length() == 3);
4082 VisitForStackValue(args->at(0)); 4131 VisitForStackValue(args->at(0));
4083 VisitForStackValue(args->at(1)); 4132 VisitForStackValue(args->at(1));
4084 VisitForAccumulatorValue(args->at(2)); 4133 VisitForAccumulatorValue(args->at(2));
4085 __ pop(ebx); 4134 __ pop(ebx);
4086 __ pop(ecx); 4135 __ pop(ecx);
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after
5306 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5355 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5307 Assembler::target_address_at(call_target_address, 5356 Assembler::target_address_at(call_target_address,
5308 unoptimized_code)); 5357 unoptimized_code));
5309 return OSR_AFTER_STACK_CHECK; 5358 return OSR_AFTER_STACK_CHECK;
5310 } 5359 }
5311 5360
5312 5361
5313 } } // namespace v8::internal 5362 } } // namespace v8::internal
5314 5363
5315 #endif // V8_TARGET_ARCH_IA32 5364 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/parser.h » ('j') | src/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698