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

Side by Side Diff: src/arm/full-codegen-arm.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 | « no previous file | src/arm64/full-codegen-arm64.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_ARM 7 #if V8_TARGET_ARCH_ARM
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 3252 matching lines...) Expand 10 before | Expand all | Expand 10 after
3263 3263
3264 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { 3264 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) {
3265 Comment cmnt(masm_, "[ SuperConstructorCall"); 3265 Comment cmnt(masm_, "[ SuperConstructorCall");
3266 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); 3266 Variable* new_target_var = scope()->DeclarationScope()->new_target_var();
3267 GetVar(result_register(), new_target_var); 3267 GetVar(result_register(), new_target_var);
3268 __ Push(result_register()); 3268 __ Push(result_register());
3269 3269
3270 EmitLoadSuperConstructor(); 3270 EmitLoadSuperConstructor();
3271 __ push(result_register()); 3271 __ push(result_register());
3272 3272
3273 SuperReference* super_ref = expr->expression()->AsSuperReference();
3274 Variable* this_var = super_ref->this_var()->var();
3275
3276 GetVar(r0, this_var);
3277 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex);
3278 Label uninitialized_this;
3279 __ b(eq, &uninitialized_this);
3280 __ mov(r0, Operand(this_var->name()));
3281 __ Push(r0);
3282 __ CallRuntime(Runtime::kThrowReferenceError, 1);
3283 __ bind(&uninitialized_this);
3284
3285 // Push the arguments ("left-to-right") on the stack. 3273 // Push the arguments ("left-to-right") on the stack.
3286 ZoneList<Expression*>* args = expr->arguments(); 3274 ZoneList<Expression*>* args = expr->arguments();
3287 int arg_count = args->length(); 3275 int arg_count = args->length();
3288 for (int i = 0; i < arg_count; i++) { 3276 for (int i = 0; i < arg_count; i++) {
3289 VisitForStackValue(args->at(i)); 3277 VisitForStackValue(args->at(i));
3290 } 3278 }
3291 3279
3292 // Call the construct call builtin that handles allocation and 3280 // Call the construct call builtin that handles allocation and
3293 // constructor invocation. 3281 // constructor invocation.
3294 SetSourcePosition(expr->position()); 3282 SetSourcePosition(expr->position());
(...skipping 15 matching lines...) Expand all
3310 __ Move(r2, FeedbackVector()); 3298 __ Move(r2, FeedbackVector());
3311 __ mov(r3, Operand(SmiFromSlot(expr->CallFeedbackSlot()))); 3299 __ mov(r3, Operand(SmiFromSlot(expr->CallFeedbackSlot())));
3312 3300
3313 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); 3301 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET);
3314 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); 3302 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL);
3315 3303
3316 __ Drop(1); 3304 __ Drop(1);
3317 3305
3318 RecordJSReturnSite(expr); 3306 RecordJSReturnSite(expr);
3319 3307
3308 SuperReference* super_ref = expr->expression()->AsSuperReference();
3309 Variable* this_var = super_ref->this_var()->var();
3310 GetVar(r1, this_var);
3311 __ CompareRoot(r1, Heap::kTheHoleValueRootIndex);
3312 Label uninitialized_this;
3313 __ b(eq, &uninitialized_this);
3314 __ mov(r0, Operand(this_var->name()));
3315 __ Push(r0);
3316 __ CallRuntime(Runtime::kThrowReferenceError, 1);
3317 __ bind(&uninitialized_this);
3318
3320 EmitVariableAssignment(this_var, Token::INIT_CONST); 3319 EmitVariableAssignment(this_var, Token::INIT_CONST);
3321 context()->Plug(r0); 3320 context()->Plug(r0);
3322 } 3321 }
3323 3322
3324 3323
3325 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { 3324 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) {
3326 ZoneList<Expression*>* args = expr->arguments(); 3325 ZoneList<Expression*>* args = expr->arguments();
3327 DCHECK(args->length() == 1); 3326 DCHECK(args->length() == 1);
3328 3327
3329 VisitForAccumulatorValue(args->at(0)); 3328 VisitForAccumulatorValue(args->at(0));
(...skipping 2161 matching lines...) Expand 10 before | Expand all | Expand 10 after
5491 5490
5492 DCHECK(interrupt_address == 5491 DCHECK(interrupt_address ==
5493 isolate->builtins()->OsrAfterStackCheck()->entry()); 5492 isolate->builtins()->OsrAfterStackCheck()->entry());
5494 return OSR_AFTER_STACK_CHECK; 5493 return OSR_AFTER_STACK_CHECK;
5495 } 5494 }
5496 5495
5497 5496
5498 } } // namespace v8::internal 5497 } } // namespace v8::internal
5499 5498
5500 #endif // V8_TARGET_ARCH_ARM 5499 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm64/full-codegen-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698