diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2018-08-20 12:20:28 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2018-08-20 11:50:15 +0000 |
commit | e47bd1fc0e6fc2b2e3ca82c48ccb2f8f7dd5ee92 (patch) | |
tree | a5c98155ca381ebee6fe4f7c455f9b3dac73c604 /src/qml/jit | |
parent | 87a4d4babe0a3d6b8a57048205eccc7105931474 (diff) |
V4: clarify current vs. next instruction offset in ByteCodeHandler
When executing an interpreter instruction, the code pointer points to
the next instruction. However, sometimes a pointer to the current
instruction is needed. That was hacked-around by having startInstruction
be called before updating the pointer. This is confusing and leads to
unexpected off-by-one-instruction cases.
So now during startInstruction calls and generate_instructionName calls,
there is a currentInstructionOffset() and a nextInstructionOffset() that
do what's on the tin in both places.
Change-Id: Ie8dd35ff0a7d236f008030ef4c29ec3f31c07349
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jit')
-rw-r--r-- | src/qml/jit/qv4baselinejit.cpp | 18 | ||||
-rw-r--r-- | src/qml/jit/qv4baselinejit_p.h | 5 |
2 files changed, 13 insertions, 10 deletions
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; |