Reviewers: arv,
Description:
Remove Scope::scope_uses_arguments_ flag
Use of arguments is tracked as a variable, like any other variable.
[email protected]
LOG=N
BUG=
Please review this at https://codereview.chromium.org/1124233002/
Base URL: https://chromium.googlesource.com/v8/v8@master
Affected files (+6, -30 lines):
M src/preparser.h
M src/scopes.h
M src/scopes.cc
M test/cctest/test-parsing.cc
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index
543f82ee56a281dfc5984a7aa9a9be91319cf659..bdc0bdceba89a83beee326da42d0791e1575cc2e
100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -2071,7 +2071,6 @@
ParserBase<Traits>::ParseAndClassifyIdentifier(ExpressionClassifier*
classifier,
classifier->RecordExpressionError(scanner()->location(),
"strong_arguments");
}
- if (this->IsArguments(name)) scope_->RecordArgumentsUsage();
return name;
} else if (is_sloppy(language_mode()) &&
(next == Token::FUTURE_STRICT_RESERVED_WORD ||
@@ -2104,7 +2103,6 @@ typename ParserBase<Traits>::IdentifierT ParserBase<
}
IdentifierT name = this->GetSymbol(scanner());
- if (this->IsArguments(name)) scope_->RecordArgumentsUsage();
return name;
}
@@ -2122,7 +2120,6 @@ ParserBase<Traits>::ParseIdentifierName(bool* ok) {
}
IdentifierT name = this->GetSymbol(scanner());
- if (this->IsArguments(name)) scope_->RecordArgumentsUsage();
return name;
}
Index: src/scopes.cc
diff --git a/src/scopes.cc b/src/scopes.cc
index
8d23180f9e407bb43cb4a50599e6b130a5126c8b..a5af8c015783152c94ae3b24a9cf6c137bb93dd6
100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -163,7 +163,6 @@ void Scope::SetDefaults(ScopeType scope_type, Scope*
outer_scope,
scope_inside_with_ = false;
scope_contains_with_ = false;
scope_calls_eval_ = false;
- scope_uses_arguments_ = false;
scope_uses_super_property_ = false;
asm_module_ = false;
asm_function_ = outer_scope != NULL && outer_scope->asm_module_;
@@ -171,7 +170,6 @@ void Scope::SetDefaults(ScopeType scope_type, Scope*
outer_scope,
language_mode_ = outer_scope != NULL ? outer_scope->language_mode_ :
SLOPPY;
outer_scope_calls_sloppy_eval_ = false;
inner_scope_calls_eval_ = false;
- inner_scope_uses_arguments_ = false;
inner_scope_uses_super_property_ = false;
force_eager_compilation_ = false;
force_context_allocation_ = (outer_scope != NULL && !is_function_scope())
@@ -367,7 +365,6 @@ Scope* Scope::FinalizeBlockScope() {
}
// Propagate usage flags to outer scope.
- if (uses_arguments()) outer_scope_->RecordArgumentsUsage();
if (uses_super_property()) outer_scope_->RecordSuperPropertyUsage();
if (scope_calls_eval_) outer_scope_->RecordEvalCall();
@@ -915,12 +912,8 @@ void Scope::Print(int n) {
if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n");
if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n");
if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n");
- if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n");
if (scope_uses_super_property_)
Indent(n1, "// scope uses 'super' property\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 (outer_scope_calls_sloppy_eval_) {
@@ -1271,9 +1264,6 @@ void Scope::PropagateScopeInfo(bool
outer_scope_calls_sloppy_eval ) {
// usage of arguments/super/this, but do not propagate them out from
normal
// functions.
if (!inner->is_function_scope() || inner->is_arrow_scope()) {
- if (inner->scope_uses_arguments_ ||
inner->inner_scope_uses_arguments_) {
- inner_scope_uses_arguments_ = true;
- }
if (inner->scope_uses_super_property_ ||
inner->inner_scope_uses_super_property_) {
inner_scope_uses_super_property_ = true;
Index: src/scopes.h
diff --git a/src/scopes.h b/src/scopes.h
index
f3c64f9eadf73c7c4f9c1671779c4f55926697f9..7a013e96c7ffd63aa9ceb4073a7cf7a3e044a467
100644
--- a/src/scopes.h
+++ b/src/scopes.h
@@ -212,9 +212,6 @@ class Scope: public ZoneObject {
// Inform the scope that the corresponding code contains an eval call.
void RecordEvalCall() { if (!is_script_scope()) scope_calls_eval_ =
true; }
- // Inform the scope that the corresponding code uses "arguments".
- void RecordArgumentsUsage() { scope_uses_arguments_ = true; }
-
// Inform the scope that the corresponding code uses "super".
void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; }
@@ -311,10 +308,6 @@ class Scope: public ZoneObject {
// Does this scope contain a with statement.
bool contains_with() const { return scope_contains_with_; }
- // Does this scope access "arguments".
- bool uses_arguments() const { return scope_uses_arguments_; }
- // Does any inner scope access "arguments".
- bool inner_uses_arguments() const { return inner_scope_uses_arguments_; }
// Does this scope access "super" property (super.foo).
bool uses_super_property() const { return scope_uses_super_property_; }
// Does any inner scope access "super" property.
@@ -581,8 +574,6 @@ class Scope: public ZoneObject {
// This scope or a nested catch scope or with scope contain an 'eval'
call. At
// the 'eval' call site this scope is the declaration scope.
bool scope_calls_eval_;
- // This scope uses "arguments".
- bool scope_uses_arguments_;
// This scope uses "super" property ('super.foo').
bool scope_uses_super_property_;
// This scope contains an "use asm" annotation.
@@ -598,7 +589,6 @@ class Scope: public ZoneObject {
// Computed via PropagateScopeInfo.
bool outer_scope_calls_sloppy_eval_;
bool inner_scope_calls_eval_;
- bool inner_scope_uses_arguments_;
bool inner_scope_uses_super_property_;
bool force_eager_compilation_;
bool force_context_allocation_;
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index
f0abbc958f9a241f2270bc85864db9561817c34b..92be55b91b8fc6bc9486e91a9b7c2b38db928a6d
100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -960,7 +960,6 @@ TEST(ScopeUsesArgumentsSuperThis) {
ARGUMENTS = 1,
SUPER_PROPERTY = 1 << 1,
THIS = 1 << 2,
- INNER_ARGUMENTS = 1 << 3,
INNER_SUPER_PROPERTY = 1 << 4,
};
@@ -1001,9 +1000,9 @@ TEST(ScopeUsesArgumentsSuperThis) {
{"return { m(x) { return () => super.m() } }", NONE},
// Flags must be correctly set when using block scoping.
{"\"use strict\"; while (true) { let x; this, arguments; }",
- INNER_ARGUMENTS | THIS},
+ ARGUMENTS | THIS},
{"\"use strict\"; while (true) { let x; this, super.f(), arguments; }",
- INNER_ARGUMENTS | INNER_SUPER_PROPERTY | THIS},
+ ARGUMENTS | INNER_SUPER_PROPERTY | THIS},
{"\"use strict\"; if (foo()) { let x; this.f() }", THIS},
{"\"use strict\"; if (foo()) { let x; super.f() }",
INNER_SUPER_PROPERTY},
@@ -1064,8 +1063,10 @@ TEST(ScopeUsesArgumentsSuperThis) {
CHECK_EQ(1, scope->inner_scopes()->length());
scope = scope->inner_scopes()->at(0);
}
- CHECK_EQ((source_data[i].expected & ARGUMENTS) != 0,
- scope->uses_arguments());
+ // Arguments usage in an arrow function doesn't cause local
allocation of
+ // an arguments object.
+ CHECK_EQ((source_data[i].expected & ARGUMENTS) != 0 && j != 1,
+ scope->arguments() != nullptr);
CHECK_EQ((source_data[i].expected & SUPER_PROPERTY) != 0,
scope->uses_super_property());
if ((source_data[i].expected & THIS) != 0) {
@@ -1073,8 +1074,6 @@ TEST(ScopeUsesArgumentsSuperThis) {
// script scope are marked as used.
CHECK(scope->LookupThis()->is_used());
}
- CHECK_EQ((source_data[i].expected & INNER_ARGUMENTS) != 0,
- scope->inner_uses_arguments());
CHECK_EQ((source_data[i].expected & INNER_SUPER_PROPERTY) != 0,
scope->inner_uses_super_property());
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.