Scope cleanup: remove unused bits and accessors

- inner_scope_uses_arguments_ was completely unused
- The public accessor for contains_with() was not called
- inside_with() had helper methods on Parser and PatternRewriter, but was
  only called in one place.

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

Cr-Commit-Position: refs/heads/master@{#31587}
This commit is contained in:
adamk 2015-10-26 17:47:40 -07:00 committed by Commit bot
parent 0abac748cd
commit a6ef1ea8ae
5 changed files with 3 additions and 25 deletions

View File

@ -927,7 +927,6 @@ class Parser : public ParserBase<ParserTraits> {
void SetCachedData(ParseInfo* info);
bool inside_with() const { return scope_->inside_with(); }
ScriptCompiler::CompileOptions compile_options() const {
return compile_options_;
}
@ -1049,7 +1048,6 @@ class Parser : public ParserBase<ParserTraits> {
AstValueFactory* ast_value_factory() const {
return descriptor_->parser->ast_value_factory();
}
bool inside_with() const { return descriptor_->parser->inside_with(); }
Zone* zone() const { return descriptor_->parser->zone(); }
Expression* pattern_;

View File

@ -158,7 +158,7 @@ void Parser::PatternRewriter::VisitVariableProxy(VariableProxy* pattern) {
// we're in a with. The initialization value should not
// necessarily be stored in the global object in that case,
// which is why we need to generate a separate assignment node.
if (value != NULL && !inside_with()) {
if (value != NULL && !descriptor_->scope->inside_with()) {
arguments->Add(value, zone());
value = NULL; // zap the value to avoid the unnecessary assignment
// Construct the call to Runtime_InitializeVarGlobal

View File

@ -194,7 +194,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;
scope_nonlinear_ = false;
force_eager_compilation_ = false;
force_context_allocation_ = (outer_scope != NULL && !is_function_scope())
@ -998,9 +997,6 @@ void Scope::Print(int 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 (outer_scope_calls_sloppy_eval_) {
Indent(n1, "// outer scope calls 'eval' in sloppy context\n");
}
@ -1347,14 +1343,6 @@ void Scope::PropagateScopeInfo(bool outer_scope_calls_sloppy_eval ) {
if (inner->scope_calls_eval_ || inner->inner_scope_calls_eval_) {
inner_scope_calls_eval_ = true;
}
// If the inner scope is an arrow function, propagate the flags tracking
// 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->force_eager_compilation_) {
force_eager_compilation_ = true;
}

View File

@ -339,13 +339,9 @@ class Scope: public ZoneObject {
// Is this scope inside a with statement.
bool inside_with() const { return scope_inside_with_; }
// 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 this scope have the potential to execute declarations non-linearly?
@ -675,7 +671,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 force_eager_compilation_;
bool force_context_allocation_;

View File

@ -979,7 +979,6 @@ TEST(ScopeUsesArgumentsSuperThis) {
ARGUMENTS = 1,
SUPER_PROPERTY = 1 << 1,
THIS = 1 << 2,
INNER_ARGUMENTS = 1 << 3,
EVAL = 1 << 4
};
@ -1021,9 +1020,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},
THIS},
{"\"use strict\"; while (true) { let x; this, super.f(), arguments; }",
INNER_ARGUMENTS | SUPER_PROPERTY | THIS},
SUPER_PROPERTY | THIS},
{"\"use strict\"; if (foo()) { let x; this.f() }", THIS},
{"\"use strict\"; if (foo()) { let x; super.f() }", SUPER_PROPERTY},
{"\"use strict\"; if (1) {"
@ -1094,8 +1093,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 & EVAL) != 0, scope->calls_eval());
}
}