Changeset 126301 in webkit


Ignore:
Timestamp:
Aug 22, 2012 7:13:19 AM (12 years ago)
Author:
Csaba Osztrogonác
Message:

Unreviewed, rolling out r126287.
http://trac.webkit.org/changeset/126287
https://bugs.webkit.org/show_bug.cgi?id=94708

It made WK1 layout testing 3.7x slower (>1hours) (Requested by
ossy on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-08-22

Source/WebCore:

  • bridge/qt/qt_instance.cpp:

(JSC::Bindings::unusedWeakObjectMapCallback):
(Bindings):
(JSC::Bindings::WeakMapImpl::WeakMapImpl):
(JSC::Bindings::WeakMapImpl::~WeakMapImpl):
(JSC::Bindings::WeakMap::~WeakMap):
(JSC::Bindings::WeakMap::set):
(JSC::Bindings::WeakMap::get):
(JSC::Bindings::WeakMap::remove):

  • bridge/qt/qt_instance.h:

(QtInstance):

  • bridge/qt/qt_runtime.cpp:

(JSC::Bindings::prototypeForSignalsAndSlots):
(JSC::Bindings::QtRuntimeMethod::~QtRuntimeMethod):
(JSC::Bindings::QtRuntimeMethod::call):
(JSC::Bindings::QtRuntimeMethod::jsObjectRef):
(JSC::Bindings::QtRuntimeMethod::connectOrDisconnect):

  • bridge/qt/qt_runtime.h:

(QtRuntimeMethod):

Source/WebKit/qt:

  • tests/qobjectbridge/tst_qobjectbridge.cpp:

(tst_QObjectBridge::objectDeleted):
(tst_QObjectBridge::introspectQtMethods_data):
(tst_QObjectBridge::introspectQtMethods):

LayoutTests:

  • platform/qt/Skipped:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r126292 r126301  
     12012-08-22  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r126287.
     4        http://trac.webkit.org/changeset/126287
     5        https://bugs.webkit.org/show_bug.cgi?id=94708
     6
     7        It made WK1 layout testing 3.7x slower (>1hours) (Requested by
     8        ossy on #webkit).
     9
     10        * platform/qt/Skipped:
     11
    1122012-08-22  KwangYong Choi  <ky0.choi@samsung.com>
    213
  • trunk/LayoutTests/platform/qt/Skipped

    r126287 r126301  
    27312731svg/custom/use-instanceRoot-as-event-target.xhtml
    27322732
     2733# https://bugs.webkit.org/show_bug.cgi?id=93897
     2734fast/profiler/nested-start-and-stop-profiler.html
     2735
    27332736# New test introduced in r125648 fast/events/autoscroll-in-textarea.html fails
    27342737# https://bugs.webkit.org/show_bug.cgi?id=94076
  • trunk/Source/WebCore/ChangeLog

    r126300 r126301  
     12012-08-22  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r126287.
     4        http://trac.webkit.org/changeset/126287
     5        https://bugs.webkit.org/show_bug.cgi?id=94708
     6
     7        It made WK1 layout testing 3.7x slower (>1hours) (Requested by
     8        ossy on #webkit).
     9
     10        * bridge/qt/qt_instance.cpp:
     11        (JSC::Bindings::unusedWeakObjectMapCallback):
     12        (Bindings):
     13        (JSC::Bindings::WeakMapImpl::WeakMapImpl):
     14        (JSC::Bindings::WeakMapImpl::~WeakMapImpl):
     15        (JSC::Bindings::WeakMap::~WeakMap):
     16        (JSC::Bindings::WeakMap::set):
     17        (JSC::Bindings::WeakMap::get):
     18        (JSC::Bindings::WeakMap::remove):
     19        * bridge/qt/qt_instance.h:
     20        (QtInstance):
     21        * bridge/qt/qt_runtime.cpp:
     22        (JSC::Bindings::prototypeForSignalsAndSlots):
     23        (JSC::Bindings::QtRuntimeMethod::~QtRuntimeMethod):
     24        (JSC::Bindings::QtRuntimeMethod::call):
     25        (JSC::Bindings::QtRuntimeMethod::jsObjectRef):
     26        (JSC::Bindings::QtRuntimeMethod::connectOrDisconnect):
     27        * bridge/qt/qt_runtime.h:
     28        (QtRuntimeMethod):
     29
    1302012-08-22  Pavel Feldman  <pfeldman@chromium.org>
    231
  • trunk/Source/WebCore/bridge/qt/qt_instance.cpp

    r126290 r126301  
    4242namespace Bindings {
    4343
     44static void unusedWeakObjectMapCallback(JSWeakObjectMapRef, void*)
     45{
     46}
     47
     48WeakMapImpl::WeakMapImpl(JSContextGroupRef group)
     49{
     50    m_context = JSGlobalContextCreateInGroup(group, 0);
     51    // Deleted by GC when m_context's globalObject gets collected.
     52    m_map = JSWeakObjectMapCreate(m_context, 0, unusedWeakObjectMapCallback);
     53}
     54
     55WeakMapImpl::~WeakMapImpl()
     56{
     57    JSGlobalContextRelease(m_context);
     58    m_context = 0;
     59    m_map = 0;
     60}
     61
     62typedef HashMap<JSContextGroupRef, RefPtr<WeakMapImpl> > WeakMapSet;
     63static WeakMapSet weakMaps;
     64
     65WeakMap::~WeakMap()
     66{
     67    // If this is the last WeakMap instance left, then we should remove
     68    // the cached WeakMapImpl from the global weakMaps, too.
     69    if (m_impl && m_impl->refCount() == 2) {
     70        weakMaps.remove(JSContextGetGroup(m_impl->m_context));
     71        ASSERT(m_impl->hasOneRef());
     72    }
     73}
     74
     75void WeakMap::set(JSContextRef context, void *key, JSObjectRef object)
     76{
     77    if (!m_impl) {
     78        JSContextGroupRef group = JSContextGetGroup(context);
     79        WeakMapSet::AddResult entry = weakMaps.add(group, 0);
     80        if (entry.isNewEntry)
     81            entry.iterator->second = adoptRef(new WeakMapImpl(group));
     82        m_impl = entry.iterator->second;
     83    }
     84    JSWeakObjectMapSet(m_impl->m_context, m_impl->m_map, key, object);
     85}
     86
     87JSObjectRef WeakMap::get(void* key)
     88{
     89    if (!m_impl)
     90        return 0;
     91    return JSWeakObjectMapGet(m_impl->m_context, m_impl->m_map, key);
     92}
     93
     94void WeakMap::remove(void *key)
     95{
     96    if (!m_impl)
     97        return;
     98    JSWeakObjectMapRemove(m_impl->m_context, m_impl->m_map, key);
     99}
     100
    44101// Cache QtInstances
    45102typedef QMultiHash<void*, QtInstance*> QObjectInstanceMap;
  • trunk/Source/WebCore/bridge/qt/qt_instance.h

    r126287 r126301  
    110110    QObject* m_hashkey;
    111111    mutable QHash<QByteArray, QtRuntimeMethod*> m_methods;
     112    WeakMap m_cachedMethods;
    112113    mutable QHash<QString, QtField*> m_fields;
    113114    ValueOwnership m_ownership;
  • trunk/Source/WebCore/bridge/qt/qt_runtime.cpp

    r126290 r126301  
    13111311{
    13121312    static JSClassDefinition classDef = {
    1313         0, kJSClassAttributeNoAutomaticPrototype, 0, 0, 0, 0,
    1314         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
     1313        0, 0, 0, 0, 0, 0,
     1314        0, 0, 0, 0, 0, 0, 0, QtRuntimeMethod::call, 0, 0, 0
    13151315    };
    13161316    static JSClassRef cls = JSClassCreate(&classDef);
     
    13291329QtRuntimeMethod::~QtRuntimeMethod()
    13301330{
     1331    if (JSObjectRef cachedWrapper = m_instance->m_cachedMethods.get(this))
     1332        JSObjectSetPrivate(cachedWrapper, 0);
     1333    m_instance->m_cachedMethods.remove(this);
    13311334}
    13321335
    13331336JSValueRef QtRuntimeMethod::call(JSContextRef context, JSObjectRef function, JSObjectRef /*thisObject*/, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
    13341337{
    1335     QtRuntimeMethod* d = toRuntimeMethod(context, function);
     1338    QtRuntimeMethod* d = reinterpret_cast<QtRuntimeMethod*>(JSObjectGetPrivate(function));
    13361339    if (!d) {
    13371340        setException(context, exception, QStringLiteral("cannot call function of deleted runtime method"));
     
    13761379JSObjectRef QtRuntimeMethod::jsObjectRef(JSContextRef context, JSValueRef* exception)
    13771380{
    1378     if (m_jsObject)
    1379         return toRef(m_jsObject.get());
     1381    if (JSObjectRef cachedWrapper = m_instance->m_cachedMethods.get(this))
     1382        return cachedWrapper;
     1383
     1384    static const JSClassDefinition classDefForConnect = {
     1385        0, 0, "connect", 0, 0, 0,
     1386        0, 0, 0, 0, 0, 0, 0, connect, 0, 0, 0
     1387    };
     1388
     1389    static const JSClassDefinition classDefForDisconnect = {
     1390        0, 0, "disconnect", 0, 0, 0,
     1391        0, 0, 0, 0, 0, 0, 0, disconnect, 0, 0, 0
     1392    };
     1393
     1394    static JSClassRef classRefConnect = JSClassCreate(&classDefForConnect);
     1395    static JSClassRef classRefDisconnect = JSClassCreate(&classDefForDisconnect);
     1396    bool isSignal = m_flags & MethodIsSignal;
     1397    JSObjectRef object = JSObjectMake(context, prototypeForSignalsAndSlots(), this);
     1398    JSObjectRef connectFunction = JSObjectMake(context, classRefConnect, this);
     1399    JSObjectRef disconnectFunction = JSObjectMake(context, classRefDisconnect, this);
     1400    JSPropertyAttributes attributes = kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete;
    13801401
    13811402    static JSStringRef connectStr = JSStringCreateWithUTF8CString("connect");
    13821403    static JSStringRef disconnectStr = JSStringCreateWithUTF8CString("disconnect");
     1404    static JSStringRef lengthStr = JSStringCreateWithUTF8CString("length");
     1405    static JSStringRef nameStr = JSStringCreateWithUTF8CString("name");
    13831406    JSRetainPtr<JSStringRef> actualNameStr(Adopt, JSStringCreateWithUTF8CString(m_identifier.constData()));
    13841407
    1385     JSObjectRef object = JSObjectMakeFunctionWithCallback(context, actualNameStr.get(), call);
    1386     JSValueProtect(context, object);
    1387 
    1388     JSObjectRef generalFunctionProto = JSValueToObject(context, JSObjectGetPrototype(context, object), 0);
    1389     JSObjectRef runtimeMethodProto = JSObjectMake(context, prototypeForSignalsAndSlots(), this);
    1390     JSObjectSetPrototype(context, runtimeMethodProto, generalFunctionProto);
    1391 
    1392     JSObjectSetPrototype(context, object, runtimeMethodProto);
    1393 
    1394     JSObjectRef connectFunction = JSObjectMakeFunctionWithCallback(context, connectStr, connect);
    1395     JSObjectSetPrototype(context, connectFunction, runtimeMethodProto);
    1396 
    1397     JSObjectRef disconnectFunction = JSObjectMakeFunctionWithCallback(context, disconnectStr, disconnect);
    1398     JSObjectSetPrototype(context, disconnectFunction, runtimeMethodProto);
    1399 
    1400     const JSPropertyAttributes attributes = kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete;
     1408    JSObjectSetProperty(context, connectFunction, lengthStr, JSValueMakeNumber(context, isSignal ? 1 : 0), attributes, exception);
     1409    JSObjectSetProperty(context, connectFunction, nameStr, JSValueMakeString(context, connectStr), attributes, exception);
     1410    JSObjectSetProperty(context, disconnectFunction, lengthStr, JSValueMakeNumber(context, isSignal ? 1 : 0), attributes, exception);
     1411    JSObjectSetProperty(context, disconnectFunction, nameStr, JSValueMakeString(context, disconnectStr), attributes, exception);
     1412
    14011413    JSObjectSetProperty(context, object, connectStr, connectFunction, attributes, exception);
    14021414    JSObjectSetProperty(context, object, disconnectStr, disconnectFunction, attributes, exception);
    1403 
    1404     m_jsObject = PassWeak<JSObject>(toJS(object));
     1415    JSObjectSetProperty(context, object, lengthStr, JSValueMakeNumber(context, 0), attributes, exception);
     1416    JSObjectSetProperty(context, object, nameStr, JSValueMakeString(context, actualNameStr.get()), attributes, exception);
     1417
     1418    m_instance->m_cachedMethods.set(context, this, object);
    14051419
    14061420    return object;
    14071421}
    14081422
    1409 QtRuntimeMethod* QtRuntimeMethod::toRuntimeMethod(JSContextRef context, JSObjectRef object)
    1410 {
    1411     JSObjectRef proto = JSValueToObject(context, JSObjectGetPrototype(context, object), 0);
    1412     if (!proto)
    1413         return 0;
    1414     if (!JSValueIsObjectOfClass(context, proto, prototypeForSignalsAndSlots()))
    1415         return 0;
    1416     return static_cast<QtRuntimeMethod*>(JSObjectGetPrivate(proto));
    1417 }
    1418 
    14191423JSValueRef QtRuntimeMethod::connectOrDisconnect(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception, bool connect)
    14201424{
    1421     QtRuntimeMethod* d = toRuntimeMethod(context, thisObject);
     1425    QtRuntimeMethod* d = static_cast<QtRuntimeMethod*>(JSObjectGetPrivate(thisObject));
    14221426    if (!d)
    1423         d = toRuntimeMethod(context, function);
    1424     if (!d) {
    1425         QString errorStr = QStringLiteral("QtMetaMethod.%1: Cannot connect to/from deleted QObject").arg(connect ?  QStringLiteral("connect") : QStringLiteral("disconnect"));
    1426         setException(context, exception, errorStr);
    1427         return JSValueMakeUndefined(context);
    1428     }
     1427        d = static_cast<QtRuntimeMethod*>(JSObjectGetPrivate(function));
    14291428
    14301429    QString functionName = connect ? QStringLiteral("connect") : QStringLiteral("disconnect");
     
    14621461        // object.signal.connect(someFunction);
    14631462        if (JSObjectIsFunction(context, targetFunction)) {
    1464             // object.signal.connect(otherObject.slot);
    1465             if (QtRuntimeMethod* targetMethod = toRuntimeMethod(context, targetFunction))
    1466                 targetObject = toRef(QtInstance::getQtInstance(targetMethod->m_object.data(), d->m_instance->rootObject(), QtInstance::QtOwnership)->createRuntimeObject(toJS(context)));
     1463            if (JSValueIsObjectOfClass(context, targetFunction, prototypeForSignalsAndSlots())) {
     1464                // object.signal.connect(otherObject.slot);
     1465                if (QtRuntimeMethod* targetMethod = static_cast<QtRuntimeMethod*>(JSObjectGetPrivate(targetFunction)))
     1466                    targetObject = toRef(QtInstance::getQtInstance(targetMethod->m_object.data(), d->m_instance->rootObject(), QtInstance::QtOwnership)->createRuntimeObject(toJS(context)));
     1467            }
    14671468        } else
    14681469            targetFunction = 0;
  • trunk/Source/WebCore/bridge/qt/qt_runtime.h

    r126290 r126301  
    115115
    116116private:
    117     static QtRuntimeMethod* toRuntimeMethod(JSContextRef, JSObjectRef);
     117    static const JSStaticFunction connectFunction;
     118    static const JSStaticFunction disconnectFunction;
    118119
    119120    static JSValueRef connectOrDisconnect(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception, bool connect);
     
    122123    int m_index;
    123124    int m_flags;
    124     Weak<JSObject> m_jsObject;
    125125    QtInstance* m_instance;
    126126};
  • trunk/Source/WebKit/qt/ChangeLog

    r126291 r126301  
     12012-08-22  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r126287.
     4        http://trac.webkit.org/changeset/126287
     5        https://bugs.webkit.org/show_bug.cgi?id=94708
     6
     7        It made WK1 layout testing 3.7x slower (>1hours) (Requested by
     8        ossy on #webkit).
     9
     10        * tests/qobjectbridge/tst_qobjectbridge.cpp:
     11        (tst_QObjectBridge::objectDeleted):
     12        (tst_QObjectBridge::introspectQtMethods_data):
     13        (tst_QObjectBridge::introspectQtMethods):
     14
    1152012-08-22  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
    216
  • trunk/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp

    r126287 r126301  
    18801880    QCOMPARE(qobj->intProperty(), 123);
    18811881    qobj->resetQtFunctionInvoked();
    1882     evalJS("bar.myInvokable.call(bar);");
     1882    evalJS("bar.myInvokable(bar);");
    18831883    QCOMPARE(qobj->qtFunctionInvoked(), 0);
    18841884
     
    21492149
    21502150    QTest::newRow("myObject.mySignal")
    2151         << "myObject" << "mySignal" << (QStringList() << "connect" << "disconnect" << "name");
     2151        << "myObject" << "mySignal" << (QStringList() << "connect" << "disconnect" << "length" << "name");
    21522152    QTest::newRow("myObject.mySlot")
    2153         << "myObject" << "mySlot" << (QStringList() << "connect" << "disconnect" << "name");
     2153        << "myObject" << "mySlot" << (QStringList() << "connect" << "disconnect" << "length" << "name");
    21542154    QTest::newRow("myObject.myInvokable")
    2155         << "myObject" << "myInvokable" << (QStringList() << "connect" << "disconnect" << "name");
     2155        << "myObject" << "myInvokable" << (QStringList() << "connect" << "disconnect" << "length" << "name");
    21562156    QTest::newRow("myObject.mySignal.connect")
    2157         << "myObject.mySignal" << "connect" << (QStringList() << "name");
     2157        << "myObject.mySignal" << "connect" << (QStringList() << "length" << "name");
    21582158    QTest::newRow("myObject.mySignal.disconnect")
    2159         << "myObject.mySignal" << "disconnect" << (QStringList() << "name");
     2159        << "myObject.mySignal" << "disconnect" << (QStringList() << "length" << "name");
    21602160}
    21612161
     
    21782178        QCOMPARE(evalJS(QString::fromLatin1("descriptor.value === %0['%1']").arg(methodLookup).arg(name)), sTrue);
    21792179        QCOMPARE(evalJS(QString::fromLatin1("descriptor.enumerable")), sFalse);
    2180         QCOMPARE(evalJS(QString::fromLatin1("descriptor.configurable")), sFalse);
     2180        QCOMPARE(evalJS(QString::fromLatin1("descriptor.configurable")), sTrue);
    21812181    }
    21822182
Note: See TracChangeset for help on using the changeset viewer.