Skip to content

Fix PPC64 JIT conditional branch offset overflow for large QVM files#387

Closed
runlevel5 wants to merge 1 commit intoec-:mainfrom
runlevel5:fix/vm-powerpc-branch-offset
Closed

Fix PPC64 JIT conditional branch offset overflow for large QVM files#387
runlevel5 wants to merge 1 commit intoec-:mainfrom
runlevel5:fix/vm-powerpc-branch-offset

Conversation

@runlevel5
Copy link
Copy Markdown
Contributor

No description provided.

emit_branchConditionalShort() used PPC_BC which only supports 16-bit
signed offsets (±32KB). Large QVM files like cgame.qvm have branch
targets exceeding this limit, causing 'offset is too large' errors.

Replace with long-form pattern: inverted conditional branch (+8) to
skip over an unconditional branch (26-bit offset, ±128MB range).
This ensures consistent code size across compilation passes and
works for any QVM size on both ppc64le and ppc64.
@ec-
Copy link
Copy Markdown
Owner

ec- commented Mar 31, 2026

Could you send me such large qvms?

@runlevel5
Copy link
Copy Markdown
Contributor Author

@ec- this issue would impact pretty much all standard map, ./quake3e.ppc64le +map q3dm1 for example.

-----------------------------------
loaded skill 5 from bots/default_c.c
loaded skill 5 from bots/crash_c.c
loaded bots/crash_i.c
loaded bots/crash_w.c
loaded crash from bots/crash_t.c
RE_Shutdown( 0 )
----- R_Init -----
GAMMA: software w/ 0 overbright bits
texturemode: GL_LINEAR_MIPMAP_LINEAR
texture bits: 32
picmip: 1
Initializing Shaders
----- finished R_Init -----
Loading vm file vm/ui.qvm...
VM file ui compiled to 547600 bytes of code (dataMask=0xfffff stackBottom=487960 programStack=1048576)
ui loaded in 1689600 bytes on the hunk
35 arenas parsed
32 bots parsed
Loading vm file vm/cgame.qvm...
********************
ERROR: emit_branchConditionalShort: offset is too large
********************
----- Server Shutdown (Server crashed: emit_branchConditionalShort: offset is too large) -----
==== ShutdownGame ====
AAS shutdown.

when I submitted the PPC64 JIT patch then, I missed this issue because I was testing with replays/demos in automated fashion only.

@ec-
Copy link
Copy Markdown
Owner

ec- commented Apr 1, 2026

So this is with stock 1.32b gamecode?
This PR defeats the purpose, I'll implement multi-pass expansion to handle that

@ec-
Copy link
Copy Markdown
Owner

ec- commented Apr 2, 2026

@runlevel5
this should be fixed with 65560d7

@ec- ec- closed this Apr 16, 2026
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