Commit dc6a5939 authored by adamk's avatar adamk Committed by Commit bot

[ast cleanup] Remove unnecessary frozen_ bit from ModuleDescriptor

This may have made more sense in the old module design (where
"unification" was a thing), but as-is it's only used for a few
asserts in debug mode. These asserts don't make much sense inside
ModuleDescriptor; instead, as the modules implementation is fleshed
out, I expect the appropriate replacement asserts to show up at the
use of the ModuleDescriptor.

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

Cr-Commit-Position: refs/heads/master@{#33345}
parent 25532be5
...@@ -13,7 +13,6 @@ namespace internal { ...@@ -13,7 +13,6 @@ namespace internal {
void ModuleDescriptor::AddLocalExport(const AstRawString* export_name, void ModuleDescriptor::AddLocalExport(const AstRawString* export_name,
const AstRawString* local_name, const AstRawString* local_name,
Zone* zone, bool* ok) { Zone* zone, bool* ok) {
DCHECK(!IsFrozen());
void* key = const_cast<AstRawString*>(export_name); void* key = const_cast<AstRawString*>(export_name);
ZoneAllocationPolicy allocator(zone); ZoneAllocationPolicy allocator(zone);
......
...@@ -26,8 +26,7 @@ class ModuleDescriptor : public ZoneObject { ...@@ -26,8 +26,7 @@ class ModuleDescriptor : public ZoneObject {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Mutators. // Mutators.
// Add a name to the list of exports. If it already exists, or this descriptor // Add a name to the list of exports. If it already exists, that's an error.
// is frozen, that's an error.
void AddLocalExport(const AstRawString* export_name, void AddLocalExport(const AstRawString* export_name,
const AstRawString* local_name, Zone* zone, bool* ok); const AstRawString* local_name, Zone* zone, bool* ok);
...@@ -35,30 +34,22 @@ class ModuleDescriptor : public ZoneObject { ...@@ -35,30 +34,22 @@ class ModuleDescriptor : public ZoneObject {
// if not already present. // if not already present.
void AddModuleRequest(const AstRawString* module_specifier, Zone* zone); void AddModuleRequest(const AstRawString* module_specifier, Zone* zone);
// Do not allow any further refinements, directly or through unification.
void Freeze() { frozen_ = true; }
// Assign an index. // Assign an index.
void Allocate(int index) { void Allocate(int index) {
DCHECK(IsFrozen() && index_ == -1); DCHECK_EQ(-1, index_);
index_ = index; index_ = index;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Accessors. // Accessors.
// Check whether this is closed (i.e. fully determined).
bool IsFrozen() { return frozen_; }
int Length() { int Length() {
DCHECK(IsFrozen());
ZoneHashMap* exports = exports_; ZoneHashMap* exports = exports_;
return exports ? exports->occupancy() : 0; return exports ? exports->occupancy() : 0;
} }
// The context slot in the hosting script context pointing to this module. // The context slot in the hosting script context pointing to this module.
int Index() { int Index() {
DCHECK(IsFrozen());
return index_; return index_;
} }
...@@ -104,12 +95,8 @@ class ModuleDescriptor : public ZoneObject { ...@@ -104,12 +95,8 @@ class ModuleDescriptor : public ZoneObject {
// Implementation. // Implementation.
private: private:
explicit ModuleDescriptor(Zone* zone) explicit ModuleDescriptor(Zone* zone)
: frozen_(false), : exports_(NULL), requested_modules_(1, zone), index_(-1) {}
exports_(NULL),
requested_modules_(1, zone),
index_(-1) {}
bool frozen_;
ZoneHashMap* exports_; // Module exports and their types (allocated lazily) ZoneHashMap* exports_; // Module exports and their types (allocated lazily)
ZoneList<const AstRawString*> requested_modules_; ZoneList<const AstRawString*> requested_modules_;
int index_; int index_;
......
...@@ -1347,7 +1347,6 @@ void* Parser::ParseModuleItemList(ZoneList<Statement*>* body, bool* ok) { ...@@ -1347,7 +1347,6 @@ void* Parser::ParseModuleItemList(ZoneList<Statement*>* body, bool* ok) {
} }
} }
scope_->module()->Freeze();
return NULL; return NULL;
} }
......
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