Skip to content

comp.ts sheds 1,012 tokens: tighter comments and four small simplifications - #1786

Merged
nicolas-abril merged 1 commit into
mainfrom
comp-simplify
Oct 20, 2026
Merged

nicolas-abril merged 1 commit into
mainfrom
comp-simplify

Conversation

@Lorenzobattistela

Copy link
Copy Markdown
Collaborator

comp.ts goes from 65,931 to 64,919 ttok, out of its 66,000 cap. That frees 1,012 tokens without changing what the compiler emits.

Comments (about −920 ttok)

32 long comment blocks are tightened. Each keeps its facts and drops narration, restatement of the code beneath it, and benchmark anecdotes:

One term_drop comment line also comes back under 80 columns.

Code (about −94 ttok)

  • f32_text builds the decimal form in one loop over the digit places, with a point before place −1. This replaces three memmove/memset cases (ex < 0, ex < p, else). The scientific branch now returns directly.
    • Old and new give the same text and length for all 2^32 f32 bit patterns, checked in a C harness.
    • p never reaches 9, so char d[9] cannot overflow.
  • bend_dev: CUDA's early turn_groups return moves into the CUDA #else branch. The back-to-back #endif / #ifndef __METAL_VERSION__ pair goes. The text after preprocessing is the same on Metal, CUDA and the host.
  • JS io_run requeues a step that has run 64 effects through io_push(op.kont, x, false, io), the helper io_wait already uses. Before, it mutated and re-pushed s.
  • term_open and open_of return a named type Open, replacing the literal type written three times. emit_native reads f.h, which is always fun_of(k).h.

Two changes were left out because #1576's review restored them: dropping the trailing #undef WL_X, and emit_jump's seg_ref.

Same output as main

All 1,773 programs under tests/, bench/ and demos/ were built to .c, .js and .mjs with main's comp.ts and with this one:

  • .mjs and build messages: byte-identical, including every expected build error.
  • .c and .js: they differ only in comment lines and the three runtime edits above. The compiler's own output (tables, spins, segments, JS program text) is byte-identical.

Gates (on main 257f896)

  • repo 54/54
  • test 1688/1688
  • ping 63/63
  • perf 123/124 on two branch runs, against 123/124 for main run between them. The one failing cell, mandelbrot SEQ-CPU at about 1.33x, fails on main too. Geomeans per column match main within noise.

🤖 Generated with Claude Code

…ations

- f32_text writes a decimal in one loop over its places instead of three
  memmove cases (identical text for all 2^32 bit patterns)
- bend_dev's CUDA early return joins its #else branch
- JS io_run requeues through io_push
- term_open's type is a named Open; emit_native reads f.h
- long comments keep their facts, drop narration and benchmark tales

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@nicolas-abril
nicolas-abril merged commit 642d8e1 into main Oct 20, 2026
1 check passed
nicolas-abril added a commit to nicolas-abril/bend that referenced this pull request Oct 20, 2026
…s print through Bend

The 68 commits of bendlang#1601 (ai/1601-prerebase, 053163d) squashed onto
642d8e1; bendlang#1786's comment and code cuts kept where they overlap.
@Lorenzobattistela
Lorenzobattistela deleted the comp-simplify branch October 20, 2026 13:04
nicolas-abril added a commit to nicolas-abril/bend that referenced this pull request Oct 20, 2026
…s print through Bend

The 68 commits of bendlang#1601 (ai/1601-prerebase, 053163d) squashed onto
642d8e1; bendlang#1786's comment and code cuts kept where they overlap.
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