aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4engine.cpp11
-rw-r--r--src/qml/jsruntime/qv4engine_p.h4
-rw-r--r--src/qml/jsruntime/qv4function.cpp4
-rw-r--r--src/qml/jsruntime/qv4function_p.h8
-rw-r--r--src/qml/jsruntime/qv4global_p.h4
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp33
6 files changed, 53 insertions, 11 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index b92bd3992d..beb856c2f6 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -793,7 +793,7 @@ int CppStackFrame::lineNumber() const
};
const QV4::CompiledData::Function *cf = v4Function->compiledFunction;
- uint offset = static_cast<uint>(instructionPointer - v4Function->codeData);
+ uint offset = instructionPointer;
const CompiledData::CodeOffsetToLine *lineNumbers = cf->lineNumberTable();
uint nLineNumbers = cf->nLineNumbers;
const CompiledData::CodeOffsetToLine *line = std::lower_bound(lineNumbers, lineNumbers + nLineNumbers, offset, findLine) - 1;
@@ -1545,6 +1545,15 @@ QV4::ReturnedValue ExecutionEngine::metaTypeToJS(int type, const void *data)
return 0;
}
+bool ExecutionEngine::canJIT()
+{
+#ifdef V4_ENABLE_JIT
+ return true;
+#else
+ return false;
+#endif
+}
+
// Converts a JS value to a meta-type.
// data must point to a place that can store a value of the given type.
// Returns true if conversion succeeded, false otherwise.
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h
index d165294a87..148dec44bd 100644
--- a/src/qml/jsruntime/qv4engine_p.h
+++ b/src/qml/jsruntime/qv4engine_p.h
@@ -94,7 +94,7 @@ struct Q_QML_EXPORT CppStackFrame {
CallData *jsFrame;
const Value *originalArguments;
int originalArgumentsCount;
- const uchar *instructionPointer;
+ int instructionPointer;
QString source() const;
QString function() const;
@@ -477,6 +477,8 @@ public:
bool checkStackLimits();
+ static bool canJIT();
+
private:
#ifndef QT_NO_QML_DEBUGGER
QScopedPointer<QV4::Debugging::Debugger> m_debugger;
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp
index 32a72fda3f..83e861138b 100644
--- a/src/qml/jsruntime/qv4function.cpp
+++ b/src/qml/jsruntime/qv4function.cpp
@@ -46,6 +46,7 @@
#include "qv4lookup_p.h"
#include <private/qv4mm_p.h>
#include <private/qv4identifiertable_p.h>
+#include <assembler/MacroAssemblerCodeRef.h>
QT_BEGIN_NAMESPACE
@@ -56,6 +57,8 @@ Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit,
, compilationUnit(unit)
, code(codePtr)
, codeData(function->code())
+ , jittedCode(nullptr)
+ , codeRef(nullptr)
, hasQmlDependencies(function->hasQmlDependencies())
{
Q_UNUSED(engine);
@@ -76,6 +79,7 @@ Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit,
Function::~Function()
{
+ delete codeRef;
}
void Function::updateInternalClass(ExecutionEngine *engine, const QList<QByteArray> &parameters)
diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h
index 6c62881998..0e61be5115 100644
--- a/src/qml/jsruntime/qv4function_p.h
+++ b/src/qml/jsruntime/qv4function_p.h
@@ -56,6 +56,10 @@
#include <private/qv4context_p.h>
#include <private/qv4vme_moth_p.h>
+namespace JSC {
+class MacroAssemblerCodeRef;
+}
+
QT_BEGIN_NAMESPACE
namespace QV4 {
@@ -72,6 +76,10 @@ struct Q_QML_EXPORT Function {
Code code;
const uchar *codeData;
+ typedef ReturnedValue (*JittedCode)(CppStackFrame *, ExecutionEngine *);
+ JittedCode jittedCode;
+ JSC::MacroAssemblerCodeRef *codeRef;
+
// first nArguments names in internalClass are the actual arguments
InternalClass *internalClass;
uint nFormals;
diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h
index 6bdeda3313..090a164ef6 100644
--- a/src/qml/jsruntime/qv4global_p.h
+++ b/src/qml/jsruntime/qv4global_p.h
@@ -107,8 +107,8 @@ inline double trunc(double d) { return d > 0 ? floor(d) : ceil(d); }
# if defined(Q_OS_LINUX)
# define V4_ENABLE_JIT
# endif
-#elif defined(Q_PROCESSOR_MIPS_32) && defined(Q_OS_LINUX)
-# define V4_ENABLE_JIT
+//#elif defined(Q_PROCESSOR_MIPS_32) && defined(Q_OS_LINUX)
+//# define V4_ENABLE_JIT
#endif
// Black list some platforms
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index 9159f55245..e2071986a5 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -60,6 +60,8 @@
#include "qv4alloca_p.h"
+#include <private/qv4jit_p.h>
+
#undef COUNT_INSTRUCTIONS
extern "C" {
@@ -477,7 +479,7 @@ static bool compareEqualInt(Value &accumulator, Value lhs, int rhs)
}
}
-#define STORE_IP() frame.instructionPointer = code;
+#define STORE_IP() frame.instructionPointer = int(code - codeStart);
#define STORE_ACC() accumulator = acc;
#define ACC Primitive::fromReturnedValue(acc)
#define VALUE_TO_INT(i, val) \
@@ -542,22 +544,37 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const Value *thisObject,
frame.parent = engine->currentStackFrame;
frame.v4Function = function;
- frame.instructionPointer = function->codeData;
+ frame.instructionPointer = 0;
frame.jsFrame = callData;
engine->currentStackFrame = &frame;
}
CHECK_STACK_LIMITS(engine);
- Profiling::FunctionCallProfiler profiler(engine, function);
- if (QV4::Debugging::Debugger *debugger = engine->debugger())
- debugger->enteringFunction();
+ Profiling::FunctionCallProfiler profiler(engine, function); // start execution profiling
+ QV4::Debugging::Debugger *debugger = engine->debugger();
const uchar *exceptionHandler = 0;
QV4::Value &accumulator = frame.jsFrame->accumulator;
QV4::ReturnedValue acc = Encode::undefined();
+#ifdef V4_ENABLE_JIT
+ static const bool forceInterpreter = qEnvironmentVariableIsSet("QV4_FORCE_INTERPRETER");
+ if (function->jittedCode == nullptr) {
+ if (ExecutionEngine::canJIT() && debugger == nullptr && !forceInterpreter)
+ QV4::JIT::BaselineJIT(function).generate();
+ }
+#endif // V4_ENABLE_JIT
+
+ if (debugger)
+ debugger->enteringFunction();
+
+ if (function->jittedCode != nullptr && debugger == nullptr) {
+ acc = function->jittedCode(&frame, engine);
+ } else {
+ // interpreter
const uchar *code = function->codeData;
+ const uchar *codeStart = code;
MOTH_JUMP_TABLE;
@@ -660,7 +677,7 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const Value *thisObject,
STORE_ACC();
Runtime::method_storeNameStrict(engine, name, accumulator);
CHECK_EXCEPTION;
- MOTH_END_INSTR(StoreNameSloppy)
+ MOTH_END_INSTR(StoreNameStrict)
MOTH_BEGIN_INSTR(StoreNameSloppy)
STORE_IP();
@@ -835,7 +852,8 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const Value *thisObject,
MOTH_END_INSTR(ThrowException)
MOTH_BEGIN_INSTR(GetException)
- acc = engine->hasException ? engine->exceptionValue->asReturnedValue() : Primitive::emptyValue().asReturnedValue();
+ acc = engine->hasException ? engine->exceptionValue->asReturnedValue()
+ : Primitive::emptyValue().asReturnedValue();
engine->hasException = false;
MOTH_END_INSTR(HasException)
@@ -1352,6 +1370,7 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const Value *thisObject,
}
code = exceptionHandler;
}
+ }
functionExit:
if (QV4::Debugging::Debugger *debugger = engine->debugger())