| OLD | NEW |
| 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 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1454 // if (false) { const x; }; var y = x; | 1454 // if (false) { const x; }; var y = x; |
| 1455 // | 1455 // |
| 1456 // The condition on the declaration scopes is a conservative check for | 1456 // The condition on the declaration scopes is a conservative check for |
| 1457 // nested functions that access a binding and are called before the | 1457 // nested functions that access a binding and are called before the |
| 1458 // binding is initialized: | 1458 // binding is initialized: |
| 1459 // function() { f(); let x = 1; function f() { x = 2; } } | 1459 // function() { f(); let x = 1; function f() { x = 2; } } |
| 1460 // | 1460 // |
| 1461 bool skip_init_check; | 1461 bool skip_init_check; |
| 1462 if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) { | 1462 if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) { |
| 1463 skip_init_check = false; | 1463 skip_init_check = false; |
| 1464 } else if (var->is_this()) { |
| 1465 CHECK((info_->shared_info()->kind() & kSubclassConstructor) != 0); |
| 1466 // TODO(dslomov): implement 'this' hole check elimination. |
| 1467 skip_init_check = false; |
| 1464 } else { | 1468 } else { |
| 1465 // Check that we always have valid source position. | 1469 // Check that we always have valid source position. |
| 1466 DCHECK(var->initializer_position() != RelocInfo::kNoPosition); | 1470 DCHECK(var->initializer_position() != RelocInfo::kNoPosition); |
| 1467 DCHECK(proxy->position() != RelocInfo::kNoPosition); | 1471 DCHECK(proxy->position() != RelocInfo::kNoPosition); |
| 1468 skip_init_check = var->mode() != CONST_LEGACY && | 1472 skip_init_check = var->mode() != CONST_LEGACY && |
| 1469 var->initializer_position() < proxy->position(); | 1473 var->initializer_position() < proxy->position(); |
| 1470 } | 1474 } |
| 1471 | 1475 |
| 1472 if (!skip_init_check) { | 1476 if (!skip_init_check) { |
| 1473 // Let and const need a read barrier. | 1477 // Let and const need a read barrier. |
| (...skipping 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3126 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 3130 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
| 3127 context()->Plug(eax); | 3131 context()->Plug(eax); |
| 3128 } | 3132 } |
| 3129 | 3133 |
| 3130 | 3134 |
| 3131 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { | 3135 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
| 3132 SuperReference* super_ref = expr->expression()->AsSuperReference(); | 3136 SuperReference* super_ref = expr->expression()->AsSuperReference(); |
| 3133 EmitLoadSuperConstructor(super_ref); | 3137 EmitLoadSuperConstructor(super_ref); |
| 3134 __ push(result_register()); | 3138 __ push(result_register()); |
| 3135 | 3139 |
| 3140 Variable* this_var = super_ref->this_var()->var(); |
| 3141 GetVar(eax, this_var); |
| 3142 __ cmp(eax, isolate()->factory()->the_hole_value()); |
| 3143 Label uninitialized_this; |
| 3144 __ j(equal, &uninitialized_this); |
| 3145 __ push(Immediate(this_var->name())); |
| 3146 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
| 3147 __ bind(&uninitialized_this); |
| 3148 |
| 3136 // Push the arguments ("left-to-right") on the stack. | 3149 // Push the arguments ("left-to-right") on the stack. |
| 3137 ZoneList<Expression*>* args = expr->arguments(); | 3150 ZoneList<Expression*>* args = expr->arguments(); |
| 3138 int arg_count = args->length(); | 3151 int arg_count = args->length(); |
| 3139 for (int i = 0; i < arg_count; i++) { | 3152 for (int i = 0; i < arg_count; i++) { |
| 3140 VisitForStackValue(args->at(i)); | 3153 VisitForStackValue(args->at(i)); |
| 3141 } | 3154 } |
| 3142 | 3155 |
| 3143 // Call the construct call builtin that handles allocation and | 3156 // Call the construct call builtin that handles allocation and |
| 3144 // constructor invocation. | 3157 // constructor invocation. |
| 3145 SetSourcePosition(expr->position()); | 3158 SetSourcePosition(expr->position()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3160 | 3173 |
| 3161 __ LoadHeapObject(ebx, FeedbackVector()); | 3174 __ LoadHeapObject(ebx, FeedbackVector()); |
| 3162 __ mov(edx, Immediate(SmiFromSlot(expr->CallFeedbackSlot()))); | 3175 __ mov(edx, Immediate(SmiFromSlot(expr->CallFeedbackSlot()))); |
| 3163 | 3176 |
| 3164 // TODO(dslomov): use a different stub and propagate new.target. | 3177 // TODO(dslomov): use a different stub and propagate new.target. |
| 3165 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); | 3178 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); |
| 3166 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3179 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
| 3167 | 3180 |
| 3168 RecordJSReturnSite(expr); | 3181 RecordJSReturnSite(expr); |
| 3169 | 3182 |
| 3170 // TODO(dslomov): implement TDZ for `this`. | 3183 EmitVariableAssignment(this_var, Token::INIT_CONST); |
| 3171 EmitVariableAssignment(super_ref->this_var()->var(), Token::ASSIGN); | |
| 3172 context()->Plug(eax); | 3184 context()->Plug(eax); |
| 3173 } | 3185 } |
| 3174 | 3186 |
| 3175 | 3187 |
| 3176 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 3188 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
| 3177 ZoneList<Expression*>* args = expr->arguments(); | 3189 ZoneList<Expression*>* args = expr->arguments(); |
| 3178 DCHECK(args->length() == 1); | 3190 DCHECK(args->length() == 1); |
| 3179 | 3191 |
| 3180 VisitForAccumulatorValue(args->at(0)); | 3192 VisitForAccumulatorValue(args->at(0)); |
| 3181 | 3193 |
| (...skipping 2094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5276 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5288 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 5277 Assembler::target_address_at(call_target_address, | 5289 Assembler::target_address_at(call_target_address, |
| 5278 unoptimized_code)); | 5290 unoptimized_code)); |
| 5279 return OSR_AFTER_STACK_CHECK; | 5291 return OSR_AFTER_STACK_CHECK; |
| 5280 } | 5292 } |
| 5281 | 5293 |
| 5282 | 5294 |
| 5283 } } // namespace v8::internal | 5295 } } // namespace v8::internal |
| 5284 | 5296 |
| 5285 #endif // V8_TARGET_ARCH_IA32 | 5297 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |