Shape Number/%TypedArray% constructors and %TypedArray%.prototype; add [JsInstanceSlot]#2581
Merged
Merged
Conversation
- NumberConstructor: Number.parseInt / parseFloat are the same functions as the global parseInt / parseFloat (Jint's ClrFunction equality compares the underlying delegate). They wrap static delegates with no realm dependency, so — like RegExp exec — they become per-realm [JsProperty] ClrFunction instance slots created in the constructor. The hand-written SetProperty tail + ExtraCapacity are gone. - IntrinsicTypedArrayConstructor (%TypedArray%): clean (from/of + @@species symbol accessor); opts in directly. Benchmarks (BuiltinShapeBenchmark, default job, vs prior commit; EngineOnly control byte- identical at 13.70 KB): EngineInitConstructors (extended to touch Number/%TypedArray%) 50.51 -> 49.58 KB (-0.93 KB). Conformance: full Test262 0 new failures (only the pre-existing annexB RegExp-*-escape-BMP concurrent-load flakes). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018Fq5mF1QEwh2qDMD8vVwt3
…totype
Add a [JsInstanceSlot("name")] class-level attribute that reserves a per-realm own-property
slot (appended after all other own properties, matching a hand-written SetProperty tail) which
the host fills in Initialize via SetBuiltinSlotByName(name, descriptor). This expresses a
computed/lazy value the generator can't — specifically a cross-object alias.
Use it for %TypedArray%.prototype.toString, which per spec is the SAME function object as
%Array.prototype.toString% (a different-host alias resolved lazily per realm). This unblocks the
37-member IntrinsicTypedArrayPrototype (10 accessors, ~20 methods, @@iterator === values); its
ExtraCapacity + the raw _properties.AddDangerous("toString", ...) tail are gone. Resolution stays
lazy, so touching %TypedArray%.prototype does not force Array init.
Benchmarks (BuiltinShapeBenchmark, default job, vs prior commit; EngineOnly control byte-
identical at 13.70 KB): EngineInitPrototypes (extended to touch %TypedArray%.prototype)
84.83 -> 81.14 KB (-3.69 KB).
Conformance: full Test262 0 new failures (only the pre-existing annexB RegExp-*-escape-BMP
concurrent-load flakes); Jint.Tests.SourceGenerators 30/30 (snapshot updated for the attribute).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Fq5mF1QEwh2qDMD8vVwt3
This was referenced Jul 5, 2026
This was referenced Jul 13, 2026
This was referenced Jul 20, 2026
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.
Summary
Follow-up to #2580 — shapes three more built-in hosts, including the last big one, and adds a small reusable generator mechanism for host-computed properties.
Number.parseInt/parseFloatare the same functions as globalparseInt/parseFloat(Jint'sClrFunctionequality compares the underlying delegate). They wrap static delegates with no realm dependency, so — likeRegExp.prototype.execin Built-in shapes for prototypes and constructors: composable storage, accessors, aliases #2580 — they become per-realm[JsProperty]ClrFunctioninstance slots created in the constructor. Hand-writtenSetPropertytail +ExtraCapacitygone.%TypedArray%) — clean (from/of+@@species); opts in directly.[JsInstanceSlot("name")]— reserves a per-realm own-property slot (appended after all other own properties) that the host fills inInitializeviaSetBuiltinSlotByName(name, descriptor), for a computed/lazy value the generator can't express (specifically a cross-object alias).%TypedArray%.prototype, 37 members: 10 accessors, ~20 methods,@@iterator === values) — itstoStringis the same function object as%Array.prototype.toString%, a lazy cross-object alias, now expressed via[JsInstanceSlot]. Resolution stays lazy, so touching%TypedArray%.prototypedoesn't forceArrayinit.Benchmarks
Jint.Benchmark/BuiltinShapeBenchmark.cs, default job. Each commit A/B'd against a byte-identicalEngineOnlycontrol (13.70 KB); per-realmInitializeallocation removed:%TypedArray%constructorEngineInitConstructors50.51 → 49.58 KB (−0.93 KB)[JsInstanceSlot]+%TypedArray%.prototypeEngineInitPrototypes84.83 → 81.14 KB (−3.69 KB)Conformance
annexB RegExp-*-escape-BMPconcurrent-load timeout flakes).Remaining (deliberately on the dictionary path)
The TypedArray constructor hierarchy (
Uint8ArrayConstructorwould re-implementIBuiltinShapedwith only its own members, dropping the inheritedBYTES_PER_ELEMENTfrom the abstract base's shape — needs generator support for inherited[JsObject]members),RegExpConstructorlegacy statics, and the intrinsic-reference / thrower hosts (GlobalObject, Intl/Temporal instances,FunctionPrototype).🤖 Generated with Claude Code
https://claude.ai/code/session_018Fq5mF1QEwh2qDMD8vVwt3