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

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: CHECK_OK fixed 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/x64/builtins-x64.cc ('k') | test/mjsunit/harmony/classes-experimental.js » ('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_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 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 // if (false) { const x; }; var y = x; 1489 // if (false) { const x; }; var y = x;
1490 // 1490 //
1491 // The condition on the declaration scopes is a conservative check for 1491 // The condition on the declaration scopes is a conservative check for
1492 // nested functions that access a binding and are called before the 1492 // nested functions that access a binding and are called before the
1493 // binding is initialized: 1493 // binding is initialized:
1494 // function() { f(); let x = 1; function f() { x = 2; } } 1494 // function() { f(); let x = 1; function f() { x = 2; } }
1495 // 1495 //
1496 bool skip_init_check; 1496 bool skip_init_check;
1497 if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) { 1497 if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) {
1498 skip_init_check = false; 1498 skip_init_check = false;
1499 } else if (var->is_this()) {
1500 CHECK((info_->shared_info()->kind() & kSubclassConstructor) != 0);
1501 // TODO(dslomov): implement 'this' hole check elimination.
1502 skip_init_check = false;
1499 } else { 1503 } else {
1500 // Check that we always have valid source position. 1504 // Check that we always have valid source position.
1501 DCHECK(var->initializer_position() != RelocInfo::kNoPosition); 1505 DCHECK(var->initializer_position() != RelocInfo::kNoPosition);
1502 DCHECK(proxy->position() != RelocInfo::kNoPosition); 1506 DCHECK(proxy->position() != RelocInfo::kNoPosition);
1503 skip_init_check = var->mode() != CONST_LEGACY && 1507 skip_init_check = var->mode() != CONST_LEGACY &&
1504 var->initializer_position() < proxy->position(); 1508 var->initializer_position() < proxy->position();
1505 } 1509 }
1506 1510
1507 if (!skip_init_check) { 1511 if (!skip_init_check) {
1508 // Let and const need a read barrier. 1512 // Let and const need a read barrier.
(...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after
3131 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); 3135 PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
3132 context()->Plug(rax); 3136 context()->Plug(rax);
3133 } 3137 }
3134 3138
3135 3139
3136 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { 3140 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) {
3137 SuperReference* super_ref = expr->expression()->AsSuperReference(); 3141 SuperReference* super_ref = expr->expression()->AsSuperReference();
3138 EmitLoadSuperConstructor(super_ref); 3142 EmitLoadSuperConstructor(super_ref);
3139 __ Push(result_register()); 3143 __ Push(result_register());
3140 3144
3145 Variable* this_var = super_ref->this_var()->var();
3146
3147 GetVar(rax, this_var);
3148 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
3149 Label uninitialized_this;
3150 __ j(equal, &uninitialized_this);
3151 __ Push(this_var->name());
3152 __ CallRuntime(Runtime::kThrowReferenceError, 1);
3153 __ bind(&uninitialized_this);
3154
3155
3141 // Push the arguments ("left-to-right") on the stack. 3156 // Push the arguments ("left-to-right") on the stack.
3142 ZoneList<Expression*>* args = expr->arguments(); 3157 ZoneList<Expression*>* args = expr->arguments();
3143 int arg_count = args->length(); 3158 int arg_count = args->length();
3144 for (int i = 0; i < arg_count; i++) { 3159 for (int i = 0; i < arg_count; i++) {
3145 VisitForStackValue(args->at(i)); 3160 VisitForStackValue(args->at(i));
3146 } 3161 }
3147 3162
3148 // Call the construct call builtin that handles allocation and 3163 // Call the construct call builtin that handles allocation and
3149 // constructor invocation. 3164 // constructor invocation.
3150 SetSourcePosition(expr->position()); 3165 SetSourcePosition(expr->position());
(...skipping 14 matching lines...) Expand all
3165 3180
3166 __ Move(rbx, FeedbackVector()); 3181 __ Move(rbx, FeedbackVector());
3167 __ Move(rdx, SmiFromSlot(expr->CallFeedbackSlot())); 3182 __ Move(rdx, SmiFromSlot(expr->CallFeedbackSlot()));
3168 3183
3169 // TODO(dslomov): use a different stub and propagate new.target. 3184 // TODO(dslomov): use a different stub and propagate new.target.
3170 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); 3185 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET);
3171 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); 3186 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL);
3172 3187
3173 RecordJSReturnSite(expr); 3188 RecordJSReturnSite(expr);
3174 3189
3175 // TODO(dslomov): implement TDZ for `this`. 3190 EmitVariableAssignment(this_var, Token::INIT_CONST);
3176 EmitVariableAssignment(super_ref->this_var()->var(), Token::ASSIGN);
3177 context()->Plug(rax); 3191 context()->Plug(rax);
3178 } 3192 }
3179 3193
3180 3194
3181 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { 3195 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) {
3182 ZoneList<Expression*>* args = expr->arguments(); 3196 ZoneList<Expression*>* args = expr->arguments();
3183 DCHECK(args->length() == 1); 3197 DCHECK(args->length() == 1);
3184 3198
3185 VisitForAccumulatorValue(args->at(0)); 3199 VisitForAccumulatorValue(args->at(0));
3186 3200
(...skipping 2110 matching lines...) Expand 10 before | Expand all | Expand 10 after
5297 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5311 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5298 Assembler::target_address_at(call_target_address, 5312 Assembler::target_address_at(call_target_address,
5299 unoptimized_code)); 5313 unoptimized_code));
5300 return OSR_AFTER_STACK_CHECK; 5314 return OSR_AFTER_STACK_CHECK;
5301 } 5315 }
5302 5316
5303 5317
5304 } } // namespace v8::internal 5318 } } // namespace v8::internal
5305 5319
5306 #endif // V8_TARGET_ARCH_X64 5320 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | test/mjsunit/harmony/classes-experimental.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698