compiler, runtime: optimize zero-sized allocations

Instead of referring to an unused global, use a constant value. This is
safe even when using `-gc=none` (since no actual memory gets allocated)
which wasn't the case before. It should also reduce binary size by a few
bytes for most programs.
This commit is contained in:
Ayke van Laethem
2026-05-25 18:55:36 +02:00
committed by Ron Evans
parent 221ea6a54c
commit 134de98ba5
18 changed files with 63 additions and 12 deletions
+2
View File
@@ -9,6 +9,8 @@ const GOARCH = "arm" // avr pretends to be arm
// The bitness of the CPU (e.g. 8, 32, 64).
const TargetBits = 8
const zeroSizeAllocPtr uintptr = 16 // points into the register file or I/O sapce (which is memory mapped but shouldn't be accessed directly)
const deferExtraRegs = 1 // the frame pointer (Y register) also needs to be stored
const callInstSize = 2 // "call" is 4 bytes, "rcall" is 2 bytes