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