Repository navigation
feat(javascript): the Generational Collection story, in 2D and 3D - #225
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds the optional snapshot extension the story needs: Snapshot.spaces, HeapObject.copyOf, the copied heap state (its slots give no references) and the scavenge GC phase, with shared helpers spaceOf, objectsInSpace, isSpaceFreed, originOf, copiesOf and getCopyTrails. Traces set none of them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The views draw a FROM-SPACE / TO-SPACE tag whenever a role is set, so beats 1, 2 and 10 carry no role. The spec's space table says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… story The shared 2D stack-and-heap view draws a heap split into spaces: one band per space with a header above its row, FROM-SPACE / TO-SPACE tags from the data, FREE on a space freed as a whole (no per-object RECLAIMED there), a COPIED tag, a dotted copy trail, #origin labels, and frames as roots during a scavenge. A snapshot without spaces lays out exactly as before (golden fixture recorded from the earlier stories). GenerationalCollectionStory follows the Garbage Collection story in its section, with the prose changes from the approved spec. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The enter animation ends at opacity 1 with fill-mode both, which overrode the opacity attribute on an object's group, so COPIED and collected objects were drawn at full strength. The fade now sits on an inner group. A heap split into spaces gets a narrower stack (190), a 212-unit column pitch and fixed 132-unit rows: the drawing is 900x586 instead of 1014x760, so 12-unit labels are drawn at about 11.3px on a 1280px page. Snapshots without spaces lay out as before (fixture test). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shared 3D stack-and-heap view draws the generational collection story: one floor slab per space with its caption (FROM-SPACE / TO-SPACE / FREE), copied objects half faded with a COPIED line, no per-object RECLAIMED in a freed space, a dotted copy trail with a one-beat glide (none with reduced motion), #origin labels, and frames as roots during a scavenge. A stack arc to a first-column object behind another lands on its stack-facing side. A snapshot without spaces lays out exactly as before (fixture test). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Generational Collection story, from the approved spec
docs/stories/javascript/generational-collection.md, in 2D and 3D. It sits in the Garbage Collection section, after the Garbage Collection story.What it shows
cache = { calls: 0 }andbatch()run twice. Each run makes temporary objects that die young. A minor collection copiescachefrom semi-space A to semi-space B and updates the reference to point at the copy. All of A is then freed in one step, without visiting the dead objects (the aha, beat 6: a collection costs what survives, not what died). The spaces swap roles, and a second collection promotescacheto the old generation. 10 beats.Changes
Snapshot.spaces,HeapObject.copyOf, acopiedstate and ascavengephase, plus helpers (spaceOf,isSpaceFreed,originOf,getCopyTrails…). A test traces the story's program and checks none of them appear.spaceslay out exactly as before in both views.collectedobjects never faded. They now do, in the Garbage Collection story too.beat-modelskill: a moved object is drawn as a copy, never as an object changing cell.Validation
npx tsc -b, lint,npm run test:run(1,505 tests in 106 files), build,agents:check, and the lazy-chunk check all pass.Known
#draftat 800px wide on beats 1, 2, 7 and 9. This was already the case before this PR.🤖 Generated with Claude Code