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

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

Issue 918603004: new classes: implement correct check for uninitialized this in 'super()' (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix 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/arm64/full-codegen-arm64.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »
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 3128 matching lines...) Expand 10 before | Expand all | Expand 10 after
3139 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); 3139 PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
3140 context()->Plug(eax); 3140 context()->Plug(eax);
3141 } 3141 }
3142 3142
3143 3143
3144 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { 3144 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) {
3145 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); 3145 Variable* new_target_var = scope()->DeclarationScope()->new_target_var();
3146 GetVar(eax, new_target_var); 3146 GetVar(eax, new_target_var);
3147 __ push(eax); 3147 __ push(eax);
3148 3148
3149 SuperReference* super_ref = expr->expression()->AsSuperReference();
3150 EmitLoadSuperConstructor(); 3149 EmitLoadSuperConstructor();
3151 __ push(result_register()); 3150 __ push(result_register());
3152 3151
3153 Variable* this_var = super_ref->this_var()->var();
3154 GetVar(eax, this_var);
3155 __ cmp(eax, isolate()->factory()->the_hole_value());
3156 Label uninitialized_this;
3157 __ j(equal, &uninitialized_this);
3158 __ push(Immediate(this_var->name()));
3159 __ CallRuntime(Runtime::kThrowReferenceError, 1);
3160 __ bind(&uninitialized_this);
3161
3162 // Push the arguments ("left-to-right") on the stack. 3152 // Push the arguments ("left-to-right") on the stack.
3163 ZoneList<Expression*>* args = expr->arguments(); 3153 ZoneList<Expression*>* args = expr->arguments();
3164 int arg_count = args->length(); 3154 int arg_count = args->length();
3165 for (int i = 0; i < arg_count; i++) { 3155 for (int i = 0; i < arg_count; i++) {
3166 VisitForStackValue(args->at(i)); 3156 VisitForStackValue(args->at(i));
3167 } 3157 }
3168 3158
3169 // Call the construct call builtin that handles allocation and 3159 // Call the construct call builtin that handles allocation and
3170 // constructor invocation. 3160 // constructor invocation.
3171 SetSourcePosition(expr->position()); 3161 SetSourcePosition(expr->position());
(...skipping 15 matching lines...) Expand all
3187 __ LoadHeapObject(ebx, FeedbackVector()); 3177 __ LoadHeapObject(ebx, FeedbackVector());
3188 __ mov(edx, Immediate(SmiFromSlot(expr->CallFeedbackSlot()))); 3178 __ mov(edx, Immediate(SmiFromSlot(expr->CallFeedbackSlot())));
3189 3179
3190 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); 3180 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET);
3191 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); 3181 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL);
3192 3182
3193 __ Drop(1); 3183 __ Drop(1);
3194 3184
3195 RecordJSReturnSite(expr); 3185 RecordJSReturnSite(expr);
3196 3186
3187 SuperReference* super_ref = expr->expression()->AsSuperReference();
3188 Variable* this_var = super_ref->this_var()->var();
3189 GetVar(ecx, this_var);
3190 __ cmp(ecx, isolate()->factory()->the_hole_value());
3191 Label uninitialized_this;
3192 __ j(equal, &uninitialized_this);
3193 __ push(Immediate(this_var->name()));
3194 __ CallRuntime(Runtime::kThrowReferenceError, 1);
3195 __ bind(&uninitialized_this);
3196
3197 EmitVariableAssignment(this_var, Token::INIT_CONST); 3197 EmitVariableAssignment(this_var, Token::INIT_CONST);
3198 context()->Plug(eax); 3198 context()->Plug(eax);
3199 } 3199 }
3200 3200
3201 3201
3202 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { 3202 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) {
3203 ZoneList<Expression*>* args = expr->arguments(); 3203 ZoneList<Expression*>* args = expr->arguments();
3204 DCHECK(args->length() == 1); 3204 DCHECK(args->length() == 1);
3205 3205
3206 VisitForAccumulatorValue(args->at(0)); 3206 VisitForAccumulatorValue(args->at(0));
(...skipping 2144 matching lines...) Expand 10 before | Expand all | Expand 10 after
5351 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5351 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5352 Assembler::target_address_at(call_target_address, 5352 Assembler::target_address_at(call_target_address,
5353 unoptimized_code)); 5353 unoptimized_code));
5354 return OSR_AFTER_STACK_CHECK; 5354 return OSR_AFTER_STACK_CHECK;
5355 } 5355 }
5356 5356
5357 5357
5358 } } // namespace v8::internal 5358 } } // namespace v8::internal
5359 5359
5360 #endif // V8_TARGET_ARCH_IA32 5360 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/arm64/full-codegen-arm64.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698