Commit d67e07f3 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Move workaround with TDZ of 'this' variable.

Note that this just narrows the existing workaround for any 'this' in
derived constructors (having a temporal dead zone) so that we can still
recognize static cases correctly (i.e. when 'this' is provably outside
or inside the temporal dead zone).

R=rossberg@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#29762}
parent 6a528510
...@@ -520,6 +520,13 @@ bool AstGraphBuilder::CreateGraph(bool stack_check) { ...@@ -520,6 +520,13 @@ bool AstGraphBuilder::CreateGraph(bool stack_check) {
// Initialize control scope. // Initialize control scope.
ControlScope control(this); ControlScope control(this);
// TODO(mstarzinger): For now we cannot assume that the {this} parameter is
// not {the_hole}, because for derived classes {this} has a TDZ and the
// JSConstructStubForDerived magically passes {the_hole} as a receiver.
if (scope->has_this_declaration() && scope->receiver()->is_const_mode()) {
env.RawParameterBind(0, jsgraph()->TheHoleConstant());
}
// Build receiver check for sloppy mode if necessary. // Build receiver check for sloppy mode if necessary.
// TODO(mstarzinger/verwaest): Should this be moved back into the CallIC? // TODO(mstarzinger/verwaest): Should this be moved back into the CallIC?
if (scope->has_this_declaration()) { if (scope->has_this_declaration()) {
...@@ -3352,12 +3359,9 @@ Node* AstGraphBuilder::BuildVariableLoad(Variable* variable, ...@@ -3352,12 +3359,9 @@ Node* AstGraphBuilder::BuildVariableLoad(Variable* variable,
} }
} else if (mode == LET || mode == CONST) { } else if (mode == LET || mode == CONST) {
// Perform check for uninitialized let/const variables. // Perform check for uninitialized let/const variables.
// TODO(mstarzinger): For now we cannot use the below optimization for
// the {this} parameter, because JSConstructStubForDerived magically
// passes {the_hole} as a receiver.
if (value->op() == the_hole->op()) { if (value->op() == the_hole->op()) {
value = BuildThrowReferenceError(variable, bailout_id); value = BuildThrowReferenceError(variable, bailout_id);
} else if (value->opcode() == IrOpcode::kPhi || variable->is_this()) { } else if (value->opcode() == IrOpcode::kPhi) {
value = BuildHoleCheckThenThrow(value, variable, value, bailout_id); value = BuildHoleCheckThenThrow(value, variable, value, bailout_id);
} }
} }
......
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