2 Commits

Author SHA1 Message Date
01adf80751 Rework the megademo to fit the 80-column source line limit
Some checks failed
akbasic CI Build / cmake_build (push) Failing after 3m29s
akbasic CI Build / coverage (push) Failing after 3m58s
akbasic CI Build / sanitizers (push) Failing after 4m36s
akbasic CI Build / mutation_test (push) Failing after 3m52s
akbasic CI Build / akgl_build (push) Failing after 7m29s
AKBASIC_MAX_LINE_LENGTH's cut from 256 to 80 left seventeen lines of
examples/megademo unloadable: the sixteen IM$() picture strings (up to
252 characters) and TUNEA/TUNEB's four-bar PLAY strings (174 and 175).
The real ceiling is 78 characters, not 80 -- stdio_readline() refuses a
read that fills the 80-byte buffer without a newline, so content plus
its terminator must fit in 79.

The picture: vaporwave.py's PAYLOAD drops from 240 to 64, so every
emitted IM$(NN) = "..." line fits under the ceiling. chop() no longer
slices blind; it walks the stream a record at a time -- two characters
for a run, three for an R row record -- and never cuts inside one,
because the decoder reads a record's tail with MID on the string it is
walking and a record straddling two IM$ entries decodes as garbage.
The old blind slice at 240 only happened to be safe. verify() now
simulates the CHOPPED strings with the cursor threaded across the
boundaries exactly the way DRAWSTREAM executes them, so a bad cut is
an assertion failure instead of a corrupted screen, and emit_block()
asserts every emitted line fits. The picture is 56 strings where it
was 16; the decoder needed no changes at all, since it already carries
X#/Y# from one IM$ entry to the next.

The music: TUNEA and TUNEB each become four PLAY statements, one bar
apiece. play.c keeps voice, envelope, level and duration state on the
runtime across statements and every PLAY appends to the same queue, so
four bars queue exactly as one long string did. Each bar restates the
V1T3U9S prefix so a bar dropped by QFULL cannot leave the next batch
playing on the drum kit's envelope.

Everything still clears the shrunken pools with room to spare: 1625
source lines of 2048, ~704 array slots of 2048, identifiers within the
24-character symtab key. Verified end to end against this branch's
build: the demo loads, the offscreen host renders every scene, and the
scene-5 still is pixel-identical to vaporwave.py's own preview. The
test suite fails the same seventeen cases with and without this
commit.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ACffnV6F7sxQuG3Y8a1L3s
2026-08-03 22:57:57 -04:00
17af2d406c Cut akbasic_Runtime's static footprint from 10.75 MiB to 2.40 MiB
Some checks failed
akbasic CI Build / cmake_build (push) Failing after 3m29s
akbasic CI Build / coverage (push) Failing after 3m40s
akbasic CI Build / sanitizers (push) Failing after 4m37s
akbasic CI Build / mutation_test (push) Failing after 3m35s
akbasic CI Build / akgl_build (push) Failing after 7m20s
Nothing in this interpreter mallocs; every pool is a fixed array sized by an
AKBASIC_MAX_* constant, so sizeof(akbasic_Runtime) is a compile-time number
and most of it was headroom nobody was using. Measured concurrent-use
high-water marks off examples/breakout and examples/megademo -- the two most
demanding programs this interpreter runs -- against each pool's ceiling:

  AKBASIC_MAX_ENVIRONMENTS   32 -> 12    (measured peak concurrency: 6-7)
  AKBASIC_MAX_FUNCTIONS      64 -> 8     (measured: 0, neither program uses DEF FN)
  AKBASIC_MAX_ARRAY_VALUES 4096 -> 2048  (measured peak: 1618 slots)
  AKBASIC_MAX_SOURCE_LINES 9999 -> 2048  (measured: ~1270-1496 non-blank lines)
  AKBASIC_SYMTAB_MAX_SLOTS  256 -> 172   (no caller ever requests more than 128)
  AKBASIC_SYMTAB_MAX_KEY     64 -> 24    (longest identifier measured: 11 chars)
  AKBASIC_MAX_LINE_LENGTH   256 -> 80    (Commodore BASIC's own line limit)

AKBASIC_MAX_VARIABLES (128) is untouched on purpose: breakout alone reaches
121 of 128 concurrent named variables, so it has the least slack of any pool
measured and is not a shrink candidate.

akbasic_Variable.name shrinks from AKBASIC_MAX_STRING_LENGTH (256) to
AKBASIC_SYMTAB_MAX_KEY: every variable name is registered with
akbasic_symtab_set() right after this field is populated
(akbasic_environment_create(), src/environment.c), and that call already
refuses anything AKBASIC_SYMTAB_MAX_KEY characters or longer. The wider field
was headroom nothing could ever put a byte into.

Two defects surfaced while testing the line-length drop against the golden
corpus, both fixed here because the 80-byte ceiling makes them routine rather
than theoretical:

- sourcepath (runtime.h) was borrowing AKBASIC_MAX_LINE_LENGTH by accident.
  It holds a directory, not a line of BASIC, and this checkout's own test
  paths are 81+ characters deep -- every golden test failed to load until
  this split into its own AKBASIC_MAX_SOURCE_PATH_LENGTH, backed by PATH_MAX
  the way libakerror already sizes its own path buffers.

- src/sink_stdio.c's stdio_readline() called aksl_fgets() but never checked
  its own documented contract: a full buffer with no trailing newline means
  the line was longer than the buffer, and the unread remainder is still in
  the stream. Unchecked, the next readline() picks that remainder up as its
  own statement -- a real line silently becomes two wrong ones instead of a
  clean AKBASIC_ERR_BOUNDS refusal. At 256 bytes this was theoretical; at 80
  it is not, so it now refuses loudly.

tests/value_pool.c's test_pool_is_untouched_by_scopes() was pinned to the old
4x1024=4096 pool math (four max-size arrays proving nothing leaked); rewritten
to 2x1024=2048 for the same proof against the new AKBASIC_MAX_ARRAY_VALUES.

Known consequence, tracked in andrew/akbasic#32 rather than worked around
here: two files in the protected tests/reference/ corpus
(language/functions/mod.bas, language/flowcontrol/nestedforloopwaitingfor
command.bas) have 82-character lines and cannot be shortened -- MAINTENANCE.md
and CMakeLists.txt:585 are explicit that tests/reference/ is never edited to
suit this interpreter. Twelve tests/language/ cases and one docs/18 line are
in the same position but are this project's own content. Shipping 80 anyway,
with the fallout tracked rather than hidden, was an explicit call on this PR
rather than something decided here.

Verified: cmake --build build-akgl && ctest --test-dir build-akgl, 97/112 (15
known failures, all AKBASIC_MAX_LINE_LENGTH-related, filed as #32).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Andrew Kesterson <andrew@aklabs.net>
2026-08-03 21:44:16 -04:00
10 changed files with 222 additions and 65 deletions

View File

@@ -56,7 +56,10 @@ This is a tour of the interpreter's edges, on purpose:
counterpoint: a genuine 24x21 `SPRSAV` type-in sprite, 63 bytes, which is counterpoint: a genuine 24x21 `SPRSAV` type-in sprite, 63 bytes, which is
everything `DATA` has room to say. The paint is the reveal, and the exit is a everything `DATA` has room to say. The paint is the reveal, and the exit is a
stride-63 column dissolve — 63 is coprime to 160, so the walk hits every stride-63 column dissolve — 63 is coprime to 160, so the walk hits every
column once and looks random while carrying no state. column once and looks random while carrying no state. The strings come in
64-character chunks because a source line is 80 columns, like the machines
this pretends to be — the decoder carries its cursor from one `IM$` entry to
the next, and the generator refuses to cut inside a run.
- **And then the picture is video.** Six delta frames loop the floor grid toward - **And then the picture is video.** Six delta frames loop the floor grid toward
you and crawl the sun's slice pattern — full motion video, 1.3 KB total, about you and crawl the sun's slice pattern — full motion video, 1.3 KB total, about
220 bytes a frame. A delta re-encodes only the rows that changed: an `R` 220 bytes a frame. A delta re-encodes only the rows that changed: an `R`
@@ -82,6 +85,10 @@ This is a tour of the interpreter's edges, on purpose:
batch a bar of noise drums. Noise is real: `ENVELOPE`'s sixth argument is a batch a bar of noise drums. Noise is real: `ENVELOPE`'s sixth argument is a
waveform, 0 to 3, which Chapter 7 forgot to mention. Voice 1 carries the tune so waveform, 0 to 3, which Chapter 7 forgot to mention. Voice 1 carries the tune so
the collision blips (voice 2) and scene sweeps (voice 3) never steal its channel. the collision blips (voice 2) and scene sweeps (voice 3) never steal its channel.
A batch is four `PLAY` statements, one bar each — the 80-column line limit will
not hold four bars in one string, and it does not need to: the parser's voice,
envelope and duration state persists across statements and every `PLAY` appends
to the same queue, so four bars queue exactly as one line would.
It also probes for its hardware like a proper boot loader, with one `TRAP` per It also probes for its hardware like a proper boot loader, with one `TRAP` per
device: no graphics refuses by name and exits, no audio mutes the soundtrack, no device: no graphics refuses by name and exits, no audio mutes the soundtrack, no

View File

@@ -461,38 +461,78 @@ BS% = W# / 160
IF BS% < 1 THEN BS% = 1 IF BS% < 1 THEN BS% = 1
REM ---- PICTURE-BEGIN (generated by vaporwave.py; do not REM ---- PICTURE-BEGIN (generated by vaporwave.py; do not
REM ---- hand-edit -- rerun the script to change the picture) REM ---- hand-edit -- rerun the script to change the picture)
DIM IM$(16) DIM IM$(56)
DIM VA#(6) DIM VA#(6)
DIM VB#(6) DIM VB#(6)
NS# = 9 NS# = 32
VA#(0) = 9 VA#(0) = 32
V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A9A9A9APRDCE9E9E9E9EP"
IM$(44) = "RBOQ9QNK3QHKWRBPQ9QOI9IWRBUQ9QTKHQHKPQHKNRBVQ9QOI9IWRB0Q9QQIKKH"
IM$(45) = "IPKHIHKDRB1Q9QQC9CSRB2Q9QRC9CQRB6Q9QTIPKHIYRB8Q9QVC9CIRCKA9A9A9"
IM$(46) = "A9APRCLE9E9E9E9EPRCQA9A9A9A9APRCRE9E9E9E9EPRCZA9A9A9A9APRC1E9E9"
IM$(47) = "E9E9EPRDCA9A9A9A9APRDFE9E9E9E9EP"
IM$(48) = "RBOQ9QNI9IYRBTQ9QOKEQHKPQHKVRBUQ9QTI9IRRBZQ9QTKHQHKPQHKHRB0Q9QQ"
IM$(49) = "C9CSRB5Q9QTIHKHI5KARB7Q9QUC9CKRCBQ9QYI9ICRCHA9A9A9A9APRCIE9E9E9"
IM$(50) = "E9EPRCLA9A9A9A9APRCME9E9E9E9EPRCRA9A9A9A9APRCTE9E9E9E9EPRC1A9A9"
IM$(51) = "A9A9APRC3E9E9E9E9EPRDFA9A9A9A9APRDIE9E9E9E9EP"
IM$(52) = "RBSQ9QTKPQHK3RBTQ9QOI9IWRBYQ9QPKDQHKPQHKHRBZQ9QTI9ILRB4Q9QSIAKH"
IM$(53) = "I5KHIBRB6Q9QTC9CMRCAQ9QXI9IERCEE9E9E9E9EPRCFA9A9A9A9APRCGE9E9E9"
IM$(54) = "E9EPRCMA9A9A9A9APRCNE9E9E9E9EPRCTA9A9A9A9APRCUE9E9E9E9EPRC3A9A9"
IM$(55) = "A9A9APRC5E9E9E9E9EPRDIA9A9A9A9AP"
REM ---- PICTURE-END REM ---- PICTURE-END
SS# = 0 SS# = 0
SE# = NS# - 1 SE# = NS# - 1
@@ -1317,13 +1357,25 @@ TB# = TB# + 1
IF TB# > 2 THEN TB# = 0 IF TB# > 2 THEN TB# = 0
RETURN RETURN
REM A batch is four PLAY statements, one bar each: the parser's V, T,
REM U and duration state persists across statements and every PLAY
REM appends to the same queue, so four bars queue exactly as one long
REM string would -- which the 80-column line limit no longer allows.
REM Each bar restates the prefix anyway, so a bar dropped by QFULL
REM never leaves the next one playing with drum-kit state.
LABEL TUNEA LABEL TUNEA
PLAY "V1T3U9S O1AO2AO3AO2AO3AO4CEAO1AO2AO4CEAO5CO4AE O1FO2FO3FO2FO3FAO4CFO1FO2FO3AO4CFAO5CO4A O1CO2CO3CO2CO3CEGO4CO1CO2CO3EGO4CEGO5C O1GO2GO3GO2GO3GBO4DGO1GO2GO3BO4DGBO5DO4B" PLAY "V1T3U9S O1AO2AO3AO2AO3AO4CEAO1AO2AO4CEAO5CO4AE"
PLAY "V1T3U9S O1FO2FO3FO2FO3FAO4CFO1FO2FO3AO4CFAO5CO4A"
PLAY "V1T3U9S O1CO2CO3CO2CO3CEGO4CO1CO2CO3EGO4CEGO5C"
PLAY "V1T3U9S O1GO2GO3GO2GO3GBO4DGO1GO2GO3BO4DGBO5DO4B"
MT# = TI# + 270 MT# = TI# + 270
RETURN RETURN
LABEL TUNEB LABEL TUNEB
PLAY "V1T3U9S O1AO2AO3AO2AO3AO4CEAO1AO2AO4CEAO5CEO4A O1FO2FO3FO2FO3FAO4CFO1FO2FO3AO4CFAO5CO4A O1DO2DO3DO2DO3DFAO4DO1DO2DO3FAO4DFAO5D O1EO2EO3EO2EO3E#GBO4EO1EO2EO3#GBO4E#GBO5E" PLAY "V1T3U9S O1AO2AO3AO2AO3AO4CEAO1AO2AO4CEAO5CEO4A"
PLAY "V1T3U9S O1FO2FO3FO2FO3FAO4CFO1FO2FO3AO4CFAO5CO4A"
PLAY "V1T3U9S O1DO2DO3DO2DO3DFAO4DO1DO2DO3FAO4DFAO5D"
PLAY "V1T3U9S O1EO2EO3EO2EO3E#GBO4EO1EO2EO3#GBO4E#GBO5E"
MT# = TI# + 270 MT# = TI# + 270
RETURN RETURN

View File

@@ -58,7 +58,14 @@ SKIP = "Q"
ROWREC = "R" ROWREC = "R"
LENCH = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" LENCH = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
MAXRUN = len(LENCH) MAXRUN = len(LENCH)
PAYLOAD = 240
# The interpreter reads source through an 80-byte line buffer and refuses
# any line that fills it (AKBASIC_MAX_LINE_LENGTH, sink_stdio.c), so a
# stored line is at most 78 characters plus its newline. 'IM$(NN) = "' and
# the closing quote spend 12 of those; 64 keeps the emitted lines under
# the ceiling with margin to spare while the index stays two digits.
PAYLOAD = 64
MAXLINE = 78
SUN_CX, SUN_CY, SUN_R = 80, 50, 30 SUN_CX, SUN_CY, SUN_R = 80, 50, 30
HORIZON = 74 HORIZON = 74
@@ -206,13 +213,32 @@ def encode_delta(prev, cur):
def chop(blob): def chop(blob):
return [blob[i:i + PAYLOAD] for i in range(0, len(blob), PAYLOAD)] """Split a stream into strings of at most PAYLOAD characters, cutting
only between records. The decoder reads a record's tail characters
with MID on the string it is walking, so a run (two characters) or a
row record (three) that straddled two IM$ entries would decode as
garbage; DRAWSTREAM only carries the cursor, never a partial record."""
out, cur = [], ""
p = 0
while p < len(blob):
n = 3 if blob[p] == ROWREC else 2
if len(cur) + n > PAYLOAD:
out.append(cur)
cur = ""
cur += blob[p:p + n]
p += n
if cur:
out.append(cur)
return out
def simulate(raster, blob): def simulate(raster, blob, x=0, y=0):
"""Apply one encoded stream to a raster exactly the way the BASIC """Apply one encoded stream to a raster exactly the way the BASIC
decoder does, skips-draw-nothing and all.""" decoder does, skips-draw-nothing and all. The cursor comes in and
x = y = p = 0 goes back out because DRAWSTREAM carries it from one IM$ entry to
the next -- decoding the chopped strings one at a time with the
cursor threaded through is exactly what the demo will execute."""
p = 0
while p < len(blob): while p < len(blob):
c = blob[p] c = blob[p]
if c == ROWREC: if c == ROWREC:
@@ -230,20 +256,31 @@ def simulate(raster, blob):
x = 0 x = 0
y += 1 y += 1
p += 2 p += 2
return raster, x, y
def simulate_lines(raster, lines):
"""One stream as its chopped strings, cursor carried across the
boundaries the way DRAWSTREAM carries X# and Y#."""
x = y = 0
for line in lines:
raster, x, y = simulate(raster, line, x, y)
return raster return raster
def verify(frames, base_blob, delta_blobs): def verify(frames, base_lines, delta_line_groups):
"""The base must reproduce frame 0 exactly, and each delta must """The base must reproduce frame 0 exactly, and each delta must
carry the raster exactly to the next frame. A skip leaves the cell carry the raster exactly to the next frame. A skip leaves the cell
the encoder promised was already right, so equality is total and the encoder promised was already right, so equality is total and
any difference at all is an encoder bug.""" any difference at all is an encoder bug. This decodes the CHOPPED
strings, not the blobs, so a chop that split a record would fail
here instead of corrupting the screen."""
raster = [[1] * W for _ in range(H)] raster = [[1] * W for _ in range(H)]
raster = simulate(raster, base_blob) raster = simulate_lines(raster, base_lines)
assert raster == frames[0], "base stream does not reproduce frame 0" assert raster == frames[0], "base stream does not reproduce frame 0"
for i, blob in enumerate(delta_blobs): for i, lines in enumerate(delta_line_groups):
want = frames[(i + 1) % PHASES] want = frames[(i + 1) % PHASES]
raster = simulate(raster, blob) raster = simulate_lines(raster, lines)
assert raster == want, "delta %d does not reproduce its frame" % i assert raster == want, "delta %d does not reproduce its frame" % i
@@ -261,6 +298,9 @@ def emit_block(base_lines, delta_ranges, all_lines):
for i, s in enumerate(all_lines): for i, s in enumerate(all_lines):
out.append('IM$(%d) = "%s"' % (i, s)) out.append('IM$(%d) = "%s"' % (i, s))
out.append("REM ---- PICTURE-END") out.append("REM ---- PICTURE-END")
for line in out:
assert len(line) <= MAXLINE, "emitted line over %d chars: %r" % (
MAXLINE, line)
return out return out
@@ -303,15 +343,15 @@ def main():
base_lines = chop(base_blob) base_lines = chop(base_blob)
all_lines = list(base_lines) all_lines = list(base_lines)
delta_ranges = [] delta_ranges = []
delta_blobs = [] delta_line_groups = []
for i in range(PHASES): for i in range(PHASES):
blob = encode_delta(frames[i], frames[(i + 1) % PHASES]) blob = encode_delta(frames[i], frames[(i + 1) % PHASES])
delta_blobs.append(blob)
lines = chop(blob) lines = chop(blob)
delta_line_groups.append(lines)
delta_ranges.append((len(all_lines), len(all_lines) + len(lines) - 1)) delta_ranges.append((len(all_lines), len(all_lines) + len(lines) - 1))
all_lines.extend(lines) all_lines.extend(lines)
verify(frames, base_blob, delta_blobs) verify(frames, base_lines, delta_line_groups)
dbytes = sum(len(b) for b in delta_blobs) dbytes = sum(len(l) for g in delta_line_groups for l in g)
print("base %d bytes in %d strings; video %d bytes in %d strings; " print("base %d bytes in %d strings; video %d bytes in %d strings; "
"%d strings total" % "%d strings total" %
(sum(len(s) for s in base_lines), len(base_lines), dbytes, (sum(len(s) for s in base_lines), len(base_lines), dbytes,

View File

@@ -211,8 +211,12 @@ typedef struct akbasic_Runtime
* not exist relative to the working directory, which is what makes a `.bas` * not exist relative to the working directory, which is what makes a `.bas`
* beside its art work from anywhere. Group F's disk verbs will want the * beside its art work from anywhere. Group F's disk verbs will want the
* same, which is why it is on the runtime rather than in the sprite state. * same, which is why it is on the runtime rather than in the sprite state.
*
* Sized to AKBASIC_MAX_SOURCE_PATH_LENGTH, not AKBASIC_MAX_LINE_LENGTH: a
* directory is a filesystem path, not a line of BASIC, and the two do not
* belong to the same budget.
*/ */
char sourcepath[AKBASIC_MAX_LINE_LENGTH]; char sourcepath[AKBASIC_MAX_SOURCE_PATH_LENGTH];
/* /*
* The armed interrupts, and the environment the one currently running was * The armed interrupts, and the environment the one currently running was
@@ -365,7 +369,7 @@ akerr_ErrorContext AKERR_NOIGNORE *akbasic_runtime_set_ui(akbasic_Runtime *obj,
* @param path Path to the program file, or NULL for none. * @param path Path to the program file, or NULL for none.
* @return `NULL` on success, otherwise an error context owned by the caller. * @return `NULL` on success, otherwise an error context owned by the caller.
* @throws AKERR_NULLPOINTER When `obj` is NULL. * @throws AKERR_NULLPOINTER When `obj` is NULL.
* @throws AKBASIC_ERR_BOUNDS When the path is longer than AKBASIC_MAX_LINE_LENGTH. * @throws AKBASIC_ERR_BOUNDS When the path is longer than AKBASIC_MAX_SOURCE_PATH_LENGTH.
*/ */
akerr_ErrorContext AKERR_NOIGNORE *akbasic_runtime_set_source_path(akbasic_Runtime *obj, const char *path); akerr_ErrorContext AKERR_NOIGNORE *akbasic_runtime_set_source_path(akbasic_Runtime *obj, const char *path);

View File

@@ -23,9 +23,17 @@
* serves variables, functions and labels. Capacity is a member; the table is * serves variables, functions and labels. Capacity is a member; the table is
* kept below a 75% load factor by construction because `capacity` counts slots * kept below a 75% load factor by construction because `capacity` counts slots
* and the caller's logical maximum is smaller. * and the caller's logical maximum is smaller.
*
* 172 rather than the old 256: no caller passes akbasic_symtab_init() anything
* larger than AKBASIC_MAX_VARIABLES (128), and 172 keeps that under the 75%
* load factor the comment above promises (128 / 0.75 = 170.7).
*
* AKBASIC_SYMTAB_MAX_KEY 24 rather than 64: the longest identifier across
* examples/breakout and examples/megademo -- variables, DIMmed arrays, labels
* and DEF FN names alike -- is 11 characters (TITLESCREEN, CLEARPOWERS).
*/ */
#define AKBASIC_SYMTAB_MAX_SLOTS 256 #define AKBASIC_SYMTAB_MAX_SLOTS 172
#define AKBASIC_SYMTAB_MAX_KEY 64 #define AKBASIC_SYMTAB_MAX_KEY 24
typedef struct typedef struct
{ {

View File

@@ -6,6 +6,7 @@
#ifndef _AKBASIC_TYPES_H_ #ifndef _AKBASIC_TYPES_H_
#define _AKBASIC_TYPES_H_ #define _AKBASIC_TYPES_H_
#include <limits.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
@@ -27,15 +28,39 @@
#define AKBASIC_MAX_VALUES 64 #define AKBASIC_MAX_VALUES 64
#define AKBASIC_MAX_VARIABLES 128 #define AKBASIC_MAX_VARIABLES 128
/* Whole-runtime pools */ /*
#define AKBASIC_MAX_SOURCE_LINES 9999 * Whole-runtime pools.
#define AKBASIC_MAX_LINE_LENGTH 256 *
* AKBASIC_MAX_SOURCE_LINES, AKBASIC_MAX_LINE_LENGTH, AKBASIC_MAX_ARRAY_VALUES,
* AKBASIC_MAX_ENVIRONMENTS and AKBASIC_MAX_FUNCTIONS were cut from their
* original values against measurements taken off examples/breakout and
* examples/megademo, the two most demanding programs this interpreter runs --
* see the memory-footprint discussion this commit's PR body links. Each is
* sized at roughly 1.5-2x the peak the reference corpus actually reaches, not
* at the peak itself.
*
* AKBASIC_MAX_LINE_LENGTH in particular follows Commodore BASIC's own 80-column
* line limit rather than a measurement, which is why sink_stdio.c now refuses a
* line that fills the buffer with no terminator instead of silently truncating
* it: at 256 bytes that failure mode was theoretical, and at 80 it is not.
*
* AKBASIC_MAX_SOURCE_PATH_LENGTH is its own constant rather than a reuse of
* AKBASIC_MAX_LINE_LENGTH, which is where it used to come from. `sourcepath`
* (runtime.h) holds a directory, not a line of BASIC, and the two ideas do not
* scale together: shrinking the line limit to 80 broke every golden test in
* this checkout, because this repository's own working directory is deeper
* than that. PATH_MAX is the actual bound a filesystem path is subject to, so
* it is the one this borrows.
*/
#define AKBASIC_MAX_SOURCE_LINES 2048
#define AKBASIC_MAX_LINE_LENGTH 80 /* Commodore BASIC's own line limit */
#define AKBASIC_MAX_SOURCE_PATH_LENGTH PATH_MAX
#define AKBASIC_MAX_ARRAY_DEPTH 64 /* dimensions per array */ #define AKBASIC_MAX_ARRAY_DEPTH 64 /* dimensions per array */
#define AKBASIC_MAX_ARRAY_ELEMENTS 1024 /* elements in one array */ #define AKBASIC_MAX_ARRAY_ELEMENTS 1024 /* elements in one array */
#define AKBASIC_MAX_ARRAY_VALUES 4096 /* array elements across all variables */ #define AKBASIC_MAX_ARRAY_VALUES 2048 /* array elements across all variables */
#define AKBASIC_MAX_STRING_LENGTH 256 /* see TODO.md 1.2 */ #define AKBASIC_MAX_STRING_LENGTH 256 /* see TODO.md 1.2 */
#define AKBASIC_MAX_ENVIRONMENTS 32 /* new: Go allocated these unbounded */ #define AKBASIC_MAX_ENVIRONMENTS 12 /* new: Go allocated these unbounded */
#define AKBASIC_MAX_FUNCTIONS 64 /* new: Go used an unbounded map */ #define AKBASIC_MAX_FUNCTIONS 8 /* new: Go used an unbounded map */
#define AKBASIC_MAX_LABELS 64 /* new: Go used an unbounded map */ #define AKBASIC_MAX_LABELS 64 /* new: Go used an unbounded map */
/* /*
* Leaves a DO/LOOP condition may use. Its own small pool rather than a second * Leaves a DO/LOOP condition may use. Its own small pool rather than a second

View File

@@ -13,12 +13,22 @@
#include <akerror.h> #include <akerror.h>
#include <akbasic/symtab.h>
#include <akbasic/types.h> #include <akbasic/types.h>
#include <akbasic/value.h> #include <akbasic/value.h>
typedef struct typedef struct
{ {
char name[AKBASIC_MAX_STRING_LENGTH]; /*
* Sized to AKBASIC_SYMTAB_MAX_KEY, not AKBASIC_MAX_STRING_LENGTH: this name
* only ever gets here by surviving akbasic_symtab_set() first
* (akbasic_environment_create() calls it right after this field is
* populated), and that call refuses anything AKBASIC_SYMTAB_MAX_KEY
* characters or longer with AKBASIC_ERR_BOUNDS. A variable whose name did
* not fit could never exist, so the wider buffer was 232 bytes of headroom
* nothing could ever put a byte into.
*/
char name[AKBASIC_SYMTAB_MAX_KEY];
akbasic_Type valuetype; akbasic_Type valuetype;
akbasic_Value *values; /** The pool, or `inlinevalue` for a scalar */ akbasic_Value *values; /** The pool, or `inlinevalue` for a scalar */
int valuecount; int valuecount;

View File

@@ -301,7 +301,7 @@ akerr_ErrorContext *akbasic_runtime_set_source_path(akbasic_Runtime *obj, const
} }
FAIL_ZERO_RETURN(errctx, (length < sizeof(obj->sourcepath)), AKBASIC_ERR_BOUNDS, FAIL_ZERO_RETURN(errctx, (length < sizeof(obj->sourcepath)), AKBASIC_ERR_BOUNDS,
"Program path of %zu characters exceeds the %d character limit", "Program path of %zu characters exceeds the %d character limit",
length, AKBASIC_MAX_LINE_LENGTH - 1); length, AKBASIC_MAX_SOURCE_PATH_LENGTH - 1);
PASS(errctx, aksl_memcpy(obj->sourcepath, path, length)); PASS(errctx, aksl_memcpy(obj->sourcepath, path, length));
obj->sourcepath[length] = '\0'; obj->sourcepath[length] = '\0';
SUCCEED_RETURN(errctx); SUCCEED_RETURN(errctx);

View File

@@ -74,6 +74,19 @@ static akerr_ErrorContext *stdio_readline(akbasic_TextSink *self, char *dest, si
if ( *eof ) { if ( *eof ) {
SUCCEED_RETURN(errctx); SUCCEED_RETURN(errctx);
} }
/*
* aksl_fgets(3)'s own contract: a full buffer with no trailing newline is
* how a caller spots a line longer than the buffer, because the rest of it
* is still sitting unread in the stream. Refusing here is what makes that
* true -- without it, the unread remainder is picked up by the *next*
* readline() as if it were its own statement, which does not fail, it just
* runs the wrong program. AKBASIC_MAX_LINE_LENGTH is small enough now that
* this is not a hypothetical: examples/breakout's own longest line used to
* clear the old 256-byte ceiling by more than half.
*/
FAIL_NONZERO_RETURN(errctx, (used == len - 1 && dest[used - 1] != '\n' && dest[used - 1] != '\r'),
AKBASIC_ERR_BOUNDS,
"Source line exceeds the %zu character limit", len - 1);
/* /*
* Strip the line terminator. The scanner treats \r and \n as end-of-line * Strip the line terminator. The scanner treats \r and \n as end-of-line
* anyway, but leaving them on would make a stored source line differ from * anyway, but leaving them on would make a stored source line differ from

View File

@@ -97,9 +97,9 @@ static void test_scoped_loop_counter_costs_nothing(void)
/** /**
* @brief The pool is genuinely untouched, not merely large enough. * @brief The pool is genuinely untouched, not merely large enough.
* *
* Two hundred scope entries and then the pool's *entire* width -- four arrays, * Two hundred scope entries and then the pool's *entire* width -- two arrays,
* because AKBASIC_MAX_ARRAY_ELEMENTS caps any one of them at 1024 while the pool * because AKBASIC_MAX_ARRAY_ELEMENTS caps any one of them at 1024 while the pool
* holds 4096. One leaked slot and the fourth `DIM` has nowhere to go, which * holds 2048. One leaked slot and the second `DIM` has nowhere to go, which
* makes this the sharpest of the three and by far the cheapest: the two above * makes this the sharpest of the three and by far the cheapest: the two above
* prove a program finishes, this proves nothing at all was spent. The long ones * prove a program finishes, this proves nothing at all was spent. The long ones
* stay because they are the shape the defect was found in. * stay because they are the shape the defect was found in.
@@ -111,10 +111,8 @@ static void test_pool_is_untouched_by_scopes(void)
"30 NEXT T#\n" "30 NEXT T#\n"
"40 DIM A#(1024)\n" "40 DIM A#(1024)\n"
"50 DIM B#(1024)\n" "50 DIM B#(1024)\n"
"60 DIM C#(1024)\n" "70 B#(1023) = 7\n"
"70 DIM D#(1024)\n" "90 PRINT B#(1023)\n"
"80 D#(1023) = 7\n"
"90 PRINT D#(1023)\n"
"100 END\n" "100 END\n"
"110 LABEL SUBA\n" "110 LABEL SUBA\n"
"120 LOC# = 1\n" "120 LOC# = 1\n"