Index: src/ia32/full-codegen-ia32.cc |
diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc |
index b4195350cbb4641f21c07225681efab25d5e89d9..5e8e310ef96789148e31508ef76c0b5ec7eb75a8 100644 |
--- a/src/ia32/full-codegen-ia32.cc |
+++ b/src/ia32/full-codegen-ia32.cc |
@@ -1460,6 +1460,9 @@ void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) { |
bool skip_init_check; |
if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) { |
skip_init_check = false; |
+ } 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()
|
+ // TODO(dslomov): implement 'this' hole check elimination. |
+ skip_init_check = false; |
} else { |
// Check that we always have valid source position. |
DCHECK(var->initializer_position() != RelocInfo::kNoPosition); |
@@ -3139,6 +3142,15 @@ void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
EmitLoadSuperConstructor(super_ref); |
__ push(result_register()); |
+ Variable* this_var = super_ref->this_var()->var(); |
+ GetVar(eax, this_var); |
+ __ cmp(eax, isolate()->factory()->the_hole_value()); |
+ Label uninitialized_this; |
+ __ j(equal, &uninitialized_this); |
+ __ push(Immediate(this_var->name())); |
+ __ CallRuntime(Runtime::kThrowReferenceError, 1); |
+ __ bind(&uninitialized_this); |
+ |
// Push the arguments ("left-to-right") on the stack. |
ZoneList<Expression*>* args = expr->arguments(); |
int arg_count = args->length(); |
@@ -3173,8 +3185,7 @@ void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
RecordJSReturnSite(expr); |
- // TODO(dslomov): implement TDZ for `this`. |
- EmitVariableAssignment(super_ref->this_var()->var(), Token::ASSIGN); |
+ EmitVariableAssignment(this_var, Token::INIT_CONST); |
context()->Plug(eax); |
} |