aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-11-14 15:58:39 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-22 14:54:36 +0100
commit85fea8a68b90c817c47022ca5157ff80cb497d4d (patch)
treea35010ed51fb282d4c727631cb9ce42603d26a80 /src
parentbf173fe5da381c88343296ca33ef6b06389c6d20 (diff)
Saner and simpler way to handle line numbers for JITed code
Instead of storing the current instruction pointer in the ExecutionContext, we might as well directly store the current line number there. Leads to simpler code, works cross platform and should also be faster. Change-Id: Ifb7897cf8dbe8a962505fe876aa3ed43283ebb06 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/compiler/qv4isel_masm.cpp21
-rw-r--r--src/qml/compiler/qv4isel_masm_p.h26
-rw-r--r--src/qml/jsruntime/qv4context_p.h8
-rw-r--r--src/qml/jsruntime/qv4engine.cpp9
4 files changed, 11 insertions, 53 deletions
diff --git a/src/qml/compiler/qv4isel_masm.cpp b/src/qml/compiler/qv4isel_masm.cpp
index 91cc5a9b4e..aca28eac2c 100644
--- a/src/qml/compiler/qv4isel_masm.cpp
+++ b/src/qml/compiler/qv4isel_masm.cpp
@@ -439,15 +439,6 @@ static void printDisassembledOutputWithCalls(const char* output, const QHash<voi
}
#endif
-void Assembler::recordLineNumber(int lineNumber)
-{
- CodeLineNumerMapping mapping;
- mapping.location = label();
- mapping.lineNumber = lineNumber;
- codeLineNumberMappings << mapping;
-}
-
-
JSC::MacroAssemblerCodeRef Assembler::link(int *codeSize)
{
Label endOfCode = label();
@@ -467,14 +458,6 @@ JSC::MacroAssemblerCodeRef Assembler::link(int *codeSize)
JSC::JSGlobalData dummy(_executableAllocator);
JSC::LinkBuffer linkBuffer(dummy, this, 0);
- QVector<uint> lineNumberMapping(codeLineNumberMappings.count() * 2);
-
- for (int i = 0; i < codeLineNumberMappings.count(); ++i) {
- lineNumberMapping[i * 2] = linkBuffer.offsetOf(codeLineNumberMappings.at(i).location);
- lineNumberMapping[i * 2 + 1] = codeLineNumberMappings.at(i).lineNumber;
- }
- _isel->jsUnitGenerator()->registerLineNumberMapping(_function, lineNumberMapping);
-
QHash<void*, const char*> functions;
foreach (CallToLink ctl, _callsToLink) {
linkBuffer.link(ctl.call, ctl.externalFunction);
@@ -642,9 +625,9 @@ void InstructionSelection::run(int functionIndex)
foreach (V4IR::Stmt *s, _block->statements) {
if (s->location.isValid()) {
- _as->recordLineNumber(s->location.startLine);
if (int(s->location.startLine) != lastLine) {
- _as->saveInstructionPointer(Assembler::ScratchRegister);
+ Assembler::Address lineAddr(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext, lineNumber));
+ _as->store32(Assembler::TrustedImm32(s->location.startLine), lineAddr);
lastLine = s->location.startLine;
}
}
diff --git a/src/qml/compiler/qv4isel_masm_p.h b/src/qml/compiler/qv4isel_masm_p.h
index e3b41857ea..570400656a 100644
--- a/src/qml/compiler/qv4isel_masm_p.h
+++ b/src/qml/compiler/qv4isel_masm_p.h
@@ -466,23 +466,6 @@ public:
V4IR::BasicBlock *block;
};
- void saveInstructionPointer(RegisterID freeScratchRegister) {
- Address ipAddr(ContextRegister, qOffsetOf(QV4::ExecutionContext, jitInstructionPointer));
- RegisterID sourceRegister = freeScratchRegister;
-
-#if CPU(X86_64) || CPU(X86)
- callToRetrieveIP();
- peek(sourceRegister);
- pop();
-#elif CPU(ARM)
- move(JSC::ARMRegisters::pc, sourceRegister);
-#else
-#error "Port me!"
-#endif
-
- storePtr(sourceRegister, ipAddr);
- }
-
void callAbsolute(const char* functionName, FunctionPtr function) {
CallToLink ctl;
ctl.call = call();
@@ -1397,8 +1380,6 @@ public:
JSC::MacroAssemblerCodeRef link(int *codeSize);
- void recordLineNumber(int lineNumber);
-
const StackLayout stackLayout() const { return _stackLayout; }
ConstantTable &constantTable() { return _constTable; }
@@ -1424,13 +1405,6 @@ private:
QV4::ExecutableAllocator *_executableAllocator;
InstructionSelection *_isel;
-
- struct CodeLineNumerMapping
- {
- Assembler::Label location;
- int lineNumber;
- };
- QVector<CodeLineNumerMapping> codeLineNumberMappings;
};
template <typename T> inline void prepareRelativeCall(const T &, Assembler *){}
diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h
index 9b080dc590..e7f5ee9a9e 100644
--- a/src/qml/jsruntime/qv4context_p.h
+++ b/src/qml/jsruntime/qv4context_p.h
@@ -110,7 +110,7 @@ struct Q_QML_EXPORT ExecutionContext : public Managed
EvalCode *currentEvalCode;
const uchar **interpreterInstructionPointer;
- char *jitInstructionPointer;
+ int lineNumber;
void initBaseContext(Type type, ExecutionEngine *engine, ExecutionContext *parentContext)
{
@@ -123,7 +123,7 @@ struct Q_QML_EXPORT ExecutionContext : public Managed
compilationUnit = 0;
currentEvalCode = 0;
interpreterInstructionPointer = 0;
- jitInstructionPointer = 0;
+ lineNumber = -1;
}
CallContext *newCallContext(FunctionObject *f, CallData *callData);
@@ -141,11 +141,11 @@ struct Q_QML_EXPORT ExecutionContext : public Managed
ReturnedValue throwError(const QV4::ValueRef value);
ReturnedValue throwError(const QString &message);
ReturnedValue throwSyntaxError(const QString &message);
- ReturnedValue throwSyntaxError(const QString &message, const QString &fileName, int line, int column);
+ ReturnedValue throwSyntaxError(const QString &message, const QString &fileName, int lineNumber, int column);
ReturnedValue throwTypeError();
ReturnedValue throwTypeError(const QString &message);
ReturnedValue throwReferenceError(const ValueRef value);
- ReturnedValue throwReferenceError(const QString &value, const QString &fileName, int line, int column);
+ ReturnedValue throwReferenceError(const QString &value, const QString &fileName, int lineNumber, int column);
ReturnedValue throwRangeError(const ValueRef value);
ReturnedValue throwRangeError(const QString &message);
ReturnedValue throwURIError(const ValueRef msg);
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 19aaee104f..90220f0a36 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -621,11 +621,12 @@ namespace {
void resolve(StackFrame *frame, ExecutionContext *context, Function *function)
{
qptrdiff offset;
- if (context->interpreterInstructionPointer)
+ if (context->interpreterInstructionPointer) {
offset = *context->interpreterInstructionPointer - 1 - function->codeData;
- else
- offset = context->jitInstructionPointer - (char*)function->codePtr;
- frame->line = function->lineNumberForProgramCounter(offset);
+ frame->line = function->lineNumberForProgramCounter(offset);
+ } else {
+ frame->line = context->lineNumber;
+ }
}
};
}