QV4::Function *runtimeFunction = runtimeFunctions.at(i);
const CompiledData::Function *compiledFunction = data->functionAt(i);
- runtimeFunction->init(this, compiledFunction);
+ runtimeFunction->init(this, compiledFunction,
+ (Value (*)(QV4::ExecutionContext *, const uchar *)) codeRefs[i].code().executableAddress(),
+ codeRefs[i].size());
+
+ UnwindHelper::registerFunction(runtimeFunction);
if (compiledFunction == compiledRootFunction) {
assert(!rootRuntimeFunction);
const Assembler::VoidType Assembler::Void;
-Assembler::Assembler(InstructionSelection *isel, V4IR::Function* function, QV4::Function *vmFunction, QV4::ExecutionEngine *engine)
- : _function(function), _vmFunction(vmFunction), _isel(isel), _engine(engine), _nextBlock(0)
+Assembler::Assembler(InstructionSelection *isel, V4IR::Function* function, QV4::ExecutionEngine *engine)
+ : _function(function), _isel(isel), _engine(engine), _nextBlock(0)
{
}
binOpFinished.link(this);
}
#if OS(LINUX) || OS(MAC_OS_X)
-static void printDisassembledOutputWithCalls(const char* output, const QHash<void*, const char*>& functions,
- const QVector<String*> &identifiers)
+static void printDisassembledOutputWithCalls(const char* output, const QHash<void*, const char*>& functions)
{
QByteArray processedOutput(output);
for (QHash<void*, const char*>::ConstIterator it = functions.begin(), end = functions.end();
ptrString.prepend("0x");
processedOutput = processedOutput.replace(ptrString, it.value());
}
- for (QVector<String*>::ConstIterator it = identifiers.begin(), end = identifiers.end();
- it != end; ++it) {
- QByteArray ptrString = QByteArray::number(quintptr(*it), 16);
- ptrString.prepend("0x");
- QByteArray replacement = "\"" + (*it)->toQString().toUtf8() + "\"";
- processedOutput = processedOutput.replace(ptrString, replacement);
- }
fprintf(stderr, "%s\n", processedOutput.constData());
}
#endif
}
-JSC::MacroAssemblerCodeRef Assembler::link(QV4::Function *vmFunc)
+JSC::MacroAssemblerCodeRef Assembler::link()
{
- 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)
JSC::JSGlobalData dummy(_engine->executableAllocator);
JSC::LinkBuffer linkBuffer(dummy, this, 0);
- vmFunc->codeSize = linkBuffer.offsetOf(endOfCode);
QVector<uint> lineNumberMapping(codeLineNumberMappings.count() * 2);
# endif
# if CPU(X86) || CPU(X86_64)
QHash<void*, String*> idents;
- printDisassembledOutputWithCalls(disasmOutput, functions, _vmFunction->identifiers);
+ printDisassembledOutputWithCalls(disasmOutput, functions);
# endif
# if OS(LINUX)
free(disasmOutput);
codeRef = linkBuffer.finalizeCodeWithoutDisassembly();
}
- vmFunc->code = (Value (*)(QV4::ExecutionContext *, const uchar *)) codeRef.code().executableAddress();
return codeRef;
}
: EvalInstructionSelection(engine, module)
, _block(0)
, _function(0)
- , _vmFunction(0)
, _as(0)
, _locals(0)
{
QVector<Lookup> lookups;
QSet<V4IR::BasicBlock*> reentryBlocks;
qSwap(_function, function);
- qSwap(_vmFunction, vmFunction);
qSwap(_reentryBlocks, reentryBlocks);
Assembler* oldAssembler = _as;
- _as = new Assembler(this, _function, _vmFunction, engine());
+ _as = new Assembler(this, _function, engine());
V4IR::Optimizer opt(_function);
opt.run();
}
}
- JSC::MacroAssemblerCodeRef codeRef =_as->link(_vmFunction);
+ JSC::MacroAssemblerCodeRef codeRef =_as->link();
codeRefs[_function] = codeRef;
- UnwindHelper::registerFunction(_vmFunction);
-
- qSwap(_vmFunction, vmFunction);
qSwap(_function, function);
qSwap(_reentryBlocks, reentryBlocks);
qSwap(_locals, locals);
class Assembler : public JSC::MacroAssembler
{
public:
- Assembler(InstructionSelection *isel, V4IR::Function* function, QV4::Function *vmFunction, QV4::ExecutionEngine *engine);
+ Assembler(InstructionSelection *isel, V4IR::Function* function, QV4::ExecutionEngine *engine);
#if CPU(X86)
#undef VALUE_FITS_IN_REGISTER
return Jump();
}
- JSC::MacroAssemblerCodeRef link(QV4::Function *vmFunc);
+ JSC::MacroAssemblerCodeRef link();
void recordLineNumber(int lineNumber);
private:
V4IR::Function *_function;
- QV4::Function *_vmFunction;
QHash<V4IR::BasicBlock *, Label> _addrs;
QHash<V4IR::BasicBlock *, QVector<Jump> > _patches;
QList<CallToLink> _callsToLink;
V4IR::BasicBlock *_block;
V4IR::Function* _function;
- QV4::Function* _vmFunction;
Assembler* _as;
QSet<V4IR::BasicBlock*> _reentryBlocks;
int _locals;