Commit 71784ec0 authored by cdai2's avatar cdai2

X87: new classes: implement correct check for uninitialized this in 'super()'

port fdcf3e59 (r26599)

original commit message:

    new classes: implement correct check for uninitialized this in 'super()'

BUG=
R=weiliang.lin@intel.com

Review URL: https://codereview.chromium.org/913383002

Cr-Commit-Position: refs/heads/master@{#26603}
parent 42c30b8f
...@@ -3133,19 +3133,9 @@ void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { ...@@ -3133,19 +3133,9 @@ void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) {
GetVar(eax, new_target_var); GetVar(eax, new_target_var);
__ push(eax); __ push(eax);
SuperReference* super_ref = expr->expression()->AsSuperReference();
EmitLoadSuperConstructor(); EmitLoadSuperConstructor();
__ push(result_register()); __ 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. // Push the arguments ("left-to-right") on the stack.
ZoneList<Expression*>* args = expr->arguments(); ZoneList<Expression*>* args = expr->arguments();
int arg_count = args->length(); int arg_count = args->length();
...@@ -3181,6 +3171,16 @@ void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { ...@@ -3181,6 +3171,16 @@ void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) {
RecordJSReturnSite(expr); RecordJSReturnSite(expr);
SuperReference* super_ref = expr->expression()->AsSuperReference();
Variable* this_var = super_ref->this_var()->var();
GetVar(ecx, this_var);
__ cmp(ecx, isolate()->factory()->the_hole_value());
Label uninitialized_this;
__ j(equal, &uninitialized_this);
__ push(Immediate(this_var->name()));
__ CallRuntime(Runtime::kThrowReferenceError, 1);
__ bind(&uninitialized_this);
EmitVariableAssignment(this_var, Token::INIT_CONST); EmitVariableAssignment(this_var, Token::INIT_CONST);
context()->Plug(eax); context()->Plug(eax);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment