aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-05-03 14:08:55 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2013-05-03 14:39:29 +0200
commitbf51873870f94f56e8dccf25fea67b120f2db98f (patch)
tree36d7a9969cf801c2c0d5d10735db3c1095ce2aa2 /src
parentb7fd57098fb4668dc896e14a95d9b577e6eb7ee6 (diff)
Cleanup v8 Context handling
We don't need or use v8 Context objects, so it's sufficient to have one global context for now. Remove all code related to entering or leaving Context's. Change-Id: I4f7ddaa4907e59de5713368fa13bbc40e5830542 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/particles/qquickcustomaffector.cpp1
-rw-r--r--src/particles/qquickparticleemitter.cpp1
-rw-r--r--src/particles/qquicktrailemitter.cpp1
-rw-r--r--src/particles/qquickv8particledata.cpp2
-rw-r--r--src/qml/debugger/qv8debugservice.cpp1
-rw-r--r--src/qml/qml/qqmlbinding.cpp2
-rw-r--r--src/qml/qml/qqmlboundsignal.cpp2
-rw-r--r--src/qml/qml/qqmlcomponent.cpp3
-rw-r--r--src/qml/qml/qqmlexpression.cpp1
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp4
-rw-r--r--src/qml/qml/qqmllocale.cpp1
-rw-r--r--src/qml/qml/qqmlvme.cpp2
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp3
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp3
-rw-r--r--src/qml/qml/v4/qv4v8.cpp42
-rw-r--r--src/qml/qml/v4/qv4v8_p.h72
-rw-r--r--src/qml/qml/v8/qjsengine.cpp3
-rw-r--r--src/qml/qml/v8/qscriptisolate_p.h89
-rw-r--r--src/qml/qml/v8/qv8bindings.cpp2
-rw-r--r--src/qml/qml/v8/qv8engine.cpp12
-rw-r--r--src/qml/qml/v8/qv8engine_p.h7
-rw-r--r--src/qml/qml/v8/qv8include.cpp1
-rw-r--r--src/qml/qml/v8/qv8qobjectwrapper.cpp1
-rw-r--r--src/qml/qml/v8/script.pri1
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp2
-rw-r--r--src/qml/types/qqmllistmodel.cpp1
-rw-r--r--src/qml/types/qquickworkerscript.cpp4
-rw-r--r--src/qml/util/qqmladaptormodel.cpp1
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp2
29 files changed, 14 insertions, 253 deletions
diff --git a/src/particles/qquickcustomaffector.cpp b/src/particles/qquickcustomaffector.cpp
index c7fc7a7830..23a1f6db50 100644
--- a/src/particles/qquickcustomaffector.cpp
+++ b/src/particles/qquickcustomaffector.cpp
@@ -144,7 +144,6 @@ void QQuickCustomAffector::affectSystem(qreal dt)
dt = 1.0;
v8::HandleScope handle_scope;
- v8::Context::Scope scope(QQmlEnginePrivate::getV8Engine(qmlEngine(this))->context());
v8::Handle<v8::Array> array = v8::Array::New(toAffect.size());
for (int i=0; i<toAffect.size(); i++)
array->Set(i, toAffect[i]->v8Value().toV8Handle());
diff --git a/src/particles/qquickparticleemitter.cpp b/src/particles/qquickparticleemitter.cpp
index 4177f873e2..e9e748d4d8 100644
--- a/src/particles/qquickparticleemitter.cpp
+++ b/src/particles/qquickparticleemitter.cpp
@@ -480,7 +480,6 @@ void QQuickParticleEmitter::emitWindow(int timeStamp)
//Done after emitParticle so that the Painter::load is done first, this allows you to customize its static variables
//We then don't need to request another reload, because the first reload isn't scheduled until we get back to the render thread
v8::HandleScope handle_scope;
- v8::Context::Scope scope(QQmlEnginePrivate::getV8Engine(qmlEngine(this))->context());
v8::Handle<v8::Array> array = v8::Array::New(toEmit.size());
for (int i=0; i<toEmit.size(); i++)
array->Set(i, toEmit[i]->v8Value().toV8Handle());
diff --git a/src/particles/qquicktrailemitter.cpp b/src/particles/qquicktrailemitter.cpp
index 244e35bb00..aca11f114e 100644
--- a/src/particles/qquicktrailemitter.cpp
+++ b/src/particles/qquicktrailemitter.cpp
@@ -270,7 +270,6 @@ void QQuickTrailEmitter::emitWindow(int timeStamp)
if (isEmitConnected() || isEmitFollowConnected()) {
v8::HandleScope handle_scope;
- v8::Context::Scope scope(QQmlEnginePrivate::getV8Engine(qmlEngine(this))->context());
v8::Handle<v8::Array> array = v8::Array::New(toEmit.size());
for (int i=0; i<toEmit.size(); i++)
array->Set(i, toEmit[i]->v8Value().toV8Handle());
diff --git a/src/particles/qquickv8particledata.cpp b/src/particles/qquickv8particledata.cpp
index 68f701fa88..4ca01e0a08 100644
--- a/src/particles/qquickv8particledata.cpp
+++ b/src/particles/qquickv8particledata.cpp
@@ -427,7 +427,6 @@ FAKE_FLOAT_GETTER_AND_SETTER(curAY, curAY, setInstantaneousAY)
QV8ParticleDataDeletable::QV8ParticleDataDeletable(QV8Engine *engine)
{
v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
ft->InstanceTemplate()->SetHasExternalResource(true);
@@ -485,7 +484,6 @@ QQuickV8ParticleData::QQuickV8ParticleData(QV8Engine* engine, QQuickParticleData
if (!engine || !datum)
return;
v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
QV8ParticleDataDeletable *d = particleV8Data(engine);
m_v8Value = qPersistentNew(d->constructor->NewInstance());
diff --git a/src/qml/debugger/qv8debugservice.cpp b/src/qml/debugger/qv8debugservice.cpp
index 5b692f83b0..ec9a5197ca 100644
--- a/src/qml/debugger/qv8debugservice.cpp
+++ b/src/qml/debugger/qv8debugservice.cpp
@@ -278,7 +278,6 @@ void QV8DebugService::processDebugMessages()
{
Q_D(QV8DebugService);
v8::HandleScope handleScope;
- v8::Context::Scope contextScope(d->engine->context());
// ### FIXME: v4 v8::Debug::ProcessDebugMessages();
}
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index d9abd1f2f0..61370fd97f 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -280,7 +280,6 @@ void QQmlBinding::update(QQmlPropertyPrivate::WriteFlags flags)
bool isUndefined = false;
v8::HandleScope handle_scope;
- v8::Context::Scope scope(ep->v8engine()->context());
v8::Local<v8::Value> result =
QQmlJavaScriptExpression::evaluate(context(), v8function, &isUndefined);
@@ -323,7 +322,6 @@ QVariant QQmlBinding::evaluate()
bool isUndefined = false;
v8::HandleScope handle_scope;
- v8::Context::Scope scope(ep->v8engine()->context());
v8::Local<v8::Value> result =
QQmlJavaScriptExpression::evaluate(context(), v8function, &isUndefined);
diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp
index ef869cd986..d0b7109891 100644
--- a/src/qml/qml/qqmlboundsignal.cpp
+++ b/src/qml/qml/qqmlboundsignal.cpp
@@ -141,7 +141,6 @@ QString QQmlBoundSignalExpression::expression() const
if (m_expressionFunctionValid) {
Q_ASSERT (context() && engine());
v8::HandleScope handle_scope;
- v8::Context::Scope context_scope(QQmlEnginePrivate::get(engine())->v8engine()->context());
return m_v8function->v4Value().toQString();
} else if (!m_expressionUtf8.isEmpty()) {
return QString::fromUtf8(m_expressionUtf8);
@@ -164,7 +163,6 @@ void QQmlBoundSignalExpression::evaluate(void **a)
ep->referenceScarceResources(); // "hold" scarce resources in memory during evaluation.
{
v8::HandleScope handle_scope;
- v8::Context::Scope context_scope(ep->v8engine()->context());
if (!m_expressionFunctionValid) {
//TODO: look at using the property cache here (as in the compiler)
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index fdba47beee..f55dd5b4b6 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -1361,7 +1361,6 @@ void QQmlComponentPrivate::initializeObjectWithInitialProperties(v8::Handle<v8::
QV4::ExecutionEngine *v4engine = QV8Engine::getV4(v8engine);
v8::HandleScope handle_scope;
- v8::Context::Scope scope(v8engine->context());
v8::Handle<v8::Value> ov = v8engine->newQObject(toCreate);
Q_ASSERT(ov->IsObject());
v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(ov);
@@ -1378,7 +1377,6 @@ void QQmlComponentPrivate::initializeObjectWithInitialProperties(v8::Handle<v8::
QQmlComponentExtension::QQmlComponentExtension(QV8Engine *engine)
{
v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
forceCompletion = qPersistentNew(V8FUNCTION(QV8IncubatorResource::ForceCompletion, engine));
@@ -1492,7 +1490,6 @@ void QV8IncubatorResource::statusChanged(Status s)
if (!callback.IsEmpty() && !callback->IsUndefined()) {
if (callback->IsFunction()) {
- v8::Context::Scope context_scope(engine->context());
v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(callback);
v8::Handle<v8::Value> args[] = { v8::Integer::NewFromUnsigned(s) };
v8::TryCatch tc;
diff --git a/src/qml/qml/qqmlexpression.cpp b/src/qml/qml/qqmlexpression.cpp
index e27a6651c4..d0cf3e95ab 100644
--- a/src/qml/qml/qqmlexpression.cpp
+++ b/src/qml/qml/qqmlexpression.cpp
@@ -377,7 +377,6 @@ QVariant QQmlExpressionPrivate::value(bool *isUndefined)
{
v8::HandleScope handle_scope;
- v8::Context::Scope context_scope(ep->v8engine()->context());
v8::Local<v8::Value> result = v8value(isUndefined);
rv = ep->v8engine()->toVariant(result->v4Value(), -1);
}
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp
index 8bb5001226..558a8c78dd 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -92,7 +92,6 @@ void QQmlDelayedError::convertMessageToError(QQmlEngine *engine) const
{
if (!m_message.IsEmpty() && engine) {
v8::HandleScope handle_scope;
- v8::Context::Scope context_scope(QQmlEnginePrivate::getV8Engine(engine)->context());
QQmlExpressionPrivate::exceptionToError(m_message, m_error);
qPersistentDispose(m_message);
}
@@ -185,7 +184,6 @@ QQmlJavaScriptExpression::evaluate(QQmlContextData *context,
if (watcher.wasDeleted()) {
} else if (try_catch.HasCaught()) {
- v8::Context::Scope scope(ep->v8engine()->context());
v8::Local<v8::Message> message = try_catch.Message();
if (!message.IsEmpty()) {
delayedError()->setMessage(message);
@@ -339,7 +337,6 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scope,
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
v8::HandleScope handle_scope;
- v8::Context::Scope ctxtscope(ep->v8engine()->context());
v8::TryCatch tc;
v8::Local<v8::Object> scopeobject = ep->v8engine()->qmlScope(ctxt, scope);
@@ -381,7 +378,6 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scope,
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
v8::HandleScope handle_scope;
- v8::Context::Scope ctxtscope(ep->v8engine()->context());
v8::TryCatch tc;
v8::Local<v8::Object> scopeobject = ep->v8engine()->qmlScope(ctxt, scope);
diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp
index 0d8ed39eaa..8e7bf25255 100644
--- a/src/qml/qml/qqmllocale.cpp
+++ b/src/qml/qml/qqmllocale.cpp
@@ -727,7 +727,6 @@ public:
QV8LocaleDataDeletable::QV8LocaleDataDeletable(QV8Engine *engine)
{
v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
ft->InstanceTemplate()->SetHasExternalResource(true);
diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp
index 91c2226248..29cc8c4298 100644
--- a/src/qml/qml/qqmlvme.cpp
+++ b/src/qml/qml/qqmlvme.cpp
@@ -341,7 +341,6 @@ QObject *QQmlVME::run(QList<QQmlError> *errors,
// Need a v8 handle scope and execution context for StoreVar instructions.
v8::HandleScope handleScope;
- v8::Context::Scope contextScope(ep->v8engine()->context());
int status = -1; // needed for dbus
QQmlPropertyPrivate::WriteFlags flags = QQmlPropertyPrivate::BypassInterceptor |
@@ -1244,7 +1243,6 @@ v8::Persistent<v8::Object> QQmlVME::run(QQmlContextData *parentCtxt, QQmlScriptD
}
v8::HandleScope handle_scope;
- v8::Context::Scope scope(v8engine->context());
v8::TryCatch try_catch;
if (!script->isInitialized())
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index 24c60bc9ad..64859e401f 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -706,7 +706,6 @@ int QQmlVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a)
QV8Engine *v8e = (ep == 0) ? 0 : ep->v8engine();
if (v8e) {
v8::HandleScope handleScope;
- v8::Context::Scope contextScope(v8e->context());
if (c == QMetaObject::ReadProperty) {
*reinterpret_cast<QVariant *>(a[0]) = readPropertyAsVariant(id);
} else if (c == QMetaObject::WriteProperty) {
@@ -933,7 +932,6 @@ int QQmlVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a)
QQmlVMEMetaData::MethodData *data = metaData->methodData() + id;
v8::HandleScope handle_scope;
- v8::Context::Scope scope(ep->v8engine()->context());
v8::Handle<v8::Value> *args = 0;
if (data->parameterCount) {
@@ -1235,7 +1233,6 @@ bool QQmlVMEMetaObject::ensureVarPropertiesAllocated()
void QQmlVMEMetaObject::allocateVarPropertiesArray()
{
v8::HandleScope handleScope;
- v8::Context::Scope cs(QQmlEnginePrivate::get(ctxt->engine)->v8engine()->context());
varProperties = qPersistentNew(v8::Array::New(metaData->varPropertyCount));
varProperties.MakeWeak(static_cast<void*>(this), VarPropertiesWeakReferenceCallback);
varPropertiesInitialized = true;
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 9f2af9b424..945eda809d 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -1465,7 +1465,6 @@ const QByteArray &QQmlXMLHttpRequest::rawResponseBody() const
void QQmlXMLHttpRequest::dispatchCallback(v8::Handle<v8::Object> me)
{
v8::HandleScope hs;
- v8::Context::Scope scope(engine->context());
if (me.IsEmpty() || me->IsNull()) {
v8::ThrowException(v8::Exception::Error(v8::String::New("Unable to dispatch QQmlXmlHttpRequest callback: invalid object")));
@@ -1505,8 +1504,6 @@ void QQmlXMLHttpRequest::dispatchCallback(v8::Handle<v8::Object> me)
// Must have a handle scope
void QQmlXMLHttpRequest::printError(v8::Handle<v8::Message> message)
{
- v8::Context::Scope scope(engine->context());
-
QQmlError error;
QQmlExpressionPrivate::exceptionToError(message, error);
QQmlEnginePrivate::warning(QQmlEnginePrivate::get(engine->engine()), error);
diff --git a/src/qml/qml/v4/qv4v8.cpp b/src/qml/qml/v4/qv4v8.cpp
index a82ccfb252..0278865d25 100644
--- a/src/qml/qml/v4/qv4v8.cpp
+++ b/src/qml/qml/v4/qv4v8.cpp
@@ -62,7 +62,7 @@ using namespace QV4;
namespace v8 {
-#define currentEngine() Isolate::GetCurrent()->GetCurrentContext()->GetEngine()
+#define currentEngine() Isolate::GetCurrent()->GetEngine()
#define Q_D(obj) QV4::Value *d = reinterpret_cast<QV4::Value*>(obj)
@@ -1948,13 +1948,16 @@ void Isolate::setException(const QV4::Value &ex)
ExecutionEngine *Isolate::GetEngine()
{
- return Isolate::GetCurrent()->GetCurrentContext()->GetEngine();
+ return Isolate::GetCurrent()->m_context->GetEngine();
}
Isolate *Isolate::GetCurrent()
{
- if (!currentIsolate.hasLocalData())
- currentIsolate.setLocalData(new Isolate);
+ if (!currentIsolate.hasLocalData()) {
+ Isolate *i = new Isolate;
+ i->m_context = new Context;
+ currentIsolate.setLocalData(i);
+ }
return currentIsolate.localData();
}
@@ -2087,26 +2090,9 @@ Context::~Context()
delete d;
}
-Persistent<Context> Context::New(ExtensionConfiguration *extensions, Handle<ObjectTemplate> global_template, Handle<Value> global_object)
-{
- Context *result = new Context;
- return Persistent<Context>::New(Handle<Context>(result));
-}
-
-Local<Object> Context::Global()
-{
- return Local<Object>::New(Value::fromV4Value(QV4::Value::fromObject(d->engine->globalObject)));
-}
-
Local<Context> Context::GetCurrent()
{
- return Context::Adopt(Isolate::GetCurrent()->m_contextStack.top());
-}
-
-Local<Context> Context::GetCalling()
-{
- Q_UNIMPLEMENTED();
- Q_UNREACHABLE();
+ return Context::Adopt(Isolate::GetCurrent()->m_context);
}
Local<Object> Context::GetCallingQmlGlobal()
@@ -2129,18 +2115,6 @@ Local<Value> Context::GetCallingScriptData()
Q_UNREACHABLE();
}
-void Context::Enter()
-{
- Isolate* iso = Isolate::GetCurrent();
- iso->m_contextStack.push(this);
-}
-
-void Context::Exit()
-{
- Isolate::GetCurrent()->m_contextStack.pop();
-}
-
-
QV4::ExecutionEngine *Context::GetEngine()
{
return d->engine.data();
diff --git a/src/qml/qml/v4/qv4v8_p.h b/src/qml/qml/v4/qv4v8_p.h
index 92d941a23a..bdcc72daf6 100644
--- a/src/qml/qml/v4/qv4v8_p.h
+++ b/src/qml/qml/v4/qv4v8_p.h
@@ -2231,7 +2231,6 @@ class V8EXPORT Isolate {
*/
static Isolate* GetCurrent();
- Context *GetCurrentContext() { return m_contextStack.top(); }
void setException(const QV4::Value &ex);
static QV4::ExecutionEngine *GetEngine();
@@ -2239,7 +2238,7 @@ class V8EXPORT Isolate {
private:
friend class Context;
friend class TryCatch;
- QStack<Context*> m_contextStack;
+ Context *m_context;
TryCatch *tryCatch;
};
@@ -2411,46 +2410,6 @@ class V8EXPORT Context : public QSharedData {
l.object->ref.ref();
return l;
}
- /**
- * Returns the global proxy object or global object itself for
- * detached contexts.
- *
- * Global proxy object is a thin wrapper whose prototype points to
- * actual context's global object with the properties like Object, etc.
- * This is done that way for security reasons (for more details see
- * https://wiki.mozilla.org/Gecko:SplitWindow).
- *
- * Please note that changes to global proxy object prototype most probably
- * would break VM---v8 expects only global object as a prototype of
- * global proxy object.
- *
- * If DetachGlobal() has been invoked, Global() would return actual global
- * object until global is reattached with ReattachGlobal().
- */
- Local<Object> Global();
-
- /** Creates a new context.
- *
- * Returns a persistent handle to the newly allocated context. This
- * persistent handle has to be disposed when the context is no
- * longer used so the context can be garbage collected.
- *
- * \param extensions An optional extension configuration containing
- * the extensions to be installed in the newly created context.
- *
- * \param global_template An optional object template from which the
- * global object for the newly created context will be created.
- *
- * \param global_object An optional global object to be reused for
- * the newly created context. This global object must have been
- * created by a previous call to Context::New with the same global
- * template. The state of the global object will be completely reset
- * and only object identify will remain.
- */
- static Persistent<Context> New(
- ExtensionConfiguration* extensions = NULL,
- Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(),
- Handle<Value> global_object = Handle<Value>());
/** Returns the context that is on the top of the stack. */
static Local<Context> GetCurrent();
@@ -2460,25 +2419,10 @@ class V8EXPORT Context : public QSharedData {
* context of the top-most JavaScript frame. If there are no
* JavaScript frames an empty handle is returned.
*/
- static Local<Context> GetCalling();
static Local<Object> GetCallingQmlGlobal();
static Local<Value> GetCallingScriptData();
/**
- * Enter this context. After entering a context, all code compiled
- * and run is compiled and run in this context. If another context
- * is already entered, this old context is saved so it can be
- * restored when the new context is exited.
- */
- void Enter();
-
- /**
- * Exit this context. Exiting the current context restores the
- * context that was in place when entering the current context.
- */
- void Exit();
-
- /**
* Associate an additional data object with the context. This is mainly used
* with the debugger to provide additional information on the context through
* the debugger API.
@@ -2486,20 +2430,6 @@ class V8EXPORT Context : public QSharedData {
void SetData(Handle<Value> data);
Local<Value> GetData();
- /**
- * Stack-allocated class which sets the execution context for all
- * operations executed within a local scope.
- */
- class Scope {
- public:
- explicit Scope(Handle<Context> context) : context_(context) {
- context_->Enter();
- }
- ~Scope() { context_->Exit(); }
- private:
- Handle<Context> context_;
- };
-
QV4::ExecutionEngine *GetEngine();
private:
diff --git a/src/qml/qml/v8/qjsengine.cpp b/src/qml/qml/v8/qjsengine.cpp
index 2fd0bb242f..658f6f3bcd 100644
--- a/src/qml/qml/v8/qjsengine.cpp
+++ b/src/qml/qml/v8/qjsengine.cpp
@@ -43,7 +43,6 @@
#include "qjsengine_p.h"
#include "qjsvalue.h"
#include "qjsvalue_p.h"
-#include "qscriptisolate_p.h"
#include "qv8engine_p.h"
#include "private/qv4engine_p.h"
@@ -320,7 +319,6 @@ QJSValue QJSEngine::newQObject(QObject *object)
{
// ###
Q_D(QJSEngine);
- QScriptIsolate api(d, QScriptIsolate::NotNullEngine);
v8::HandleScope handleScope;
return d->scriptValueFromInternal(d->newQObject(object, QV8Engine::JavaScriptOwnership));
}
@@ -347,7 +345,6 @@ QJSValue QJSEngine::globalObject() const
QJSValue QJSEngine::create(int type, const void *ptr)
{
Q_D(QJSEngine);
- QScriptIsolate api(d, QScriptIsolate::NotNullEngine);
v8::HandleScope handleScope;
return new QJSValuePrivate(QV8Engine::getV4(d), d->metaTypeToJS(type, ptr));
}
diff --git a/src/qml/qml/v8/qscriptisolate_p.h b/src/qml/qml/v8/qscriptisolate_p.h
deleted file mode 100644
index d6326bf915..0000000000
--- a/src/qml/qml/v8/qscriptisolate_p.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, 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, Digia gives you certain additional
-** rights. These rights are described in the Digia 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.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef APIPREAMBLE_P_H
-#define APIPREAMBLE_P_H
-
-#include <private/qv8_p.h>
-#include "qv8engine_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/**
- \internal
- Class used to switch to the right isolate. It does the same thing as v8::Isolate::Scope but
- it checks for a null engine.
- \attention We decided to put context switching "up" which means that it should be as high
- as possible on call stack. And it should be switched at most once per public API function call.
-*/
-class QScriptIsolate {
-public:
- // OperationMode was introduced to reduce number of checking for a null engine pointer. If we
- // know that given pointer is not null than we should pass NotNullEngine as constructor argument
- // that would nicely remove checking on compilation time.
- enum OperationMode {Default, NotNullEngine};
- inline QScriptIsolate(const QV8Engine *engine, const OperationMode mode = Default)
- : m_engine(engine)
- , m_mode(mode)
- {
- if (m_mode == NotNullEngine || m_engine) {
- Q_ASSERT(m_engine);
- m_engine->context()->Enter();
- }
- }
-
- inline ~QScriptIsolate()
- {
- if (m_mode == NotNullEngine || m_engine) {
- m_engine->context()->Exit();
- }
- }
-
-private:
- Q_DISABLE_COPY(QScriptIsolate);
- const QV8Engine *m_engine;
- const OperationMode m_mode;
-};
-
-
-QT_END_NAMESPACE
-
-#endif // APIPREAMBLE_P_H
diff --git a/src/qml/qml/v8/qv8bindings.cpp b/src/qml/qml/v8/qv8bindings.cpp
index 8d133e728a..e9a0ef9cb9 100644
--- a/src/qml/qml/v8/qv8bindings.cpp
+++ b/src/qml/qml/v8/qv8bindings.cpp
@@ -171,7 +171,6 @@ void QV8Bindings::Binding::update(QQmlPropertyPrivate::WriteFlags flags)
ep->referenceScarceResources();
v8::HandleScope handle_scope;
- v8::Context::Scope scope(ep->v8engine()->context());
v8::Local<v8::Value> result =
evaluate(context,
v8::Handle<v8::Function>::Cast(parent->functions()->Get(instruction->value)),
@@ -244,7 +243,6 @@ QV8Bindings::QV8Bindings(QQmlCompiledData::V8Program *program,
if (program->bindings.IsEmpty()) {
v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
v8::Local<v8::Script> script;
bool compileFailed = false;
diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp
index aa06a795ca..b7abe17783 100644
--- a/src/qml/qml/v8/qv8engine.cpp
+++ b/src/qml/qml/v8/qv8engine.cpp
@@ -129,10 +129,9 @@ static bool ObjectComparisonCallback(v8::Local<v8::Object> lhs, v8::Local<v8::Ob
}
-QV8Engine::QV8Engine(QJSEngine* qq, ContextOwnership ownership)
+QV8Engine::QV8Engine(QJSEngine* qq)
: q(qq)
, m_engine(0)
- , m_ownsV8Context(ownership == CreateNewContext)
, m_xmlHttpRequestData(0)
, m_listModelData(0)
, m_platform(0)
@@ -151,9 +150,8 @@ QV8Engine::QV8Engine(QJSEngine* qq, ContextOwnership ownership)
ensurePerThreadIsolate();
v8::HandleScope handle_scope;
- m_context = (ownership == CreateNewContext) ? v8::Context::New() : v8::Persistent<v8::Context>::New(v8::Context::GetCurrent());
+ m_context = v8::Persistent<v8::Context>::New(v8::Context::GetCurrent());
qPersistentRegister(m_context);
- v8::Context::Scope context_scope(m_context);
m_v4Engine = v8::Isolate::GetEngine();
m_v4Engine->publicEngine = q;
@@ -198,8 +196,7 @@ QV8Engine::~QV8Engine()
m_qobjectWrapper.destroy();
m_contextWrapper.destroy();
- if (m_ownsV8Context)
- qPersistentDispose(m_context);
+ qPersistentDispose(m_context);
}
QVariant QV8Engine::toVariant(const QV4::Value &value, int typeHint)
@@ -873,8 +870,7 @@ void QV8Engine::ensurePerThreadIsolate()
void QV8Engine::initQmlGlobalObject()
{
v8::HandleScope handels;
- v8::Context::Scope contextScope(m_context);
- initializeGlobal(m_context->Global());
+ initializeGlobal(QV4::Value::fromObject(m_v4Engine->globalObject));
freezeObject(QV4::Value::fromObject(m_v4Engine->globalObject));
}
diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h
index acd9a25a5a..b5a0e07e8a 100644
--- a/src/qml/qml/v8/qv8engine_p.h
+++ b/src/qml/qml/v8/qv8engine_p.h
@@ -266,11 +266,7 @@ public:
static QV4::ExecutionEngine *getV4(QJSEngine *q) { return q->handle()->m_v4Engine; }
static QV4::ExecutionEngine *getV4(QV8Engine *d) { return d->m_v4Engine; }
- enum ContextOwnership {
- AdoptCurrentContext,
- CreateNewContext
- };
- QV8Engine(QJSEngine* qq, ContextOwnership ownership = CreateNewContext);
+ QV8Engine(QJSEngine* qq);
virtual ~QV8Engine();
// This enum should be in sync with QQmlEngine::ObjectOwnership
@@ -437,7 +433,6 @@ protected:
QV4::ExecutionEngine *m_v4Engine;
- bool m_ownsV8Context;
v8::Persistent<v8::Context> m_context;
QV4::PersistentValue m_bindingFlagKey;
diff --git a/src/qml/qml/v8/qv8include.cpp b/src/qml/qml/v8/qv8include.cpp
index eb897fa42f..1c3895106b 100644
--- a/src/qml/qml/v8/qv8include.cpp
+++ b/src/qml/qml/v8/qv8include.cpp
@@ -140,7 +140,6 @@ void QV8Include::finished()
importContext->isPragmaLibraryContext = m_context->isPragmaLibraryContext;
importContext->setParent(m_context, true);
- v8::Context::Scope ctxtscope(m_engine->context());
v8::TryCatch try_catch;
v8::Local<v8::Script> script = m_engine->qmlModeCompile(code, m_url.toString());
diff --git a/src/qml/qml/v8/qv8qobjectwrapper.cpp b/src/qml/qml/v8/qv8qobjectwrapper.cpp
index a435bf1819..424e90328c 100644
--- a/src/qml/qml/v8/qv8qobjectwrapper.cpp
+++ b/src/qml/qml/v8/qv8qobjectwrapper.cpp
@@ -1310,7 +1310,6 @@ int QV8QObjectConnectionList::qt_metacall(QMetaObject::Call method, int index, v
int *argsTypes = QQmlPropertyCache::methodParameterTypes(data(), index, dummy, 0);
v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
int argCount = argsTypes?argsTypes[0]:0;
QVarLengthArray<v8::Handle<v8::Value>, 9> args(argCount);
diff --git a/src/qml/qml/v8/script.pri b/src/qml/qml/v8/script.pri
index bb8a2aa5b6..f70588ec7b 100644
--- a/src/qml/qml/v8/script.pri
+++ b/src/qml/qml/v8/script.pri
@@ -9,5 +9,4 @@ HEADERS += \
$$PWD/qjsvalue.h \
$$PWD/qjsvalue_p.h \
$$PWD/qjsvalueiterator.h \
- $$PWD/qscriptisolate_p.h \
$$PWD/qjsvalueiterator_p.h
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index 98955f959b..af29b11aa4 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -1592,7 +1592,6 @@ void QQmlDelegateModelItemMetaType::initializeMetaObject()
void QQmlDelegateModelItemMetaType::initializeConstructor()
{
v8::HandleScope handleScope;
- v8::Context::Scope contextScope(v8Engine->context());
QQmlDelegateModelEngineData *data = engineData(v8Engine);
@@ -2103,7 +2102,6 @@ void QQmlDelegateModelGroupPrivate::emitChanges(QV8Engine *engine)
Q_Q(QQmlDelegateModelGroup);
if (isChangedConnected() && !changeSet.isEmpty()) {
v8::HandleScope handleScope;
- v8::Context::Scope contextScope(engine->context());
v8::Local<v8::Object> removed = engineData(engine)->array(engine, changeSet.removes());
v8::Local<v8::Object> inserted = engineData(engine)->array(engine, changeSet.inserts());
emit q->changed(QQmlV4Handle::fromV8Handle(removed), QQmlV4Handle::fromV8Handle(inserted));
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp
index 021bc93120..8450b598d4 100644
--- a/src/qml/types/qqmllistmodel.cpp
+++ b/src/qml/types/qqmllistmodel.cpp
@@ -1261,7 +1261,6 @@ void ModelNodeMetaObject::propertyWritten(int index)
QVariant value = operator[](index);
v8::HandleScope handle_scope;
- v8::Context::Scope scope(eng->context());
v8::Handle<v8::Value> v = eng->fromVariant(value);
diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp
index 237805db88..8a47baeb84 100644
--- a/src/qml/types/qquickworkerscript.cpp
+++ b/src/qml/types/qquickworkerscript.cpp
@@ -224,7 +224,6 @@ void QQuickWorkerScriptEnginePrivate::WorkerEngine::init()
"})"
v8::HandleScope handle_scope;
- v8::Context::Scope scope(context());
{
v8::Local<v8::Script> onmessagescript = v8::Script::New(v8::String::New(CALL_ONMESSAGE_SCRIPT));
@@ -344,7 +343,6 @@ void QQuickWorkerScriptEnginePrivate::processMessage(int id, const QByteArray &d
return;
v8::HandleScope handle_scope;
- v8::Context::Scope scope(workerEngine->context());
v8::Handle<v8::Value> value = QV8Worker::deserialize(data, workerEngine);
@@ -372,7 +370,6 @@ void QQuickWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
QQmlScript::Parser::extractPragmas(sourceCode);
v8::HandleScope handle_scope;
- v8::Context::Scope scope(workerEngine->context());
WorkerScript *script = workers.value(id);
if (!script)
@@ -720,7 +717,6 @@ bool QQuickWorkerScript::event(QEvent *event)
WorkerDataEvent *workerEvent = static_cast<WorkerDataEvent *>(event);
QV8Engine *v8engine = QQmlEnginePrivate::get(engine)->v8engine();
v8::HandleScope handle_scope;
- v8::Context::Scope scope(v8engine->context());
v8::Handle<v8::Value> value = QV8Worker::deserialize(workerEvent->data(), v8engine);
emit message(QQmlV4Handle::fromV8Handle(value));
}
diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp
index 35cc2170ac..207b3f8a38 100644
--- a/src/qml/util/qqmladaptormodel.cpp
+++ b/src/qml/util/qqmladaptormodel.cpp
@@ -415,7 +415,6 @@ public:
if (type->constructor.IsEmpty()) {
QQmlAdaptorModelEngineData * const data = engineData(engine);
v8::HandleScope handleScope;
- v8::Context::Scope contextScope(engine->context());
type->initializeConstructor(data);
type->constructor->SetAccessor(data->hasModelChildren(), get_hasModelChildren);
}
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index a3652c4132..473e915790 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -3458,7 +3458,6 @@ QImage QQuickContext2D::toImage(const QRectF& bounds)
QQuickContext2DEngineData::QQuickContext2DEngineData(QV8Engine *engine)
{
v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
ft->InstanceTemplate()->SetHasExternalResource(true);
@@ -3662,7 +3661,6 @@ void QQuickContext2D::reset()
void QQuickContext2D::setV8Engine(QV8Engine *engine)
{
v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
if (m_v8engine != engine) {
m_v8engine = engine;