From e47bd1fc0e6fc2b2e3ca82c48ccb2f8f7dd5ee92 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Mon, 20 Aug 2018 12:20:28 +0200 Subject: 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 --- src/qml/jit/qv4baselinejit_p.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/qml/jit/qv4baselinejit_p.h') 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; -- cgit v1.2.3