From 15e62e98ad6fa73f052113c158b24549b7b28e4f Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Wed, 24 Aug 2011 15:48:03 +0200 Subject: Get the image of the FBO of a effect texture The Qml Designer needs this image because every item in the text file is rendered in an external process in an image and send over a socket to the main process. Change-Id: I73cbc798d783098d3e1937181259c227b008082e Reviewed-on: http://codereview.qt.nokia.com/3509 Reviewed-by: Thomas Hartmann Reviewed-by: Gunnar Sletta --- src/declarative/items/qsgshadereffectsource.cpp | 8 ++++++++ src/declarative/items/qsgshadereffectsource_p.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/declarative/items/qsgshadereffectsource.cpp b/src/declarative/items/qsgshadereffectsource.cpp index d7653b578b..e05d20ed69 100644 --- a/src/declarative/items/qsgshadereffectsource.cpp +++ b/src/declarative/items/qsgshadereffectsource.cpp @@ -365,6 +365,14 @@ void QSGShaderEffectTexture::grab() markDirtyTexture(); // Continuously update if 'live' and 'recursive'. } +QImage QSGShaderEffectTexture::toImage() const +{ + if (m_fbo) + return m_fbo->toImage(); + + return QImage(); +} + /*! \qmlclass ShaderEffectSource QSGShaderEffectSource \since 5.0 diff --git a/src/declarative/items/qsgshadereffectsource_p.h b/src/declarative/items/qsgshadereffectsource_p.h index ac8fde50d9..0cb449a46c 100644 --- a/src/declarative/items/qsgshadereffectsource_p.h +++ b/src/declarative/items/qsgshadereffectsource_p.h @@ -114,6 +114,8 @@ public: void scheduleUpdate(); + QImage toImage() const; + Q_SIGNALS: void textureChanged(); -- cgit v1.2.3 From 59440312401f7fc26d4b60a5c3966154c8b43f27 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Wed, 24 Aug 2011 15:47:35 +0200 Subject: Move QSGViewPrivate to qsgview_p.h For the qml designer we need access to the private class. Change-Id: I2f368daf8e79baa433d11b69a29ef37d53a18a36 Reviewed-on: http://codereview.qt.nokia.com/3508 Reviewed-by: Thomas Hartmann Reviewed-by: Gunnar Sletta --- src/declarative/items/items.pri | 1 + src/declarative/items/qsgview.cpp | 33 +----------- src/declarative/items/qsgview_p.h | 106 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 31 deletions(-) create mode 100644 src/declarative/items/qsgview_p.h diff --git a/src/declarative/items/items.pri b/src/declarative/items/items.pri index 848c782a6e..9880dd8dc6 100644 --- a/src/declarative/items/items.pri +++ b/src/declarative/items/items.pri @@ -53,6 +53,7 @@ HEADERS += \ $$PWD/qsgtranslate_p.h \ $$PWD/qsgclipnode_p.h \ $$PWD/qsgview.h \ + $$PWD/qsgview_p.h \ $$PWD/qsganimation_p.h \ $$PWD/qsganimation_p_p.h \ $$PWD/qsgstateoperations_p.h \ diff --git a/src/declarative/items/qsgview.cpp b/src/declarative/items/qsgview.cpp index 416b803814..e2fb42e22b 100644 --- a/src/declarative/items/qsgview.cpp +++ b/src/declarative/items/qsgview.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qsgview.h" +#include "qsgview_p.h" #include "qsgcanvas_p.h" #include "qsgitem_p.h" @@ -52,43 +53,13 @@ #include #include + // XXX todo - This whole class should probably be merged with QDeclarativeView for // maximum seamlessness QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(frameRateDebug, QML_SHOW_FRAMERATE) -class QSGViewPrivate : public QSGCanvasPrivate, - public QSGItemChangeListener -{ - Q_DECLARE_PUBLIC(QSGView) -public: - QSGViewPrivate(); - ~QSGViewPrivate(); - - void execute(); - void itemGeometryChanged(QSGItem *item, const QRectF &newGeometry, const QRectF &oldGeometry); - void initResize(); - void updateSize(); - void setRootObject(QObject *); - - void init(); - - QSize rootObjectSize() const; - - QPointer root; - - QUrl source; - - QDeclarativeEngine engine; - QDeclarativeComponent *component; - QBasicTimer resizetimer; - - QSGView::ResizeMode resizeMode; - QSize initialSize; - QElapsedTimer frameTimer; -}; - void QSGViewPrivate::init() { q_func()->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); diff --git a/src/declarative/items/qsgview_p.h b/src/declarative/items/qsgview_p.h new file mode 100644 index 0000000000..8b2ee88ee8 --- /dev/null +++ b/src/declarative/items/qsgview_p.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSGVIEW_P_H +#define QSGVIEW_P_H + +#include "qsgview.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "qsgitemchangelistener_p.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarativeContext; +class QDeclarativeError; +class QSGItem; +class QDeclarativeComponent; + +class QSGViewPrivate : public QSGCanvasPrivate, + public QSGItemChangeListener +{ + Q_DECLARE_PUBLIC(QSGView) +public: + static QSGViewPrivate* get(QSGView *view) { return view->d_func(); } + static const QSGViewPrivate* get(const QSGView *view) { return view->d_func(); } + + QSGViewPrivate(); + ~QSGViewPrivate(); + + void execute(); + void itemGeometryChanged(QSGItem *item, const QRectF &newGeometry, const QRectF &oldGeometry); + void initResize(); + void updateSize(); + void setRootObject(QObject *); + + void init(); + + QSize rootObjectSize() const; + + QPointer root; + + QUrl source; + + QDeclarativeEngine engine; + QDeclarativeComponent *component; + QBasicTimer resizetimer; + + QSGView::ResizeMode resizeMode; + QSize initialSize; + QElapsedTimer frameTimer; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QSGVIEW_P_H -- cgit v1.2.3 From 6dd1ab81e1c7943053feea321b6f7774b688ee5d Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 25 Aug 2011 17:03:10 +1000 Subject: Fix memory leak in ListModel custom parser ModelNodes created by the parser for ListElement definitions were not deleted. (cherry picked from commit c1491c356f3cca92a359468ce37f38bc1873eec4) Task-number: QTBUG-21084 Change-Id: Ic55a054bb8e30cdabd11080e4f827df5deb1a014 Reviewed-on: http://codereview.qt.nokia.com/3567 Reviewed-by: Qt Sanity Bot Reviewed-by: Michael Brasser --- src/declarative/util/qdeclarativelistmodel.cpp | 1 + src/qtquick1/util/qdeclarativelistmodel.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 15d87c828d..da841c1618 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -932,6 +932,7 @@ void QDeclarativeListModelParser::setCustomData(QObject *obj, const QByteArray & QDeclarativeListModel *rv = static_cast(obj); ModelNode *root = new ModelNode(rv->m_nested); + rv->m_nested->m_ownsRoot = true; rv->m_nested->_root = root; QStack nodes; nodes << root; diff --git a/src/qtquick1/util/qdeclarativelistmodel.cpp b/src/qtquick1/util/qdeclarativelistmodel.cpp index d5aa75bec5..08e15c52b6 100644 --- a/src/qtquick1/util/qdeclarativelistmodel.cpp +++ b/src/qtquick1/util/qdeclarativelistmodel.cpp @@ -787,6 +787,7 @@ void QDeclarative1ListModelParser::setCustomData(QObject *obj, const QByteArray QDeclarative1ListModel *rv = static_cast(obj); ModelNode *root = new ModelNode(rv->m_nested); + rv->m_nested->m_ownsRoot = true; rv->m_nested->_root = root; QStack nodes; nodes << root; -- cgit v1.2.3 From 46af4afe0cfd3afddfe204913b5012be7369870f Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 25 Aug 2011 12:51:03 +0200 Subject: Don't enumerate Function.prototype.{connect,disconnect} MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QML/JS adds connect and disconnect methods to the standard Function.prototype object. Follow the convention of ECMA-262: Function properties should be non-enumerable. In particular, we don't want such built-in properties to show up in user code "for-in" statements. Task-number: QTBUG-21120 Change-Id: I416106badf35daddf32e16f757d37b2b09e58310 Reviewed-on: http://codereview.qt.nokia.com/3587 Reviewed-by: Qt Sanity Bot Reviewed-by: Jędrzej Nowacki --- src/declarative/qml/v8/qv8qobjectwrapper.cpp | 4 ++-- tests/auto/declarative/qjsengine/tst_qjsengine.cpp | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/declarative/qml/v8/qv8qobjectwrapper.cpp b/src/declarative/qml/v8/qv8qobjectwrapper.cpp index c7ed0116e1..f59e995e2d 100644 --- a/src/declarative/qml/v8/qv8qobjectwrapper.cpp +++ b/src/declarative/qml/v8/qv8qobjectwrapper.cpp @@ -280,8 +280,8 @@ void QV8QObjectWrapper::init(QV8Engine *engine) { v8::Local prototype = engine->global()->Get(v8::String::New("Function"))->ToObject()->Get(v8::String::New("prototype"))->ToObject(); - prototype->Set(v8::String::New("connect"), V8FUNCTION(Connect, engine)); - prototype->Set(v8::String::New("disconnect"), V8FUNCTION(Disconnect, engine)); + prototype->Set(v8::String::New("connect"), V8FUNCTION(Connect, engine), v8::DontEnum); + prototype->Set(v8::String::New("disconnect"), V8FUNCTION(Disconnect, engine), v8::DontEnum); } } diff --git a/tests/auto/declarative/qjsengine/tst_qjsengine.cpp b/tests/auto/declarative/qjsengine/tst_qjsengine.cpp index d2f4b3b6ac..a6b4251c36 100644 --- a/tests/auto/declarative/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/declarative/qjsengine/tst_qjsengine.cpp @@ -325,6 +325,7 @@ private slots: void dateRoundtripQtJSQt(); void dateConversionJSQt(); void dateConversionQtJS(); + void functionPrototypeExtensions(); }; tst_QJSEngine::tst_QJSEngine() @@ -6478,6 +6479,24 @@ void tst_QJSEngine::scriptValueFromQMetaObject() } #endif +void tst_QJSEngine::functionPrototypeExtensions() +{ + // QJS adds connect and disconnect properties to Function.prototype. + QJSEngine eng; + QJSValue funProto = eng.globalObject().property("Function").property("prototype"); + QVERIFY(funProto.isFunction()); + QVERIFY(funProto.property("connect").isFunction()); + QCOMPARE(funProto.propertyFlags("connect"), QJSValue::SkipInEnumeration); + QVERIFY(funProto.property("disconnect").isFunction()); + QCOMPARE(funProto.propertyFlags("disconnect"), QJSValue::SkipInEnumeration); + + // No properties should appear in for-in statements. + QJSValue props = eng.evaluate("props = []; for (var p in Function.prototype) props.push(p); props"); + QVERIFY(!eng.hasUncaughtException()); + QVERIFY(props.isArray()); + QCOMPARE(props.property("length").toInt32(), 0); +} + QTEST_MAIN(tst_QJSEngine) #include "tst_qjsengine.moc" -- cgit v1.2.3 From 33ecffd4e278955ddb36853580990d156e03fa09 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 24 Aug 2011 15:14:59 +0200 Subject: Deprecate QDeclarativeDebugHelper class This was a helper class for enable debugging in 4.7. Since Qt 4.8 you should just say CONFIG += declarative_debug Change-Id: I51dabaec36e175a097721570061aad38c3f828d1 Reviewed-on: http://codereview.qt.nokia.com/3507 Reviewed-by: Qt Sanity Bot Reviewed-by: Aurindam Jana --- .../debugger/qdeclarativedebughelper.cpp | 1 + .../debugger/qdeclarativedebughelper_p.h | 4 + .../qmldbg_inspector/abstractviewinspector.cpp | 8 +- .../qmldbg_inspector/sgviewinspector.cpp | 1 - src/qmltest/qmltest.pro | 2 +- src/qmltest/quicktest.cpp | 9 -- tests/auto/declarative/declarative.pro | 1 - .../qdeclarativedebug/qdeclarativedebug.pro | 2 +- .../qdeclarativedebug/tst_qdeclarativedebug.cpp | 5 - .../qdeclarativedebugclient.pro | 4 + .../tst_qdeclarativedebugclient.cpp | 5 - .../private_headers/qdeclarativedebughelper_p.h | 71 ------------- .../qdeclarativedebughelper.pro | 6 -- .../tst_qdeclarativedebughelper.cpp | 112 --------------------- .../qdeclarativedebugservice.pro | 2 +- .../tst_qdeclarativedebugservice.cpp | 4 - 16 files changed, 17 insertions(+), 220 deletions(-) delete mode 100644 tests/auto/declarative/qdeclarativedebughelper/private_headers/qdeclarativedebughelper_p.h delete mode 100644 tests/auto/declarative/qdeclarativedebughelper/qdeclarativedebughelper.pro delete mode 100644 tests/auto/declarative/qdeclarativedebughelper/tst_qdeclarativedebughelper.cpp diff --git a/src/declarative/debugger/qdeclarativedebughelper.cpp b/src/declarative/debugger/qdeclarativedebughelper.cpp index 5f5d8754bb..cbe4a85c61 100644 --- a/src/declarative/debugger/qdeclarativedebughelper.cpp +++ b/src/declarative/debugger/qdeclarativedebughelper.cpp @@ -58,6 +58,7 @@ void QDeclarativeDebugHelper::setAnimationSlowDownFactor(qreal factor) } void QDeclarativeDebugHelper::enableDebugging() { + qWarning("QDeclarativeDebugHelper::enableDebugging() is deprecated! Add CONFIG += declarative_debug to your .pro file instead."); #ifndef QDECLARATIVE_NO_DEBUG_PROTOCOL if (!QDeclarativeEnginePrivate::qml_debugging_enabled) { qWarning("Qml debugging is enabled. Only use this in a safe environment!"); diff --git a/src/declarative/debugger/qdeclarativedebughelper_p.h b/src/declarative/debugger/qdeclarativedebughelper_p.h index 60187112bf..d9ed5796ee 100644 --- a/src/declarative/debugger/qdeclarativedebughelper_p.h +++ b/src/declarative/debugger/qdeclarativedebughelper_p.h @@ -52,6 +52,10 @@ QT_BEGIN_NAMESPACE class QDeclarativeEngine; +#ifndef QT_BUILD_DECLARATIVE_LIB +#warning Use of this header file is deprecated! Add CONFIG += declarative_debug to your .pro file instead. +#endif + // Helper methods to access private API through a stable interface // This is used in the qmljsdebugger library of QtCreator. class Q_DECLARATIVE_EXPORT QDeclarativeDebugHelper diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp index 3323d54246..03cd7947f9 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp @@ -47,7 +47,7 @@ #include #include -#include +#include #include "QtDeclarative/private/qdeclarativeinspectorservice_p.h" #include @@ -180,7 +180,8 @@ void AbstractViewInspector::animationSpeedChangeRequested(qreal factor) } const float effectiveFactor = m_animationPaused ? 0 : factor; - QDeclarativeDebugHelper::setAnimationSlowDownFactor(effectiveFactor); + QUnifiedTimer::instance()->setSlowModeEnabled(effectiveFactor != 1.0); + QUnifiedTimer::instance()->setSlowdownFactor(effectiveFactor); } void AbstractViewInspector::animationPausedChangeRequested(bool paused) @@ -191,7 +192,8 @@ void AbstractViewInspector::animationPausedChangeRequested(bool paused) } const float effectiveFactor = paused ? 0 : m_slowDownFactor; - QDeclarativeDebugHelper::setAnimationSlowDownFactor(effectiveFactor); + QUnifiedTimer::instance()->setSlowModeEnabled(effectiveFactor != 1.0); + QUnifiedTimer::instance()->setSlowdownFactor(effectiveFactor); } void AbstractViewInspector::setShowAppOnTop(bool appOnTop) diff --git a/src/plugins/qmltooling/qmldbg_inspector/sgviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/sgviewinspector.cpp index bb9ad52fee..497e51db4d 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/sgviewinspector.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/sgviewinspector.cpp @@ -46,7 +46,6 @@ #include "sgselectiontool.h" #include -#include #include #include diff --git a/src/qmltest/qmltest.pro b/src/qmltest/qmltest.pro index 418136aa0a..b19ad55092 100644 --- a/src/qmltest/qmltest.pro +++ b/src/qmltest/qmltest.pro @@ -4,7 +4,7 @@ TARGET = QtQuickTest QPRO_PWD = $$PWD CONFIG += module -CONFIG += dll warn_on +CONFIG += dll warn_on declarative_debug MODULE_PRI += ../../modules/qt_qmltest.pri QT += testlib-private declarative testlib qtquick1 diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp index 3164d9ec06..7c207084c5 100644 --- a/src/qmltest/quicktest.cpp +++ b/src/qmltest/quicktest.cpp @@ -67,15 +67,6 @@ QT_BEGIN_NAMESPACE -// Copied from qdeclarativedebughelper_p.h in Qt, to avoid a dependency -// on a private header from Qt. -class Q_DECLARATIVE_EXPORT QDeclarativeDebugHelper -{ -public: - static QJSEngine *getScriptEngine(QDeclarativeEngine *engine); - static void setAnimationSlowDownFactor(qreal factor); - static void enableDebugging(); -}; class QTestRootObject : public QObject { diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index a99656a3ee..00717daa1f 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -33,7 +33,6 @@ PRIVATETESTS += \ qdeclarativeconnection \ qdeclarativedebug \ qdeclarativedebugclient \ - qdeclarativedebughelper \ qdeclarativedebugservice \ qdeclarativeecmascript \ qdeclarativeimageprovider \ diff --git a/tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro b/tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro index cd5577219d..7e04cb8edc 100644 --- a/tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro +++ b/tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro @@ -6,6 +6,6 @@ HEADERS += ../shared/debugutil_p.h SOURCES += tst_qdeclarativedebug.cpp \ ../shared/debugutil.cpp -CONFIG += parallel_test +CONFIG += parallel_test declarative_debug QT += core-private gui-private declarative-private diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp index ade51c43f6..8ad5e314e4 100644 --- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp +++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp @@ -55,11 +55,9 @@ #include #include #include -#include #include #include #include -#include #include "../../../shared/util.h" #include "../shared/debugutil_p.h" @@ -296,9 +294,6 @@ void tst_QDeclarativeDebug::initTestCase() qRegisterMetaType(); qmlRegisterType("Test", 1, 0, "NonScriptPropertyElement"); - QTest::ignoreMessage(QtWarningMsg, "Qml debugging is enabled. Only use this in a safe environment!"); - QDeclarativeDebugHelper::enableDebugging(); - QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 3768..."); m_engine = new QDeclarativeEngine(this); diff --git a/tests/auto/declarative/qdeclarativedebugclient/qdeclarativedebugclient.pro b/tests/auto/declarative/qdeclarativedebugclient/qdeclarativedebugclient.pro index 189133a526..28e25e9450 100644 --- a/tests/auto/declarative/qdeclarativedebugclient/qdeclarativedebugclient.pro +++ b/tests/auto/declarative/qdeclarativedebugclient/qdeclarativedebugclient.pro @@ -5,4 +5,8 @@ macx:CONFIG -= app_bundle HEADERS += ../shared/debugutil_p.h SOURCES += tst_qdeclarativedebugclient.cpp \ ../shared/debugutil.cpp + +CONFIG += declarative_debug + QT += core-private gui-private declarative-private + diff --git a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp index d41cfa3d4d..d7f53c9620 100644 --- a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp +++ b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp @@ -49,9 +49,7 @@ #include #include -#include #include -#include #include "../../../shared/util.h" #include "../shared/debugutil_p.h" @@ -73,9 +71,6 @@ private slots: void tst_QDeclarativeDebugClient::initTestCase() { - QTest::ignoreMessage(QtWarningMsg, "Qml debugging is enabled. Only use this in a safe environment!"); - QDeclarativeDebugHelper::enableDebugging(); - QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 13770..."); new QDeclarativeEngine(this); diff --git a/tests/auto/declarative/qdeclarativedebughelper/private_headers/qdeclarativedebughelper_p.h b/tests/auto/declarative/qdeclarativedebughelper/private_headers/qdeclarativedebughelper_p.h deleted file mode 100644 index c08f6fd639..0000000000 --- a/tests/auto/declarative/qdeclarativedebughelper/private_headers/qdeclarativedebughelper_p.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDEBUGHELPER_P_H -#define QDECLARATIVEDEBUGHELPER_P_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QJSEngine; -class QDeclarativeEngine; - -// Helper methods to access private API through a stable interface -// This is used in the qmljsdebugger library of QtCreator. -class Q_DECLARATIVE_EXPORT QDeclarativeDebugHelper -{ -public: - static QJSEngine *getScriptEngine(QDeclarativeEngine *engine); - static void setAnimationSlowDownFactor(qreal factor); - - // Enables remote debugging functionality - // Only use this for debugging in a safe environment! - static void enableDebugging(); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGHELPER_P_H diff --git a/tests/auto/declarative/qdeclarativedebughelper/qdeclarativedebughelper.pro b/tests/auto/declarative/qdeclarativedebughelper/qdeclarativedebughelper.pro deleted file mode 100644 index 1e62c12363..0000000000 --- a/tests/auto/declarative/qdeclarativedebughelper/qdeclarativedebughelper.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += network declarative -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativedebughelper.cpp -QT += core-private gui-private declarative-private diff --git a/tests/auto/declarative/qdeclarativedebughelper/tst_qdeclarativedebughelper.cpp b/tests/auto/declarative/qdeclarativedebughelper/tst_qdeclarativedebughelper.cpp deleted file mode 100644 index f67d5c5a89..0000000000 --- a/tests/auto/declarative/qdeclarativedebughelper/tst_qdeclarativedebughelper.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include - -#include -#include -#include -#include - -// We have copied the header which is used in the qmljsdebugger (part of QtCreator) -// to catch BC changes. Don't update it unless you know what you are doing! -#include "private_headers/qdeclarativedebughelper_p.h" - -class tst_qdeclarativedebughelper : public QObject { - Q_OBJECT -private slots: - void setAnimationSlowDownFactor(); - void enableDebugging(); -}; - -class TestAnimation : public QAbstractAnimation { -public: - int updateCalled; - - TestAnimation() : updateCalled(0) {} - - virtual void updateCurrentTime(int /*currentTime*/) { - updateCalled++; - } - virtual int duration() const { - return 100; - } -}; - -void tst_qdeclarativedebughelper::setAnimationSlowDownFactor() -{ - TestAnimation animation; - - // first check whether setup works - QCOMPARE(animation.updateCalled, 0); - animation.start(); - QTest::qWait(animation.totalDuration() + 150); -#ifdef Q_OS_WIN - if (animation.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", "On windows, consistent timing is not working properly due to bad timer resolution", Abort); -#endif - QCOMPARE(animation.state(), QAbstractAnimation::Stopped); - QVERIFY(animation.updateCalled > 1); - - // check if we can pause all animations - animation.updateCalled = 0; - QDeclarativeDebugHelper::setAnimationSlowDownFactor(0.0); - animation.start(); - QTest::qWait(animation.totalDuration() + 150); - QVERIFY(animation.updateCalled <= 1); // updateCurrentTime seems to be called at least once - - // now run them again - animation.updateCalled = 0; - QDeclarativeDebugHelper::setAnimationSlowDownFactor(2.0); - animation.start(); - QTest::qWait(animation.totalDuration() + 150); - QVERIFY(animation.updateCalled > 1); -} - -void tst_qdeclarativedebughelper::enableDebugging() -{ - QTest::ignoreMessage(QtWarningMsg, "Qml debugging is enabled. Only use this in a safe environment!"); - QDeclarativeDebugHelper::enableDebugging(); -} - -QTEST_MAIN(tst_qdeclarativedebughelper) - -#include "tst_qdeclarativedebughelper.moc" - diff --git a/tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro b/tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro index 785e8a7bf1..999e19279b 100644 --- a/tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro +++ b/tests/auto/declarative/qdeclarativedebugservice/qdeclarativedebugservice.pro @@ -6,6 +6,6 @@ HEADERS += ../shared/debugutil_p.h SOURCES += tst_qdeclarativedebugservice.cpp \ ../shared/debugutil.cpp -CONFIG += parallel_test +CONFIG += parallel_test declarative_debug QT += core-private gui-private declarative-private diff --git a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp index 3fa8bba682..74f549c076 100644 --- a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp +++ b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp @@ -46,7 +46,6 @@ #include #include -#include #include #include @@ -76,9 +75,6 @@ private slots: void tst_QDeclarativeDebugService::initTestCase() { - QTest::ignoreMessage(QtWarningMsg, "Qml debugging is enabled. Only use this in a safe environment!"); - QDeclarativeDebugHelper::enableDebugging(); - QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 13769..."); new QDeclarativeEngine(this); -- cgit v1.2.3 From b5e069a1832550bf620a5591102d43e33132a609 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 26 Aug 2011 10:56:46 +1000 Subject: Remove unnecessary code. QT_NO_LOCALFILE_OPTIMIZED_QML should never be defined, and we don't need to manually resolve urls coming from QML. Change-Id: I7cdeb2814385bcb9d6004ab43686f65d388620eb Reviewed-on: http://codereview.qt.nokia.com/3684 Reviewed-by: Qt Sanity Bot Reviewed-by: Martin Jones --- src/declarative/items/qsganimatedimage.cpp | 3 +-- src/declarative/items/qsgborderimage.cpp | 5 +---- src/declarative/util/qdeclarativefontloader.cpp | 7 ++----- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/declarative/items/qsganimatedimage.cpp b/src/declarative/items/qsganimatedimage.cpp index ea36153ef0..e4bba512af 100644 --- a/src/declarative/items/qsganimatedimage.cpp +++ b/src/declarative/items/qsganimatedimage.cpp @@ -264,7 +264,6 @@ void QSGAnimatedImage::load() if (d->progress != oldProgress) emit progressChanged(d->progress); } else { -#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url); if (!lf.isEmpty()) { //### should be unified with movieRequestFinished @@ -298,7 +297,7 @@ void QSGAnimatedImage::load() emit progressChanged(d->progress); return; } -#endif + d->status = Loading; d->progress = 0; emit statusChanged(d->status); diff --git a/src/declarative/items/qsgborderimage.cpp b/src/declarative/items/qsgborderimage.cpp index 931a681c1a..bd62eaf1bb 100644 --- a/src/declarative/items/qsgborderimage.cpp +++ b/src/declarative/items/qsgborderimage.cpp @@ -306,15 +306,12 @@ void QSGBorderImage::load() } else { d->status = Loading; if (d->url.path().endsWith(QLatin1String("sci"))) { -#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url); if (!lf.isEmpty()) { QFile file(lf); file.open(QIODevice::ReadOnly); setGridScaledImage(QSGGridScaledImage(&file)); - } else -#endif - { + } else { QNetworkRequest req(d->url); d->sciReply = qmlEngine(this)->networkAccessManager()->get(req); diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp index 7a1dec88f0..f7a7738172 100644 --- a/src/declarative/util/qdeclarativefontloader.cpp +++ b/src/declarative/util/qdeclarativefontloader.cpp @@ -193,10 +193,9 @@ void QDeclarativeFontLoader::setSource(const QUrl &url) Q_D(QDeclarativeFontLoader); if (url == d->url) return; - d->url = qmlContext(this)->resolvedUrl(url); + d->url = url; emit sourceChanged(); -#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML QString localFile = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url); if (!localFile.isEmpty()) { if (!d->fonts.contains(d->url)) { @@ -211,9 +210,7 @@ void QDeclarativeFontLoader::setSource(const QUrl &url) } else { updateFontInfo(QFontDatabase::applicationFontFamilies(d->fonts[d->url]->id).at(0), Ready); } - } else -#endif - { + } else { if (!d->fonts.contains(d->url)) { QDeclarativeFontObject *fo = new QDeclarativeFontObject; d->fonts[d->url] = fo; -- cgit v1.2.3 From 4d763c3d9f26da034495b98fe829b88fed34a22c Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 29 Aug 2011 10:29:01 +1000 Subject: Re-add QDeclarativeFontLoader autotest. Was accidently removed in the qtquick1 work. Change-Id: I511efa65e85858e22909257a95f635d5c06cb0a5 Reviewed-on: http://codereview.qt.nokia.com/3685 Reviewed-by: Martin Jones --- .../qdeclarativefontloader/data/daniel.ttf | Bin 0 -> 51984 bytes .../qdeclarativefontloader/data/dummy.ttf | 0 .../qdeclarativefontloader/data/tarzeau_ocr_a.ttf | Bin 0 -> 24544 bytes .../qdeclarativefontloader.pro | 18 ++ .../tst_qdeclarativefontloader.cpp | 230 +++++++++++++++++++++ 5 files changed, 248 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativefontloader/data/daniel.ttf create mode 100644 tests/auto/declarative/qdeclarativefontloader/data/dummy.ttf create mode 100644 tests/auto/declarative/qdeclarativefontloader/data/tarzeau_ocr_a.ttf create mode 100644 tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro create mode 100644 tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp diff --git a/tests/auto/declarative/qdeclarativefontloader/data/daniel.ttf b/tests/auto/declarative/qdeclarativefontloader/data/daniel.ttf new file mode 100644 index 0000000000..aae50d5035 Binary files /dev/null and b/tests/auto/declarative/qdeclarativefontloader/data/daniel.ttf differ diff --git a/tests/auto/declarative/qdeclarativefontloader/data/dummy.ttf b/tests/auto/declarative/qdeclarativefontloader/data/dummy.ttf new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/declarative/qdeclarativefontloader/data/tarzeau_ocr_a.ttf b/tests/auto/declarative/qdeclarativefontloader/data/tarzeau_ocr_a.ttf new file mode 100644 index 0000000000..cf93f9651f Binary files /dev/null and b/tests/auto/declarative/qdeclarativefontloader/data/tarzeau_ocr_a.ttf differ diff --git a/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro new file mode 100644 index 0000000000..946e5a8a16 --- /dev/null +++ b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro @@ -0,0 +1,18 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui network +macx:CONFIG -= app_bundle + +HEADERS += ../../declarative/shared/testhttpserver.h +SOURCES += tst_qdeclarativefontloader.cpp ../../declarative/shared/testhttpserver.cpp + +symbian: { + importFiles.files = data + importFiles.path = . + DEPLOYMENT += importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test + +QT += core-private gui-private declarative-private diff --git a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp new file mode 100644 index 0000000000..29fe0329bb --- /dev/null +++ b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp @@ -0,0 +1,230 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include "../../../shared/util.h" +#include "../../declarative/shared/testhttpserver.h" + +#define SERVER_PORT 14448 + +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + +class tst_qdeclarativefontloader : public QObject +{ + Q_OBJECT +public: + tst_qdeclarativefontloader(); + +private slots: + void init(); + void noFont(); + void namedFont(); + void localFont(); + void failLocalFont(); + void webFont(); + void redirWebFont(); + void failWebFont(); + void changeFont(); + +private: + QDeclarativeEngine engine; + TestHTTPServer server; +}; + +tst_qdeclarativefontloader::tst_qdeclarativefontloader() : + server(SERVER_PORT) +{ + server.serveDirectory(SRCDIR "/data"); +} + +void tst_qdeclarativefontloader::init() +{ + QVERIFY(server.isValid()); +} + +void tst_qdeclarativefontloader::noFont() +{ + QString componentStr = "import QtQuick 2.0\nFontLoader { }"; + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); + + QVERIFY(fontObject != 0); + QCOMPARE(fontObject->name(), QString("")); + QCOMPARE(fontObject->source(), QUrl("")); + QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Null); + + delete fontObject; +} + +void tst_qdeclarativefontloader::namedFont() +{ + QString componentStr = "import QtQuick 2.0\nFontLoader { name: \"Helvetica\" }"; + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); + + QVERIFY(fontObject != 0); + QCOMPARE(fontObject->source(), QUrl("")); + QCOMPARE(fontObject->name(), QString("Helvetica")); + QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); +} + +void tst_qdeclarativefontloader::localFont() +{ + QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" SRCDIR "/data/tarzeau_ocr_a.ttf\" }"; + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); + + QVERIFY(fontObject != 0); + QVERIFY(fontObject->source() != QUrl("")); + QTRY_COMPARE(fontObject->name(), QString("OCRA")); + QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); +} + +void tst_qdeclarativefontloader::failLocalFont() +{ + QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\" }"; + QTest::ignoreMessage(QtWarningMsg, QString("file::2:1: QML FontLoader: Cannot load font: \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\"").toUtf8().constData()); + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); + + QVERIFY(fontObject != 0); + QVERIFY(fontObject->source() != QUrl("")); + QTRY_COMPARE(fontObject->name(), QString("")); + QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Error); +} + +void tst_qdeclarativefontloader::webFont() +{ + QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/tarzeau_ocr_a.ttf\" }"; + QDeclarativeComponent component(&engine); + + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); + + QVERIFY(fontObject != 0); + QVERIFY(fontObject->source() != QUrl("")); + QTRY_COMPARE(fontObject->name(), QString("OCRA")); + QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); +} + +void tst_qdeclarativefontloader::redirWebFont() +{ + server.addRedirect("olddir/oldname.ttf","../tarzeau_ocr_a.ttf"); + + QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/olddir/oldname.ttf\" }"; + QDeclarativeComponent component(&engine); + + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); + + QVERIFY(fontObject != 0); + QVERIFY(fontObject->source() != QUrl("")); + QTRY_COMPARE(fontObject->name(), QString("OCRA")); + QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); +} + +void tst_qdeclarativefontloader::failWebFont() +{ + QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/nonexist.ttf\" }"; + QTest::ignoreMessage(QtWarningMsg, "file::2:1: QML FontLoader: Cannot load font: \"http://localhost:14448/nonexist.ttf\""); + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); + + QVERIFY(fontObject != 0); + QVERIFY(fontObject->source() != QUrl("")); + QTRY_COMPARE(fontObject->name(), QString("")); + QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Error); +} + +void tst_qdeclarativefontloader::changeFont() +{ + QString componentStr = "import QtQuick 2.0\nFontLoader { source: font }"; + QDeclarativeContext *ctxt = engine.rootContext(); + ctxt->setContextProperty("font", QUrl::fromLocalFile(SRCDIR "/data/tarzeau_ocr_a.ttf")); + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); + + QVERIFY(fontObject != 0); + + QSignalSpy nameSpy(fontObject, SIGNAL(nameChanged())); + QSignalSpy statusSpy(fontObject, SIGNAL(statusChanged())); + + QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); + QCOMPARE(nameSpy.count(), 0); + QCOMPARE(statusSpy.count(), 0); + QTRY_COMPARE(fontObject->name(), QString("OCRA")); + + ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf"); + QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Loading); + QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); + QCOMPARE(nameSpy.count(), 1); + QCOMPARE(statusSpy.count(), 2); + QTRY_COMPARE(fontObject->name(), QString("Daniel")); + + ctxt->setContextProperty("font", QUrl::fromLocalFile(SRCDIR "/data/tarzeau_ocr_a.ttf")); + QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); + QCOMPARE(nameSpy.count(), 2); + QCOMPARE(statusSpy.count(), 2); + QTRY_COMPARE(fontObject->name(), QString("OCRA")); + + ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf"); + QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); + QCOMPARE(nameSpy.count(), 3); + QCOMPARE(statusSpy.count(), 2); + QTRY_COMPARE(fontObject->name(), QString("Daniel")); +} + +QTEST_MAIN(tst_qdeclarativefontloader) + +#include "tst_qdeclarativefontloader.moc" -- cgit v1.2.3 From b016460dc49c0ea5a1ed54c71f47ba52819921a8 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 26 Aug 2011 16:35:57 +1000 Subject: Fix QSGItem::polish() at startup logic Change-Id: I4e3f81bd8e95d34fe59e39b1ae807211e00aaaa5 Reviewed-on: http://codereview.qt.nokia.com/3632 Reviewed-by: Qt Sanity Bot Reviewed-by: Bea Lam --- src/declarative/items/qsgcanvas.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/declarative/items/qsgcanvas.cpp b/src/declarative/items/qsgcanvas.cpp index 6873c41cef..4f1fcefee4 100644 --- a/src/declarative/items/qsgcanvas.cpp +++ b/src/declarative/items/qsgcanvas.cpp @@ -975,6 +975,8 @@ bool QSGCanvas::event(QEvent *e) if (e->type() == QEvent::User) { if (!d->thread->syncAlreadyHappened) d->thread->sync(false); + else + d->renderThreadAwakened = false; d->thread->syncAlreadyHappened = false; -- cgit v1.2.3 From 438639f9c40311b51a57b501428d2650f21615cf Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Fri, 26 Aug 2011 10:47:13 +0200 Subject: qmlplugindump: Load QtQuick 1 plugin. This allows the QtQuick1 types to be dumped with --builtin and to be skipped when dumping other plugins that use them. Change-Id: I23ecba5cea7c11e998861746f1c7056e8911abf3 Reviewed-on: http://codereview.qt.nokia.com/3650 Reviewed-by: Erik Verbruggen --- tools/qmlplugindump/main.cpp | 13 +++++++++++++ tools/qmlplugindump/qmlplugindump.pro | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index 46d31739ee..1fdfb2e83d 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -540,6 +540,19 @@ int main(int argc, char *argv[]) engine.addImportPath(pluginImportPath); } + // load the QtQuick 1 plugin + { + QByteArray code("import QtQuick 1.0\nQtObject {}"); + QDeclarativeComponent c(&engine); + c.setData(code, QUrl::fromLocalFile(pluginImportPath + "/loadqtquick1.qml")); + c.create(); + if (!c.errors().isEmpty()) { + foreach (const QDeclarativeError &error, c.errors()) + qWarning() << error.toString(); + return EXIT_IMPORTERROR; + } + } + // find all QMetaObjects reachable from the builtin module QSet defaultReachable = collectReachableMetaObjects(); QList defaultTypes = QDeclarativeMetaType::qmlTypes(); diff --git a/tools/qmlplugindump/qmlplugindump.pro b/tools/qmlplugindump/qmlplugindump.pro index 0ac3a70c14..49134a05ab 100644 --- a/tools/qmlplugindump/qmlplugindump.pro +++ b/tools/qmlplugindump/qmlplugindump.pro @@ -2,7 +2,7 @@ TEMPLATE = app CONFIG += qt uic console DESTDIR = $$QT.declarative.bins -QT += declarative declarative-private core-private +QT += declarative declarative-private qtquick1 core-private TARGET = qmlplugindump -- cgit v1.2.3 From f29bfda2e609f00fad46160495017168094eff7b Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 29 Aug 2011 15:06:14 +1000 Subject: Use the optimized QDeclarativeExpression constructor where possible. Pass in the QDeclarativeScriptString directly, to make use of the precompiled binding. Also does some minor cleanup of the related internal implementation. Change-Id: I4b199298c9da3ee11c51c9c98b384c8324f62c26 Reviewed-on: http://codereview.qt.nokia.com/3696 Reviewed-by: Qt Sanity Bot Reviewed-by: Charles Yin --- src/declarative/qml/qdeclarativebinding.cpp | 2 +- src/declarative/qml/qdeclarativeexpression.cpp | 4 ++-- src/declarative/util/qdeclarativeanimation.cpp | 8 ++------ src/declarative/util/qdeclarativestateoperations.cpp | 8 ++------ 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp index 069744153a..d817990d7b 100644 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ b/src/declarative/qml/qdeclarativebinding.cpp @@ -235,7 +235,7 @@ QDeclarativeBinding::createBinding(Identifier id, QObject *obj, QDeclarativeCont QDeclarativeContextData *ctxtdata = QDeclarativeContextData::get(ctxt); - QDeclarativeEnginePrivate *engine = QDeclarativeEnginePrivate::get(qmlEngine(obj)); + QDeclarativeEnginePrivate *engine = QDeclarativeEnginePrivate::get(ctxt->engine()); QDeclarativeCompiledData *cdata = 0; QDeclarativeTypeData *typeData = 0; if (engine && ctxtdata && !ctxtdata->url.isEmpty()) { diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp index 8806996bd4..a24d46914c 100644 --- a/src/declarative/qml/qdeclarativeexpression.cpp +++ b/src/declarative/qml/qdeclarativeexpression.cpp @@ -242,7 +242,7 @@ QDeclarativeExpression::QDeclarativeExpression(const QDeclarativeScriptString &s } else { QDeclarativeContextData *ctxtdata = QDeclarativeContextData::get(script.context()); - QDeclarativeEnginePrivate *engine = QDeclarativeEnginePrivate::get(qmlEngine(script.scopeObject())); + QDeclarativeEnginePrivate *engine = QDeclarativeEnginePrivate::get(script.context()->engine()); QDeclarativeCompiledData *cdata = 0; QDeclarativeTypeData *typeData = 0; if (engine && ctxtdata && !ctxtdata->url.isEmpty()) { @@ -251,7 +251,7 @@ QDeclarativeExpression::QDeclarativeExpression(const QDeclarativeScriptString &s } if (cdata) - d->init(ctxtdata, cdata->primitives.at(id), cdata, script.scopeObject(), + d->init(ctxtdata, cdata->primitives.at(id), true, script.scopeObject(), cdata->name, script.d.data()->lineNumber); else defaultConstruction = true; diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 11e1c7cc0a..6cdba7c5d9 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -827,12 +827,8 @@ void QDeclarativeScriptActionPrivate::execute() QDeclarativeScriptString scriptStr = hasRunScriptScript ? runScriptScript : script; - const QString &str = scriptStr.script(); - if (!str.isEmpty()) { - QDeclarativeExpression expr(scriptStr.context(), scriptStr.scopeObject(), str); - QDeclarativeData *ddata = QDeclarativeData::get(q); - if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) - expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); + if (!scriptStr.script().isEmpty()) { + QDeclarativeExpression expr(scriptStr); expr.evaluate(); if (expr.hasError()) qmlInfo(q) << expr.error(); diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index 6ac21002a5..98f437d9a3 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -131,12 +131,8 @@ void QDeclarativeStateChangeScript::setName(const QString &n) void QDeclarativeStateChangeScript::execute(Reason) { Q_D(QDeclarativeStateChangeScript); - const QString &script = d->script.script(); - if (!script.isEmpty()) { - QDeclarativeExpression expr(d->script.context(), d->script.scopeObject(), script); - QDeclarativeData *ddata = QDeclarativeData::get(this); - if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) - expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); + if (!d->script.script().isEmpty()) { + QDeclarativeExpression expr(d->script); expr.evaluate(); if (expr.hasError()) qmlInfo(this, expr.error()); -- cgit v1.2.3 From e233d8aa0710f8253e6ca2635cf6c9afa95757d2 Mon Sep 17 00:00:00 2001 From: Xizhi Zhu Date: Mon, 29 Aug 2011 13:55:09 +0300 Subject: Fix build break introduced by changes in QTestLog. The mode parameter of QTestLog::addSkip() has been removed, more details at: http://codereview.qt.nokia.com/3547 Change-Id: Id5428a506d177ae9d4480a522ee492672048dad7 Reviewed-on: http://codereview.qt.nokia.com/3735 Reviewed-by: Qt Sanity Bot Reviewed-by: Xizhi Zhu --- src/qmltest/quicktestresult.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qmltest/quicktestresult.cpp b/src/qmltest/quicktestresult.cpp index 534c57e1c2..80c3f8b3d5 100644 --- a/src/qmltest/quicktestresult.cpp +++ b/src/qmltest/quicktestresult.cpp @@ -442,14 +442,14 @@ bool QuickTestResult::compare void QuickTestResult::skipSingle (const QString &message, const QString &file, int line) { - QTestResult::addSkip(message.toLatin1().constData(), QTest::SkipSingle, + QTestResult::addSkip(message.toLatin1().constData(), qtest_fixFile(file).toLatin1().constData(), line); } void QuickTestResult::skipAll (const QString &message, const QString &file, int line) { - QTestResult::addSkip(message.toLatin1().constData(), QTest::SkipAll, + QTestResult::addSkip(message.toLatin1().constData(), qtest_fixFile(file).toLatin1().constData(), line); QTestResult::setSkipCurrentTest(true); } -- cgit v1.2.3 From e71904e231e27e6f6f88b35c4a7e2d7cf8ba2640 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 16 Aug 2011 14:00:13 +0200 Subject: Remove V8 submodule from QtDeclarative QtDeclarative should now link against the QtV8 library from qtbase. The patch files have been moved to qtbase as well. Applications that use the QtDeclarative private headers may need to add the following to their .pro file: QT += v8-private This ensures that is found, which is (indirectly) included by many QtDeclarative private headers. Task-number: QTBUG-20963 Change-Id: I31e973a6fcc0c416d3b258a61c26564cee3dcd4b Reviewed-on: http://codereview.qt.nokia.com/3093 Reviewed-by: Qt Sanity Bot Reviewed-by: Kent Hansen --- .gitmodules | 3 - src/3rdparty/v8 | 1 - src/declarative/declarative.pro | 3 +- src/declarative/qml/v8/qv8_p.h | 2 +- ...shing-and-comparison-methods-to-v8-String.patch | 343 ---- .../v8/0002-Add-a-bit-field-3-to-Map.patch | 118 -- ...back-mode-for-named-property-interceptors.patch | 364 ---- ...0004-Generalize-external-object-resources.patch | 894 ---------- .../v8/0005-Introduce-a-QML-compilation-mode.patch | 1777 -------------------- ...6-Allow-access-to-the-calling-script-data.patch | 48 - src/declarative/v8/0007-Fix-warnings.patch | 46 - .../0008-Add-custom-object-compare-callback.patch | 489 ------ ...unction-method-to-the-Object-class-in-the.patch | 286 ---- ...allAsConstructor-method-for-Object-in-the.patch | 397 ----- ...-Add-new-v8-api-to-check-if-a-value-is-an.patch | 63 - ...d-IsCallable-method-for-Object-in-the-API.patch | 116 -- .../0013-Remove-execute-flag-from-v8-debug.h.patch | 15 - src/declarative/v8/README | 1 - src/declarative/v8/v8.pri | 253 --- src/declarative/v8/v8base.pri | 19 - src/declarative/v8/wrapcc.pl | 48 - src/imports/gestures/gestures.pro | 2 +- src/imports/particles/particles.pro | 2 +- src/imports/testlib/testlib.pro | 2 +- .../qmldbg_inspector/qmldbg_inspector.pro | 2 +- src/qtquick1/qtquick1.pro | 2 +- tests/auto/declarative/declarative.pro | 3 +- tests/auto/declarative/examples/examples.pro | 2 +- .../qdeclarativeanimations.pro | 2 +- .../qdeclarativebehaviors.pro | 2 +- .../qdeclarativeconnection.pro | 2 +- .../qdeclarativedebug/qdeclarativedebug.pro | 2 +- .../qdeclarativeecmascript.pro | 2 +- .../qdeclarativeinstruction.pro | 2 +- .../qdeclarativelanguage/qdeclarativelanguage.pro | 2 +- .../qdeclarativelistmodel.pro | 2 +- .../qdeclarativeproperty/qdeclarativeproperty.pro | 2 +- .../declarative/qdeclarativeqt/qdeclarativeqt.pro | 2 +- .../qdeclarativesmoothedanimation.pro | 2 +- .../qdeclarativespringanimation.pro | 2 +- .../qdeclarativesqldatabase.pro | 2 +- .../qdeclarativestates/qdeclarativestates.pro | 2 +- .../declarative/qdeclarativev4/qdeclarativev4.pro | 2 +- .../qdeclarativevaluetypes.pro | 2 +- .../qdeclarativeworkerscript.pro | 2 +- .../qdeclarativexmllistmodel.pro | 2 +- .../qpacketprotocol/qpacketprotocol.pro | 2 +- .../auto/declarative/qsgflickable/qsgflickable.pro | 2 +- tests/auto/declarative/qsgflipable/qsgflipable.pro | 2 +- tests/auto/declarative/qsggridview/qsggridview.pro | 2 +- tests/auto/declarative/qsglistview/qsglistview.pro | 2 +- tests/auto/declarative/qsgpathview/qsgpathview.pro | 2 +- .../declarative/qsgpositioners/qsgpositioners.pro | 2 +- tests/auto/declarative/qsgtext/qsgtext.pro | 2 +- tests/auto/declarative/qsgtextedit/qsgtextedit.pro | 2 +- .../auto/declarative/qsgtextinput/qsgtextinput.pro | 2 +- .../declarative/qsgtextinput/tst_qsgtextinput.cpp | 2 +- .../qsgvisualdatamodel/qsgvisualdatamodel.pro | 2 +- tests/auto/declarative/v8/Makefile.nonqt | 11 - tests/auto/declarative/v8/README.txt | 13 - tests/auto/declarative/v8/tst_v8.cpp | 79 - tests/auto/declarative/v8/v8.pro | 10 - tests/auto/declarative/v8/v8main.cpp | 17 - tests/auto/declarative/v8/v8test.cpp | 254 --- tests/auto/declarative/v8/v8test.h | 51 - .../qdeclarativeanchors/qdeclarativeanchors.pro | 2 +- .../qdeclarativeanimations.pro | 2 +- .../qdeclarativebehaviors.pro | 2 +- .../qdeclarativeconnection.pro | 2 +- .../qdeclarativeflickable.pro | 2 +- .../qdeclarativeflipable/qdeclarativeflipable.pro | 2 +- .../qdeclarativegridview/qdeclarativegridview.pro | 2 +- .../qtquick1/qdeclarativeitem/qdeclarativeitem.pro | 2 +- .../qdeclarativelistview/qdeclarativelistview.pro | 2 +- .../qdeclarativepathview/qdeclarativepathview.pro | 2 +- .../qdeclarativepositioners.pro | 2 +- .../qdeclarativesmoothedanimation.pro | 2 +- .../qdeclarativespringanimation.pro | 2 +- .../qdeclarativestates/qdeclarativestates.pro | 2 +- .../qtquick1/qdeclarativetext/qdeclarativetext.pro | 2 +- .../qdeclarativetextedit/qdeclarativetextedit.pro | 2 +- .../qdeclarativetextinput.pro | 2 +- .../qdeclarativeviewer/qdeclarativeviewer.pro | 2 +- .../qdeclarativevisualdatamodel.pro | 2 +- .../qdeclarativexmllistmodel.pro | 2 +- tools/qmlviewer/qml.pri | 2 +- 86 files changed, 60 insertions(+), 5778 deletions(-) delete mode 100644 .gitmodules delete mode 160000 src/3rdparty/v8 delete mode 100644 src/declarative/v8/0001-Add-hashing-and-comparison-methods-to-v8-String.patch delete mode 100644 src/declarative/v8/0002-Add-a-bit-field-3-to-Map.patch delete mode 100644 src/declarative/v8/0003-Add-a-fallback-mode-for-named-property-interceptors.patch delete mode 100644 src/declarative/v8/0004-Generalize-external-object-resources.patch delete mode 100644 src/declarative/v8/0005-Introduce-a-QML-compilation-mode.patch delete mode 100644 src/declarative/v8/0006-Allow-access-to-the-calling-script-data.patch delete mode 100644 src/declarative/v8/0007-Fix-warnings.patch delete mode 100644 src/declarative/v8/0008-Add-custom-object-compare-callback.patch delete mode 100644 src/declarative/v8/0009-Add-CallAsFunction-method-to-the-Object-class-in-the.patch delete mode 100644 src/declarative/v8/0010-Implement-CallAsConstructor-method-for-Object-in-the.patch delete mode 100644 src/declarative/v8/0011-QtScript-V8-Add-new-v8-api-to-check-if-a-value-is-an.patch delete mode 100644 src/declarative/v8/0012-Add-IsCallable-method-for-Object-in-the-API.patch delete mode 100644 src/declarative/v8/0013-Remove-execute-flag-from-v8-debug.h.patch delete mode 100644 src/declarative/v8/README delete mode 100644 src/declarative/v8/v8.pri delete mode 100644 src/declarative/v8/v8base.pri delete mode 100755 src/declarative/v8/wrapcc.pl delete mode 100644 tests/auto/declarative/v8/Makefile.nonqt delete mode 100644 tests/auto/declarative/v8/README.txt delete mode 100644 tests/auto/declarative/v8/tst_v8.cpp delete mode 100644 tests/auto/declarative/v8/v8.pro delete mode 100644 tests/auto/declarative/v8/v8main.cpp delete mode 100644 tests/auto/declarative/v8/v8test.cpp delete mode 100644 tests/auto/declarative/v8/v8test.h diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 183f5b46cc..0000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "src/3rdparty/v8"] - path = src/3rdparty/v8 - url = git://github.com/aaronkennedy/v8.git diff --git a/src/3rdparty/v8 b/src/3rdparty/v8 deleted file mode 160000 index dc2cad4f8f..0000000000 --- a/src/3rdparty/v8 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit dc2cad4f8fc88c52fcea09b8d0262d35cd32dc44 diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro index 2d9248ef66..22907d894c 100644 --- a/src/declarative/declarative.pro +++ b/src/declarative/declarative.pro @@ -6,7 +6,7 @@ QPRO_PWD = $$PWD CONFIG += module MODULE_PRI += ../../modules/qt_declarative.pri -QT = core-private gui-private network opengl-private +QT = core-private gui-private network opengl-private v8-private contains(QT_CONFIG, svg): QT += svg DEFINES += QT_BUILD_DECLARATIVE_LIB QT_NO_URL_CAST_FROM_STRING win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000 @@ -33,7 +33,6 @@ include(debugger/debugger.pri) include(scenegraph/scenegraph.pri) include(items/items.pri) include(particles/particles.pri) -include(v8/v8.pri) symbian: { TARGET.UID3=0x2001E623 diff --git a/src/declarative/qml/v8/qv8_p.h b/src/declarative/qml/v8/qv8_p.h index 8df007e804..d41fb559f7 100644 --- a/src/declarative/qml/v8/qv8_p.h +++ b/src/declarative/qml/v8/qv8_p.h @@ -39,4 +39,4 @@ ** ****************************************************************************/ -#include "../../../3rdparty/v8/include/v8.h" +#include diff --git a/src/declarative/v8/0001-Add-hashing-and-comparison-methods-to-v8-String.patch b/src/declarative/v8/0001-Add-hashing-and-comparison-methods-to-v8-String.patch deleted file mode 100644 index 1fb3b90733..0000000000 --- a/src/declarative/v8/0001-Add-hashing-and-comparison-methods-to-v8-String.patch +++ /dev/null @@ -1,343 +0,0 @@ -From e13ce09287a56c920d5ffdc5d4662d49f1838f16 Mon Sep 17 00:00:00 2001 -From: Aaron Kennedy -Date: Mon, 23 May 2011 15:47:20 +1000 -Subject: [PATCH 01/13] Add hashing and comparison methods to v8::String - -This allows us to more rapidly search for a v8::String inside -a hash of QStrings. ---- - include/v8.h | 44 ++++++++++++++++++++++++++++++ - src/api.cc | 43 +++++++++++++++++++++++++++++ - src/heap-inl.h | 2 + - src/heap.cc | 3 ++ - src/objects-inl.h | 1 + - src/objects.cc | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++- - src/objects.h | 15 +++++++++- - 7 files changed, 182 insertions(+), 3 deletions(-) - -diff --git a/include/v8.h b/include/v8.h -index d15d024..bbd29e9 100644 ---- a/include/v8.h -+++ b/include/v8.h -@@ -994,6 +994,48 @@ class String : public Primitive { - V8EXPORT int Utf8Length() const; - - /** -+ * Returns the hash of this string. -+ */ -+ V8EXPORT uint32_t Hash() const; -+ -+ struct CompleteHashData { -+ CompleteHashData() : length(0), hash(0), symbol_id(0) {} -+ int length; -+ uint32_t hash; -+ uint32_t symbol_id; -+ }; -+ -+ /** -+ * Returns the "complete" hash of the string. This is -+ * all the information about the string needed to implement -+ * a very efficient hash keyed on the string. -+ * -+ * The members of CompleteHashData are: -+ * length: The length of the string. Equivalent to Length() -+ * hash: The hash of the string. Equivalent to Hash() -+ * symbol_id: If the string is a sequential symbol, the symbol -+ * id, otherwise 0. If the symbol ids of two strings are -+ * the same (and non-zero) the two strings are identical. -+ * If the symbol ids are different the strings may still be -+ * identical, but an Equals() check must be performed. -+ */ -+ V8EXPORT CompleteHashData CompleteHash() const; -+ -+ /** -+ * Compute a hash value for the passed UTF16 string -+ * data. -+ */ -+ V8EXPORT static uint32_t ComputeHash(uint16_t *string, int length); -+ V8EXPORT static uint32_t ComputeHash(char *string, int length); -+ -+ /** -+ * Returns true if this string is equal to the external -+ * string data provided. -+ */ -+ V8EXPORT bool Equals(uint16_t *string, int length); -+ V8EXPORT bool Equals(char *string, int length); -+ -+ /** - * Write the contents of the string to an external buffer. - * If no arguments are given, expects the buffer to be large - * enough to hold the entire string and NULL terminator. Copies -@@ -1023,6 +1065,8 @@ class String : public Primitive { - HINT_MANY_WRITES_EXPECTED = 1 - }; - -+ V8EXPORT uint16_t GetCharacter(int index); -+ - V8EXPORT int Write(uint16_t* buffer, - int start = 0, - int length = -1, -diff --git a/src/api.cc b/src/api.cc -index a2373cd..381935b 100644 ---- a/src/api.cc -+++ b/src/api.cc -@@ -3284,6 +3284,49 @@ int String::Utf8Length() const { - return str->Utf8Length(); - } - -+uint32_t String::Hash() const { -+ i::Handle str = Utils::OpenHandle(this); -+ if (IsDeadCheck(str->GetIsolate(), "v8::String::Hash()")) return 0; -+ return str->Hash(); -+} -+ -+String::CompleteHashData String::CompleteHash() const { -+ i::Handle str = Utils::OpenHandle(this); -+ if (IsDeadCheck(str->GetIsolate(), "v8::String::CompleteHash()")) return CompleteHashData(); -+ CompleteHashData result; -+ result.length = str->length(); -+ result.hash = str->Hash(); -+ if (str->IsSeqString()) -+ result.symbol_id = i::SeqString::cast(*str)->symbol_id(); -+ return result; -+} -+ -+uint32_t String::ComputeHash(uint16_t *string, int length) { -+ return i::HashSequentialString(string, length) >> i::String::kHashShift; -+} -+ -+uint32_t String::ComputeHash(char *string, int length) { -+ return i::HashSequentialString(string, length) >> i::String::kHashShift; -+} -+ -+uint16_t String::GetCharacter(int index) -+{ -+ i::Handle str = Utils::OpenHandle(this); -+ return str->Get(index); -+} -+ -+bool String::Equals(uint16_t *string, int length) { -+ i::Handle str = Utils::OpenHandle(this); -+ if (IsDeadCheck(str->GetIsolate(), "v8::String::Equals()")) return 0; -+ return str->SlowEqualsExternal(string, length); -+} -+ -+bool String::Equals(char *string, int length) -+{ -+ i::Handle str = Utils::OpenHandle(this); -+ if (IsDeadCheck(str->GetIsolate(), "v8::String::Equals()")) return 0; -+ return str->SlowEqualsExternal(string, length); -+} - - int String::WriteUtf8(char* buffer, - int capacity, -diff --git a/src/heap-inl.h b/src/heap-inl.h -index 99737ed..f4fce7b 100644 ---- a/src/heap-inl.h -+++ b/src/heap-inl.h -@@ -93,6 +93,7 @@ MaybeObject* Heap::AllocateAsciiSymbol(Vector str, - String* answer = String::cast(result); - answer->set_length(str.length()); - answer->set_hash_field(hash_field); -+ SeqString::cast(answer)->set_symbol_id(0); - - ASSERT_EQ(size, answer->Size()); - -@@ -126,6 +127,7 @@ MaybeObject* Heap::AllocateTwoByteSymbol(Vector str, - String* answer = String::cast(result); - answer->set_length(str.length()); - answer->set_hash_field(hash_field); -+ SeqString::cast(answer)->set_symbol_id(0); - - ASSERT_EQ(size, answer->Size()); - -diff --git a/src/heap.cc b/src/heap.cc -index 2b6c11f..930c97b 100644 ---- a/src/heap.cc -+++ b/src/heap.cc -@@ -3519,6 +3519,7 @@ MaybeObject* Heap::AllocateInternalSymbol(unibrow::CharacterStream* buffer, - String* answer = String::cast(result); - answer->set_length(chars); - answer->set_hash_field(hash_field); -+ SeqString::cast(result)->set_symbol_id(0); - - ASSERT_EQ(size, answer->Size()); - -@@ -3561,6 +3562,7 @@ MaybeObject* Heap::AllocateRawAsciiString(int length, PretenureFlag pretenure) { - HeapObject::cast(result)->set_map(ascii_string_map()); - String::cast(result)->set_length(length); - String::cast(result)->set_hash_field(String::kEmptyHashField); -+ SeqString::cast(result)->set_symbol_id(0); - ASSERT_EQ(size, HeapObject::cast(result)->Size()); - return result; - } -@@ -3596,6 +3598,7 @@ MaybeObject* Heap::AllocateRawTwoByteString(int length, - HeapObject::cast(result)->set_map(string_map()); - String::cast(result)->set_length(length); - String::cast(result)->set_hash_field(String::kEmptyHashField); -+ SeqString::cast(result)->set_symbol_id(0); - ASSERT_EQ(size, HeapObject::cast(result)->Size()); - return result; - } -diff --git a/src/objects-inl.h b/src/objects-inl.h -index 65aec5d..c82080d 100644 ---- a/src/objects-inl.h -+++ b/src/objects-inl.h -@@ -1924,6 +1924,7 @@ INT_ACCESSORS(ExternalArray, length, kLengthOffset) - - - SMI_ACCESSORS(String, length, kLengthOffset) -+SMI_ACCESSORS(SeqString, symbol_id, kSymbolIdOffset) - - - uint32_t String::hash_field() { -diff --git a/src/objects.cc b/src/objects.cc -index df61956..dc4b260 100644 ---- a/src/objects.cc -+++ b/src/objects.cc -@@ -5346,6 +5346,66 @@ static inline bool CompareStringContentsPartial(Isolate* isolate, - } - } - -+bool String::SlowEqualsExternal(uc16 *string, int length) { -+ int len = this->length(); -+ if (len != length) return false; -+ if (len == 0) return true; -+ -+ // We know the strings are both non-empty. Compare the first chars -+ // before we try to flatten the strings. -+ if (this->Get(0) != string[0]) return false; -+ -+ String* lhs = this->TryFlattenGetString(); -+ -+ if (lhs->IsFlat()) { -+ if (lhs->IsAsciiRepresentation()) { -+ Vector vec1 = lhs->ToAsciiVector(); -+ VectorIterator buf1(vec1); -+ VectorIterator ib(string, length); -+ return CompareStringContents(&buf1, &ib); -+ } else { -+ Vector vec1 = lhs->ToUC16Vector(); -+ Vector vec2(string, length); -+ return CompareRawStringContents(vec1, vec2); -+ } -+ } else { -+ Isolate* isolate = GetIsolate(); -+ isolate->objects_string_compare_buffer_a()->Reset(0, lhs); -+ VectorIterator ib(string, length); -+ return CompareStringContents(isolate->objects_string_compare_buffer_a(), &ib); -+ } -+} -+ -+bool String::SlowEqualsExternal(char *string, int length) -+{ -+ int len = this->length(); -+ if (len != length) return false; -+ if (len == 0) return true; -+ -+ // We know the strings are both non-empty. Compare the first chars -+ // before we try to flatten the strings. -+ if (this->Get(0) != string[0]) return false; -+ -+ String* lhs = this->TryFlattenGetString(); -+ -+ if (StringShape(lhs).IsSequentialAscii()) { -+ const char* str1 = SeqAsciiString::cast(lhs)->GetChars(); -+ return CompareRawStringContents(Vector(str1, len), -+ Vector(string, len)); -+ } -+ -+ if (lhs->IsFlat()) { -+ Vector vec1 = lhs->ToUC16Vector(); -+ VectorIterator buf1(vec1); -+ VectorIterator buf2(string, length); -+ return CompareStringContents(&buf1, &buf2); -+ } else { -+ Isolate* isolate = GetIsolate(); -+ isolate->objects_string_compare_buffer_a()->Reset(0, lhs); -+ VectorIterator ib(string, length); -+ return CompareStringContents(isolate->objects_string_compare_buffer_a(), &ib); -+ } -+} - - bool String::SlowEquals(String* other) { - // Fast check: negative check with lengths. -@@ -8655,9 +8715,24 @@ class AsciiSymbolKey : public SequentialSymbolKey { - - MaybeObject* AsObject() { - if (hash_field_ == 0) Hash(); -- return HEAP->AllocateAsciiSymbol(string_, hash_field_); -+ MaybeObject *result = HEAP->AllocateAsciiSymbol(string_, hash_field_); -+ if (!result->IsFailure() && result->ToObjectUnchecked()->IsSeqString()) { -+ while (true) { -+ Atomic32 my_symbol_id = next_symbol_id; -+ if (my_symbol_id > Smi::kMaxValue) -+ break; -+ if (my_symbol_id == NoBarrier_CompareAndSwap(&next_symbol_id, my_symbol_id, my_symbol_id + 1)) { -+ SeqString::cast(result->ToObjectUnchecked())->set_symbol_id(my_symbol_id); -+ break; -+ } -+ } -+ } -+ return result; - } -+ -+ static Atomic32 next_symbol_id; - }; -+Atomic32 AsciiSymbolKey::next_symbol_id = 1; - - - class TwoByteSymbolKey : public SequentialSymbolKey { -diff --git a/src/objects.h b/src/objects.h -index e966b3d..6e26f57 100644 ---- a/src/objects.h -+++ b/src/objects.h -@@ -5359,6 +5359,9 @@ class String: public HeapObject { - bool IsAsciiEqualTo(Vector str); - bool IsTwoByteEqualTo(Vector str); - -+ bool SlowEqualsExternal(uc16 *string, int length); -+ bool SlowEqualsExternal(char *string, int length); -+ - // Return a UTF8 representation of the string. The string is null - // terminated but may optionally contain nulls. Length is returned - // in length_output if length_output is not a null pointer The string -@@ -5610,9 +5613,17 @@ class String: public HeapObject { - class SeqString: public String { - public: - -+ // Get and set the symbol id of the string -+ inline int symbol_id(); -+ inline void set_symbol_id(int value); -+ - // Casting. - static inline SeqString* cast(Object* obj); - -+ // Layout description. -+ static const int kSymbolIdOffset = String::kSize; -+ static const int kSize = kSymbolIdOffset + kPointerSize; -+ - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(SeqString); - }; -@@ -5647,7 +5658,7 @@ class SeqAsciiString: public SeqString { - } - - // Layout description. -- static const int kHeaderSize = String::kSize; -+ static const int kHeaderSize = SeqString::kSize; - static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); - - // Maximal memory usage for a single sequential ASCII string. -@@ -5701,7 +5712,7 @@ class SeqTwoByteString: public SeqString { - } - - // Layout description. -- static const int kHeaderSize = String::kSize; -+ static const int kHeaderSize = SeqString::kSize; - static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize); - - // Maximal memory usage for a single sequential two-byte string. --- -1.7.2.3 - diff --git a/src/declarative/v8/0002-Add-a-bit-field-3-to-Map.patch b/src/declarative/v8/0002-Add-a-bit-field-3-to-Map.patch deleted file mode 100644 index daf8b35570..0000000000 --- a/src/declarative/v8/0002-Add-a-bit-field-3-to-Map.patch +++ /dev/null @@ -1,118 +0,0 @@ -From 7c9cfff80b7864d5687432d424074e51712c4a07 Mon Sep 17 00:00:00 2001 -From: Aaron Kennedy -Date: Mon, 23 May 2011 15:55:26 +1000 -Subject: [PATCH 02/13] Add a bit field 3 to Map - -Bit field 3 will be used to add QML specific map flags. ---- - src/heap.cc | 2 ++ - src/objects-inl.h | 10 ++++++++++ - src/objects.cc | 2 ++ - src/objects.h | 9 ++++++++- - 4 files changed, 22 insertions(+), 1 deletions(-) - -diff --git a/src/heap.cc b/src/heap.cc -index 930c97b..900f462 100644 ---- a/src/heap.cc -+++ b/src/heap.cc -@@ -1573,6 +1573,7 @@ MaybeObject* Heap::AllocatePartialMap(InstanceType instance_type, - reinterpret_cast(result)->set_unused_property_fields(0); - reinterpret_cast(result)->set_bit_field(0); - reinterpret_cast(result)->set_bit_field2(0); -+ reinterpret_cast(result)->set_bit_field3(0); - return result; - } - -@@ -1599,6 +1600,7 @@ MaybeObject* Heap::AllocateMap(InstanceType instance_type, int instance_size) { - map->set_unused_property_fields(0); - map->set_bit_field(0); - map->set_bit_field2((1 << Map::kIsExtensible) | (1 << Map::kHasFastElements)); -+ map->set_bit_field3(0); - - // If the map object is aligned fill the padding area with Smi 0 objects. - if (Map::kPadStart < Map::kSize) { -diff --git a/src/objects-inl.h b/src/objects-inl.h -index c82080d..cce3edd 100644 ---- a/src/objects-inl.h -+++ b/src/objects-inl.h -@@ -2430,6 +2430,16 @@ void Map::set_bit_field2(byte value) { - } - - -+byte Map::bit_field3() { -+ return READ_BYTE_FIELD(this, kBitField3Offset); -+} -+ -+ -+void Map::set_bit_field3(byte value) { -+ WRITE_BYTE_FIELD(this, kBitField3Offset, value); -+} -+ -+ - void Map::set_non_instance_prototype(bool value) { - if (value) { - set_bit_field(bit_field() | (1 << kHasNonInstancePrototype)); -diff --git a/src/objects.cc b/src/objects.cc -index dc4b260..79d7240 100644 ---- a/src/objects.cc -+++ b/src/objects.cc -@@ -3614,6 +3614,7 @@ MaybeObject* Map::CopyDropDescriptors() { - } - Map::cast(result)->set_bit_field(bit_field()); - Map::cast(result)->set_bit_field2(bit_field2()); -+ Map::cast(result)->set_bit_field3(bit_field3()); - Map::cast(result)->set_is_shared(false); - Map::cast(result)->ClearCodeCache(heap); - return result; -@@ -3642,6 +3643,7 @@ MaybeObject* Map::CopyNormalized(PropertyNormalizationMode mode, - - Map::cast(result)->set_bit_field(bit_field()); - Map::cast(result)->set_bit_field2(bit_field2()); -+ Map::cast(result)->set_bit_field3(bit_field3()); - - Map::cast(result)->set_is_shared(sharing == SHARED_NORMALIZED_MAP); - -diff --git a/src/objects.h b/src/objects.h -index 6e26f57..07e1089 100644 ---- a/src/objects.h -+++ b/src/objects.h -@@ -3597,6 +3597,10 @@ class Map: public HeapObject { - inline byte bit_field2(); - inline void set_bit_field2(byte value); - -+ // Bit field 3. -+ inline byte bit_field3(); -+ inline void set_bit_field3(byte value); -+ - // Tells whether the object in the prototype property will be used - // for instances created from this function. If the prototype - // property is set to a value that is not a JSObject, the prototype -@@ -3844,7 +3848,7 @@ class Map: public HeapObject { - // Layout description. - static const int kInstanceSizesOffset = HeapObject::kHeaderSize; - static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; -- static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; -+ static const int kPrototypeOffset = POINTER_SIZE_ALIGN(kInstanceAttributesOffset + 2 * kIntSize); - static const int kConstructorOffset = kPrototypeOffset + kPointerSize; - static const int kInstanceDescriptorsOffset = - kConstructorOffset + kPointerSize; -@@ -3876,6 +3880,7 @@ class Map: public HeapObject { - static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 1; - static const int kBitFieldOffset = kInstanceAttributesOffset + 2; - static const int kBitField2Offset = kInstanceAttributesOffset + 3; -+ static const int kBitField3Offset = kInstanceAttributesOffset + 4; - - STATIC_CHECK(kInstanceTypeOffset == Internals::kMapInstanceTypeOffset); - -@@ -3898,6 +3903,8 @@ class Map: public HeapObject { - static const int kIsShared = 5; - static const int kHasExternalArrayElements = 6; - -+ // Bit positions for bit field 3 -+ - // Layout of the default cache. It holds alternating name and code objects. - static const int kCodeCacheEntrySize = 2; - static const int kCodeCacheEntryNameOffset = 0; --- -1.7.2.3 - diff --git a/src/declarative/v8/0003-Add-a-fallback-mode-for-named-property-interceptors.patch b/src/declarative/v8/0003-Add-a-fallback-mode-for-named-property-interceptors.patch deleted file mode 100644 index 1c81b2af9d..0000000000 --- a/src/declarative/v8/0003-Add-a-fallback-mode-for-named-property-interceptors.patch +++ /dev/null @@ -1,364 +0,0 @@ -From ae8688b53d67044f2c9b0cce25fc282b078610c1 Mon Sep 17 00:00:00 2001 -From: Aaron Kennedy -Date: Mon, 23 May 2011 16:21:02 +1000 -Subject: [PATCH 03/13] Add a "fallback" mode for named property interceptors - -By default interceptors are called before the normal property -resolution on objects. When an interceptor is installed as a -"fallback" interceptor, it is only called if the object doesn't -already have the property. - -In the case of a global object having an fallback interceptor, -the interceptor is not invoked at all for var or function -declarations. ---- - include/v8.h | 8 ++++++++ - src/api.cc | 29 +++++++++++++++++++++++++++++ - src/factory.cc | 4 ++++ - src/handles.cc | 6 ++++-- - src/handles.h | 3 ++- - src/objects-inl.h | 16 ++++++++++++++++ - src/objects.cc | 22 ++++++++++++++++------ - src/objects.h | 18 ++++++++++++++---- - src/runtime.cc | 11 ++++++----- - 9 files changed, 99 insertions(+), 18 deletions(-) - -diff --git a/include/v8.h b/include/v8.h -index bbd29e9..85452aa 100644 ---- a/include/v8.h -+++ b/include/v8.h -@@ -2169,6 +2169,7 @@ class V8EXPORT FunctionTemplate : public Template { - NamedPropertyQuery query, - NamedPropertyDeleter remover, - NamedPropertyEnumerator enumerator, -+ bool is_fallback, - Handle data); - void SetIndexedInstancePropertyHandler(IndexedPropertyGetter getter, - IndexedPropertySetter setter, -@@ -2253,6 +2254,13 @@ class V8EXPORT ObjectTemplate : public Template { - NamedPropertyEnumerator enumerator = 0, - Handle data = Handle()); - -+ void SetFallbackPropertyHandler(NamedPropertyGetter getter, -+ NamedPropertySetter setter = 0, -+ NamedPropertyQuery query = 0, -+ NamedPropertyDeleter deleter = 0, -+ NamedPropertyEnumerator enumerator = 0, -+ Handle data = Handle()); -+ - /** - * Sets an indexed property handler on the object template. - * -diff --git a/src/api.cc b/src/api.cc -index 381935b..8b0b32a 100644 ---- a/src/api.cc -+++ b/src/api.cc -@@ -981,6 +981,7 @@ void FunctionTemplate::SetNamedInstancePropertyHandler( - NamedPropertyQuery query, - NamedPropertyDeleter remover, - NamedPropertyEnumerator enumerator, -+ bool is_fallback, - Handle data) { - i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); - if (IsDeadCheck(isolate, -@@ -999,6 +1000,7 @@ void FunctionTemplate::SetNamedInstancePropertyHandler( - if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); - if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); - if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); -+ obj->set_is_fallback(i::Smi::FromInt(is_fallback)); - - if (data.IsEmpty()) data = v8::Undefined(); - obj->set_data(*Utils::OpenHandle(*data)); -@@ -1143,6 +1145,33 @@ void ObjectTemplate::SetNamedPropertyHandler(NamedPropertyGetter getter, - query, - remover, - enumerator, -+ false, -+ data); -+} -+ -+ -+void ObjectTemplate::SetFallbackPropertyHandler(NamedPropertyGetter getter, -+ NamedPropertySetter setter, -+ NamedPropertyQuery query, -+ NamedPropertyDeleter remover, -+ NamedPropertyEnumerator enumerator, -+ Handle data) { -+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); -+ if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetFallbackPropertyHandler()")) { -+ return; -+ } -+ ENTER_V8(isolate); -+ i::HandleScope scope(isolate); -+ EnsureConstructor(this); -+ i::FunctionTemplateInfo* constructor = -+ i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); -+ i::Handle cons(constructor); -+ Utils::ToLocal(cons)->SetNamedInstancePropertyHandler(getter, -+ setter, -+ query, -+ remover, -+ enumerator, -+ true, - data); - } - -diff --git a/src/factory.cc b/src/factory.cc -index 7dee66f..dcdc645 100644 ---- a/src/factory.cc -+++ b/src/factory.cc -@@ -1058,6 +1058,10 @@ Handle Factory::CreateApiFunction( - // Set interceptor information in the map. - if (!obj->named_property_handler()->IsUndefined()) { - map->set_has_named_interceptor(); -+ -+ InterceptorInfo *nph = InterceptorInfo::cast(obj->named_property_handler()); -+ bool is_fallback = nph->is_fallback()->IsUndefined()?false:nph->is_fallback()->value(); -+ map->set_named_interceptor_is_fallback(is_fallback); - } - if (!obj->indexed_property_handler()->IsUndefined()) { - map->set_has_indexed_interceptor(); -diff --git a/src/handles.cc b/src/handles.cc -index 326de86..dd3a86c 100644 ---- a/src/handles.cc -+++ b/src/handles.cc -@@ -262,9 +262,11 @@ Handle SetProperty(Handle object, - Handle key, - Handle value, - PropertyAttributes attributes, -- StrictModeFlag strict_mode) { -+ StrictModeFlag strict_mode, -+ bool skip_fallback_interceptor) { - CALL_HEAP_FUNCTION(object->GetIsolate(), -- object->SetProperty(*key, *value, attributes, strict_mode), -+ object->SetProperty(*key, *value, attributes, strict_mode, -+ skip_fallback_interceptor), - Object); - } - -diff --git a/src/handles.h b/src/handles.h -index 3839f37..4b42506 100644 ---- a/src/handles.h -+++ b/src/handles.h -@@ -188,7 +188,8 @@ Handle SetProperty(Handle object, - Handle key, - Handle value, - PropertyAttributes attributes, -- StrictModeFlag strict_mode); -+ StrictModeFlag strict_mode, -+ bool skip_fallback_interceptor = false); - - Handle SetProperty(Handle object, - Handle key, -diff --git a/src/objects-inl.h b/src/objects-inl.h -index cce3edd..6aaca2f 100644 ---- a/src/objects-inl.h -+++ b/src/objects-inl.h -@@ -2521,6 +2521,21 @@ bool Map::is_shared() { - } - - -+void Map::set_named_interceptor_is_fallback(bool value) -+{ -+ if (value) { -+ set_bit_field3(bit_field3() | (1 << kNamedInterceptorIsFallback)); -+ } else { -+ set_bit_field3(bit_field3() & ~(1 << kNamedInterceptorIsFallback)); -+ } -+} -+ -+bool Map::named_interceptor_is_fallback() -+{ -+ return ((1 << kNamedInterceptorIsFallback) & bit_field3()) != 0; -+} -+ -+ - JSFunction* Map::unchecked_constructor() { - return reinterpret_cast(READ_FIELD(this, kConstructorOffset)); - } -@@ -2970,6 +2985,7 @@ ACCESSORS(InterceptorInfo, query, Object, kQueryOffset) - ACCESSORS(InterceptorInfo, deleter, Object, kDeleterOffset) - ACCESSORS(InterceptorInfo, enumerator, Object, kEnumeratorOffset) - ACCESSORS(InterceptorInfo, data, Object, kDataOffset) -+ACCESSORS(InterceptorInfo, is_fallback, Smi, kFallbackOffset) - - ACCESSORS(CallHandlerInfo, callback, Object, kCallbackOffset) - ACCESSORS(CallHandlerInfo, data, Object, kDataOffset) -diff --git a/src/objects.cc b/src/objects.cc -index 79d7240..15e2cdb 100644 ---- a/src/objects.cc -+++ b/src/objects.cc -@@ -1712,9 +1712,10 @@ MaybeObject* JSObject::SetPropertyWithInterceptor( - MaybeObject* JSObject::SetProperty(String* name, - Object* value, - PropertyAttributes attributes, -- StrictModeFlag strict_mode) { -+ StrictModeFlag strict_mode, -+ bool skip_fallback_interceptor) { - LookupResult result; -- LocalLookup(name, &result); -+ LocalLookup(name, &result, skip_fallback_interceptor); - return SetProperty(&result, name, value, attributes, strict_mode); - } - -@@ -3148,7 +3149,8 @@ AccessorDescriptor* Map::FindAccessor(String* name) { - } - - --void JSObject::LocalLookup(String* name, LookupResult* result) { -+void JSObject::LocalLookup(String* name, LookupResult* result, -+ bool skip_fallback_interceptor) { - ASSERT(name->IsString()); - - Heap* heap = GetHeap(); -@@ -3174,22 +3176,30 @@ void JSObject::LocalLookup(String* name, LookupResult* result) { - } - - // Check for lookup interceptor except when bootstrapping. -- if (HasNamedInterceptor() && !heap->isolate()->bootstrapper()->IsActive()) { -+ bool wouldIntercept = HasNamedInterceptor() && !heap->isolate()->bootstrapper()->IsActive(); -+ if (wouldIntercept && !map()->named_interceptor_is_fallback()) { - result->InterceptorResult(this); - return; - } - - LocalLookupRealNamedProperty(name, result); -+ -+ if (wouldIntercept && !skip_fallback_interceptor && !result->IsProperty() && -+ map()->named_interceptor_is_fallback()) { -+ result->InterceptorResult(this); -+ return; -+ } - } - - --void JSObject::Lookup(String* name, LookupResult* result) { -+void JSObject::Lookup(String* name, LookupResult* result, -+ bool skip_fallback_interceptor) { - // Ecma-262 3rd 8.6.2.4 - Heap* heap = GetHeap(); - for (Object* current = this; - current != heap->null_value(); - current = JSObject::cast(current)->GetPrototype()) { -- JSObject::cast(current)->LocalLookup(name, result); -+ JSObject::cast(current)->LocalLookup(name, result, skip_fallback_interceptor); - if (result->IsProperty()) return; - } - result->NotFound(); -diff --git a/src/objects.h b/src/objects.h -index 07e1089..a209cd0 100644 ---- a/src/objects.h -+++ b/src/objects.h -@@ -1405,7 +1405,8 @@ class JSObject: public HeapObject { - MUST_USE_RESULT MaybeObject* SetProperty(String* key, - Object* value, - PropertyAttributes attributes, -- StrictModeFlag strict_mode); -+ StrictModeFlag strict_mode, -+ bool skip_fallback_interceptor = false); - MUST_USE_RESULT MaybeObject* SetProperty(LookupResult* result, - String* key, - Object* value, -@@ -1637,8 +1638,8 @@ class JSObject: public HeapObject { - - // Lookup a property. If found, the result is valid and has - // detailed information. -- void LocalLookup(String* name, LookupResult* result); -- void Lookup(String* name, LookupResult* result); -+ void LocalLookup(String* name, LookupResult* result, bool skip_fallback_interceptor = false); -+ void Lookup(String* name, LookupResult* result, bool skip_fallback_interceptor = false); - - // The following lookup functions skip interceptors. - void LocalLookupRealNamedProperty(String* name, LookupResult* result); -@@ -3714,6 +3715,12 @@ class Map: public HeapObject { - inline void set_is_access_check_needed(bool access_check_needed); - inline bool is_access_check_needed(); - -+ -+ // Whether the named interceptor is a fallback interceptor or not -+ inline void set_named_interceptor_is_fallback(bool value); -+ inline bool named_interceptor_is_fallback(); -+ -+ - // [prototype]: implicit prototype object. - DECL_ACCESSORS(prototype, Object) - -@@ -3904,6 +3911,7 @@ class Map: public HeapObject { - static const int kHasExternalArrayElements = 6; - - // Bit positions for bit field 3 -+ static const int kNamedInterceptorIsFallback = 0; - - // Layout of the default cache. It holds alternating name and code objects. - static const int kCodeCacheEntrySize = 2; -@@ -6276,6 +6284,7 @@ class InterceptorInfo: public Struct { - DECL_ACCESSORS(deleter, Object) - DECL_ACCESSORS(enumerator, Object) - DECL_ACCESSORS(data, Object) -+ DECL_ACCESSORS(is_fallback, Smi) - - static inline InterceptorInfo* cast(Object* obj); - -@@ -6295,7 +6304,8 @@ class InterceptorInfo: public Struct { - static const int kDeleterOffset = kQueryOffset + kPointerSize; - static const int kEnumeratorOffset = kDeleterOffset + kPointerSize; - static const int kDataOffset = kEnumeratorOffset + kPointerSize; -- static const int kSize = kDataOffset + kPointerSize; -+ static const int kFallbackOffset = kDataOffset + kPointerSize; -+ static const int kSize = kFallbackOffset + kPointerSize; - - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(InterceptorInfo); -diff --git a/src/runtime.cc b/src/runtime.cc -index 7335da8..660352c 100644 ---- a/src/runtime.cc -+++ b/src/runtime.cc -@@ -1097,7 +1097,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareGlobals) { - // Lookup the property in the global object, and don't set the - // value of the variable if the property is already there. - LookupResult lookup; -- global->Lookup(*name, &lookup); -+ global->Lookup(*name, &lookup, true); - if (lookup.IsProperty()) { - // Determine if the property is local by comparing the holder - // against the global object. The information will be used to -@@ -1152,7 +1152,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareGlobals) { - } - - LookupResult lookup; -- global->LocalLookup(*name, &lookup); -+ global->LocalLookup(*name, &lookup, true); - - PropertyAttributes attributes = is_const_property - ? static_cast(base | READ_ONLY) -@@ -1196,7 +1196,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareGlobals) { - name, - value, - attributes, -- strict_mode)); -+ strict_mode, -+ true)); - } - } - -@@ -1343,7 +1344,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { - JSObject* real_holder = global; - LookupResult lookup; - while (true) { -- real_holder->LocalLookup(*name, &lookup); -+ real_holder->LocalLookup(*name, &lookup, true); - if (lookup.IsProperty()) { - // Determine if this is a redeclaration of something read-only. - if (lookup.IsReadOnly()) { -@@ -1400,7 +1401,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { - - global = isolate->context()->global(); - if (assign) { -- return global->SetProperty(*name, args[2], attributes, strict_mode); -+ return global->SetProperty(*name, args[2], attributes, strict_mode, true); - } - return isolate->heap()->undefined_value(); - } --- -1.7.2.3 - diff --git a/src/declarative/v8/0004-Generalize-external-object-resources.patch b/src/declarative/v8/0004-Generalize-external-object-resources.patch deleted file mode 100644 index 6b85666cf0..0000000000 --- a/src/declarative/v8/0004-Generalize-external-object-resources.patch +++ /dev/null @@ -1,894 +0,0 @@ -From 4827116b12c50f6662794017c5a662b5dbb2da0b Mon Sep 17 00:00:00 2001 -From: Aaron Kennedy -Date: Mon, 23 May 2011 16:55:35 +1000 -Subject: [PATCH 04/13] Generalize external object resources - -V8 was already able to manage and finalize an external string -resource. This change generalizes that mechanism to handle a -single generic external resource - a v8::Object::ExternalResource -derived instance - on normal JSObject's. - -This is useful for mapping C++ objects to JS objects where the -C++ object's memory is effectively owned by the JS Object, and -thus needs to destroyed when the JS Object is garbage collected. -The V8 mailing list suggests using a weak persistent handle for -this purpose, but that seems to incur a fairly massive performance -penalty for short lived objects as weak persistent handle callbacks -are not called until the object has been promoted into the old -object space. ---- - include/v8.h | 25 ++++++ - src/api.cc | 64 ++++++++++++++- - src/extensions/externalize-string-extension.cc | 4 +- - src/factory.cc | 11 +++ - src/heap-inl.h | 101 +++++++++++++++--------- - src/heap.cc | 68 ++++++++-------- - src/heap.h | 42 +++++----- - src/liveobjectlist.cc | 4 +- - src/mark-compact.cc | 21 +++--- - src/objects-inl.h | 41 +++++++++- - src/objects.h | 14 +++- - 11 files changed, 280 insertions(+), 115 deletions(-) - -diff --git a/include/v8.h b/include/v8.h -index 85452aa..7f06ae7 100644 ---- a/include/v8.h -+++ b/include/v8.h -@@ -1630,6 +1630,25 @@ class Object : public Value { - /** Sets a native pointer in an internal field. */ - V8EXPORT void SetPointerInInternalField(int index, void* value); - -+ class V8EXPORT ExternalResource { // NOLINT -+ public: -+ ExternalResource() {} -+ virtual ~ExternalResource() {} -+ -+ protected: -+ virtual void Dispose() { delete this; } -+ -+ private: -+ // Disallow copying and assigning. -+ ExternalResource(const ExternalResource&); -+ void operator=(const ExternalResource&); -+ -+ friend class v8::internal::Heap; -+ }; -+ -+ V8EXPORT void SetExternalResource(ExternalResource *); -+ V8EXPORT ExternalResource *GetExternalResource(); -+ - // Testers for local properties. - V8EXPORT bool HasRealNamedProperty(Handle key); - V8EXPORT bool HasRealIndexedProperty(uint32_t index); -@@ -2331,6 +2350,12 @@ class V8EXPORT ObjectTemplate : public Template { - */ - void SetInternalFieldCount(int value); - -+ /** -+ * Sets whether the object can store an "external resource" object. -+ */ -+ bool HasExternalResource(); -+ void SetHasExternalResource(bool value); -+ - private: - ObjectTemplate(); - static Local New(Handle constructor); -diff --git a/src/api.cc b/src/api.cc -index 8b0b32a..1a6fbbb 100644 ---- a/src/api.cc -+++ b/src/api.cc -@@ -1294,6 +1294,34 @@ void ObjectTemplate::SetInternalFieldCount(int value) { - } - - -+bool ObjectTemplate::HasExternalResource() -+{ -+ if (IsDeadCheck(Utils::OpenHandle(this)->GetIsolate(), -+ "v8::ObjectTemplate::HasExternalResource()")) { -+ return 0; -+ } -+ return !Utils::OpenHandle(this)->has_external_resource()->IsUndefined(); -+} -+ -+ -+void ObjectTemplate::SetHasExternalResource(bool value) -+{ -+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); -+ if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetHasExternalResource()")) { -+ return; -+ } -+ ENTER_V8(isolate); -+ if (value) { -+ EnsureConstructor(this); -+ } -+ if (value) { -+ Utils::OpenHandle(this)->set_has_external_resource(i::Smi::FromInt(1)); -+ } else { -+ Utils::OpenHandle(this)->set_has_external_resource(Utils::OpenHandle(this)->GetHeap()->undefined_value()); -+ } -+} -+ -+ - // --- S c r i p t D a t a --- - - -@@ -3652,6 +3680,34 @@ void v8::Object::SetPointerInInternalField(int index, void* value) { - } - - -+void v8::Object::SetExternalResource(v8::Object::ExternalResource *resource) { -+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); -+ ENTER_V8(isolate); -+ i::Handle obj = Utils::OpenHandle(this); -+ if (CanBeEncodedAsSmi(resource)) { -+ obj->SetExternalResourceObject(EncodeAsSmi(resource)); -+ } else { -+ obj->SetExternalResourceObject(*isolate->factory()->NewProxy(static_cast((void *)resource))); -+ } -+ if (!obj->IsSymbol()) { -+ isolate->heap()->external_resource_table()->AddObject(*obj); -+ } -+} -+ -+ -+v8::Object::ExternalResource *v8::Object::GetExternalResource() { -+ i::Handle obj = Utils::OpenHandle(this); -+ i::Object* value = obj->GetExternalResourceObject(); -+ if (value->IsSmi()) { -+ return reinterpret_cast(i::Internals::GetExternalPointerFromSmi(value)); -+ } else if (value->IsProxy()) { -+ return reinterpret_cast(i::Proxy::cast(value)->proxy()); -+ } else { -+ return NULL; -+ } -+} -+ -+ - // --- E n v i r o n m e n t --- - - -@@ -4144,7 +4200,7 @@ Local v8::String::NewExternal( - LOG_API(isolate, "String::NewExternal"); - ENTER_V8(isolate); - i::Handle result = NewExternalStringHandle(isolate, resource); -- isolate->heap()->external_string_table()->AddString(*result); -+ isolate->heap()->external_resource_table()->AddString(*result); - return Utils::ToLocal(result); - } - -@@ -4162,7 +4218,7 @@ bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { - } - bool result = obj->MakeExternal(resource); - if (result && !obj->IsSymbol()) { -- isolate->heap()->external_string_table()->AddString(*obj); -+ isolate->heap()->external_resource_table()->AddString(*obj); - } - return result; - } -@@ -4175,7 +4231,7 @@ Local v8::String::NewExternal( - LOG_API(isolate, "String::NewExternal"); - ENTER_V8(isolate); - i::Handle result = NewExternalAsciiStringHandle(isolate, resource); -- isolate->heap()->external_string_table()->AddString(*result); -+ isolate->heap()->external_resource_table()->AddString(*result); - return Utils::ToLocal(result); - } - -@@ -4194,7 +4250,7 @@ bool v8::String::MakeExternal( - } - bool result = obj->MakeExternal(resource); - if (result && !obj->IsSymbol()) { -- isolate->heap()->external_string_table()->AddString(*obj); -+ isolate->heap()->external_resource_table()->AddString(*obj); - } - return result; - } -diff --git a/src/extensions/externalize-string-extension.cc b/src/extensions/externalize-string-extension.cc -index b3f83fe..8e50904 100644 ---- a/src/extensions/externalize-string-extension.cc -+++ b/src/extensions/externalize-string-extension.cc -@@ -100,7 +100,7 @@ v8::Handle ExternalizeStringExtension::Externalize( - data, string->length()); - result = string->MakeExternal(resource); - if (result && !string->IsSymbol()) { -- HEAP->external_string_table()->AddString(*string); -+ HEAP->external_resource_table()->AddString(*string); - } - if (!result) delete resource; - } else { -@@ -110,7 +110,7 @@ v8::Handle ExternalizeStringExtension::Externalize( - data, string->length()); - result = string->MakeExternal(resource); - if (result && !string->IsSymbol()) { -- HEAP->external_string_table()->AddString(*string); -+ HEAP->external_resource_table()->AddString(*string); - } - if (!result) delete resource; - } -diff --git a/src/factory.cc b/src/factory.cc -index dcdc645..d530a75 100644 ---- a/src/factory.cc -+++ b/src/factory.cc -@@ -997,15 +997,21 @@ Handle Factory::CreateApiFunction( - Handle construct_stub = isolate()->builtins()->JSConstructStubApi(); - - int internal_field_count = 0; -+ bool has_external_resource = false; -+ - if (!obj->instance_template()->IsUndefined()) { - Handle instance_template = - Handle( - ObjectTemplateInfo::cast(obj->instance_template())); - internal_field_count = - Smi::cast(instance_template->internal_field_count())->value(); -+ has_external_resource = -+ !instance_template->has_external_resource()->IsUndefined(); - } - - int instance_size = kPointerSize * internal_field_count; -+ if (has_external_resource) instance_size += kPointerSize; -+ - InstanceType type = INVALID_TYPE; - switch (instance_type) { - case JavaScriptObject: -@@ -1040,6 +1046,11 @@ Handle Factory::CreateApiFunction( - - Handle map = Handle(result->initial_map()); - -+ // Mark as having external data object if needed -+ if (has_external_resource) { -+ map->set_has_external_resource(true); -+ } -+ - // Mark as undetectable if needed. - if (obj->undetectable()) { - map->set_is_undetectable(); -diff --git a/src/heap-inl.h b/src/heap-inl.h -index f4fce7b..58e7adf 100644 ---- a/src/heap-inl.h -+++ b/src/heap-inl.h -@@ -205,21 +205,36 @@ MaybeObject* Heap::NumberFromUint32(uint32_t value) { - } - - --void Heap::FinalizeExternalString(String* string) { -- ASSERT(string->IsExternalString()); -- v8::String::ExternalStringResourceBase** resource_addr = -- reinterpret_cast( -- reinterpret_cast(string) + -- ExternalString::kResourceOffset - -- kHeapObjectTag); -- -- // Dispose of the C++ object if it has not already been disposed. -- if (*resource_addr != NULL) { -- (*resource_addr)->Dispose(); -- } -+void Heap::FinalizeExternalString(HeapObject* string) { -+ ASSERT(string->IsExternalString() || string->map()->has_external_resource()); -+ -+ if (string->IsExternalString()) { -+ v8::String::ExternalStringResourceBase** resource_addr = -+ reinterpret_cast( -+ reinterpret_cast(string) + -+ ExternalString::kResourceOffset - -+ kHeapObjectTag); -+ -+ // Dispose of the C++ object if it has not already been disposed. -+ if (*resource_addr != NULL) { -+ (*resource_addr)->Dispose(); -+ } - -- // Clear the resource pointer in the string. -- *resource_addr = NULL; -+ // Clear the resource pointer in the string. -+ *resource_addr = NULL; -+ } else { -+ JSObject *object = JSObject::cast(string); -+ Object *value = object->GetExternalResourceObject(); -+ v8::Object::ExternalResource *resource = 0; -+ if (value->IsSmi()) { -+ resource = reinterpret_cast(Internals::GetExternalPointerFromSmi(value)); -+ } else if (value->IsProxy()) { -+ resource = reinterpret_cast(Proxy::cast(value)->proxy()); -+ } -+ if (resource) { -+ resource->Dispose(); -+ } -+ } - } - - -@@ -556,53 +571,63 @@ inline bool Heap::allow_allocation(bool new_state) { - #endif - - --void ExternalStringTable::AddString(String* string) { -- ASSERT(string->IsExternalString()); -+void ExternalResourceTable::AddString(String* string) { -+ ASSERT(string->IsExternalString() ); - if (heap_->InNewSpace(string)) { -- new_space_strings_.Add(string); -+ new_space_objects_.Add(string); -+ } else { -+ old_space_objects_.Add(string); -+ } -+} -+ -+ -+void ExternalResourceTable::AddObject(HeapObject* object) { -+ ASSERT(object->map()->has_external_resource()); -+ if (heap_->InNewSpace(object)) { -+ new_space_objects_.Add(object); - } else { -- old_space_strings_.Add(string); -+ old_space_objects_.Add(object); - } - } - - --void ExternalStringTable::Iterate(ObjectVisitor* v) { -- if (!new_space_strings_.is_empty()) { -- Object** start = &new_space_strings_[0]; -- v->VisitPointers(start, start + new_space_strings_.length()); -+void ExternalResourceTable::Iterate(ObjectVisitor* v) { -+ if (!new_space_objects_.is_empty()) { -+ Object** start = &new_space_objects_[0]; -+ v->VisitPointers(start, start + new_space_objects_.length()); - } -- if (!old_space_strings_.is_empty()) { -- Object** start = &old_space_strings_[0]; -- v->VisitPointers(start, start + old_space_strings_.length()); -+ if (!old_space_objects_.is_empty()) { -+ Object** start = &old_space_objects_[0]; -+ v->VisitPointers(start, start + old_space_objects_.length()); - } - } - - - // Verify() is inline to avoid ifdef-s around its calls in release - // mode. --void ExternalStringTable::Verify() { -+void ExternalResourceTable::Verify() { - #ifdef DEBUG -- for (int i = 0; i < new_space_strings_.length(); ++i) { -- ASSERT(heap_->InNewSpace(new_space_strings_[i])); -- ASSERT(new_space_strings_[i] != HEAP->raw_unchecked_null_value()); -+ for (int i = 0; i < new_space_objects_.length(); ++i) { -+ ASSERT(heap_->InNewSpace(new_space_objects_[i])); -+ ASSERT(new_space_objects_[i] != HEAP->raw_unchecked_null_value()); - } -- for (int i = 0; i < old_space_strings_.length(); ++i) { -- ASSERT(!heap_->InNewSpace(old_space_strings_[i])); -- ASSERT(old_space_strings_[i] != HEAP->raw_unchecked_null_value()); -+ for (int i = 0; i < old_space_objects_.length(); ++i) { -+ ASSERT(!heap_->InNewSpace(old_space_objects_[i])); -+ ASSERT(old_space_objects_[i] != HEAP->raw_unchecked_null_value()); - } - #endif - } - - --void ExternalStringTable::AddOldString(String* string) { -- ASSERT(string->IsExternalString()); -- ASSERT(!heap_->InNewSpace(string)); -- old_space_strings_.Add(string); -+void ExternalResourceTable::AddOldObject(HeapObject* object) { -+ ASSERT(object->IsExternalString() || object->map()->has_external_resource()); -+ ASSERT(!heap_->InNewSpace(object)); -+ old_space_objects_.Add(object); - } - - --void ExternalStringTable::ShrinkNewStrings(int position) { -- new_space_strings_.Rewind(position); -+void ExternalResourceTable::ShrinkNewObjects(int position) { -+ new_space_objects_.Rewind(position); - Verify(); - } - -diff --git a/src/heap.cc b/src/heap.cc -index 900f462..bf2940e 100644 ---- a/src/heap.cc -+++ b/src/heap.cc -@@ -155,7 +155,7 @@ Heap::Heap() - memset(roots_, 0, sizeof(roots_[0]) * kRootListLength); - global_contexts_list_ = NULL; - mark_compact_collector_.heap_ = this; -- external_string_table_.heap_ = this; -+ external_resource_table_.heap_ = this; - } - - -@@ -1030,8 +1030,8 @@ void Heap::Scavenge() { - - new_space_front = DoScavenge(&scavenge_visitor, new_space_front); - -- UpdateNewSpaceReferencesInExternalStringTable( -- &UpdateNewSpaceReferenceInExternalStringTableEntry); -+ UpdateNewSpaceReferencesInExternalResourceTable( -+ &UpdateNewSpaceReferenceInExternalResourceTableEntry); - - LiveObjectList::UpdateReferencesForScavengeGC(); - isolate()->runtime_profiler()->UpdateSamplesAfterScavenge(); -@@ -1053,38 +1053,38 @@ void Heap::Scavenge() { - } - - --String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap, -- Object** p) { -+HeapObject* Heap::UpdateNewSpaceReferenceInExternalResourceTableEntry(Heap* heap, -+ Object** p) { - MapWord first_word = HeapObject::cast(*p)->map_word(); - - if (!first_word.IsForwardingAddress()) { - // Unreachable external string can be finalized. -- heap->FinalizeExternalString(String::cast(*p)); -+ heap->FinalizeExternalString(HeapObject::cast(*p)); - return NULL; - } - - // String is still reachable. -- return String::cast(first_word.ToForwardingAddress()); -+ return HeapObject::cast(first_word.ToForwardingAddress()); - } - - --void Heap::UpdateNewSpaceReferencesInExternalStringTable( -- ExternalStringTableUpdaterCallback updater_func) { -- external_string_table_.Verify(); -+void Heap::UpdateNewSpaceReferencesInExternalResourceTable( -+ ExternalResourceTableUpdaterCallback updater_func) { -+ external_resource_table_.Verify(); - -- if (external_string_table_.new_space_strings_.is_empty()) return; -+ if (external_resource_table_.new_space_objects_.is_empty()) return; - -- Object** start = &external_string_table_.new_space_strings_[0]; -- Object** end = start + external_string_table_.new_space_strings_.length(); -+ Object** start = &external_resource_table_.new_space_objects_[0]; -+ Object** end = start + external_resource_table_.new_space_objects_.length(); - Object** last = start; - - for (Object** p = start; p < end; ++p) { - ASSERT(InFromSpace(*p)); -- String* target = updater_func(this, p); -+ HeapObject* target = updater_func(this, p); - - if (target == NULL) continue; - -- ASSERT(target->IsExternalString()); -+ ASSERT(target->IsExternalString() || target->map()->has_external_resource()); - - if (InNewSpace(target)) { - // String is still in new space. Update the table entry. -@@ -1092,12 +1092,12 @@ void Heap::UpdateNewSpaceReferencesInExternalStringTable( - ++last; - } else { - // String got promoted. Move it to the old string list. -- external_string_table_.AddOldString(target); -+ external_resource_table_.AddOldObject(target); - } - } - - ASSERT(last <= end); -- external_string_table_.ShrinkNewStrings(static_cast(last - start)); -+ external_resource_table_.ShrinkNewObjects(static_cast(last - start)); - } - - -@@ -4468,7 +4468,7 @@ void Heap::IterateWeakRoots(ObjectVisitor* v, VisitMode mode) { - v->Synchronize("symbol_table"); - if (mode != VISIT_ALL_IN_SCAVENGE) { - // Scavenge collections have special processing for this. -- external_string_table_.Iterate(v); -+ external_resource_table_.Iterate(v); - } - v->Synchronize("external_string_table"); - } -@@ -4970,7 +4970,7 @@ void Heap::TearDown() { - - isolate_->global_handles()->TearDown(); - -- external_string_table_.TearDown(); -+ external_resource_table_.TearDown(); - - new_space_.TearDown(); - -@@ -5835,31 +5835,31 @@ void TranscendentalCache::Clear() { - } - - --void ExternalStringTable::CleanUp() { -+void ExternalResourceTable::CleanUp() { - int last = 0; -- for (int i = 0; i < new_space_strings_.length(); ++i) { -- if (new_space_strings_[i] == heap_->raw_unchecked_null_value()) continue; -- if (heap_->InNewSpace(new_space_strings_[i])) { -- new_space_strings_[last++] = new_space_strings_[i]; -+ for (int i = 0; i < new_space_objects_.length(); ++i) { -+ if (new_space_objects_[i] == heap_->raw_unchecked_null_value()) continue; -+ if (heap_->InNewSpace(new_space_objects_[i])) { -+ new_space_objects_[last++] = new_space_objects_[i]; - } else { -- old_space_strings_.Add(new_space_strings_[i]); -+ old_space_objects_.Add(new_space_objects_[i]); - } - } -- new_space_strings_.Rewind(last); -+ new_space_objects_.Rewind(last); - last = 0; -- for (int i = 0; i < old_space_strings_.length(); ++i) { -- if (old_space_strings_[i] == heap_->raw_unchecked_null_value()) continue; -- ASSERT(!heap_->InNewSpace(old_space_strings_[i])); -- old_space_strings_[last++] = old_space_strings_[i]; -+ for (int i = 0; i < old_space_objects_.length(); ++i) { -+ if (old_space_objects_[i] == heap_->raw_unchecked_null_value()) continue; -+ ASSERT(!heap_->InNewSpace(old_space_objects_[i])); -+ old_space_objects_[last++] = old_space_objects_[i]; - } -- old_space_strings_.Rewind(last); -+ old_space_objects_.Rewind(last); - Verify(); - } - - --void ExternalStringTable::TearDown() { -- new_space_strings_.Free(); -- old_space_strings_.Free(); -+void ExternalResourceTable::TearDown() { -+ new_space_objects_.Free(); -+ old_space_objects_.Free(); - } - - -diff --git a/src/heap.h b/src/heap.h -index ae4e9e7..8cbf378 100644 ---- a/src/heap.h -+++ b/src/heap.h -@@ -237,8 +237,8 @@ class Isolate; - class WeakObjectRetainer; - - --typedef String* (*ExternalStringTableUpdaterCallback)(Heap* heap, -- Object** pointer); -+typedef HeapObject* (*ExternalResourceTableUpdaterCallback)(Heap* heap, -+ Object** pointer); - - typedef bool (*DirtyRegionCallback)(Heap* heap, - Address start, -@@ -284,43 +284,45 @@ class PromotionQueue { - }; - - --// External strings table is a place where all external strings are --// registered. We need to keep track of such strings to properly --// finalize them. --class ExternalStringTable { -+// External resource table is a place where all external strings and -+// objects with an external resource are registered. We need to keep -+// track of such strings to properly finalize them. -+class ExternalResourceTable { - public: - // Registers an external string. - inline void AddString(String* string); -+ // Registers an external object. -+ inline void AddObject(HeapObject* object); - - inline void Iterate(ObjectVisitor* v); - - // Restores internal invariant and gets rid of collected strings. -- // Must be called after each Iterate() that modified the strings. -+ // Must be called after each Iterate() that modified the objects. - void CleanUp(); - - // Destroys all allocated memory. - void TearDown(); - - private: -- ExternalStringTable() { } -+ ExternalResourceTable() { } - - friend class Heap; - - inline void Verify(); - -- inline void AddOldString(String* string); -+ inline void AddOldObject(HeapObject* object); - - // Notifies the table that only a prefix of the new list is valid. -- inline void ShrinkNewStrings(int position); -+ inline void ShrinkNewObjects(int position); - - // To speed up scavenge collections new space string are kept - // separate from old space strings. -- List new_space_strings_; -- List old_space_strings_; -+ List new_space_objects_; -+ List old_space_objects_; - - Heap* heap_; - -- DISALLOW_COPY_AND_ASSIGN(ExternalStringTable); -+ DISALLOW_COPY_AND_ASSIGN(ExternalResourceTable); - }; - - -@@ -753,7 +755,7 @@ class Heap { - - // Finalizes an external string by deleting the associated external - // data and clearing the resource pointer. -- inline void FinalizeExternalString(String* string); -+ inline void FinalizeExternalString(HeapObject* string); - - // Allocates an uninitialized object. The memory is non-executable if the - // hardware and OS allow. -@@ -1191,8 +1193,8 @@ class Heap { - survived_since_last_expansion_ += survived; - } - -- void UpdateNewSpaceReferencesInExternalStringTable( -- ExternalStringTableUpdaterCallback updater_func); -+ void UpdateNewSpaceReferencesInExternalResourceTable( -+ ExternalResourceTableUpdaterCallback updater_func); - - void ProcessWeakReferences(WeakObjectRetainer* retainer); - -@@ -1228,8 +1230,8 @@ class Heap { - return &mark_compact_collector_; - } - -- ExternalStringTable* external_string_table() { -- return &external_string_table_; -+ ExternalResourceTable* external_resource_table() { -+ return &external_resource_table_; - } - - inline Isolate* isolate(); -@@ -1462,7 +1464,7 @@ class Heap { - // Performs a minor collection in new generation. - void Scavenge(); - -- static String* UpdateNewSpaceReferenceInExternalStringTableEntry( -+ static HeapObject* UpdateNewSpaceReferenceInExternalResourceTableEntry( - Heap* heap, - Object** pointer); - -@@ -1593,7 +1595,7 @@ class Heap { - // configured through the API until it is setup. - bool configured_; - -- ExternalStringTable external_string_table_; -+ ExternalResourceTable external_resource_table_; - - bool is_safe_to_read_maps_; - -diff --git a/src/liveobjectlist.cc b/src/liveobjectlist.cc -index 5795a6b..8866e58 100644 ---- a/src/liveobjectlist.cc -+++ b/src/liveobjectlist.cc -@@ -1989,7 +1989,7 @@ Object* LiveObjectList::PrintObj(int obj_id) { - ASSERT(resource->IsAscii()); - Handle dump_string = - Factory::NewExternalStringFromAscii(resource); -- ExternalStringTable::AddString(*dump_string); -+ ExternalResourceTable::AddString(*dump_string); - return *dump_string; - } else { - delete resource; -@@ -2193,7 +2193,7 @@ Object* LiveObjectList::GetPathPrivate(HeapObject* obj1, HeapObject* obj2) { - ASSERT(resource->IsAscii()); - Handle path_string = - Factory::NewExternalStringFromAscii(resource); -- ExternalStringTable::AddString(*path_string); -+ ExternalResourceTable::AddString(*path_string); - return *path_string; - } else { - delete resource; -diff --git a/src/mark-compact.cc b/src/mark-compact.cc -index 68a5062..1b1e361 100644 ---- a/src/mark-compact.cc -+++ b/src/mark-compact.cc -@@ -163,7 +163,7 @@ void MarkCompactCollector::Finish() { - // objects (empty string, illegal builtin). - heap()->isolate()->stub_cache()->Clear(); - -- heap()->external_string_table_.CleanUp(); -+ heap()->external_resource_table_.CleanUp(); - - // If we've just compacted old space there's no reason to check the - // fragmentation limit. Just return. -@@ -1019,8 +1019,9 @@ class SymbolTableCleaner : public ObjectVisitor { - - // Since no objects have yet been moved we can safely access the map of - // the object. -- if ((*p)->IsExternalString()) { -- heap_->FinalizeExternalString(String::cast(*p)); -+ if ((*p)->IsExternalString() || -+ (*p)->IsHeapObject() && HeapObject::cast(*p)->map()->has_external_resource()) { -+ heap_->FinalizeExternalString(HeapObject::cast(*p)); - } - // Set the entry to null_value (as deleted). - *p = heap_->raw_unchecked_null_value(); -@@ -1433,8 +1434,8 @@ void MarkCompactCollector::MarkLiveObjects() { - SymbolTableCleaner v(heap()); - symbol_table->IterateElements(&v); - symbol_table->ElementsRemoved(v.PointersRemoved()); -- heap()->external_string_table_.Iterate(&v); -- heap()->external_string_table_.CleanUp(); -+ heap()->external_resource_table_.Iterate(&v); -+ heap()->external_resource_table_.CleanUp(); - - // Process the weak references. - MarkCompactWeakObjectRetainer mark_compact_object_retainer; -@@ -1948,11 +1949,11 @@ static void UpdatePointerToNewGen(HeapObject** p) { - } - - --static String* UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap, -- Object** p) { -+static HeapObject* UpdateNewSpaceReferenceInExternalResourceTableEntry(Heap* heap, -+ Object** p) { - Address old_addr = HeapObject::cast(*p)->address(); - Address new_addr = Memory::Address_at(old_addr); -- return String::cast(HeapObject::FromAddress(new_addr)); -+ return HeapObject::FromAddress(new_addr); - } - - -@@ -2083,8 +2084,8 @@ static void SweepNewSpace(Heap* heap, NewSpace* space) { - updating_visitor.VisitPointer(heap->global_contexts_list_address()); - - // Update pointers from external string table. -- heap->UpdateNewSpaceReferencesInExternalStringTable( -- &UpdateNewSpaceReferenceInExternalStringTableEntry); -+ heap->UpdateNewSpaceReferencesInExternalResourceTable( -+ &UpdateNewSpaceReferenceInExternalResourceTableEntry); - - // All pointers were updated. Update auxiliary allocation info. - heap->IncrementYoungSurvivorsCounter(survivors_size); -diff --git a/src/objects-inl.h b/src/objects-inl.h -index 6aaca2f..231b835 100644 ---- a/src/objects-inl.h -+++ b/src/objects-inl.h -@@ -1392,13 +1392,13 @@ int JSObject::GetInternalFieldCount() { - // Make sure to adjust for the number of in-object properties. These - // properties do contribute to the size, but are not internal fields. - return ((Size() - GetHeaderSize()) >> kPointerSizeLog2) - -- map()->inobject_properties(); -+ map()->inobject_properties() - map()->has_external_resource()?1:0; - } - - - int JSObject::GetInternalFieldOffset(int index) { - ASSERT(index < GetInternalFieldCount() && index >= 0); -- return GetHeaderSize() + (kPointerSize * index); -+ return GetHeaderSize() + (kPointerSize * (index + map()->has_external_resource()?1:0)); - } - - -@@ -1407,7 +1407,7 @@ Object* JSObject::GetInternalField(int index) { - // Internal objects do follow immediately after the header, whereas in-object - // properties are at the end of the object. Therefore there is no need - // to adjust the index here. -- return READ_FIELD(this, GetHeaderSize() + (kPointerSize * index)); -+ return READ_FIELD(this, GetHeaderSize() + (kPointerSize * (index + map()->has_external_resource()?1:0))); - } - - -@@ -1416,12 +1416,29 @@ void JSObject::SetInternalField(int index, Object* value) { - // Internal objects do follow immediately after the header, whereas in-object - // properties are at the end of the object. Therefore there is no need - // to adjust the index here. -- int offset = GetHeaderSize() + (kPointerSize * index); -+ int offset = GetHeaderSize() + (kPointerSize * (index + map()->has_external_resource()?1:0)); - WRITE_FIELD(this, offset, value); - WRITE_BARRIER(this, offset); - } - - -+void JSObject::SetExternalResourceObject(Object *value) { -+ ASSERT(map()->has_external_resource()); -+ int offset = GetHeaderSize(); -+ WRITE_FIELD(this, offset, value); -+ WRITE_BARRIER(this, offset); -+} -+ -+ -+Object *JSObject::GetExternalResourceObject() { -+ if (map()->has_external_resource()) { -+ return READ_FIELD(this, GetHeaderSize()); -+ } else { -+ return GetHeap()->undefined_value(); -+ } -+} -+ -+ - // Access fast-case object properties at index. The use of these routines - // is needed to correctly distinguish between properties stored in-object and - // properties stored in the properties array. -@@ -2521,6 +2538,20 @@ bool Map::is_shared() { - } - - -+void Map::set_has_external_resource(bool value) { -+ if (value) { -+ set_bit_field3(bit_field3() | (1 << kHasExternalResource)); -+ } else { -+ set_bit_field3(bit_field3() & ~(1 << kHasExternalResource)); -+ } -+} -+ -+bool Map::has_external_resource() -+{ -+ return ((1 << kHasExternalResource) & bit_field3()) != 0; -+} -+ -+ - void Map::set_named_interceptor_is_fallback(bool value) - { - if (value) { -@@ -3017,6 +3048,8 @@ ACCESSORS(FunctionTemplateInfo, flag, Smi, kFlagOffset) - ACCESSORS(ObjectTemplateInfo, constructor, Object, kConstructorOffset) - ACCESSORS(ObjectTemplateInfo, internal_field_count, Object, - kInternalFieldCountOffset) -+ACCESSORS(ObjectTemplateInfo, has_external_resource, Object, -+ kHasExternalResourceOffset) - - ACCESSORS(SignatureInfo, receiver, Object, kReceiverOffset) - ACCESSORS(SignatureInfo, args, Object, kArgsOffset) -diff --git a/src/objects.h b/src/objects.h -index a209cd0..1bdb5c7 100644 ---- a/src/objects.h -+++ b/src/objects.h -@@ -1636,6 +1636,9 @@ class JSObject: public HeapObject { - inline Object* GetInternalField(int index); - inline void SetInternalField(int index, Object* value); - -+ inline void SetExternalResourceObject(Object *); -+ inline Object *GetExternalResourceObject(); -+ - // Lookup a property. If found, the result is valid and has - // detailed information. - void LocalLookup(String* name, LookupResult* result, bool skip_fallback_interceptor = false); -@@ -3715,6 +3718,12 @@ class Map: public HeapObject { - inline void set_is_access_check_needed(bool access_check_needed); - inline bool is_access_check_needed(); - -+ -+ // Tells whether the instance has the space for an external resource -+ // object -+ inline void set_has_external_resource(bool value); -+ inline bool has_external_resource(); -+ - - // Whether the named interceptor is a fallback interceptor or not - inline void set_named_interceptor_is_fallback(bool value); -@@ -3912,6 +3921,7 @@ class Map: public HeapObject { - - // Bit positions for bit field 3 - static const int kNamedInterceptorIsFallback = 0; -+ static const int kHasExternalResource = 1; - - // Layout of the default cache. It holds alternating name and code objects. - static const int kCodeCacheEntrySize = 2; -@@ -6426,6 +6436,7 @@ class ObjectTemplateInfo: public TemplateInfo { - public: - DECL_ACCESSORS(constructor, Object) - DECL_ACCESSORS(internal_field_count, Object) -+ DECL_ACCESSORS(has_external_resource, Object) - - static inline ObjectTemplateInfo* cast(Object* obj); - -@@ -6442,7 +6453,8 @@ class ObjectTemplateInfo: public TemplateInfo { - static const int kConstructorOffset = TemplateInfo::kHeaderSize; - static const int kInternalFieldCountOffset = - kConstructorOffset + kPointerSize; -- static const int kSize = kInternalFieldCountOffset + kPointerSize; -+ static const int kHasExternalResourceOffset = kInternalFieldCountOffset + kPointerSize; -+ static const int kSize = kHasExternalResourceOffset + kPointerSize; - }; - - --- -1.7.2.3 - diff --git a/src/declarative/v8/0005-Introduce-a-QML-compilation-mode.patch b/src/declarative/v8/0005-Introduce-a-QML-compilation-mode.patch deleted file mode 100644 index 2dfd3d9699..0000000000 --- a/src/declarative/v8/0005-Introduce-a-QML-compilation-mode.patch +++ /dev/null @@ -1,1777 +0,0 @@ -From fd7d475e298e5b63cd6383c78cc900635c82aa38 Mon Sep 17 00:00:00 2001 -From: Aaron Kennedy -Date: Mon, 23 May 2011 18:26:19 +1000 -Subject: [PATCH 05/13] Introduce a QML compilation mode - -In QML mode, there is a second global object - known as the QML -global object. During property resolution, if a property is not -present on the JS global object, it is resolve on the QML global -object. - -This global object behavior is only enabled if a script is being -compiled in QML mode. The object to use as the QML global object -is passed as a parameter to the Script::Run() method. Any function -closures etc. created during the run will retain a reference to this -object, so different objects can be passed in different script -runs. ---- - include/v8.h | 18 ++++++++-- - src/api.cc | 52 ++++++++++++++++++++++++----- - src/arm/code-stubs-arm.cc | 4 ++ - src/arm/full-codegen-arm.cc | 26 ++++++++------ - src/arm/lithium-arm.cc | 2 +- - src/arm/lithium-arm.h | 6 +++- - src/arm/lithium-codegen-arm.cc | 7 ++-- - src/arm/macro-assembler-arm.h | 5 +++ - src/ast-inl.h | 5 +++ - src/ast.h | 1 + - src/code-stubs.h | 2 +- - src/compiler.cc | 15 +++++++- - src/compiler.h | 22 ++++++++++-- - src/contexts.cc | 23 +++++++++++++ - src/contexts.h | 4 ++ - src/execution.cc | 28 +++++++++++++-- - src/execution.h | 6 +++ - src/full-codegen.cc | 3 +- - src/full-codegen.h | 1 + - src/heap.cc | 2 + - src/hydrogen-instructions.h | 10 ++++- - src/hydrogen.cc | 2 + - src/ia32/code-stubs-ia32.cc | 7 ++++ - src/ia32/full-codegen-ia32.cc | 26 ++++++++------ - src/ia32/lithium-codegen-ia32.cc | 7 ++-- - src/ia32/lithium-ia32.cc | 2 +- - src/ia32/lithium-ia32.h | 6 +++- - src/ia32/macro-assembler-ia32.h | 5 +++ - src/objects-inl.h | 12 +++++++ - src/objects.h | 5 +++ - src/parser.cc | 27 +++++++++++++-- - src/parser.h | 4 ++- - src/prettyprinter.cc | 3 ++ - src/runtime.cc | 68 ++++++++++++++++++++++++------------- - src/runtime.h | 8 ++-- - src/scopes.cc | 10 +++++ - src/scopes.h | 7 ++++ - src/variables.cc | 3 +- - src/variables.h | 5 +++ - src/x64/code-stubs-x64.cc | 4 ++ - src/x64/full-codegen-x64.cc | 26 ++++++++------ - src/x64/lithium-codegen-x64.cc | 7 ++-- - src/x64/lithium-x64.cc | 2 +- - src/x64/lithium-x64.h | 6 +++ - src/x64/macro-assembler-x64.h | 5 +++ - 45 files changed, 391 insertions(+), 108 deletions(-) - -diff --git a/include/v8.h b/include/v8.h -index 7f06ae7..a858eae 100644 ---- a/include/v8.h -+++ b/include/v8.h -@@ -577,6 +577,10 @@ class ScriptOrigin { - */ - class V8EXPORT Script { - public: -+ enum CompileFlags { -+ Default = 0x00, -+ QmlMode = 0x01 -+ }; - - /** - * Compiles the specified script (context-independent). -@@ -596,7 +600,8 @@ class V8EXPORT Script { - static Local