Commit aa00ad0c authored by oliver@apple.com's avatar oliver@apple.com

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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@86498 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3e84409c
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):
2011-05-14 Ryosuke Niwa <rniwa@webkit.org>
Reviewed by Eric Seidel.
......@@ -987,12 +987,11 @@ QtRuntimeMethod::QtRuntimeMethod(QtRuntimeMethodData* dd, ExecState* exec, const
{
QW_D(QtRuntimeMethod);
d->m_instance = inst;
d->m_finalizer.set(exec->globalData(), this, d);
}
QtRuntimeMethod::~QtRuntimeMethod()
{
QW_D(QtRuntimeMethod);
d->m_instance->removeCachedMethod(this);
delete d_ptr;
}
......@@ -1002,6 +1001,11 @@ QtRuntimeMethodData::~QtRuntimeMethodData()
{
}
void QtRuntimeMethodData::finalize(Handle<Unknown> value, void*)
{
m_instance->removeCachedMethod(static_cast<JSObject*>(value.get().asCell()));
}
QtRuntimeMetaMethodData::~QtRuntimeMetaMethodData()
{
......
......@@ -23,6 +23,7 @@
#include "BridgeJSC.h"
#include "Completion.h"
#include "Strong.h"
#include "Weak.h"
#include "runtime_method.h"
#include <qbytearray.h>
......@@ -115,11 +116,15 @@ private:
// Based on RuntimeMethod
// Extra data classes (to avoid the CELL_SIZE limit on JS objects)
class QtRuntimeMethodData {
class QtRuntimeMethod;
class QtRuntimeMethodData : public WeakHandleOwner {
public:
virtual ~QtRuntimeMethodData();
RefPtr<QtInstance> m_instance;
Weak<QtRuntimeMethod> m_finalizer;
private:
void finalize(Handle<Unknown>, void*);
};
class QtRuntimeConnectionMethod;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment