Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(709)

Side by Side Diff: src/scopes.cc

Issue 1154103005: Refactor lexical home object binding (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: git rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/scopes.h ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/messages.h" 9 #include "src/messages.h"
10 #include "src/parser.h" 10 #include "src/parser.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 outer_scope_ = outer_scope; 152 outer_scope_ = outer_scope;
153 scope_type_ = scope_type; 153 scope_type_ = scope_type;
154 function_kind_ = function_kind; 154 function_kind_ = function_kind;
155 block_scope_is_class_scope_ = false; 155 block_scope_is_class_scope_ = false;
156 scope_name_ = ast_value_factory_->empty_string(); 156 scope_name_ = ast_value_factory_->empty_string();
157 dynamics_ = nullptr; 157 dynamics_ = nullptr;
158 receiver_ = nullptr; 158 receiver_ = nullptr;
159 new_target_ = nullptr; 159 new_target_ = nullptr;
160 function_ = nullptr; 160 function_ = nullptr;
161 arguments_ = nullptr; 161 arguments_ = nullptr;
162 home_object_ = nullptr;
163 this_function_ = nullptr; 162 this_function_ = nullptr;
164 illegal_redecl_ = nullptr; 163 illegal_redecl_ = nullptr;
165 scope_inside_with_ = false; 164 scope_inside_with_ = false;
166 scope_contains_with_ = false; 165 scope_contains_with_ = false;
167 scope_calls_eval_ = false; 166 scope_calls_eval_ = false;
168 scope_uses_arguments_ = false; 167 scope_uses_arguments_ = false;
169 scope_uses_super_property_ = false; 168 scope_uses_super_property_ = false;
170 asm_module_ = false; 169 asm_module_ = false;
171 asm_function_ = outer_scope != NULL && outer_scope->asm_module_; 170 asm_function_ = outer_scope != NULL && outer_scope->asm_module_;
172 // Inherit the language mode from the parent scope. 171 // Inherit the language mode from the parent scope.
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 327
329 if (subclass_constructor) { 328 if (subclass_constructor) {
330 DCHECK(!is_arrow_scope()); 329 DCHECK(!is_arrow_scope());
331 variables_.Declare(this, ast_value_factory_->new_target_string(), CONST, 330 variables_.Declare(this, ast_value_factory_->new_target_string(), CONST,
332 Variable::NORMAL, kCreatedInitialized); 331 Variable::NORMAL, kCreatedInitialized);
333 } 332 }
334 333
335 if (IsConciseMethod(function_kind_) || IsConstructor(function_kind_) || 334 if (IsConciseMethod(function_kind_) || IsConstructor(function_kind_) ||
336 IsAccessorFunction(function_kind_)) { 335 IsAccessorFunction(function_kind_)) {
337 DCHECK(!is_arrow_scope()); 336 DCHECK(!is_arrow_scope());
338 // Declare '.home_object' variable which exists in all methods.
339 // Note that it might never be accessed, in which case it won't be
340 // allocated during variable allocation.
341 variables_.Declare(this, ast_value_factory_->home_object_string(), CONST,
342 Variable::NORMAL, kCreatedInitialized);
343 }
344
345 if (IsSubclassConstructor(function_kind_)) {
346 DCHECK(!is_arrow_scope());
347 variables_.Declare(this, ast_value_factory_->this_function_string(), 337 variables_.Declare(this, ast_value_factory_->this_function_string(),
348 CONST, Variable::NORMAL, kCreatedInitialized); 338 CONST, Variable::NORMAL, kCreatedInitialized);
349 } 339 }
350 } 340 }
351 } 341 }
352 342
353 343
354 Scope* Scope::FinalizeBlockScope() { 344 Scope* Scope::FinalizeBlockScope() {
355 DCHECK(is_block_scope()); 345 DCHECK(is_block_scope());
356 DCHECK(internals_.is_empty()); 346 DCHECK(internals_.is_empty());
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 // because of the current ScopeInfo implementation (see 1482 // because of the current ScopeInfo implementation (see
1493 // ScopeInfo::ScopeInfo(FunctionScope* scope) constructor). 1483 // ScopeInfo::ScopeInfo(FunctionScope* scope) constructor).
1494 if (function_ != nullptr) { 1484 if (function_ != nullptr) {
1495 AllocateNonParameterLocal(isolate, function_->proxy()->var()); 1485 AllocateNonParameterLocal(isolate, function_->proxy()->var());
1496 } 1486 }
1497 1487
1498 if (rest_parameter_ != nullptr) { 1488 if (rest_parameter_ != nullptr) {
1499 AllocateNonParameterLocal(isolate, rest_parameter_); 1489 AllocateNonParameterLocal(isolate, rest_parameter_);
1500 } 1490 }
1501 1491
1502 Variable* home_object_var =
1503 LookupLocal(ast_value_factory_->home_object_string());
1504 if (home_object_var != nullptr && MustAllocate(home_object_var)) {
1505 home_object_ = home_object_var;
1506 }
1507
1508 Variable* new_target_var = 1492 Variable* new_target_var =
1509 LookupLocal(ast_value_factory_->new_target_string()); 1493 LookupLocal(ast_value_factory_->new_target_string());
1510 if (new_target_var != nullptr && MustAllocate(new_target_var)) { 1494 if (new_target_var != nullptr && MustAllocate(new_target_var)) {
1511 new_target_ = new_target_var; 1495 new_target_ = new_target_var;
1512 } 1496 }
1513 1497
1514 Variable* this_function_var = 1498 Variable* this_function_var =
1515 LookupLocal(ast_value_factory_->this_function_string()); 1499 LookupLocal(ast_value_factory_->this_function_string());
1516 if (this_function_var != nullptr && MustAllocate(this_function_var)) { 1500 if (this_function_var != nullptr && MustAllocate(this_function_var)) {
1517 this_function_ = this_function_var; 1501 this_function_ = this_function_var;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 } 1564 }
1581 1565
1582 1566
1583 int Scope::ContextLocalCount() const { 1567 int Scope::ContextLocalCount() const {
1584 if (num_heap_slots() == 0) return 0; 1568 if (num_heap_slots() == 0) return 0;
1585 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1569 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1586 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1570 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1587 } 1571 }
1588 } // namespace internal 1572 } // namespace internal
1589 } // namespace v8 1573 } // namespace v8
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698