Bug 819443 - Make sure we don't finalize on background thread (r=luke)

This commit is contained in:
Bill McCloskey 2012-12-12 13:17:45 -08:00
parent 935ede40ea
commit 89f5ca56f4
2 changed files with 7 additions and 0 deletions

View File

@ -482,7 +482,11 @@ struct JSRuntime : js::RuntimeFriendFields
void clearOwnerThread(); void clearOwnerThread();
void setOwnerThread(); void setOwnerThread();
JS_FRIEND_API(void) abortIfWrongThread() const; JS_FRIEND_API(void) abortIfWrongThread() const;
#ifdef DEBUG
JS_FRIEND_API(void) assertValidThread() const; JS_FRIEND_API(void) assertValidThread() const;
#else
void assertValidThread() const {}
#endif
private: private:
void *ownerThread_; void *ownerThread_;
public: public:

View File

@ -225,6 +225,9 @@ JSObject::finalize(js::FreeOp *fop)
js::Probes::finalizeObject(this); js::Probes::finalizeObject(this);
if (!IsBackgroundFinalized(getAllocKind())) { if (!IsBackgroundFinalized(getAllocKind())) {
/* Assert we're on the main thread. */
fop->runtime()->assertValidThread();
/* /*
* Finalize obj first, in case it needs map and slots. Objects with * Finalize obj first, in case it needs map and slots. Objects with
* finalize hooks are not finalized in the background, as the class is * finalize hooks are not finalized in the background, as the class is