Bug 841801 - Enable finalization of objects on the background thread r=billm

--HG--
extra : rebase_source : a08fb0b68aeffac400d300715ac874cfcbf535fc
This commit is contained in:
Jon Coppeard 2013-02-15 10:18:46 +00:00
parent 3f372d1044
commit 87c20f6619
2 changed files with 5 additions and 6 deletions

View File

@ -3047,6 +3047,8 @@ struct JSClass {
#define JSCLASS_USERBIT2 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+6))
#define JSCLASS_USERBIT3 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+7))
#define JSCLASS_BACKGROUND_FINALIZE (1<<(JSCLASS_HIGH_FLAGS_SHIFT+8))
/*
* Bits 26 through 31 are reserved for the CACHED_PROTO_KEY mechanism, see
* below.

View File

@ -241,11 +241,6 @@ JSObject::finalize(js::FreeOp *fop)
}
#endif
/*
* Finalize obj first, in case it needs map and slots. Objects with
* finalize hooks are not finalized in the background, as the class is
* stored in the object's shape, which may have already been destroyed.
*/
js::Class *clasp = getClass();
if (clasp->finalize)
clasp->finalize(fop, this);
@ -943,6 +938,7 @@ JSObject::create(JSContext *cx, js::gc::AllocKind kind, js::gc::InitialHeap heap
JS_ASSERT(!!dynamicSlotsCount(shape->numFixedSlots(), shape->slotSpan()) == !!slots);
JS_ASSERT(js::gc::GetGCKindSlots(kind, type->clasp) == shape->numFixedSlots());
JS_ASSERT(cx->compartment == type->compartment());
JS_ASSERT_IF(type->clasp->flags & JSCLASS_BACKGROUND_FINALIZE, IsBackgroundFinalized(kind));
JSObject *obj = js_NewGCObject<js::CanGC>(cx, kind, heap);
if (!obj)
@ -1563,7 +1559,8 @@ CanBeFinalizedInBackground(gc::AllocKind kind, Class *clasp)
* IsBackgroundFinalized is called to prevent recursively incrementing
* the finalize kind; kind may already be a background finalize kind.
*/
return (!gc::IsBackgroundFinalized(kind) && !clasp->finalize);
return (!gc::IsBackgroundFinalized(kind) &&
(!clasp->finalize || (clasp->flags & JSCLASS_BACKGROUND_FINALIZE)));
}
/*