diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-09-11 11:26:32 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-12 19:05:44 +0200 |
commit | bf22c55036f6429ccfc849ea71f33e757fae47fa (patch) | |
tree | 7f0baad7694255ceeb9c5f50139f51875f771113 /src/qml/compiler/qv4isel_masm.cpp | |
parent | b8d0d3cbdd69291bd750912a6d8d6703a7feeb6a (diff) | |
download | qtdeclarative-bf22c55036f6429ccfc849ea71f33e757fae47fa.tar.gz |
Fix passing of exception table pointers to ARM runtime on unwinding
Our synthetic exception unwind table for ARM is located at
(char *)codeStart + function->codeSize;
This relies on function->codeSize to contain the number of bytes of
instructions the function has, not the size of the MacroAssemblerCodeRef
(which contains the size of the entire area).
This patch fixes the calculation of function->codeSize and also replaces
the QHash for the IR::Function* -> CodeRef mapping in the masm backend
with a simple vector that's perfectly sufficient.
Bug spotted by Petr Nejedly
Change-Id: I78a53599085c613c6d97aa2490922f54e0bb4f63
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4isel_masm.cpp')
-rw-r--r-- | src/qml/compiler/qv4isel_masm.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/qml/compiler/qv4isel_masm.cpp b/src/qml/compiler/qv4isel_masm.cpp index 54823b3464..d40f3c2ff5 100644 --- a/src/qml/compiler/qv4isel_masm.cpp +++ b/src/qml/compiler/qv4isel_masm.cpp @@ -80,7 +80,7 @@ void CompilationUnit::linkBackendToEngine(ExecutionEngine *engine) QV4::Function *runtimeFunction = new QV4::Function(engine, this, compiledFunction, (Value (*)(QV4::ExecutionContext *, const uchar *)) codeRefs[i].code().executableAddress(), - codeRefs[i].size()); + codeSizes[i]); runtimeFunctions[i] = runtimeFunction; } @@ -465,10 +465,10 @@ void Assembler::recordLineNumber(int lineNumber) } -JSC::MacroAssemblerCodeRef Assembler::link() +JSC::MacroAssemblerCodeRef Assembler::link(int *codeSize) { -#if defined(Q_PROCESSOR_ARM) && !defined(Q_OS_IOS) Label endOfCode = label(); +#if defined(Q_PROCESSOR_ARM) && !defined(Q_OS_IOS) // Let the ARM exception table follow right after that for (int i = 0, nops = UnwindHelper::unwindInfoSize() / 2; i < nops; ++i) nop(); @@ -519,8 +519,9 @@ JSC::MacroAssemblerCodeRef Assembler::link() } _constTable.finalize(linkBuffer, _isel); + *codeSize = linkBuffer.offsetOf(endOfCode); #if defined(Q_PROCESSOR_ARM) && !defined(Q_OS_IOS) - UnwindHelper::writeARMUnwindInfo(linkBuffer.debugAddress(), linkBuffer.offsetOf(endOfCode)); + UnwindHelper::writeARMUnwindInfo(linkBuffer.debugAddress(), *codeSize); #endif JSC::MacroAssemblerCodeRef codeRef; @@ -583,6 +584,8 @@ InstructionSelection::InstructionSelection(QV4::ExecutableAllocator *execAllocat , _as(0) { compilationUnit = new CompilationUnit; + compilationUnit->codeRefs.resize(module->functions.size()); + compilationUnit->codeSizes.resize(module->functions.size()); } InstructionSelection::~InstructionSelection() @@ -590,8 +593,9 @@ InstructionSelection::~InstructionSelection() delete _as; } -void InstructionSelection::run(V4IR::Function *function) +void InstructionSelection::run(int functionIndex) { + V4IR::Function *function = irModule->functions[functionIndex]; QVector<Lookup> lookups; QSet<V4IR::BasicBlock*> reentryBlocks; qSwap(_function, function); @@ -679,8 +683,8 @@ void InstructionSelection::run(V4IR::Function *function) } } - JSC::MacroAssemblerCodeRef codeRef =_as->link(); - codeRefs[_function] = codeRef; + JSC::MacroAssemblerCodeRef codeRef =_as->link(&compilationUnit->codeSizes[functionIndex]); + compilationUnit->codeRefs[functionIndex] = codeRef; qSwap(_function, function); qSwap(_reentryBlocks, reentryBlocks); @@ -701,10 +705,6 @@ void *InstructionSelection::addConstantTable(QVector<Value> *values) QV4::CompiledData::CompilationUnit *InstructionSelection::backendCompileStep() { compilationUnit->data = generateUnit(); - compilationUnit->codeRefs.resize(irModule->functions.size()); - int i = 0; - foreach (V4IR::Function *irFunction, irModule->functions) - compilationUnit->codeRefs[i++] = codeRefs[irFunction]; return compilationUnit; } |