From d7d73e1f33b5e22cd8cb21c3a8e40dac8f8f2f43 Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Mon, 29 Jun 2026 21:33:41 +0300 Subject: [PATCH] Built-in shapes default-on via base class (opt-out); shape Temporal.Now MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make built-in shape storage the default for any [JsObject] host that derives from BuiltinShapeObject — deriving from the base is now the opt-in, so a built-in adopts shapes with a one-line base change and no attribute flag. UseShape = false is the explicit opt-out; hosts that don't derive from BuiltinShapeObject keep the dictionary path regardless. - Generator auto-detects the base (walks the base-type chain) and uses the shape path by default for derived hosts. The UseShape attribute property now defaults to true and only means "opt this derived host back out" when set false. - New diagnostic JINT022: a BuiltinShapeObject-derived host that declares an unsupported member (accessor / intrinsic reference / thrower / instance-or-mutable property) fails the build instead of silently dropping it. - Math, JSON, Reflect, Atomics drop the now-redundant UseShape = true (auto-detected). - Temporal.Now (9 functions + Symbol.toStringTag, no properties) adopts shapes by simply deriving from BuiltinShapeObject — demonstrating the one-line adoption and adding a win. Benchmarks (BuiltinShapeBenchmark, default job, vs main; EngineOnly control identical at 13.69 KB): EngineInitMath / EngineInitBuiltins 15.51 / 20.20 KB == 15.51 / 20.20 KB (byte-identical; the default change is neutral) EngineInitTemporalNow 20.43 → 19.45 KB (−4.8%; time −5.6%) Conformance: Math 662/662, JSON 502/502, Reflect 306/306, Atomics 779/779, Temporal.Now 138/138; full Test262 0 new failures (the annexB RegExp-*-escape-BMP and Atomics.waitAsync tests are pre-existing timing flakes under concurrent load — they flake identically on main and pass in isolation). Jint.Tests 3138/3076; Jint.Tests.PublicInterface 79/79; Jint.Tests.SourceGenerators 30/30 (snapshots updated for the attribute default). Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01RDS23QeSSNRkaUB2KL74U9 --- Jint.Benchmark/BuiltinShapeBenchmark.cs | 11 +++++ Jint.SourceGenerators/Attributes.cs | 14 +++--- Jint.SourceGenerators/Diagnostics.cs | 8 ++++ Jint.SourceGenerators/Models.cs | 44 +++++++++++++++++-- ...tterAndSetter#JintAttributes.g.verified.cs | 14 +++--- ...sorGetterOnly#JintAttributes.g.verified.cs | 14 +++--- ...cesDiagnostic#JintAttributes.g.verified.cs | 14 +++--- ...ercedRestSpan#JintAttributes.g.verified.cs | 14 +++--- ...cesDiagnostic#JintAttributes.g.verified.cs | 14 +++--- ...cesDiagnostic#JintAttributes.g.verified.cs | 14 +++--- ...cesDiagnostic#JintAttributes.g.verified.cs | 14 +++--- ...cesDiagnostic#JintAttributes.g.verified.cs | 14 +++--- ...cesDiagnostic#JintAttributes.g.verified.cs | 14 +++--- ...cesDiagnostic#JintAttributes.g.verified.cs | 14 +++--- ...nstanceMethod#JintAttributes.g.verified.cs | 14 +++--- ...erConversions#JintAttributes.g.verified.cs | 14 +++--- ...nsicReference#JintAttributes.g.verified.cs | 14 +++--- ...cesDiagnostic#JintAttributes.g.verified.cs | 14 +++--- ....MinimalClass#JintAttributes.g.verified.cs | 14 +++--- ...cesDiagnostic#JintAttributes.g.verified.cs | 14 +++--- ...cesDiagnostic#JintAttributes.g.verified.cs | 14 +++--- ...cesDiagnostic#JintAttributes.g.verified.cs | 14 +++--- ...oughArguments#JintAttributes.g.verified.cs | 14 +++--- ...ertyConstants#JintAttributes.g.verified.cs | 14 +++--- ...RestParameter#JintAttributes.g.verified.cs | 14 +++--- ...chConversions#JintAttributes.g.verified.cs | 14 +++--- ...sorGetterOnly#JintAttributes.g.verified.cs | 14 +++--- ...unctionMethod#JintAttributes.g.verified.cs | 14 +++--- ....SymbolMember#JintAttributes.g.verified.cs | 14 +++--- ...astToCallable#JintAttributes.g.verified.cs | 14 +++--- ...bjectInstance#JintAttributes.g.verified.cs | 14 +++--- ...rowerAccessor#JintAttributes.g.verified.cs | 14 +++--- ...berConversion#JintAttributes.g.verified.cs | 14 +++--- ...cesDiagnostic#JintAttributes.g.verified.cs | 14 +++--- Jint/Native/Atomics/AtomicsInstance.cs | 2 +- Jint/Native/Json/JsonInstance.cs | 2 +- Jint/Native/Math/MathInstance.cs | 4 +- Jint/Native/Reflect/ReflectInstance.cs | 2 +- Jint/Native/Temporal/Now/TemporalNow.cs | 2 +- 39 files changed, 314 insertions(+), 195 deletions(-) diff --git a/Jint.Benchmark/BuiltinShapeBenchmark.cs b/Jint.Benchmark/BuiltinShapeBenchmark.cs index 4835020ac..f522ec0f2 100644 --- a/Jint.Benchmark/BuiltinShapeBenchmark.cs +++ b/Jint.Benchmark/BuiltinShapeBenchmark.cs @@ -58,4 +58,15 @@ public Engine EngineInitBuiltins() engine.Evaluate(_initBuiltins); return engine; } + + // Forces Temporal.Now (9 functions) to initialize — newly shape-backed here, dictionary on main. + private static readonly Prepared