aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/compiler/qv4bytecodehandler.cpp3
-rw-r--r--src/qml/compiler/qv4bytecodehandler_p.h6
-rw-r--r--src/qml/jit/qv4baselinejit.cpp18
-rw-r--r--src/qml/jit/qv4baselinejit_p.h5
4 files changed, 19 insertions, 13 deletions
diff --git a/src/qml/compiler/qv4bytecodehandler.cpp b/src/qml/compiler/qv4bytecodehandler.cpp
index d3c5582b28..e2533a0505 100644
--- a/src/qml/compiler/qv4bytecodehandler.cpp
+++ b/src/qml/compiler/qv4bytecodehandler.cpp
@@ -56,8 +56,9 @@ ByteCodeHandler::~ByteCodeHandler()
{ \
INSTR_##instr(MOTH_DECODE_WITH_BASE) \
Q_UNUSED(base_ptr); \
+ _currentOffset = _nextOffset; \
+ _nextOffset = code - start; \
startInstruction(Instr::Type::instr); \
- _offset = code - start; \
INSTR_##instr(DISPATCH) \
endInstruction(Instr::Type::instr); \
continue; \
diff --git a/src/qml/compiler/qv4bytecodehandler_p.h b/src/qml/compiler/qv4bytecodehandler_p.h
index 5f1121306f..ca6abf3dc3 100644
--- a/src/qml/compiler/qv4bytecodehandler_p.h
+++ b/src/qml/compiler/qv4bytecodehandler_p.h
@@ -91,7 +91,8 @@ public:
void decode(const char *code, uint len);
- int instructionOffset() const { return _offset; }
+ int currentInstructionOffset() const { return _currentOffset; }
+ int nextInstructionOffset() const { return _nextOffset; }
static std::vector<int> collectLabelsInBytecode(const char *code, uint len);
@@ -102,7 +103,8 @@ protected:
virtual void endInstruction(Moth::Instr::Type instr) = 0;
private:
- int _offset = 0;
+ int _currentOffset = 0;
+ int _nextOffset = 0;
};
} // Moth namespace
diff --git a/src/qml/jit/qv4baselinejit.cpp b/src/qml/jit/qv4baselinejit.cpp
index bf442de741..2e0f357574 100644
--- a/src/qml/jit/qv4baselinejit.cpp
+++ b/src/qml/jit/qv4baselinejit.cpp
@@ -73,7 +73,7 @@ void BaselineJIT::generate()
// qDebug()<<"done";
}
-#define STORE_IP() as->storeInstructionPointer(instructionOffset())
+#define STORE_IP() as->storeInstructionPointer(nextInstructionOffset())
#define STORE_ACC() as->saveAccumulatorInFrame()
void BaselineJIT::generate_Ret()
@@ -562,7 +562,7 @@ void BaselineJIT::generate_ConstructWithSpread(int func, int argc, int argv)
void BaselineJIT::generate_SetUnwindHandler(int offset)
{
if (offset)
- as->setUnwindHandler(instructionOffset() + offset);
+ as->setUnwindHandler(absoluteOffsetForJump(offset));
else
as->clearUnwindHandler();
}
@@ -574,7 +574,7 @@ void BaselineJIT::generate_UnwindDispatch()
void BaselineJIT::generate_UnwindToLabel(int level, int offset)
{
- as->unwindToLabel(level, instructionOffset() + offset);
+ as->unwindToLabel(level, absoluteOffsetForJump(offset));
}
@@ -824,11 +824,11 @@ void BaselineJIT::generate_ToObject()
}
-void BaselineJIT::generate_Jump(int offset) { as->jump(instructionOffset() + offset); }
-void BaselineJIT::generate_JumpTrue(int offset) { as->jumpTrue(instructionOffset() + offset); }
-void BaselineJIT::generate_JumpFalse(int offset) { as->jumpFalse(instructionOffset() + offset); }
-void BaselineJIT::generate_JumpNoException(int offset) { as->jumpNoException(instructionOffset() + offset); }
-void BaselineJIT::generate_JumpNotUndefined(int offset) { as->jumpNotUndefined(instructionOffset() + offset); }
+void BaselineJIT::generate_Jump(int offset) { as->jump(absoluteOffsetForJump(offset)); }
+void BaselineJIT::generate_JumpTrue(int offset) { as->jumpTrue(absoluteOffsetForJump(offset)); }
+void BaselineJIT::generate_JumpFalse(int offset) { as->jumpFalse(absoluteOffsetForJump(offset)); }
+void BaselineJIT::generate_JumpNoException(int offset) { as->jumpNoException(absoluteOffsetForJump(offset)); }
+void BaselineJIT::generate_JumpNotUndefined(int offset) { as->jumpNotUndefined(absoluteOffsetForJump(offset)); }
void BaselineJIT::generate_CmpEqNull() { as->cmpeqNull(); }
void BaselineJIT::generate_CmpNeNull() { as->cmpneNull(); }
@@ -932,7 +932,7 @@ void BaselineJIT::generate_LoadQmlImportedScripts(int result)
void BaselineJIT::startInstruction(Instr::Type /*instr*/)
{
if (hasLabel())
- as->addLabel(instructionOffset());
+ as->addLabel(currentInstructionOffset());
}
void BaselineJIT::endInstruction(Instr::Type instr)
diff --git a/src/qml/jit/qv4baselinejit_p.h b/src/qml/jit/qv4baselinejit_p.h
index 71b9dda9b9..6f066bb9a5 100644
--- a/src/qml/jit/qv4baselinejit_p.h
+++ b/src/qml/jit/qv4baselinejit_p.h
@@ -214,7 +214,10 @@ public:
protected:
bool hasLabel() const
- { return std::find(labels.cbegin(), labels.cend(), instructionOffset()) != labels.cend(); }
+ { return std::find(labels.cbegin(), labels.cend(), currentInstructionOffset()) != labels.cend(); }
+
+ int absoluteOffsetForJump(int relativeOffset) const
+ { return nextInstructionOffset() + relativeOffset; }
private:
QV4::Function *function;