From eb2c08f57493aa12850e6cddff2cc3527e7cbfd7 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 7 Aug 2017 14:43:03 +0200 Subject: Get rid of ExecutionContext::strictMode This should be done by generating different byte code for the strict/non strict cases. For now the VME has a workaround checking the isStrict() flag of QV4::Function. Change-Id: I2faa9e9184ffc5274491067e67f665d6989b54c2 Reviewed-by: Simon Hausmann --- src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp | 2 +- .../qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 2 +- src/qml/jsapi/qjsengine.cpp | 2 +- src/qml/jsruntime/qv4context.cpp | 5 +---- src/qml/jsruntime/qv4context_p.h | 5 ++--- src/qml/jsruntime/qv4globalobject.cpp | 3 +-- src/qml/jsruntime/qv4qmlcontext.cpp | 1 - src/qml/jsruntime/qv4script.cpp | 1 - src/qml/jsruntime/qv4script_p.h | 4 ---- 9 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index ebd28b36e0..80ead1516a 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -113,7 +113,7 @@ void JavaScriptJob::run() } QV4::Script script(ctx, this->script); - script.strictMode = ctx->d()->strictMode; + script.strictMode = ctx->d()->v4Function->isStrict(); // In order for property lookups in QML to work, we need to disable fast v4 lookups. That // is a side-effect of inheritContext. script.inheritContext = true; diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index c4d5e5f683..7f11cea9ab 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -255,7 +255,7 @@ QV4::ReturnedValue NativeDebugger::evaluateExpression(const QString &expression) m_engine->pushContext(ctx); QV4::Script script(ctx, expression); - script.strictMode = ctx->d()->strictMode; + script.strictMode = ctx->d()->v4Function->isStrict(); // In order for property lookups in QML to work, we need to disable fast v4 lookups. // That is a side-effect of inheritContext. script.inheritContext = true; diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp index 1c7540778b..61cc0294e2 100644 --- a/src/qml/jsapi/qjsengine.cpp +++ b/src/qml/jsapi/qjsengine.cpp @@ -446,7 +446,7 @@ QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, in QV4::ScopedValue result(scope); QV4::Script script(ctx, program, fileName, lineNumber); - script.strictMode = ctx->d()->strictMode; + script.strictMode = ctx->d()->v4Function ? ctx->d()->v4Function->isStrict() : false; script.inheritContext = true; script.parse(); if (!scope.engine->hasException) diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 6a6f80827f..e18d8bce83 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -68,7 +68,6 @@ Heap::CallContext *ExecutionContext::newCallContext(Function *function, CallData c->v4Function = function; - c->strictMode = function->isStrict(); c->outer.set(v4, this->d()); const CompiledData::Function *compiledFunction = function->compiledFunction; @@ -159,7 +158,6 @@ void Heap::CatchContext::init(ExecutionContext *outerContext, String *exceptionV { Heap::ExecutionContext::init(Heap::ExecutionContext::Type_CatchContext); outer.set(internalClass->engine, outerContext); - strictMode = outer->strictMode; callData = outer->callData; v4Function = outer->v4Function; @@ -259,7 +257,6 @@ ReturnedValue QV4::ExecutionContext::simpleCall(ExecutionEngine *engine, CallDat CallContext::Data *ctx = engine->memoryManager->allocSimpleCallContext(); - ctx->strictMode = function->isStrict(); ctx->callData = callData; ctx->v4Function = function; ctx->outer.set(engine, this->d()); @@ -341,7 +338,7 @@ bool ExecutionContext::setProperty(String *name, const Value &value) } - if (d()->strictMode) + if (d()->v4Function->isStrict()) return false; return engine()->globalObject->put(name, value); } diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index 67f50e5c25..44c434e637 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -128,11 +128,10 @@ DECLARE_HEAP_OBJECT(ExecutionContext, Base) { } quint8 type; - bool strictMode : 8; #if QT_POINTER_SIZE == 8 - quint8 padding_[6]; + quint8 padding_[7]; #else - quint8 padding_[2]; + quint8 padding_[3]; #endif }; V4_ASSERT_IS_TRIVIAL(ExecutionContext) diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index 179c4120ae..f210ff2659 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -382,8 +382,7 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) const ContextStateSaver stateSaver(scope, ctx); - // set the correct strict mode flag on the context - ctx->d()->strictMode = false; + // set the correct v4 function for the context ctx->d()->v4Function = function; return Q_V4_PROFILE(ctx->engine(), function, 0); diff --git a/src/qml/jsruntime/qv4qmlcontext.cpp b/src/qml/jsruntime/qv4qmlcontext.cpp index 8c6d6f11fa..88bea8156f 100644 --- a/src/qml/jsruntime/qv4qmlcontext.cpp +++ b/src/qml/jsruntime/qv4qmlcontext.cpp @@ -299,7 +299,6 @@ void Heap::QmlContext::init(QV4::ExecutionContext *outerContext, QV4::QQmlContex { Heap::ExecutionContext::init(Heap::ExecutionContext::Type_QmlContext); outer.set(internalClass->engine, outerContext->d()); - strictMode = false; callData = outer->callData; v4Function = outer->v4Function; diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 188b66d8d3..1b28882280 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -150,7 +150,6 @@ ReturnedValue Script::run() ExecutionContextSaver ctxSaver(valueScope.engine); ContextStateSaver stateSaver(valueScope, scope); - scope->d()->strictMode = vmFunction->isStrict(); scope->d()->v4Function = vmFunction; return Q_V4_PROFILE(engine, vmFunction, 0); diff --git a/src/qml/jsruntime/qv4script_p.h b/src/qml/jsruntime/qv4script_p.h index 62e1e566bf..96c3b4b32d 100644 --- a/src/qml/jsruntime/qv4script_p.h +++ b/src/qml/jsruntime/qv4script_p.h @@ -65,19 +65,16 @@ namespace QV4 { struct ContextStateSaver { Value *savedContext; - bool strictMode; QV4::Function *v4Function; ContextStateSaver(const Scope &scope, ExecutionContext *context) : savedContext(scope.alloc(1)) - , strictMode(context->d()->strictMode) , v4Function(context->d()->v4Function) { savedContext->setM(context->d()); } ContextStateSaver(const Scope &scope, Heap::ExecutionContext *context) : savedContext(scope.alloc(1)) - , strictMode(context->strictMode) , v4Function(context->v4Function) { savedContext->setM(context); @@ -86,7 +83,6 @@ struct ContextStateSaver { ~ContextStateSaver() { Heap::ExecutionContext *ctx = static_cast(savedContext->m()); - ctx->strictMode = strictMode; ctx->v4Function = v4Function; } }; -- cgit v1.2.3