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 {
Statement* statement() const { return statement_; }
void set_statement(Statement* statement) { statement_ = statement; }
Scope* scope() const { return scope_; }
SloppyBlockFunctionStatement* next() { return next_; }
void set_next(SloppyBlockFunctionStatement* next) { next_ = next; }
private:
friend class AstNodeFactory;
......@@ -1194,10 +1196,12 @@ class SloppyBlockFunctionStatement final : public Statement {
SloppyBlockFunctionStatement(Zone* zone, Statement* statement, Scope* scope)
: Statement(zone, kNoSourcePosition, kSloppyBlockFunctionStatement),
statement_(statement),
scope_(scope) {}
scope_(scope),
next_(nullptr) {}
Statement* statement_;
Scope* const scope_;
SloppyBlockFunctionStatement* next_;
};
......
......@@ -67,11 +67,8 @@ void SloppyBlockFunctionMap::Declare(Zone* zone, const AstRawString* name,
Entry* p =
ZoneHashMap::LookupOrInsert(const_cast<AstRawString*>(name), name->hash(),
ZoneAllocationPolicy(zone));
if (p->value == nullptr) {
p->value = new (zone->New(sizeof(Vector))) Vector(zone);
}
Vector* delegates = static_cast<Vector*>(p->value);
delegates->push_back(stmt);
stmt->set_next(static_cast<SloppyBlockFunctionStatement*>(p->value));
p->value = stmt;
}
......
......@@ -57,7 +57,6 @@ class SloppyBlockFunctionMap : public ZoneHashMap {
explicit SloppyBlockFunctionMap(Zone* zone);
void Declare(Zone* zone, const AstRawString* name,
SloppyBlockFunctionStatement* statement);
typedef ZoneVector<SloppyBlockFunctionStatement*> Vector;
};
......
......@@ -5272,7 +5272,7 @@ void Parser::InsertSloppyBlockFunctionVarBindings(DeclarationScope* scope,
bool var_created = false;
// 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;
while (decl_scope->is_eval_scope()) {
......@@ -5280,7 +5280,8 @@ void Parser::InsertSloppyBlockFunctionVarBindings(DeclarationScope* 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
Scope* query_scope = delegate->scope()->outer_scope();
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