Skip to content

Fix printing of yk locations.#2

Merged
ltratt merged 1 commit intoykjit:masterfrom
vext01:fix-bc-printer
Mar 5, 2026
Merged

Fix printing of yk locations.#2
ltratt merged 1 commit intoykjit:masterfrom
vext01:fix-bc-printer

Conversation

@vext01
Copy link

@vext01 vext01 commented Mar 5, 2026

I suspected we were mis-placing locations. We weren't. We were printing them incorrectly in the bytecode dump.

Before/after of bytecode dump of a simple test program:

 ...
 03        JUMP 13
-05        DUP_TOP
+05 ykloc: DUP_TOP
 06        STORE_FAST 1
 07        LOAD_FAST 0
 08        LOAD_FAST 1
 09        BINARY_OP 14 __iadd__
 10        STORE_FAST 0
 11        LOAD_CONST_SMALL_INT 1
-12 ykloc: BINARY_OP 14 __iadd__
+12        BINARY_OP 14 __iadd__
 13        DUP_TOP
 14        LOAD_CONST_SMALL_INT 100000
 18        BINARY_OP 0 __lt__
 19        POP_JUMP_IF_TRUE 5
 ...

Note POP_JUMP_IF_TRUE 5 means "jump to bytecode offset 5 if true".

Although it appears as an absolute jump in the dump, in-memory is stored as an ip-relative back-jump.

I suspected we were mis-placing locations. We weren't. We were printing
them incorrectly in the bytecode dump.

Before/after of bytecode dump of a simple test program:
```diff
 ...
 03        JUMP 13
-05        DUP_TOP
+05 ykloc: DUP_TOP
 06        STORE_FAST 1
 07        LOAD_FAST 0
 08        LOAD_FAST 1
 09        BINARY_OP 14 __iadd__
 10        STORE_FAST 0
 11        LOAD_CONST_SMALL_INT 1
-12 ykloc: BINARY_OP 14 __iadd__
+12        BINARY_OP 14 __iadd__
 13        DUP_TOP
 14        LOAD_CONST_SMALL_INT 100000
 18        BINARY_OP 0 __lt__
 19        POP_JUMP_IF_TRUE 5
 ...
```

Note `POP_JUMP_IF_TRUE 5` means "jump to bytecode offset 5 if true".

Although it appears as an absolute jump in the dump, in-memory is stored
as an ip-relative back-jump.
@ltratt ltratt added this pull request to the merge queue Mar 5, 2026
Merged via the queue into ykjit:master with commit 26732ac Mar 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants