aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-08-16 15:24:35 +0200
committerLars Knoll <lars.knoll@digia.com>2013-08-16 16:53:37 +0200
commit75cc05fcf472453fc33b262c70af46344adff666 (patch)
tree86f2b2962a39f48c56de5008bd96192c7e949b21 /src
parent944717a46c237e5a5b2d6e5ea2fd8389523638e4 (diff)
Get rid of the QV4::Function in the masm isel
Change-Id: Ide70ca5a3f3dcc793fb96fd64f8b8df6b07d1168 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/compiler/qv4compileddata_p.h1
-rw-r--r--src/qml/compiler/qv4isel_masm.cpp36
-rw-r--r--src/qml/compiler/qv4isel_masm_p.h6
-rw-r--r--src/qml/jsruntime/qv4function.cpp6
-rw-r--r--src/qml/jsruntime/qv4function_p.h3
5 files changed, 21 insertions, 31 deletions
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h
index f050c4cc93..b2bc25bdbe 100644
--- a/src/qml/compiler/qv4compileddata_p.h
+++ b/src/qml/compiler/qv4compileddata_p.h
@@ -178,7 +178,6 @@ struct Function
IsNamedExpression = 0x8
};
- QV4::Value (*code)(ExecutionContext *, const uchar *);
quint32 index; // in CompilationUnit's function table
quint32 nameIndex;
qint64 flags;
diff --git a/src/qml/compiler/qv4isel_masm.cpp b/src/qml/compiler/qv4isel_masm.cpp
index 8e7d7a1c6e..bd78256f47 100644
--- a/src/qml/compiler/qv4isel_masm.cpp
+++ b/src/qml/compiler/qv4isel_masm.cpp
@@ -74,7 +74,11 @@ QV4::Function *CompilationUnit::linkBackendToEngine(ExecutionEngine *engine)
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);
@@ -208,8 +212,8 @@ const int Assembler::calleeSavedRegisterCount = sizeof(calleeSavedRegisters) / s
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)
{
}
@@ -531,8 +535,7 @@ void Assembler::generateBinOp(V4IR::AluOp operation, V4IR::Temp* target, V4IR::T
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();
@@ -541,13 +544,6 @@ static void printDisassembledOutputWithCalls(const char* output, const QHash<voi
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
@@ -561,9 +557,8 @@ void Assembler::recordLineNumber(int lineNumber)
}
-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)
@@ -584,7 +579,6 @@ JSC::MacroAssemblerCodeRef Assembler::link(QV4::Function *vmFunc)
JSC::JSGlobalData dummy(_engine->executableAllocator);
JSC::LinkBuffer linkBuffer(dummy, this, 0);
- vmFunc->codeSize = linkBuffer.offsetOf(endOfCode);
QVector<uint> lineNumberMapping(codeLineNumberMappings.count() * 2);
@@ -659,7 +653,7 @@ JSC::MacroAssemblerCodeRef Assembler::link(QV4::Function *vmFunc)
# 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);
@@ -669,7 +663,6 @@ JSC::MacroAssemblerCodeRef Assembler::link(QV4::Function *vmFunc)
codeRef = linkBuffer.finalizeCodeWithoutDisassembly();
}
- vmFunc->code = (Value (*)(QV4::ExecutionContext *, const uchar *)) codeRef.code().executableAddress();
return codeRef;
}
@@ -677,7 +670,6 @@ InstructionSelection::InstructionSelection(QV4::ExecutionEngine *engine, V4IR::M
: EvalInstructionSelection(engine, module)
, _block(0)
, _function(0)
- , _vmFunction(0)
, _as(0)
, _locals(0)
{
@@ -694,10 +686,9 @@ void InstructionSelection::run(QV4::Function *vmFunction, V4IR::Function *functi
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();
@@ -755,12 +746,9 @@ void InstructionSelection::run(QV4::Function *vmFunction, V4IR::Function *functi
}
}
- 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);
diff --git a/src/qml/compiler/qv4isel_masm_p.h b/src/qml/compiler/qv4isel_masm_p.h
index 757d50a5a4..35b2345109 100644
--- a/src/qml/compiler/qv4isel_masm_p.h
+++ b/src/qml/compiler/qv4isel_masm_p.h
@@ -76,7 +76,7 @@ struct CompilationUnit : public QV4::CompiledData::CompilationUnit
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
@@ -779,13 +779,12 @@ public:
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;
@@ -944,7 +943,6 @@ private:
V4IR::BasicBlock *_block;
V4IR::Function* _function;
- QV4::Function* _vmFunction;
Assembler* _as;
QSet<V4IR::BasicBlock*> _reentryBlocks;
int _locals;
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp
index b814637e12..3891bb7000 100644
--- a/src/qml/jsruntime/qv4function.cpp
+++ b/src/qml/jsruntime/qv4function.cpp
@@ -64,13 +64,17 @@ Function::~Function()
compilationUnit->deref();
}
-void Function::init(CompiledData::CompilationUnit *unit, const CompiledData::Function *function)
+void Function::init(CompiledData::CompilationUnit *unit, const CompiledData::Function *function, Value (*codePtr)(ExecutionContext *, const uchar *),
+ quint32 _codeSize)
{
Q_ASSERT(!compilationUnit);
compilationUnit = unit;
compilationUnit->ref();
compiledFunction = function;
+ code = codePtr;
+ codeSize = _codeSize;
+
formals.resize(compiledFunction->nFormals);
const quint32 *formalsIndices = compiledFunction->formalsTable();
for (int i = 0; i < compiledFunction->nFormals; ++i)
diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h
index eacd7d1d7a..cc6491b9f8 100644
--- a/src/qml/jsruntime/qv4function_p.h
+++ b/src/qml/jsruntime/qv4function_p.h
@@ -119,7 +119,8 @@ struct Function {
~Function();
// ### Merge with constructor later.
- void init(CompiledData::CompilationUnit *unit, const CompiledData::Function *function);
+ void init(CompiledData::CompilationUnit *unit, const CompiledData::Function *function,
+ Value (*codePtr)(ExecutionContext *, const uchar *), quint32 _codeSize);
void ref() { ++refCount; }
void deref() { if (!--refCount) delete this; }