Commit b1d53a15 authored by verwaest's avatar verwaest Committed by Commit bot

Replace SloppyBlockFunctionMap::Vector with linked list through SloppyBlockFunctionStatement

BUG=v8:5209

Review-Url: https://codereview.chromium.org/2226803003
Cr-Commit-Position: refs/heads/master@{#38460}
parent 42cc6c05
...@@ -1187,6 +1187,8 @@ class SloppyBlockFunctionStatement final : public Statement { ...@@ -1187,6 +1187,8 @@ class SloppyBlockFunctionStatement final : public Statement {
Statement* statement() const { return statement_; } Statement* statement() const { return statement_; }
void set_statement(Statement* statement) { statement_ = statement; } void set_statement(Statement* statement) { statement_ = statement; }
Scope* scope() const { return scope_; } Scope* scope() const { return scope_; }
SloppyBlockFunctionStatement* next() { return next_; }
void set_next(SloppyBlockFunctionStatement* next) { next_ = next; }
private: private:
friend class AstNodeFactory; friend class AstNodeFactory;
...@@ -1194,10 +1196,12 @@ class SloppyBlockFunctionStatement final : public Statement { ...@@ -1194,10 +1196,12 @@ class SloppyBlockFunctionStatement final : public Statement {
SloppyBlockFunctionStatement(Zone* zone, Statement* statement, Scope* scope) SloppyBlockFunctionStatement(Zone* zone, Statement* statement, Scope* scope)
: Statement(zone, kNoSourcePosition, kSloppyBlockFunctionStatement), : Statement(zone, kNoSourcePosition, kSloppyBlockFunctionStatement),
statement_(statement), statement_(statement),
scope_(scope) {} scope_(scope),
next_(nullptr) {}
Statement* statement_; Statement* statement_;
Scope* const scope_; Scope* const scope_;
SloppyBlockFunctionStatement* next_;
}; };
......
...@@ -67,11 +67,8 @@ void SloppyBlockFunctionMap::Declare(Zone* zone, const AstRawString* name, ...@@ -67,11 +67,8 @@ void SloppyBlockFunctionMap::Declare(Zone* zone, const AstRawString* name,
Entry* p = Entry* p =
ZoneHashMap::LookupOrInsert(const_cast<AstRawString*>(name), name->hash(), ZoneHashMap::LookupOrInsert(const_cast<AstRawString*>(name), name->hash(),
ZoneAllocationPolicy(zone)); ZoneAllocationPolicy(zone));
if (p->value == nullptr) { stmt->set_next(static_cast<SloppyBlockFunctionStatement*>(p->value));
p->value = new (zone->New(sizeof(Vector))) Vector(zone); p->value = stmt;
}
Vector* delegates = static_cast<Vector*>(p->value);
delegates->push_back(stmt);
} }
......
...@@ -57,7 +57,6 @@ class SloppyBlockFunctionMap : public ZoneHashMap { ...@@ -57,7 +57,6 @@ class SloppyBlockFunctionMap : public ZoneHashMap {
explicit SloppyBlockFunctionMap(Zone* zone); explicit SloppyBlockFunctionMap(Zone* zone);
void Declare(Zone* zone, const AstRawString* name, void Declare(Zone* zone, const AstRawString* name,
SloppyBlockFunctionStatement* statement); SloppyBlockFunctionStatement* statement);
typedef ZoneVector<SloppyBlockFunctionStatement*> Vector;
}; };
......
...@@ -5272,7 +5272,7 @@ void Parser::InsertSloppyBlockFunctionVarBindings(DeclarationScope* scope, ...@@ -5272,7 +5272,7 @@ void Parser::InsertSloppyBlockFunctionVarBindings(DeclarationScope* scope,
bool var_created = false; bool var_created = false;
// Write in assignments to var for each block-scoped function declaration // Write in assignments to var for each block-scoped function declaration
auto delegates = static_cast<SloppyBlockFunctionMap::Vector*>(p->value); auto delegates = static_cast<SloppyBlockFunctionStatement*>(p->value);
DeclarationScope* decl_scope = scope; DeclarationScope* decl_scope = scope;
while (decl_scope->is_eval_scope()) { while (decl_scope->is_eval_scope()) {
...@@ -5280,7 +5280,8 @@ void Parser::InsertSloppyBlockFunctionVarBindings(DeclarationScope* scope, ...@@ -5280,7 +5280,8 @@ void Parser::InsertSloppyBlockFunctionVarBindings(DeclarationScope* scope,
} }
Scope* outer_scope = decl_scope->outer_scope(); Scope* outer_scope = decl_scope->outer_scope();
for (SloppyBlockFunctionStatement* delegate : *delegates) { for (SloppyBlockFunctionStatement* delegate = delegates;
delegate != nullptr; delegate = delegate->next()) {
// Check if there's a conflict with a lexical declaration // Check if there's a conflict with a lexical declaration
Scope* query_scope = delegate->scope()->outer_scope(); Scope* query_scope = delegate->scope()->outer_scope();
Variable* var = nullptr; Variable* var = nullptr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment