summaryrefslogtreecommitdiffstats
path: root/js/src/builtin/ModuleObject.h
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-07-08 14:53:31 +0000
committerMoonchild <moonchild@palemoon.org>2020-07-08 14:53:31 +0000
commite94f9dcced92b4bde5c60185a86d3d801359ea65 (patch)
treebcfe5d795e6313d98c58ef8284d5163c06576b39 /js/src/builtin/ModuleObject.h
parent6e72707e0b72411df12827ae1ab882ab5177f983 (diff)
downloadUXP-e94f9dcced92b4bde5c60185a86d3d801359ea65.tar
UXP-e94f9dcced92b4bde5c60185a86d3d801359ea65.tar.gz
UXP-e94f9dcced92b4bde5c60185a86d3d801359ea65.tar.lz
UXP-e94f9dcced92b4bde5c60185a86d3d801359ea65.tar.xz
UXP-e94f9dcced92b4bde5c60185a86d3d801359ea65.zip
Issue #618 - Lazily initialise module binding maps
Make it so they are not allocated on a background thread in a different zone to the final module. Ref: BZ 1372258
Diffstat (limited to 'js/src/builtin/ModuleObject.h')
-rw-r--r--js/src/builtin/ModuleObject.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/js/src/builtin/ModuleObject.h b/js/src/builtin/ModuleObject.h
index bd3e7044e..5e4e7f342 100644
--- a/js/src/builtin/ModuleObject.h
+++ b/js/src/builtin/ModuleObject.h
@@ -7,6 +7,8 @@
#ifndef builtin_ModuleObject_h
#define builtin_ModuleObject_h
+#include "mozilla/Maybe.h"
+
#include "jsapi.h"
#include "jsatom.h"
@@ -102,27 +104,27 @@ typedef Handle<ExportEntryObject*> HandleExportEntryObject;
class IndirectBindingMap
{
public:
- explicit IndirectBindingMap(Zone* zone);
- bool init();
-
void trace(JSTracer* trc);
bool put(JSContext* cx, HandleId name,
HandleModuleEnvironmentObject environment, HandleId localName);
size_t count() const {
- return map_.count();
+ return map_ ? map_->count() : 0;
}
bool has(jsid name) const {
- return map_.has(name);
+ return map_ ? map_->has(name) : false;
}
bool lookup(jsid name, ModuleEnvironmentObject** envOut, Shape** shapeOut) const;
template <typename Func>
void forEachExportedName(Func func) const {
- for (auto r = map_.all(); !r.empty(); r.popFront())
+ if (!map_)
+ return;
+
+ for (auto r = map_->all(); !r.empty(); r.popFront())
func(r.front().key());
}
@@ -136,7 +138,7 @@ class IndirectBindingMap
typedef HashMap<jsid, Binding, DefaultHasher<jsid>, ZoneAllocPolicy> Map;
- Map map_;
+ mozilla::Maybe<Map> map_;
};
class ModuleNamespaceObject : public ProxyObject