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

Unified Diff: src/scopes.h

Issue 1136883006: Reapply "Resolve references to "this" the same way as normal variables"" (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Fix this reference in super call, fix "this" in debug evaluator Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/scopeinfo.cc ('k') | src/scopes.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scopes.h
diff --git a/src/scopes.h b/src/scopes.h
index 5e3dc1f0654bf65c3ee738665fcb7bf2107be63b..f3c64f9eadf73c7c4f9c1671779c4f55926697f9 100644
--- a/src/scopes.h
+++ b/src/scopes.h
@@ -144,14 +144,15 @@ class Scope: public ZoneObject {
// Create a new unresolved variable.
VariableProxy* NewUnresolved(AstNodeFactory* factory,
const AstRawString* name,
+ Variable::Kind kind = Variable::NORMAL,
int start_position = RelocInfo::kNoPosition,
int end_position = RelocInfo::kNoPosition) {
// Note that we must not share the unresolved variables with
// the same name because they may be removed selectively via
// RemoveUnresolved().
DCHECK(!already_resolved());
- VariableProxy* proxy = factory->NewVariableProxy(
- name, Variable::NORMAL, start_position, end_position);
+ VariableProxy* proxy =
+ factory->NewVariableProxy(name, kind, start_position, end_position);
unresolved_.Add(proxy, zone_);
return proxy;
}
@@ -217,9 +218,6 @@ class Scope: public ZoneObject {
// Inform the scope that the corresponding code uses "super".
void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; }
- // Inform the scope that the corresponding code uses "this".
- void RecordThisUsage() { scope_uses_this_ = true; }
-
// Set the language mode flag (unless disabled by a global flag).
void SetLanguageMode(LanguageMode language_mode) {
language_mode_ = language_mode;
@@ -323,10 +321,6 @@ class Scope: public ZoneObject {
bool inner_uses_super_property() const {
return inner_scope_uses_super_property_;
}
- // Does this scope access "this".
- bool uses_this() const { return scope_uses_this_; }
- // Does any inner scope access "this".
- bool inner_uses_this() const { return inner_scope_uses_this_; }
const Scope* NearestOuterEvalScope() const {
if (is_eval_scope()) return this;
@@ -346,7 +340,21 @@ class Scope: public ZoneObject {
LanguageMode language_mode() const { return language_mode_; }
// The variable corresponding to the 'this' value.
- Variable* receiver() { return receiver_; }
+ Variable* receiver() {
+ DCHECK(has_this_declaration());
+ DCHECK_NOT_NULL(receiver_);
+ return receiver_;
+ }
+
+ Variable* LookupThis() { return Lookup(ast_value_factory_->this_string()); }
+
+ // TODO(wingo): Add a GLOBAL_SCOPE scope type which will lexically allocate
+ // "this" (and no other variable) on the native context. Script scopes then
+ // will not have a "this" declaration.
+ bool has_this_declaration() const {
+ return (is_function_scope() && !is_arrow_scope()) || is_module_scope() ||
+ is_script_scope();
+ }
// The variable corresponding to the 'new.target' value.
Variable* new_target_var() { return new_target_; }
@@ -577,8 +585,6 @@ class Scope: public ZoneObject {
bool scope_uses_arguments_;
// This scope uses "super" property ('super.foo').
bool scope_uses_super_property_;
- // This scope uses "this".
- bool scope_uses_this_;
// This scope contains an "use asm" annotation.
bool asm_module_;
// This scope's outer context is an asm module.
@@ -594,7 +600,6 @@ class Scope: public ZoneObject {
bool inner_scope_calls_eval_;
bool inner_scope_uses_arguments_;
bool inner_scope_uses_super_property_;
- bool inner_scope_uses_this_;
bool force_eager_compilation_;
bool force_context_allocation_;
@@ -706,6 +711,8 @@ class Scope: public ZoneObject {
void AllocateNonParameterLocal(Isolate* isolate, Variable* var);
void AllocateNonParameterLocals(Isolate* isolate);
void AllocateVariablesRecursively(Isolate* isolate);
+ void AllocateParameter(Variable* var, int index);
+ void AllocateReceiver();
void AllocateModules();
// Resolve and fill in the allocation information for all variables
« no previous file with comments | « src/scopeinfo.cc ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698