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

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

Issue 867153003: new classes: special construct stub for derived classs and TDZ for `this`. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: CR feedback Created 5 years, 11 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 1477 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 // if (false) { const x; }; var y = x; 1488 // if (false) { const x; }; var y = x;
1489 // 1489 //
1490 // The condition on the declaration scopes is a conservative check for 1490 // The condition on the declaration scopes is a conservative check for
1491 // nested functions that access a binding and are called before the 1491 // nested functions that access a binding and are called before the
1492 // binding is initialized: 1492 // binding is initialized:
1493 // function() { f(); let x = 1; function f() { x = 2; } } 1493 // function() { f(); let x = 1; function f() { x = 2; } }
1494 // 1494 //
1495 bool skip_init_check; 1495 bool skip_init_check;
1496 if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) { 1496 if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) {
1497 skip_init_check = false; 1497 skip_init_check = false;
1498 } else if (var->is_this()) {
1499 // TODO(dslomov): implement 'this' hole check elimination.
1500 skip_init_check = false;
1498 } else { 1501 } else {
1499 // Check that we always have valid source position. 1502 // Check that we always have valid source position.
1500 DCHECK(var->initializer_position() != RelocInfo::kNoPosition); 1503 DCHECK(var->initializer_position() != RelocInfo::kNoPosition);
1501 DCHECK(proxy->position() != RelocInfo::kNoPosition); 1504 DCHECK(proxy->position() != RelocInfo::kNoPosition);
1502 skip_init_check = var->mode() != CONST_LEGACY && 1505 skip_init_check = var->mode() != CONST_LEGACY &&
1503 var->initializer_position() < proxy->position(); 1506 var->initializer_position() < proxy->position();
1504 } 1507 }
1505 1508
1506 if (!skip_init_check) { 1509 if (!skip_init_check) {
1507 // Let and const need a read barrier. 1510 // Let and const need a read barrier.
(...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after
3136 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); 3139 PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
3137 context()->Plug(rax); 3140 context()->Plug(rax);
3138 } 3141 }
3139 3142
3140 3143
3141 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { 3144 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) {
3142 SuperReference* super_ref = expr->expression()->AsSuperReference(); 3145 SuperReference* super_ref = expr->expression()->AsSuperReference();
3143 EmitLoadSuperConstructor(super_ref); 3146 EmitLoadSuperConstructor(super_ref);
3144 __ Push(result_register()); 3147 __ Push(result_register());
3145 3148
3149 Variable* this_var = super_ref->this_var()->var();
3150
3151 GetVar(rax, this_var);
3152 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
3153 Label uninitialized_this;
3154 __ j(equal, &uninitialized_this);
3155 __ Push(this_var->name());
3156 __ CallRuntime(Runtime::kThrowReferenceError, 1);
3157 __ bind(&uninitialized_this);
3158
3159
3146 // Push the arguments ("left-to-right") on the stack. 3160 // Push the arguments ("left-to-right") on the stack.
3147 ZoneList<Expression*>* args = expr->arguments(); 3161 ZoneList<Expression*>* args = expr->arguments();
3148 int arg_count = args->length(); 3162 int arg_count = args->length();
3149 for (int i = 0; i < arg_count; i++) { 3163 for (int i = 0; i < arg_count; i++) {
3150 VisitForStackValue(args->at(i)); 3164 VisitForStackValue(args->at(i));
3151 } 3165 }
3152 3166
3153 // Call the construct call builtin that handles allocation and 3167 // Call the construct call builtin that handles allocation and
3154 // constructor invocation. 3168 // constructor invocation.
3155 SetSourcePosition(expr->position()); 3169 SetSourcePosition(expr->position());
(...skipping 14 matching lines...) Expand all
3170 3184
3171 __ Move(rbx, FeedbackVector()); 3185 __ Move(rbx, FeedbackVector());
3172 __ Move(rdx, SmiFromSlot(expr->CallFeedbackSlot())); 3186 __ Move(rdx, SmiFromSlot(expr->CallFeedbackSlot()));
3173 3187
3174 // TODO(dslomov): use a different stub and propagate new.target. 3188 // TODO(dslomov): use a different stub and propagate new.target.
3175 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); 3189 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET);
3176 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); 3190 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL);
3177 3191
3178 RecordJSReturnSite(expr); 3192 RecordJSReturnSite(expr);
3179 3193
3180 // TODO(dslomov): implement TDZ for `this`. 3194 EmitVariableAssignment(this_var, Token::INIT_CONST);
3181 EmitVariableAssignment(super_ref->this_var()->var(), Token::ASSIGN);
3182 context()->Plug(rax); 3195 context()->Plug(rax);
3183 } 3196 }
3184 3197
3185 3198
3186 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { 3199 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) {
3187 ZoneList<Expression*>* args = expr->arguments(); 3200 ZoneList<Expression*>* args = expr->arguments();
3188 DCHECK(args->length() == 1); 3201 DCHECK(args->length() == 1);
3189 3202
3190 VisitForAccumulatorValue(args->at(0)); 3203 VisitForAccumulatorValue(args->at(0));
3191 3204
(...skipping 2110 matching lines...) Expand 10 before | Expand all | Expand 10 after
5302 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5315 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5303 Assembler::target_address_at(call_target_address, 5316 Assembler::target_address_at(call_target_address,
5304 unoptimized_code)); 5317 unoptimized_code));
5305 return OSR_AFTER_STACK_CHECK; 5318 return OSR_AFTER_STACK_CHECK;
5306 } 5319 }
5307 5320
5308 5321
5309 } } // namespace v8::internal 5322 } } // namespace v8::internal
5310 5323
5311 #endif // V8_TARGET_ARCH_X64 5324 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698