diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-08-30 21:53:03 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-09-01 12:30:49 +0000 |
commit | 6df6f642ea382169533a0ad106be270b6d4b7d58 (patch) | |
tree | 143401796a060f2e9aef61f9e5bf9a5ffa34a73b /src/qml/jsruntime | |
parent | cc7a858698063649f9770a89949354e2b58ae288 (diff) |
Move CallContext construction into a interpreter instruction
This will allow us to further cut down on function call
overhead. To make this work, introduce a proper distinction
between EvalCode and GlobalCode and use the correct
compilation mode in all places.
Change-Id: I070621142159b7416026347c9239200c5ed7a56b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4function_p.h | 3 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4globalobject.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4script.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4script_p.h | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 5 |
5 files changed, 12 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h index d845eec4d9..c3b21b1685 100644 --- a/src/qml/jsruntime/qv4function_p.h +++ b/src/qml/jsruntime/qv4function_p.h @@ -106,9 +106,6 @@ struct Q_QML_EXPORT Function { private: static ReturnedValue call(CallData *callData, Function *function) { - if (!function->canUseSimpleCall) - callData->context = ExecutionContext::newCallContext(static_cast<Heap::ExecutionContext *>(callData->context.m()), function, callData); - return function->execute(callData); } }; diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index 08bae8fe02..44fc4d5a65 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -360,7 +360,7 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) const const QString code = scode->toQString(); bool inheritContext = !ctx->d()->v4Function->isStrict(); - Script script(ctx, code, QStringLiteral("eval code")); + Script script(ctx, QV4::Compiler::EvalCode, code, QStringLiteral("eval code")); script.strictMode = (directCall && isStrict); script.inheritContext = inheritContext; script.parse(); diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index d5f08041f6..a0aa1b1f2d 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -120,7 +120,7 @@ void Script::parse() RuntimeCodegen cg(v4, &jsGenerator, strictMode); if (inheritContext) cg.setUseFastLookups(false); - cg.generateFromProgram(sourceFile, sourceCode, program, &module, EvalCode); + cg.generateFromProgram(sourceFile, sourceCode, program, &module, compilationMode); if (v4->hasException) return; @@ -219,7 +219,7 @@ QQmlRefPointer<QV4::CompiledData::CompilationUnit> Script::precompile(QV4::Compi Codegen cg(unitGenerator, /*strict mode*/false); cg.setUseFastLookups(false); - cg.generateFromProgram(url.toString(), source, program, module, EvalCode); + cg.generateFromProgram(url.toString(), source, program, module, GlobalCode); errors = cg.qmlErrors(); if (!errors.isEmpty()) { if (reportedErrors) diff --git a/src/qml/jsruntime/qv4script_p.h b/src/qml/jsruntime/qv4script_p.h index 96c3b4b32d..8d7500eb13 100644 --- a/src/qml/jsruntime/qv4script_p.h +++ b/src/qml/jsruntime/qv4script_p.h @@ -54,6 +54,7 @@ #include "qv4engine_p.h" #include "qv4functionobject_p.h" #include "qv4qmlcontext_p.h" +#include "private/qv4compilercontext_p.h" #include <QQmlError> @@ -88,9 +89,9 @@ struct ContextStateSaver { }; struct Q_QML_EXPORT Script { - Script(ExecutionContext *scope, const QString &sourceCode, const QString &source = QString(), int line = 1, int column = 0) + Script(ExecutionContext *scope, QV4::Compiler::CompilationMode mode, const QString &sourceCode, const QString &source = QString(), int line = 1, int column = 0) : sourceFile(source), line(line), column(column), sourceCode(sourceCode) - , scope(scope), strictMode(false), inheritContext(false), parsed(false) + , scope(scope), strictMode(false), inheritContext(false), parsed(false), compilationMode(mode) , vmFunction(0), parseAsBinding(false) {} Script(ExecutionEngine *engine, QmlContext *qml, const QString &sourceCode, const QString &source = QString(), int line = 1, int column = 0) : sourceFile(source), line(line), column(column), sourceCode(sourceCode) @@ -109,6 +110,7 @@ struct Q_QML_EXPORT Script { bool strictMode; bool inheritContext; bool parsed; + QV4::Compiler::CompilationMode compilationMode = QV4::Compiler::EvalCode; QV4::PersistentValue qmlContext; QQmlRefPointer<CompiledData::CompilationUnit> compilationUnit; Function *vmFunction; diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index da0b06dac7..3f5d187770 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -807,6 +807,11 @@ QV4::ReturnedValue VME::exec(CallData *callData, QV4::Function *function) STACK_VALUE(CallData::Context) = Runtime::method_createCatchContext(c, name); MOTH_END_INSTR(PushCatchContext) + MOTH_BEGIN_INSTR(CreateCallContext) + Heap::ExecutionContext *ctx = static_cast<Heap::ExecutionContext *>(stack[CallData::Context].m()); + stack[CallData::Context] = ExecutionContext::newCallContext(ctx, function, reinterpret_cast<CallData *>(stack)); + MOTH_END_INSTR(CreateCallContext) + MOTH_BEGIN_INSTR(PushWithContext) STORE_IP(); STORE_ACC(); |