Changeset 86594 in webkit


Ignore:
Timestamp:
May 16, 2011 11:54:40 AM (13 years ago)
Author:
oliver@apple.com
Message:

2011-05-16 Oliver Hunt <oliver@apple.com>

Reviewed by Geoffrey Garen.

JSWeakObjectMap finalisation may occur while gc is in inconsistent state
https://bugs.webkit.org/show_bug.cgi?id=60908
<rdar://problem/9409491>

We need to ensure that we have called all the weak map finalizers while
the global object (and hence global context) is still in a consistent
state. The best way to achieve this is to simply use a weak handle and
finalizer on the global object.

  • JavaScriptCore.exp:
  • runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::WeakMapFinalizer::finalize):
  • runtime/JSGlobalObject.h: (JSC::JSGlobalObject::registerWeakMap):
Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r86560 r86594  
     12011-05-16  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Geoffrey Garen.
     4
     5        JSWeakObjectMap finalisation may occur while gc is in inconsistent state
     6        https://bugs.webkit.org/show_bug.cgi?id=60908
     7        <rdar://problem/9409491>
     8
     9        We need to ensure that we have called all the weak map finalizers while
     10        the global object (and hence global context) is still in a consistent
     11        state.  The best way to achieve this is to simply use a weak handle and
     12        finalizer on the global object.
     13
     14        * JavaScriptCore.exp:
     15        * runtime/JSGlobalObject.cpp:
     16        (JSC::JSGlobalObject::WeakMapFinalizer::finalize):
     17        * runtime/JSGlobalObject.h:
     18        (JSC::JSGlobalObject::registerWeakMap):
     19
    1202011-05-16  Siddharth Mathur  <siddharth.mathur@nokia.com>
    221
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r86499 r86594  
    445445}
    446446
     447void JSGlobalObject::WeakMapsFinalizer::finalize(Handle<Unknown> handle, void*)
     448{
     449    JSGlobalObject* globalObject = asGlobalObject(handle.get());
     450    globalObject->m_weakMaps.clear();
     451}
     452
     453JSGlobalObject::WeakMapsFinalizer* JSGlobalObject::weakMapsFinalizer()
     454{
     455    static WeakMapsFinalizer* finalizer = new WeakMapsFinalizer();
     456    return finalizer;
     457}
     458
    447459DynamicGlobalObjectScope::DynamicGlobalObjectScope(JSGlobalData& globalData, JSGlobalObject* dynamicGlobalObject)
    448460    : m_dynamicGlobalObjectSlot(globalData.dynamicGlobalObject)
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r85388 r86594  
    109109
    110110        WeakMapSet m_weakMaps;
     111        Weak<JSGlobalObject> m_weakMapsFinalizer;
     112        class WeakMapsFinalizer : public WeakHandleOwner {
     113        public:
     114            virtual void finalize(Handle<Unknown>, void* context);
     115        };
     116        static WeakMapsFinalizer* weakMapsFinalizer();
     117
    111118        WeakRandom m_weakRandom;
    112119
     
    257264        void registerWeakMap(OpaqueJSWeakObjectMap* map)
    258265        {
     266            if (!m_weakMapsFinalizer)
     267                m_weakMapsFinalizer.set(globalData(), this, weakMapsFinalizer());
    259268            m_weakMaps.add(map);
    260269        }
Note: See TracChangeset for help on using the changeset viewer.