| Index: src/scopes.cc
|
| diff --git a/src/scopes.cc b/src/scopes.cc
|
| index be991a1a17bc78acc8ae85aae36b4c9e45987979..d8c317779f83c2d5b73c1e9a3c03515fb7df8944 100644
|
| --- a/src/scopes.cc
|
| +++ b/src/scopes.cc
|
| @@ -156,6 +156,7 @@ void Scope::SetDefaults(ScopeType scope_type, Scope* outer_scope,
|
| scope_uses_arguments_ = false;
|
| scope_uses_super_property_ = false;
|
| scope_uses_this_ = false;
|
| + scope_uses_new_target_ = false;
|
| asm_module_ = false;
|
| asm_function_ = outer_scope != NULL && outer_scope->asm_module_;
|
| // Inherit the language mode from the parent scope.
|
| @@ -164,6 +165,7 @@ void Scope::SetDefaults(ScopeType scope_type, Scope* outer_scope,
|
| inner_scope_calls_eval_ = false;
|
| inner_scope_uses_arguments_ = false;
|
| inner_scope_uses_this_ = false;
|
| + inner_scope_uses_new_target_ = false;
|
| inner_scope_uses_super_property_ = false;
|
| force_eager_compilation_ = false;
|
| force_context_allocation_ = (outer_scope != NULL && !is_function_scope())
|
| @@ -316,13 +318,14 @@ void Scope::Initialize() {
|
| var->AllocateTo(Variable::PARAMETER, -1);
|
| receiver_ = var;
|
|
|
| - if (subclass_constructor) {
|
| - new_target_ =
|
| - variables_.Declare(this, ast_value_factory_->new_target_string(),
|
| - CONST, Variable::NEW_TARGET, kCreatedInitialized);
|
| - new_target_->AllocateTo(Variable::PARAMETER, -2);
|
| - new_target_->set_is_used();
|
| - }
|
| + // if (subclass_constructor) {
|
| + // new_target_ =
|
| + // variables_.Declare(this, ast_value_factory_->new_target_string(),
|
| + // CONST, Variable::NEW_TARGET,
|
| + // kCreatedInitialized);
|
| + // new_target_->AllocateTo(Variable::PARAMETER, -2);
|
| + // new_target_->set_is_used();
|
| + // }
|
| } else {
|
| DCHECK(outer_scope() != NULL);
|
| receiver_ = outer_scope()->receiver();
|
| @@ -337,6 +340,9 @@ void Scope::Initialize() {
|
| VAR,
|
| Variable::ARGUMENTS,
|
| kCreatedInitialized);
|
| +
|
| + variables_.Declare(this, ast_value_factory_->new_target_string(), CONST,
|
| + Variable::NEW_TARGET, kNeedsInitialization);
|
| }
|
| }
|
|
|
| @@ -371,6 +377,7 @@ Scope* Scope::FinalizeBlockScope() {
|
| if (uses_arguments()) outer_scope_->RecordArgumentsUsage();
|
| if (uses_super_property()) outer_scope_->RecordSuperPropertyUsage();
|
| if (uses_this()) outer_scope_->RecordThisUsage();
|
| + if (uses_new_target()) outer_scope_->RecordNewTargetUsage();
|
|
|
| return NULL;
|
| }
|
| @@ -917,12 +924,16 @@ void Scope::Print(int n) {
|
| if (scope_uses_super_property_)
|
| Indent(n1, "// scope uses 'super' property\n");
|
| if (scope_uses_this_) Indent(n1, "// scope uses 'this'\n");
|
| + if (scope_uses_new_target_) Indent(n1, "// scope uses 'new.target'\n");
|
| if (inner_scope_uses_arguments_) {
|
| Indent(n1, "// inner scope uses 'arguments'\n");
|
| }
|
| if (inner_scope_uses_super_property_)
|
| Indent(n1, "// inner scope uses 'super' property\n");
|
| if (inner_scope_uses_this_) Indent(n1, "// inner scope uses 'this'\n");
|
| + if (inner_scope_uses_new_target_) {
|
| + Indent(n1, "// inner scope uses 'new.target'\n");
|
| + }
|
| if (outer_scope_calls_sloppy_eval_) {
|
| Indent(n1, "// outer scope calls 'eval' in sloppy context\n");
|
| }
|
| @@ -1248,6 +1259,10 @@ void Scope::PropagateScopeInfo(bool outer_scope_calls_sloppy_eval ) {
|
| if (inner->scope_uses_this_ || inner->inner_scope_uses_this_) {
|
| inner_scope_uses_this_ = true;
|
| }
|
| + if (inner->scope_uses_new_target_ ||
|
| + inner->inner_scope_uses_new_target_) {
|
| + inner_scope_uses_new_target_ = true;
|
| + }
|
| }
|
| if (inner->force_eager_compilation_) {
|
| force_eager_compilation_ = true;
|
| @@ -1379,6 +1394,19 @@ void Scope::AllocateParameterLocals(Isolate* isolate) {
|
| }
|
| }
|
| }
|
| +
|
| + Variable* new_target = LookupLocal(ast_value_factory_->new_target_string());
|
| + // Functions have 'new_target' declared implicitly in all non arrow functions.
|
| + DCHECK(new_target != nullptr || is_arrow_scope());
|
| +
|
| + if (new_target != nullptr) {
|
| + if (IsSubclassConstructor(function_kind_)) {
|
| + new_target->ForceContextAllocation();
|
| + new_target_ = new_target;
|
| + } else if (MustAllocate(new_target)) {
|
| + new_target_ = new_target;
|
| + }
|
| + }
|
| }
|
|
|
|
|
|
|