aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-08-07 14:43:03 +0200
committerLars Knoll <lars.knoll@qt.io>2017-08-10 08:18:50 +0000
commiteb2c08f57493aa12850e6cddff2cc3527e7cbfd7 (patch)
treebe917321e6025a8ca8983881a1f07d1a0fd7680c /src/qml
parente9a8252305fa5e3b3cd4a18261990820975a79da (diff)
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 <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/jsapi/qjsengine.cpp2
-rw-r--r--src/qml/jsruntime/qv4context.cpp5
-rw-r--r--src/qml/jsruntime/qv4context_p.h5
-rw-r--r--src/qml/jsruntime/qv4globalobject.cpp3
-rw-r--r--src/qml/jsruntime/qv4qmlcontext.cpp1
-rw-r--r--src/qml/jsruntime/qv4script.cpp1
-rw-r--r--src/qml/jsruntime/qv4script_p.h4
7 files changed, 5 insertions, 16 deletions
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<Heap::ExecutionContext *>(savedContext->m());
- ctx->strictMode = strictMode;
ctx->v4Function = v4Function;
}
};