Changeset 86498 in webkit


Ignore:
Timestamp:
May 14, 2011 2:44:33 PM (13 years ago)
Author:
oliver@apple.com
Message:

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

Reviewed by Anders Carlsson.

Make Qt bindings GC safe
https://bugs.webkit.org/show_bug.cgi?id=60841

Trying to do cache management by using "this" as a key from a GC
object's destructor leads to a violation of GC semantics. Make
the qt bindings use a Weak<> handle for finalization.

  • bridge/qt/qt_runtime.cpp: (JSC::Bindings::QtRuntimeMethod::QtRuntimeMethod): (JSC::Bindings::QtRuntimeMethod::~QtRuntimeMethod):
  • bridge/qt/qt_runtime.h: (JSC::Bindings::QtRuntimeMethodData::finalize):
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r86491 r86498  
     12011-05-14  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        Make Qt bindings GC safe
     6        https://bugs.webkit.org/show_bug.cgi?id=60841
     7
     8        Trying to do cache management by using "this" as a key from a GC
     9        object's destructor leads to a violation of GC semantics.  Make
     10        the qt bindings use a Weak<> handle for finalization.
     11
     12        * bridge/qt/qt_runtime.cpp:
     13        (JSC::Bindings::QtRuntimeMethod::QtRuntimeMethod):
     14        (JSC::Bindings::QtRuntimeMethod::~QtRuntimeMethod):
     15        * bridge/qt/qt_runtime.h:
     16        (JSC::Bindings::QtRuntimeMethodData::finalize):
     17
    1182011-05-14  Ryosuke Niwa  <rniwa@webkit.org>
    219
  • trunk/Source/WebCore/bridge/qt/qt_runtime.cpp

    r84556 r86498  
    988988    QW_D(QtRuntimeMethod);
    989989    d->m_instance = inst;
     990    d->m_finalizer.set(exec->globalData(), this, d);
    990991}
    991992
    992993QtRuntimeMethod::~QtRuntimeMethod()
    993994{
    994     QW_D(QtRuntimeMethod);
    995     d->m_instance->removeCachedMethod(this);
    996995    delete d_ptr;
    997996}
     
    10011000QtRuntimeMethodData::~QtRuntimeMethodData()
    10021001{
     1002}
     1003
     1004void QtRuntimeMethodData::finalize(Handle<Unknown> value, void*)
     1005{
     1006    m_instance->removeCachedMethod(static_cast<JSObject*>(value.get().asCell()));
    10031007}
    10041008
  • trunk/Source/WebCore/bridge/qt/qt_runtime.h

    r84556 r86498  
    2424#include "Completion.h"
    2525#include "Strong.h"
     26#include "Weak.h"
    2627#include "runtime_method.h"
    2728
     
    116117
    117118// Extra data classes (to avoid the CELL_SIZE limit on JS objects)
    118 
    119 class QtRuntimeMethodData {
     119class QtRuntimeMethod;
     120class QtRuntimeMethodData : public WeakHandleOwner {
    120121    public:
    121122        virtual ~QtRuntimeMethodData();
    122123        RefPtr<QtInstance> m_instance;
     124        Weak<QtRuntimeMethod> m_finalizer;
     125
     126    private:
     127        void finalize(Handle<Unknown>, void*);
    123128};
    124129
Note: See TracChangeset for help on using the changeset viewer.