Skip to content

Instantly share code, notes, and snippets.

View mattgodbolt's full-sized avatar
💭
Hacking on Compiler Explorer

Matt Godbolt mattgodbolt

💭
Hacking on Compiler Explorer
View GitHub Profile
@mattgodbolt
mattgodbolt / gist_readme.md
Last active August 30, 2026 20:50
jsbeeb#962 PAL twitter evidence frames

Frames for mattgodbolt/jsbeeb#962: jsbeeb PAL shader vs a real Master's decoded composite (Yie Ar Kung Fu II title).

@mattgodbolt
mattgodbolt / jsbeeb-trace-basic.json
Last active August 29, 2026 04:41
jsbeeb: Perfetto call traces from the #922 spike (Chrome JSON trace events, slices named by 6502 call address)
This file has been truncated, but you can view the full file.
@mattgodbolt
mattgodbolt / v8-minimal-repro.html
Created July 22, 2026 21:44
Repro for suspected chrome bug
<!doctype html>
<!--
Minimal repro for a suspected V8 optimizer bug in Chrome 150.
Pattern: a hot method fills a Float32Array; when full, it passes the array to
a callback that transfers its ArrayBuffer via MessagePort.postMessage
(detaching it), then immediately replaces it:
this.buffer = new Float32Array(bufferLength);
P%=&2000
FORN%=0TO2STEP2:[OPT N%
LDY #&10
LDX #0
LDA #0
.lp
STA &3000, X
INX
BNE lp
INC lp + 2
CLS
PRINT "**********************************"
PRINT "**********************************"
PRINT "** PLEASE ENTER THE NUCLEAR KEY **"
PRINT "**********************************"
PRINT "**********************************"
REPEAT
PRINT "Key ";
INPUT A$
PRINT "SORRY WRONG KEY!!!"
DIM b% 32
P% = b%
[OPT2
BRK
EQUB 42
EQUS "StackExchange"
EQUB 0
]
CALL b%
[pid 2066] openat(AT_FDCWD, "/opt", O_RDONLY|O_CLOEXEC|O_PATH|O_DIRECTORY) = 4
[pid 2066] name_to_handle_at(4, "wine-stable", {handle_bytes=128 => 8, handle_type=1, f_handle=0xab090400d0e41824}, [550], 0) = 0
[pid 2066] name_to_handle_at(4, "", {handle_bytes=128 => 144}, 0x7ffd319e2e54, AT_EMPTY_PATH) = -1 EOVERFLOW (Value too large for defined data type)
[pid 2066] name_to_handle_at(4, "", {handle_bytes=144}, 0x7ffd319e2e54, AT_EMPTY_PATH) = -1 EINVAL (Invalid argument)
utils = require('utils');
hw = utils.hexword;
hb = utils.hexbyte;
every = 0;
function spew(pc) {
console.log(`${processor.currentCycles} $${hw(pc)} A=${hb(processor.a)} X=${hb(processor.x)} Y=${hb(processor.y)}`);
// breakpoint every 100 instructions lest things go awry.
return ((++every % 100) === 0);
}
@mattgodbolt
mattgodbolt / render.asm
Created August 22, 2019 22:20
A bit of Red Dog: Superior Firepower's rendering system. SH4 Assembly, circa 1998
; All new, all-singing, all-dancing textured scape renderer!
.CPU SH4
.OUTPUT DBG=DWARF
.INCLUDE "..\RedDog.pre"
; Prototype: StripHeader *texturedStripRasteriserClipped
; (StripPos *v, StripEntry *strip, Uint32 nStrip, ModelContext *context);
; Register allocation:
temp: .REG R0 ; temporary register, R0 is most accessible
10P.CHR$158;CHR$145;CHR$255;CHR$146;CHR$147;CHR$148;CHR$149