Repository navigation
Map and Set under -mm=own; size after delete - #39
Merged
Merged
Conversation
…s deleted entries out lib.generics.ts is compiled into each program, and none of Map and Set compiled under -mm=own. With the compiler's own-generator-this-borrows branch they do for number, boolean and string keys and values: - @borrows("this") on the iterators and their forwarders; the iterators read the entries through `this` at each step instead of keeping the array in their state. - forEach is a loop over the entries, not over iter(). - resizeHelper grows the entries array in place instead of moving each entry into a new one. - An entry is stored as a tuple cast to the entry type, in one place after the search loop; Set's overwrite branch was dead and is gone. - hashCodeGeneral hashes the parameter's own bytes instead of a local copy. Bug fix, every model: size was count, which still counts the deleted entries on the free list (`m.delete(k)` left `m.size` unchanged). 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>
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.
Depends on ASDAlexander77/TypeScriptCompiler#693 (merge that first): under
-mm=ownthese changes need its analysis. Under gc, rc and none they work with the current compiler too.Makes
MapandSetinsrc/generics/lib.generics.tscompile under-mm=ownfor number, boolean and string keys and values:@borrows("this")on the iterators (iter,iterKey,iterValue) and their forwarders (entries,keys,values,[Symbol.iterator]). The iterators readthis._entries[i]at each step instead of keeping the array in their state.forEachis a loop over the entries, not overiter().resizeHelpergrows_entriesin place instead of moving each entry into a new array.hashCodeGeneralhashes the parameter's own bytes (Ref(key)) instead of a local copy.Bug fix, every model:
sizereturnedcount, which still counts deleted entries on the free list, som.delete(k)leftm.sizeunchanged. New testtests/map_size_delete.ts.Tests (AOT release, compiler from #693): own 80 → 87 passing, no regressions (
map_delete,map_get,map_get_number,map_has,map_set,map_set_overwrite,map_values_reducenow pass); gc 167/167; rc 166/167 (weakref_basic, gc-only). Still failing under own: Map/Set withanyelements, including untypednew Map()/new Set([1, 2])(see the compiler PR's notes). Debug and JIT passes not run.🤖 Generated with Claude Code