Repository navigation
Toward an own default library: @nodrops C declarations, @final classes, five rewrites - #36
Merged
Merged
Conversation
… and five rewrites lib.ts compiled under -mm=own had 62 errors; with the compiler's @nodrops support and fixes (TypeScriptCompiler branch own-nodrops-declarations) and these changes, 14 remain, all waiting on two compiler decisions (an exported class's methods may be overridden in another module; an exported function cannot keep a parameter). - Every C function declaration (lib.native.d.ts, lib.win32.ts, lib.linux.ts) is `@nodrops`: it destroys nothing the program owns, so a borrow of a field may be lent to a function that calls it. Not the GC_* ones, which can run finalizers. - ArrayBuffer.slice copies the bytes, as JavaScript's does, instead of a view sharing them; transfer copies too, and [Symbol.dispose] no longer deletes (the assignment releases under rc and own, the collector frees under gc). - MatchResults.indices makes a new MatchIndicesResults each time instead of caching one in a field it could only lend out. - Headers' constructor gives set copies of the caller's strings. - HashHelpers.hashCodeAny takes the address of its parameter, not of a local copy. Release gc and rc builds pass tests.ps1 (release compile and JIT). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Boolean, Number, BigInt, Date, MatchIndicesResults, MatchResults, RegExp, String, Headers and Response are @Final in lib.ts and lib.d.ts (ArrayBuffer in lib.ts only: it has no declaration). Calls on them are direct (TypeScriptCompiler branch own-final-classes), so -mm=own knows their facts: lib.ts under own goes from 14 errors to 5 (release; 17 to 7 with --di), all of them matchAll, String[Symbol.iterator] and Response.constructor, which keep or borrow a parameter of an exported function. The Headers constructor still copies the caller's strings, with its comment corrected: set is a direct call now, but it may overwrite an element of this.values. Release gc and rc builds pass tests.ps1 (compile and JIT). 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.
Toward a default library built under
-mm=own. It needs the compiler's@nodropsand@finalsupport from ASDAlexander77/TypeScriptCompiler#611. A tslang without it ignores unknown decorators, but builds this library under gc and rc the way it did before.lib.tsunder-mm=owngoes from 62 errors to 5 (release; 7 with--di). The 5 left are inmatchAll,String[Symbol.iterator]andResponse.constructor. Those are exported functions that keep or borrow a parameter, which needs a separate compiler decision. Own stays out ofbuild.bat/build.shuntillib.tscompiles under own with no errors.@nodropson every C function declaration (lib.native.d.ts,lib.win32.ts,lib.linux.ts), except theGC_*ones, which can run finalizers.@finalonBoolean,Number,BigInt,Date,MatchIndicesResults,MatchResults,RegExp,String,HeadersandResponse, inlib.tsandlib.d.ts.ArrayBufferis marked inlib.tsonly, because it has no declaration.ArrayBuffer:slicecopies the bytes, as JavaScript's does, instead of a view that shares them.transfercopies too.[Symbol.dispose]no longerdeletes: the assignment releases the bytes under rc and own, and the collector frees them under gc.MatchResults.indicesmakes a newMatchIndicesResultseach time instead of caching one in a field.Headers' constructor givessetcopies of the caller's strings, becausesetmay overwrite an element ofthis.values.HashHelpers.hashCodeAnytakes the address of its parameter rather than of a local copy.Release gc and rc builds pass
tests.ps1, compiled and JIT: gc 167/167, rc 166/167 with 1 gc-only test skipped.🤖 Generated with Claude Code