Bug 940071: Free the proto and iface cache for generated globals. r=bz

This commit is contained in:
Kyle Huey 2013-11-19 14:05:42 +08:00
parent 46505eecd5
commit 7b4374f293
3 changed files with 22 additions and 0 deletions

View File

@ -2167,6 +2167,13 @@ TraceGlobal(JSTracer* aTrc, JSObject* aObj)
mozilla::dom::TraceProtoAndIfaceCache(aTrc, aObj);
}
void
FinalizeGlobal(JSFreeOp* aFreeOp, JSObject* aObj)
{
MOZ_ASSERT(js::GetObjectClass(aObj)->flags & JSCLASS_DOM_GLOBAL);
mozilla::dom::DestroyProtoAndIfaceCache(aObj);
}
bool
ResolveGlobal(JSContext* aCx, JS::Handle<JSObject*> aObj,
JS::MutableHandle<jsid> aId, unsigned aFlags,

View File

@ -290,6 +290,11 @@ AllocateProtoAndIfaceCache(JSObject* obj)
js::SetReservedSlot(obj, DOM_PROTOTYPE_SLOT,
JS::PrivateValue(protoAndIfaceArray));
#ifdef NS_BUILD_REFCNT_LOGGING
NS_LogCtor((void*)protoAndIfaceArray, "ProtoAndIfaceArray",
sizeof(JS::Heap<JSObject*>) * kProtoAndIfaceCacheCount);
#endif
}
inline void
@ -314,6 +319,11 @@ DestroyProtoAndIfaceCache(JSObject* obj)
JS::Heap<JSObject*>* protoAndIfaceArray = GetProtoAndIfaceArray(obj);
#ifdef NS_BUILD_REFCNT_LOGGING
NS_LogDtor((void*)protoAndIfaceArray, "ProtoAndIfaceArray",
sizeof(JS::Heap<JSObject*>) * kProtoAndIfaceCacheCount);
#endif
delete [] protoAndIfaceArray;
}
@ -2274,6 +2284,9 @@ ThreadsafeCheckIsChrome(JSContext* aCx, JSObject* aObj);
void
TraceGlobal(JSTracer* aTrc, JSObject* aObj);
void
FinalizeGlobal(JSFreeOp* aFop, JSObject* aObj);
bool
ResolveGlobal(JSContext* aCx, JS::Handle<JSObject*> aObj,
JS::MutableHandle<jsid> aId, unsigned aFlags,

View File

@ -1084,6 +1084,8 @@ def finalizeHook(descriptor, hookName, context):
finalize += "ClearWrapper(self, self);\n"
if descriptor.interface.getExtendedAttribute('OverrideBuiltins'):
finalize += "self->mExpandoAndGeneration.expando = JS::UndefinedValue();\n"
if descriptor.interface.getExtendedAttribute("Global"):
finalize += "mozilla::dom::FinalizeGlobal(fop, obj);\n"
if descriptor.nativeOwnership == 'worker':
finalize += "self->Release();"
else: