aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4bytecodehandler_p.h
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2018-08-20 12:20:28 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2018-08-20 11:50:15 +0000
commite47bd1fc0e6fc2b2e3ca82c48ccb2f8f7dd5ee92 (patch)
treea5c98155ca381ebee6fe4f7c455f9b3dac73c604 /src/qml/compiler/qv4bytecodehandler_p.h
parent87a4d4babe0a3d6b8a57048205eccc7105931474 (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/compiler/qv4bytecodehandler_p.h')
-rw-r--r--src/qml/compiler/qv4bytecodehandler_p.h6
1 files changed, 4 insertions, 2 deletions
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