Index: src/interface.h |
diff --git a/src/interface.h b/src/interface.h |
index 94ef11ba5c29d40f40e3755cafd16f2837252cfc..f824a9a8749b91b59805034d924eff5fd70f7fab 100644 |
--- a/src/interface.h |
+++ b/src/interface.h |
@@ -108,18 +108,18 @@ class Interface : public ZoneObject { |
if (*ok) Chase()->flags_ |= MODULE; |
} |
- // Set associated instance object. |
- void MakeSingleton(Handle<JSModule> instance, bool* ok) { |
- *ok = IsModule() && Chase()->instance_.is_null(); |
- if (*ok) Chase()->instance_ = instance; |
- } |
- |
// Do not allow any further refinements, directly or through unification. |
void Freeze(bool* ok) { |
*ok = IsValue() || IsModule(); |
if (*ok) Chase()->flags_ |= FROZEN; |
} |
+ // Assign an index. |
+ void Allocate(int index) { |
+ ASSERT(IsModule() && IsFrozen() && Chase()->index_ == -1); |
+ Chase()->index_ = index; |
+ } |
+ |
// --------------------------------------------------------------------------- |
// Accessors. |
@@ -138,7 +138,23 @@ class Interface : public ZoneObject { |
// Check whether this is closed (i.e. fully determined). |
bool IsFrozen() { return Chase()->flags_ & FROZEN; } |
- Handle<JSModule> Instance() { return Chase()->instance_; } |
+ bool IsUnified(Interface* that) { |
+ return Chase() == that->Chase() |
+ || (this->IsValue() == that->IsValue() && |
+ this->IsConst() == that->IsConst()); |
+ } |
+ |
+ int Length() { |
+ ASSERT(IsModule() && IsFrozen()); |
+ ZoneHashMap* exports = Chase()->exports_; |
+ return exports ? exports->occupancy() : 0; |
+ } |
+ |
+ // The context slot in the hosting global context pointing to this module. |
+ int Index() { |
+ ASSERT(IsModule() && IsFrozen()); |
+ return Chase()->index_; |
+ } |
// Look up an exported name. Returns NULL if not (yet) defined. |
Interface* Lookup(Handle<String> name, Zone* zone); |
@@ -194,12 +210,13 @@ class Interface : public ZoneObject { |
int flags_; |
Interface* forward_; // Unification link |
ZoneHashMap* exports_; // Module exports and their types (allocated lazily) |
- Handle<JSModule> instance_; |
+ int index_; |
explicit Interface(int flags) |
: flags_(flags), |
forward_(NULL), |
- exports_(NULL) { |
+ exports_(NULL), |
+ index_(-1) { |
#ifdef DEBUG |
if (FLAG_print_interface_details) |
PrintF("# Creating %p\n", static_cast<void*>(this)); |