diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2016-07-13 11:27:28 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-08-02 10:37:28 +0000 |
commit | bc84dd0b85c5067a75c7a7b6c30527c08a4844bb (patch) | |
tree | 28aa1cb68654544ea3b58bf137602185885eda94 /src/qml/jsruntime | |
parent | 54ee6994e66936c1d532f7718c858c9b18e3c91d (diff) |
Make generated code loading constants relocatable
On 32-bit architectures we were encoding the absolute address of generated
constants in memory into the load instruction. In order to make the code
reloctable, this patch changes the JIT over to use the constant table in the
compilation unit. This means two additional loads per constant. On
architectures that support instruction pointer relative addressing, we can try
to fix this in the future (arm32 for example).
Change-Id: I8ed7aa7c67711696d6c46c72b3b642d610ff2cbc
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4context.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4context_p.h | 8 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4script.cpp | 1 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4script_p.h | 4 |
5 files changed, 16 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 97b3e26a26..60717c9491 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -73,6 +73,7 @@ Heap::CallContext *ExecutionContext::newCallContext(const FunctionObject *functi c->compilationUnit = function->function()->compilationUnit; c->lookups = c->compilationUnit->runtimeLookups; + c->constantTable = c->compilationUnit->data->constants(); c->locals = (Value *)((quintptr(c + 1) + 7) & ~7); const CompiledData::Function *compiledFunction = function->function()->compiledFunction; @@ -172,6 +173,7 @@ Heap::WithContext::WithContext(ExecutionContext *outerContext, Object *with) outer = outerContext; callData = outer->callData; lookups = outer->lookups; + constantTable = outer->constantTable; compilationUnit = outer->compilationUnit; withObject = with; @@ -184,6 +186,7 @@ Heap::CatchContext::CatchContext(ExecutionContext *outerContext, String *excepti strictMode = outer->strictMode; callData = outer->callData; lookups = outer->lookups; + constantTable = outer->constantTable; compilationUnit = outer->compilationUnit; this->exceptionVarName = exceptionVarName; @@ -197,6 +200,7 @@ Heap::QmlContext::QmlContext(QV4::ExecutionContext *outerContext, QV4::QmlContex strictMode = false; callData = outer->callData; lookups = outer->lookups; + constantTable = outer->constantTable; compilationUnit = outer->compilationUnit; this->qml = qml->d(); diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index 2e6773a927..368605ca4a 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -108,6 +108,7 @@ struct ExecutionContext : Base { ExecutionEngine *engine; Pointer<ExecutionContext> outer; Lookup *lookups; + const QV4::Value *constantTable; CompiledData::CompilationUnit *compilationUnit; ContextType type : 8; @@ -118,9 +119,10 @@ struct ExecutionContext : Base { inline ExecutionContext::ExecutionContext(ExecutionEngine *engine, ContextType t) : engine(engine) - , outer(0) - , lookups(0) - , compilationUnit(0) + , outer(nullptr) + , lookups(nullptr) + , constantTable(nullptr) + , compilationUnit(nullptr) , type(t) , strictMode(false) , lineNumber(-1) diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 6b9c552350..805087e389 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -535,6 +535,7 @@ void SimpleScriptFunction::construct(const Managed *that, Scope &scope, CallData ctx.function = f->d(); ctx.compilationUnit = f->function()->compilationUnit; ctx.lookups = ctx.compilationUnit->runtimeLookups; + ctx.constantTable = ctx.compilationUnit->data->constants(); ctx.outer = f->scope(); ctx.locals = scope.alloc(f->varCount()); for (int i = callData->argc; i < (int)f->formalParameterCount(); ++i) @@ -572,6 +573,7 @@ void SimpleScriptFunction::call(const Managed *that, Scope &scope, CallData *cal ctx.function = f->d(); ctx.compilationUnit = f->function()->compilationUnit; ctx.lookups = ctx.compilationUnit->runtimeLookups; + ctx.constantTable = ctx.compilationUnit->data->constants(); ctx.outer = f->scope(); ctx.locals = scope.alloc(f->varCount()); for (int i = callData->argc; i < (int)f->formalParameterCount(); ++i) diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index a2e379ec1a..46adaf7e79 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -222,6 +222,7 @@ ReturnedValue Script::run() ContextStateSaver stateSaver(valueScope, scope); scope->d()->strictMode = vmFunction->isStrict(); scope->d()->lookups = vmFunction->compilationUnit->runtimeLookups; + scope->d()->constantTable = vmFunction->compilationUnit->data->constants(); scope->d()->compilationUnit = vmFunction->compilationUnit; return Q_V4_PROFILE(engine, vmFunction); diff --git a/src/qml/jsruntime/qv4script_p.h b/src/qml/jsruntime/qv4script_p.h index e81bc3049c..2e87a7692b 100644 --- a/src/qml/jsruntime/qv4script_p.h +++ b/src/qml/jsruntime/qv4script_p.h @@ -71,6 +71,7 @@ struct ContextStateSaver { Value *savedContext; bool strictMode; Lookup *lookups; + const QV4::Value *constantTable; CompiledData::CompilationUnit *compilationUnit; int lineNumber; @@ -78,6 +79,7 @@ struct ContextStateSaver { : savedContext(scope.alloc(1)) , strictMode(context->d()->strictMode) , lookups(context->d()->lookups) + , constantTable(context->d()->constantTable) , compilationUnit(context->d()->compilationUnit) , lineNumber(context->d()->lineNumber) { @@ -87,6 +89,7 @@ struct ContextStateSaver { : savedContext(scope.alloc(1)) , strictMode(context->strictMode) , lookups(context->lookups) + , constantTable(context->constantTable) , compilationUnit(context->compilationUnit) , lineNumber(context->lineNumber) { @@ -98,6 +101,7 @@ struct ContextStateSaver { Heap::ExecutionContext *ctx = static_cast<Heap::ExecutionContext *>(savedContext->m()); ctx->strictMode = strictMode; ctx->lookups = lookups; + ctx->constantTable = constantTable; ctx->compilationUnit = compilationUnit; ctx->lineNumber = lineNumber; } |