diff --git a/js/src/vm/EnvironmentObject.cpp b/js/src/vm/EnvironmentObject.cpp index 1c87e552ca..5ea7971e0e 100644 --- a/js/src/vm/EnvironmentObject.cpp +++ b/js/src/vm/EnvironmentObject.cpp @@ -633,7 +633,7 @@ const Class WasmFunctionCallObject::class_ = { }; /* static */ WasmFunctionCallObject* -WasmFunctionCallObject::createHollowForDebug(JSContext* cx, WasmFunctionScope* scope) +WasmFunctionCallObject::createHollowForDebug(JSContext* cx, Handle scope) { RootedObjectGroup group(cx, ObjectGroup::defaultNewGroup(cx, &class_, TaggedProto(nullptr))); if (!group) @@ -652,6 +652,7 @@ WasmFunctionCallObject::createHollowForDebug(JSContext* cx, WasmFunctionScope* s Rooted callobj(cx, &obj->as()); callobj->initEnclosingEnvironment(&cx->global()->lexicalEnvironment()); + callobj->initReservedSlot(SCOPE_SLOT, PrivateGCThingValue(scope)); return callobj; } diff --git a/js/src/vm/EnvironmentObject.h b/js/src/vm/EnvironmentObject.h index 63eded443b..4c7e53adcc 100644 --- a/js/src/vm/EnvironmentObject.h +++ b/js/src/vm/EnvironmentObject.h @@ -427,13 +427,19 @@ typedef MutableHandle MutableHandleModuleEnvironmentOb class WasmFunctionCallObject : public EnvironmentObject { + // Currently WasmFunctionCallObjects do not use their scopes in a + // meaningful way. However, it is an invariant of DebugEnvironments that + // environments kept in those maps have live scopes, thus this strong + // reference. + static const uint32_t SCOPE_SLOT = 1; + public: static const Class class_; - static const uint32_t RESERVED_SLOTS = 1; + static const uint32_t RESERVED_SLOTS = 2; static WasmFunctionCallObject* createHollowForDebug(JSContext* cx, - WasmFunctionScope* scope); + Handle scope); }; class LexicalEnvironmentObject : public EnvironmentObject