[parser] Remove more materialized literal counts + incorrect expected property count logic.

Materialized literal removal is a follow up to https://chromium-review.googlesource.com/443246

In addtion, remove ParserBase::Checkpoint; it was for restoring materialized
literal counts and expected property counts, but actually the expected property
count tracking was incorrect ("this" in arrow function param list binds to the
outside, so it's correct without the checkpoint):

(a, b = this.c = 0) => { }

BUG=

Change-Id: Ic097f6d2e7cb235166fb3a76af3bf5584bc167f0
Reviewed-on: https://chromium-review.googlesource.com/449733
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43579}
This commit is contained in:
Marja Hölttä 2017-03-03 11:43:01 +01:00 committed by Commit Bot
parent 282edda0d2
commit 14106d2d51
2 changed files with 4 additions and 47 deletions

View File

@ -78,7 +78,6 @@ struct FormalParametersBase {
DeclarationScope* scope;
bool has_rest = false;
bool is_simple = true;
int materialized_literals_count = 0;
int function_length = 0;
int arity = 0;
};
@ -287,7 +286,6 @@ class ParserBase {
enum class FunctionBodyType { kNormal, kSingleExpression };
class Checkpoint;
class ClassLiteralChecker;
class ObjectLiteralChecker;
@ -449,11 +447,6 @@ class ParserBase {
*ok = false;
}
// Used to assign an index to each literal that needs materialization in
// the function. Includes regexp literals, and boilerplate for object and
// array literals.
int next_materialized_literal_index_;
// Properties count estimation.
int expected_property_count_;
@ -477,7 +470,6 @@ class ParserBase {
bool previous_function_was_likely_called_;
friend Impl;
friend class Checkpoint;
};
// This scope sets current ReturnExprContext to given value.
@ -522,34 +514,6 @@ class ParserBase {
TailCallExpressionList* list_;
};
// Annoyingly, arrow functions first parse as comma expressions, then when we
// see the => we have to go back and reinterpret the arguments as being formal
// parameters. To do so we need to reset some of the parser state back to
// what it was before the arguments were first seen.
class Checkpoint BASE_EMBEDDED {
public:
explicit Checkpoint(ParserBase* parser) {
function_state_ = parser->function_state_;
next_materialized_literal_index_ =
function_state_->next_materialized_literal_index_;
expected_property_count_ = function_state_->expected_property_count_;
}
void Restore(int* materialized_literal_index_delta) {
*materialized_literal_index_delta =
function_state_->next_materialized_literal_index_ -
next_materialized_literal_index_;
function_state_->next_materialized_literal_index_ =
next_materialized_literal_index_;
function_state_->expected_property_count_ = expected_property_count_;
}
private:
FunctionState* function_state_;
int next_materialized_literal_index_;
int expected_property_count_;
};
struct DeclarationDescriptor {
enum Kind { NORMAL, PARAMETER };
Scope* scope;
@ -1469,7 +1433,6 @@ ParserBase<Impl>::FunctionState::FunctionState(
FunctionState** function_state_stack, Scope** scope_stack,
DeclarationScope* scope)
: BlockState(scope_stack, scope),
next_materialized_literal_index_(0),
expected_property_count_(0),
function_state_stack_(function_state_stack),
outer_function_state_(*function_state_stack),
@ -2672,7 +2635,6 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN, bool* ok) {
}
FuncNameInferrer::State fni_state(fni_);
Checkpoint checkpoint(this);
ExpressionClassifier arrow_formals_classifier(
this, classifier()->duplicate_finder());
@ -2735,8 +2697,6 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN, bool* ok) {
parameters.is_simple = false;
}
checkpoint.Restore(&parameters.materialized_literals_count);
scope->set_start_position(lhs_beg_pos);
Scanner::Location duplicate_loc = Scanner::Location::invalid();
impl()->DeclareArrowFunctionFormalParameters(&parameters, expression, loc,
@ -2812,11 +2772,10 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN, bool* ok) {
impl()->RewriteNonPattern(CHECK_OK);
impl()->AccumulateFormalParameterContainmentErrors();
// TODO(1231235): We try to estimate the set of properties set by
// constructors. We define a new property whenever there is an
// assignment to a property of 'this'. We should probably only add
// properties if we haven't seen them before. Otherwise we'll
// probably overestimate the number of properties.
// We try to estimate the set of properties set by constructors. We define a
// new property whenever there is an assignment to a property of 'this'. We
// should probably only add properties if we haven't seen them
// before. Otherwise we'll probably overestimate the number of properties.
if (op == Token::ASSIGN && impl()->IsThisProperty(expression)) {
function_state_->AddProperty();
}

View File

@ -875,7 +875,6 @@ FunctionLiteral* Parser::DoParseFunction(ParseInfo* info,
scope->set_start_position(info->start_position());
ExpressionClassifier formals_classifier(this);
ParserFormalParameters formals(scope);
Checkpoint checkpoint(this);
{
// Parsing patterns as variable reference expression creates
// NewUnresolved references in current scope. Entrer arrow function
@ -893,7 +892,6 @@ FunctionLiteral* Parser::DoParseFunction(ParseInfo* info,
}
if (ok) {
checkpoint.Restore(&formals.materialized_literals_count);
if (GetLastFunctionLiteralId() != info->function_literal_id() - 1) {
// If there were FunctionLiterals in the parameters, we need to
// renumber them to shift down so the next function literal id for