@geastack/compiler 1.0.21 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/compiler.js +2 -1
  2. package/dist/conversion/build.d.ts +12 -0
  3. package/dist/conversion/build.js +15 -0
  4. package/dist/ir/borrow-effects.js +55 -1
  5. package/dist/ir/callable-class-flow.d.ts +3 -1
  6. package/dist/ir/callable-class-flow.js +27 -1
  7. package/dist/ir/certificate.js +87 -16
  8. package/dist/ir/certify/carrier-keys.js +3 -1
  9. package/dist/ir/dense-loops.d.ts +16 -2
  10. package/dist/ir/dense-loops.js +66 -21
  11. package/dist/ir/facts.d.ts +6 -29
  12. package/dist/ir/facts.js +46 -1
  13. package/dist/ir/floats.d.ts +46 -0
  14. package/dist/ir/floats.js +196 -0
  15. package/dist/ir/hoist.d.ts +11 -2
  16. package/dist/ir/hoist.js +17 -2
  17. package/dist/ir/integer-storage.js +8 -4
  18. package/dist/ir/integers.d.ts +14 -0
  19. package/dist/ir/integers.js +55 -1
  20. package/dist/ir/lower-invocation.js +7 -1
  21. package/dist/ir/numeric-intrinsics.d.ts +1 -1
  22. package/dist/ir/numeric-intrinsics.js +3 -2
  23. package/dist/ir/proven-branches.js +3 -1
  24. package/dist/ir/reflection-demand.js +10 -0
  25. package/dist/project-preparation.js +20 -0
  26. package/dist/semantics/class-alias.d.ts +16 -1
  27. package/dist/semantics/class-alias.js +21 -2
  28. package/dist/semantics/class-heritage.js +2 -2
  29. package/dist/semantics/frontend.js +35 -7
  30. package/dist/semantics/normalize/bivariant-slot-parameter.js +21 -6
  31. package/dist/semantics/normalize/commonjs-require.d.ts +9 -5
  32. package/dist/semantics/normalize/commonjs-require.js +127 -44
  33. package/dist/semantics/normalize/host-mutation-key-reader.js +35 -10
  34. package/dist/semantics/normalize/identities.js +15 -0
  35. package/dist/semantics/normalize/object-bag-bindings.js +16 -2
  36. package/dist/semantics/normalize/omitted-stated-parameter.d.ts +1 -1
  37. package/dist/semantics/normalize/omitted-stated-parameter.js +34 -4
  38. package/dist/semantics/normalize/parameter-bindings.js +33 -7
  39. package/dist/semantics/normalize/structural.js +17 -0
  40. package/dist/semantics/program.js +42 -20
  41. package/dist/semantics/shared-declaration-files.d.ts +44 -0
  42. package/dist/semantics/shared-declaration-files.js +42 -0
  43. package/dist/semantics/subclass-member-overlay-transform.js +95 -53
  44. package/dist/targets/cpp/emit-allocation.js +34 -1
  45. package/dist/targets/cpp/emit-arrays.d.ts +2 -1
  46. package/dist/targets/cpp/emit-arrays.js +7 -3
  47. package/dist/targets/cpp/emit-bindings.js +4 -2
  48. package/dist/targets/cpp/emit-callable.js +13 -0
  49. package/dist/targets/cpp/emit-carrier-members.d.ts +3 -1
  50. package/dist/targets/cpp/emit-carrier-members.js +18 -2
  51. package/dist/targets/cpp/emit-context.d.ts +13 -0
  52. package/dist/targets/cpp/emit-context.js +18 -2
  53. package/dist/targets/cpp/emit-properties.js +16 -3
  54. package/dist/targets/cpp/emit-union-properties.js +16 -3
  55. package/dist/targets/cpp/emit.js +36 -4
  56. package/dist/targets/cpp/host/emit-host-invoke.js +10 -1
  57. package/dist/targets/cpp/host/host-members.js +43 -30
  58. package/dist/targets/cpp/manifest/capabilities.js +10 -1
  59. package/dist/targets/cpp/records.js +8 -1
  60. package/dist/targets/cpp/types.d.ts +2 -0
  61. package/dist/targets/cpp/types.js +2 -0
  62. package/package.json +13 -13
  63. package/src/targets/cpp/runtime/gea_runtime.h +146 -18
@@ -481,7 +481,10 @@ export { emitToNumericCoercion } from './emit-tonumber.js';
481
481
  export const emitSpreadCopy = (ctx, lines, operation) => {
482
482
  const receiver = operation.receiver.representation;
483
483
  const source = operation.source.representation;
484
- if (source.kind === 'dynamic' && receiver.kind !== 'dynamic' && !isDynamicCopyableIntoFieldRecord(ctx.deriver, receiver)) {
484
+ if (source.kind === 'dynamic' &&
485
+ receiver.kind !== 'dynamic' &&
486
+ !isDynamicCopyableIntoFieldRecord(ctx.deriver, receiver) &&
487
+ !(receiver.kind === 'dictionary' && receiver.key === 'string')) {
485
488
  throw createCppEmitBlockedError(`runtime-helper:protocol:spread:next:${spreadSourceCarrierKeyOf(source.kind, source, receiver, ctx.deriver)}`, `requires a dynamic object-spread receiver for a dynamic source, but the receiver is a "${representationKey(receiver)}"; this runtime-key walk is installed only for a dynamic receiver`);
486
489
  }
487
490
  if (receiver.kind === 'dynamic') {
@@ -528,8 +531,38 @@ export const emitSpreadCopy = (ctx, lines, operation) => {
528
531
  const receiverText = operandText(ctx, operation.receiver);
529
532
  const receiverRef = memberAccessOperator(receiver.ownership) === '->' ? `(*${receiverText})` : receiverText;
530
533
  const sourceText = operandText(ctx, operation.source);
534
+ if (source.kind === 'dynamic') {
535
+ emitDynamicSpreadIntoDictionary(ctx, lines, source, sourceText, receiver, receiverRef);
536
+ return;
537
+ }
531
538
  emitSpreadSourceCopy(ctx, lines, source, sourceText, receiver, receiverRef, spreadKeysOf(operation));
532
539
  };
540
+ /**
541
+ * `{ ...value }` of a dynamic source into a string-keyed dictionary: mongodb's
542
+ * `mechanismProperties = { ...optionValue }`, where `optionValue` is declared
543
+ * `unknown` and only bounded by an `isRecord` guard
544
+ * (`producers/shared.ts`'s `dynamicSpreadSourceTypeOf`). The keys exist only at
545
+ * runtime, so each own enumerable string key is read as a `gea::Value` and
546
+ * stored through the dictionary's checked value conversion -- the same walk
547
+ * `Object.assign` of a dynamic source into a typed dictionary uses
548
+ * (`host/emit-host-object.ts`). `null`/`undefined` copy nothing.
549
+ */
550
+ const emitDynamicSpreadIntoDictionary = (ctx, lines, source, sourceText, receiver, receiverRef) => {
551
+ const converted = alignedValueText(ctx, 'emit-allocation.ts:dynamic-spread-into-dictionary', source, receiver.value, '__gea_spread_value');
552
+ if (converted === null) {
553
+ throw createCppEmitBlockedError(`conversion:${representationKey(source)}->${representationKey(receiver.value)}`, `copies a dynamic object-spread source into a dictionary of "${representationKey(receiver.value)}" values; ` +
554
+ 'no installed conversion unboxes a dynamic value into that type');
555
+ }
556
+ lines.push('{');
557
+ lines.push(`const auto& __gea_spread_source = ${sourceText};`);
558
+ lines.push('if (__gea_spread_source.tag() != gea::Value::Tag::Null && __gea_spread_source.tag() != gea::Value::Tag::Undefined) {');
559
+ lines.push('for (const std::string& __gea_spread_key : __gea_spread_source.ownEnumerableStringKeys()) {');
560
+ lines.push('const gea::Value __gea_spread_value = __gea_spread_source.getProperty(gea::PropertyKey::string(__gea_spread_key));');
561
+ lines.push(`${receiverRef}[__gea_spread_key] = ${converted};`);
562
+ lines.push('}');
563
+ lines.push('}');
564
+ lines.push('}');
565
+ };
533
566
  /**
534
567
  * The keys a statically fielded source may contribute: its TYPE's own keys
535
568
  * when the operation states them (`SpreadCopyOperation.keys`), since the
@@ -1,3 +1,4 @@
1
+ import type { HoistPlan } from '../../ir/hoist.js';
1
2
  import type { IrValueId } from '../../identity/ids.js';
2
3
  import type { AllocateArrayObjectOperation, IrBlockId, IrBody } from '../../ir/model.js';
3
4
  import { type Representation } from '../../representation/model.js';
@@ -68,7 +69,7 @@ export declare const emitFillLoop: (ctx: EmitContext, lines: string[], fill: Fil
68
69
  * until a `%` compute actually renders (`emit.ts`'s `emitBinaryOperation`),
69
70
  * which is why that one field, alone of this group, is on the whitelist.
70
71
  */
71
- export declare const admitDenseWindows: (ctx: EmitContext, prepass: EmitBodyPrepassFacts, body: IrBody) => void;
72
+ export declare const admitDenseWindows: (ctx: EmitContext, prepass: EmitBodyPrepassFacts, body: IrBody, hoists: HoistPlan) => void;
72
73
  /**
73
74
  * The preheader statements one loop's dense windows need: an element pointer
74
75
  * per array, and the one loop-invariant condition that makes indexing it sound.
@@ -924,8 +924,8 @@ const denseIntegerText = (ctx, operand) => ctx.integerValues.has(operand.value)
924
924
  * until a `%` compute actually renders (`emit.ts`'s `emitBinaryOperation`),
925
925
  * which is why that one field, alone of this group, is on the whitelist.
926
926
  */
927
- export const admitDenseWindows = (ctx, prepass, body) => {
928
- const plan = denseLoopsOf(body);
927
+ export const admitDenseWindows = (ctx, prepass, body, hoists) => {
928
+ const plan = denseLoopsOf(body, hoists);
929
929
  if (plan.arrays.length === 0)
930
930
  return;
931
931
  const admitted = admittedDenseLoopPlanOf(plan, ctx.integerValues, (declaration) => denseCellName(ctx, declaration) !== null);
@@ -1061,7 +1061,11 @@ export const emitDenseSetup = (ctx, lines, blockId) => {
1061
1061
  // this may dereference it.
1062
1062
  said.push(...holder.guard, ...shape, ...writable);
1063
1063
  for (const offset of array.bases) {
1064
- const base = offset === null ? '0' : operandText(ctx, offset);
1064
+ const base = offset === null
1065
+ ? '0'
1066
+ : offset.terms.length === 1 && !offset.terms[0].negated
1067
+ ? operandText(ctx, offset.terms[0].operand)
1068
+ : `(${offset.terms.map((term, at) => `${term.negated ? '-' : at === 0 ? '' : '+'} (${operandText(ctx, term.operand)})`).join(' ')})`;
1065
1069
  said.push(`gea::denseIndexWindow(${size}, ${seed}, ${base}, ${operandText(ctx, array.bound)}, ${step}, ${array.inclusive}, ${array.widened})`);
1066
1070
  }
1067
1071
  }
@@ -5,7 +5,7 @@ import { carrierDifference, shortCarrierText } from '../../representation/differ
5
5
  import { bindingReference, createCppEmitBlockedError, cppFormalName, cppFrameLocalName, cppFrameStructName, cppReceiverName, declareCell, defineValue, defineValueAlias, isCppEmitBlockedError, operandText } from './emit-context.js';
6
6
  import { alignedValueText, classFamilyLoadText, emptyArraySentinelText, movedValueText } from './emit-narrowing.js';
7
7
  import { stringAppendStatement } from './emit-tostring.js';
8
- import { cppAbiParameterType, cppBoxedType, cppNarrowedIntegerType, cppStringLiteral, cppTypeOf } from './types.js';
8
+ import { cppAbiParameterType, cppBoxedType, cppNarrowedFloatType, cppNarrowedIntegerType, cppStringLiteral, cppTypeOf } from './types.js';
9
9
  import { receiverBoundCallableText } from './emit-callable.js';
10
10
  import { structuralRecordViewText } from './emit-record-view.js';
11
11
  import { owningConversionInputText } from './owning-conversion-input.js';
@@ -582,7 +582,9 @@ export const emitBindingWrite = (ctx, lines, operation) => {
582
582
  ? 'gea::Value::Tag'
583
583
  : ctx.integerBindings.has(operation.declaration) && !cell.boxed
584
584
  ? cppNarrowedIntegerType
585
- : cppTypeOf(held ?? operation.value.representation);
585
+ : ctx.float32.bindings.has(operation.declaration) && !cell.boxed
586
+ ? cppNarrowedFloatType
587
+ : cppTypeOf(held ?? operation.value.representation);
586
588
  if (cell.boxed) {
587
589
  // The box itself, not its pointee, is what gets declared and allocated: a
588
590
  // shared cell is born already holding this first value, so every other
@@ -918,6 +918,19 @@ const emitCharCodeBufferPush = (ctx, lines, operation) => {
918
918
  return true;
919
919
  };
920
920
  export const emitCall = (ctx, lines, operation) => {
921
+ const minMax = ctx.numericCalls.get(operation);
922
+ if (minMax === 'min' || minMax === 'max') {
923
+ // An integer result (`ir/integers.ts`) is the smaller or larger integer;
924
+ // anything else is the host's own double answer, NaN and -0 included.
925
+ const integer = operation.result !== null && isIntegerStorageValue(ctx, operation.result.id);
926
+ const args = operation.arguments.map((argument) => integer ? `static_cast<long long>(${operandText(ctx, argument)})` : `static_cast<double>(${operandText(ctx, argument)})`);
927
+ const expression = integer ? `std::${minMax}<long long>(${args.join(', ')})` : `gea::host::Math::${minMax}Direct({${args.join(', ')}})`;
928
+ if (operation.result && !ctx.unreadValues.has(operation.result.id))
929
+ lines.push(`${defineValue(ctx, operation.result)} = ${expression};`);
930
+ else
931
+ lines.push(`${expression};`);
932
+ return;
933
+ }
921
934
  if (ctx.numericCalls.get(operation) === 'imul') {
922
935
  const args = operation.arguments.map((argument) => {
923
936
  const text = operandText(ctx, argument);
@@ -1,7 +1,7 @@
1
1
  import type { DefineOwnPropertyOperation, GetOperation, IrOperand, IrResult, SetOperation } from '../../ir/model.js';
2
2
  import type { IrValueId } from '../../identity/ids.js';
3
3
  import { type ReactiveRevisionOrigin, type EmitContext, type PrototypeMethodRead } from './emit-context.js';
4
- import type { Ownership, Representation } from '../../representation/model.js';
4
+ import type { Ownership, Representation, TypedArrayElementDomain } from '../../representation/model.js';
5
5
  import { type ConversionSite } from './emit-narrowing.js';
6
6
  import { type RecordIndexSidecar } from './records.js';
7
7
  /**
@@ -64,6 +64,8 @@ export declare const arrayAccessText: (ctx: EmitContext, receiver: IrOperand, ke
64
64
  * index, and the three block-shaped members `emit-buffers.ts` owns.
65
65
  */
66
66
  export declare const deferredTypedArrayMethodClaim: (staticKeyTexts: ReadonlyMap<IrValueId, string>, receiver: IrOperand, key: IrOperand) => PrototypeMethodRead | null;
67
+ /** The views whose every element is an integer, read and written in integer registers when the census holds the value as one. */
68
+ export declare const integerTypedArrayElements: ReadonlySet<TypedArrayElementDomain>;
67
69
  export declare const typedArrayAccessText: (ctx: EmitContext, receiver: IrOperand, key: IrOperand, result: IrResult | null) => string | null;
68
70
  /**
69
71
  * `absentCapableElementText` for the typed-array reader.
@@ -336,6 +336,16 @@ export const deferredTypedArrayMethodClaim = (staticKeyTexts, receiver, key) =>
336
336
  receiverElement: typedArrayElementSpelling(carrier)
337
337
  };
338
338
  };
339
+ /** The views whose every element is an integer, read and written in integer registers when the census holds the value as one. */
340
+ export const integerTypedArrayElements = new Set([
341
+ 'int8',
342
+ 'uint8',
343
+ 'uint8-clamped',
344
+ 'int16',
345
+ 'uint16',
346
+ 'int32',
347
+ 'uint32'
348
+ ]);
339
349
  export const typedArrayAccessText = (ctx, receiver, key, result) => {
340
350
  if (receiver.representation.kind !== 'typed-array')
341
351
  return null;
@@ -394,8 +404,14 @@ export const typedArrayAccessText = (ctx, receiver, key, result) => {
394
404
  const integerKey = isIntegerStorageValue(ctx, key.value);
395
405
  const reader = integerKey ? 'elementAtIndex' : 'elementAt';
396
406
  const keyText = operandText(ctx, key);
397
- return (absentCapableNumericElementText(receiverText, keyText, result, integerKey ? 'hasElementAtIndex' : 'hasElement', reader) ??
398
- `${receiverText}->${reader}(${keyText})`);
407
+ const absentCapable = absentCapableNumericElementText(receiverText, keyText, result, integerKey ? 'hasElementAtIndex' : 'hasElement', reader);
408
+ if (absentCapable !== null)
409
+ return absentCapable;
410
+ // An integer element read into a `long long` the integer census chose is
411
+ // that integer: no conversion to `double` and back.
412
+ if (integerKey && result !== null && integerTypedArrayElements.has(receiver.representation.element) && ctx.integerValues.has(result.id))
413
+ return `${receiverText}->elementIntegerAtIndex(${keyText})`;
414
+ return `${receiverText}->${reader}(${keyText})`;
399
415
  };
400
416
  /**
401
417
  * `absentCapableElementText` for the typed-array reader.
@@ -1650,6 +1650,12 @@ export interface EmitContext {
1650
1650
  readonly integerValues: ReadonlySet<IrValueId>;
1651
1651
  /** Settled the same way as `hoistedResults`. */
1652
1652
  readonly integerBindings: ReadonlySet<DeclarationId>;
1653
+ /** `ir/floats.ts`'s answer for this body. Settled the same way as `hoistedResults`. */
1654
+ readonly float32: {
1655
+ readonly values: ReadonlySet<IrValueId>;
1656
+ readonly bindings: ReadonlySet<DeclarationId>;
1657
+ readonly arithmetic: ReadonlySet<IrValueId>;
1658
+ };
1653
1659
  /** Finite typeof snapshots proved by the IR, confined to comparison-only uses. Settled the same way as `hoistedResults`. */
1654
1660
  readonly typeQueryValues: ReadonlySet<IrValueId>;
1655
1661
  /** Settled the same way as `hoistedResults`. */
@@ -1881,6 +1887,11 @@ export interface EmitBodyPrepassFacts {
1881
1887
  readonly numericCallOnly: Set<IrValueId>;
1882
1888
  readonly integerValues: Set<IrValueId>;
1883
1889
  readonly integerBindings: Set<DeclarationId>;
1890
+ readonly float32: {
1891
+ readonly values: Set<IrValueId>;
1892
+ readonly bindings: Set<DeclarationId>;
1893
+ readonly arithmetic: Set<IrValueId>;
1894
+ };
1884
1895
  readonly typeQueryValues: Set<IrValueId>;
1885
1896
  readonly typeQueryBindings: Set<DeclarationId>;
1886
1897
  readonly typeQueryComparisons: Map<ComputeOperation, TypeQueryComparison>;
@@ -1939,6 +1950,8 @@ export declare const createEmitContext: (abi: CallableAbi | null, owner: Functio
1939
1950
  * something this does not.
1940
1951
  */
1941
1952
  export declare const storageTypeOf: (ctx: EmitContext, value: IrValueId, representation: Representation) => string;
1953
+ /** Whether a value's rendered text is a `float` -- the float32 census's twin of `isIntegerStorageValue`. */
1954
+ export declare const isFloatStorageValue: (ctx: EmitContext, value: IrValueId) => boolean;
1942
1955
  /**
1943
1956
  * Whether a value's rendered text is a `long long`, from every storage that
1944
1957
  * can make it one: the value census (`integerValues`), the cell a read names
@@ -5,7 +5,7 @@ import { noInstantiationFacts } from '../../ir/instantiation.js';
5
5
  import { observesEveryCallableIdentity } from '../../ir/callable-identity-demand.js';
6
6
  import { hostCallName, hostMemberOf, statedHostIntrinsicLength } from './host/host-members.js';
7
7
  import { representationKey } from '../../representation/model.js';
8
- import { cppBodyName, cppConstructName, cppNarrowedIntegerType, cppStringLiteral, cppStringViewLiteral, cppTypeOf, cppUndefinedIn, unitFunctionName } from './types.js';
8
+ import { cppBodyName, cppConstructName, cppNarrowedFloatType, cppNarrowedIntegerType, cppStringLiteral, cppStringViewLiteral, cppTypeOf, cppUndefinedIn, unitFunctionName } from './types.js';
9
9
  import { hostBuiltinFunctionIdentityText, hostClassValueText, hostFunctionValueText, hostJsonMemberValueText, hostMemberValueText } from './host/emit-host-value.js';
10
10
  import { createConversionNodes } from '../../conversion/nodes.js';
11
11
  import { createCppConversionRegistry } from './conversions.js';
@@ -103,6 +103,7 @@ conversions = null, nativeSelections = undefined, callableIdentityDemand = obser
103
103
  const numericCallOnly = new Set();
104
104
  const integerValues = new Set();
105
105
  const integerBindings = new Set();
106
+ const float32 = { values: new Set(), bindings: new Set(), arithmetic: new Set() };
106
107
  const typeQueryValues = new Set();
107
108
  const typeQueryBindings = new Set();
108
109
  const typeQueryComparisons = new Map();
@@ -244,6 +245,7 @@ conversions = null, nativeSelections = undefined, callableIdentityDemand = obser
244
245
  numericCallOnly,
245
246
  integerValues,
246
247
  integerBindings,
248
+ float32,
247
249
  typeQueryValues,
248
250
  typeQueryBindings,
249
251
  typeQueryComparisons,
@@ -285,6 +287,7 @@ conversions = null, nativeSelections = undefined, callableIdentityDemand = obser
285
287
  numericCallOnly,
286
288
  integerValues,
287
289
  integerBindings,
290
+ float32,
288
291
  typeQueryValues,
289
292
  typeQueryBindings,
290
293
  typeQueryComparisons,
@@ -335,7 +338,20 @@ conversions = null, nativeSelections = undefined, callableIdentityDemand = obser
335
338
  * An explicit spelling always wins: a caller that named the type knows
336
339
  * something this does not.
337
340
  */
338
- export const storageTypeOf = (ctx, value, representation) => ctx.typeQueryValues.has(value) ? 'gea::Value::Tag' : ctx.integerValues.has(value) ? cppNarrowedIntegerType : cppTypeOf(representation);
341
+ export const storageTypeOf = (ctx, value, representation) => ctx.typeQueryValues.has(value)
342
+ ? 'gea::Value::Tag'
343
+ : ctx.integerValues.has(value)
344
+ ? cppNarrowedIntegerType
345
+ : ctx.float32.values.has(value)
346
+ ? cppNarrowedFloatType
347
+ : cppTypeOf(representation);
348
+ /** Whether a value's rendered text is a `float` -- the float32 census's twin of `isIntegerStorageValue`. */
349
+ export const isFloatStorageValue = (ctx, value) => {
350
+ if (ctx.float32.values.has(value))
351
+ return true;
352
+ const declaration = ctx.bindingReadDeclarations.get(value);
353
+ return declaration !== undefined && ctx.float32.bindings.has(declaration) && !ctx.captures.isBoxed(declaration);
354
+ };
339
355
  /**
340
356
  * Whether a value's rendered text is a `long long`, from every storage that
341
357
  * can make it one: the value census (`integerValues`), the cell a read names
@@ -66,7 +66,7 @@ export const staticKeyTextOf = (ctx, key, contextDescription) => {
66
66
  throw createCppEmitBlockedError(`runtime-helper:computation:to-property-key:${contextDescription}`, `${contextDescription} has a key that was not produced by a "constant" operation in this body; this emitter has no dynamic-key path`);
67
67
  };
68
68
  import { dateMemberText } from './prototype/emit-prototype-date.js';
69
- import { arrayAccessText, presentElementText, keyedCollectionMemberText, iteratorMemberText, canonicalIndexLiteral, dictionaryPrototypeMemberRead, memberAccessOperator, positionalRecordArityText, promiseMemberText, keyedTableKeyText, emitRecordIndexSidecarStore, recordIndexSidecarReadText, reactiveRevisionText, scalarMemberText, stringMemberText, symbolMemberText, typedArrayAccessText } from './emit-carrier-members.js';
69
+ import { arrayAccessText, presentElementText, keyedCollectionMemberText, iteratorMemberText, canonicalIndexLiteral, dictionaryPrototypeMemberRead, memberAccessOperator, positionalRecordArityText, promiseMemberText, keyedTableKeyText, emitRecordIndexSidecarStore, recordIndexSidecarReadText, reactiveRevisionText, scalarMemberText, stringMemberText, symbolMemberText, typedArrayAccessText, integerTypedArrayElements } from './emit-carrier-members.js';
70
70
  import { arrayBufferAccessText, dataViewAccessText, sharedArrayBufferAccessText } from './emit-buffers.js';
71
71
  import { functionSourceReadClaimOf } from './function-source-reads.js';
72
72
  import { deferredCallableBuiltinReadClaimOf, recordWithIndexFieldClaimOf } from './property-read-claims.js';
@@ -411,6 +411,15 @@ const denseElementText = (ctx, operation) => {
411
411
  : arrayAccessText(ctx, operation.receiver, operation.key, operation.result);
412
412
  if (general === null || general === '')
413
413
  return null;
414
+ // A `float` result (`ir/floats.ts`) reads a float32 element as the `float`
415
+ // it is: both halves in `float`, so the fast half is a load and no
416
+ // conversion through `double` -- a software routine on a core whose FPU is
417
+ // single-precision only.
418
+ const receiver = operation.receiver.representation;
419
+ if (receiver.kind === 'typed-array' && receiver.element === 'float32' && ctx.float32.values.has(operation.result.id))
420
+ return `(${dense.flag} ? gea::TypedArray<float>::readInBounds(${dense.pointer}, ${dense.index}) : static_cast<float>(${general}))`;
421
+ if (receiver.kind === 'typed-array' && integerTypedArrayElements.has(receiver.element) && ctx.integerValues.has(operation.result.id))
422
+ return `(${dense.flag} ? gea::TypedArray<${cppScalarType(receiver.element)}>::readIntegerInBounds(${dense.pointer}, ${dense.index}) : static_cast<long long>(${general}))`;
414
423
  // The window's flag is a proof of presence, so the fast half is written in
415
424
  // the result's carrier the same way the general half's guarded arm is --
416
425
  // see `presentElementText`. Without it the two arms are a bare element and
@@ -1589,11 +1598,15 @@ const emitFieldStoreLines = (ctx, lines, operation, label) => {
1589
1598
  }
1590
1599
  const dense = denseCellText(ctx, operation);
1591
1600
  const value = operandText(ctx, operation.value);
1592
- const writer = isIntegerStorageValue(ctx, operation.key.value) ? 'setElementAtIndex' : 'setElement';
1601
+ const integerKey = isIntegerStorageValue(ctx, operation.key.value);
1602
+ // An integer value stores its low bits (or itself, rounded once, into a
1603
+ // float view) without the `double` modulo `setElementAtIndex` performs.
1604
+ const integerValue = isIntegerStorageValue(ctx, operation.value.value);
1605
+ const writer = integerKey ? (integerValue ? 'setElementIntegerAtIndex' : 'setElementAtIndex') : 'setElement';
1593
1606
  const general = `${typedArrayReceiver}->${writer}(${operandText(ctx, operation.key)}, ${value});`;
1594
1607
  lines.push(dense === null
1595
1608
  ? general
1596
- : `if (${dense.flag}) gea::TypedArray<${cppScalarType(operation.receiver.representation.element)}>::writeInBounds(${dense.pointer}, ${dense.index}, ${value}); else ${general}`);
1609
+ : `if (${dense.flag}) gea::TypedArray<${cppScalarType(operation.receiver.representation.element)}>::${integerValue ? 'writeIntegerInBounds' : 'writeInBounds'}(${dense.pointer}, ${dense.index}, ${value}); else ${general}`);
1597
1610
  finishTypedArrayStore();
1598
1611
  return;
1599
1612
  }
@@ -77,7 +77,14 @@ export const unionClassMethodValueReceiverClaim = (ctx, operation) => {
77
77
  // each arm has already bound its own receiver into the value
78
78
  // (`receiverBoundFieldText`), and handing the union back at the call would
79
79
  // pass it as the first ARGUMENT.
80
- const publishedAbi = abiOfCallee(operation.result.representation);
80
+ // A union whose other arms lack the member publishes the method as
81
+ // `optional(callable)`: those arms answer `undefined`. The call behind a
82
+ // guard (`value && value.isColor ? value.getHex() : ...`) still fills the
83
+ // callable's receiver slot, so the claim reads the convention through that
84
+ // absence. three.js's `ShaderMaterial.toJSON` reads `getHex` this way.
85
+ const published = operation.result.representation;
86
+ const callable = published.kind === 'optional' && published.absence === 'undefined' ? published.payload : published;
87
+ const publishedAbi = abiOfCallee(callable);
81
88
  if (publishedAbi === null || publishedAbi.receiver === null)
82
89
  return null;
83
90
  const key = ctx.staticKeyTexts.get(operation.key.value);
@@ -329,7 +336,13 @@ const armRuntimeFieldText = (ctx, arm, armExprText, key, operation) => {
329
336
  // native answer for overload probes such as `number | Vector3` reading
330
337
  // `isVector3`: the scalar arm contributes `undefined`, while the class arm
331
338
  // contributes the declared boolean marker.
332
- if (!objectPrototypeMemberNames.has(key) && published.kind === 'optional' && published.absence === 'undefined') {
339
+ //
340
+ // A `dynamic` result holds that `undefined` as well as an optional does:
341
+ // three.js's `ShaderMaterial.toJSON` reads `value.toJSON` off a uniform
342
+ // whose arms are numbers, booleans and textures, and the member's result is
343
+ // the open carrier because the class arms publish a method there.
344
+ if (!objectPrototypeMemberNames.has(key) &&
345
+ (published.kind === 'dynamic' || (published.kind === 'optional' && published.absence === 'undefined'))) {
333
346
  return cppUndefinedIn(published);
334
347
  }
335
348
  // A canonical index on a number or boolean: no wrapper prototype holds an
@@ -1212,7 +1225,7 @@ export const taggedUnionGetText = (ctx, lines, operation) => {
1212
1225
  // No native recipe is not proof of absence: a prototype or accessor
1213
1226
  // may answer this key. Keep that case visible instead of inventing an
1214
1227
  // undefined result or boxing the typed receiver.
1215
- throw createCppEmitBlockedError('property-access:tagged-union:get:false', `a "get" of "${key}" on a tagged union reaches an arm carried as "${representationKey(leaf.representation)}" with no native property recipe ` +
1228
+ throw createCppEmitBlockedError('property-access:tagged-union:get:false', `a "get" of "${key}" on the tagged union "${representationKey(receiver)}" reaches an arm carried as "${representationKey(leaf.representation)}" with no native property recipe ` +
1216
1229
  `producing "${representationKey(published)}"; boxing a typed receiver is not a property implementation`);
1217
1230
  }
1218
1231
  if (representationKey(site.representation) === representationKey(published))
@@ -17,7 +17,7 @@ import { allOperationsOf } from '../../ir/model.js';
17
17
  import { operandsOfIrOperation, resultOfIrOperation } from '../../ir/queries.js';
18
18
  import { namesMoreThanOnce } from './evaluated-once.js';
19
19
  import { isOpenDocument, representationKey } from '../../representation/model.js';
20
- import { cppFormalName, cppReceiverName, createCppEmitBlockedError, createEmitContext, defineValue, defineValueAlias, directCalleesOf, emptyCaptureIndex, isIntegerStorageValue, isCppEmitBlockedError, operandText, storageTypeOf, cppThunkEntryText, sealFactFieldsForRender, suspendsInPlace } from './emit-context.js';
20
+ import { cppFormalName, cppReceiverName, createCppEmitBlockedError, createEmitContext, defineValue, defineValueAlias, directCalleesOf, emptyCaptureIndex, isFloatStorageValue, isIntegerStorageValue, isCppEmitBlockedError, operandText, storageTypeOf, cppThunkEntryText, sealFactFieldsForRender, suspendsInPlace } from './emit-context.js';
21
21
  import { hostMemberReadsOf } from './host/emit-host-properties.js';
22
22
  import { hostNamespaceReadsOf } from './host-namespace-reads.js';
23
23
  import { functionSourceReadsOf } from './function-source-reads.js';
@@ -833,6 +833,23 @@ const emitCompute = (ctx, lines, operation) => {
833
833
  throw createCppEmitBlockedError(`runtime-helper:computation:binary:${operation.operator}:${first.representation.kind}`, `binary "${operation.operator}" on a "${first.representation.kind}" carrier has no C++ spelling in this emitter`);
834
834
  }
835
835
  const name = defineValue(ctx, operation.result);
836
+ // `ir/floats.ts`: an operation every use of which rounds to float32 is the
837
+ // single-precision operation itself; every other operator promotes a `float`
838
+ // operand back to the double the Number is, or two of them would compute in
839
+ // single precision where ECMA-262 computes in double.
840
+ if (ctx.float32.arithmetic.has(operation.result.id) && spelling.kind === 'infix') {
841
+ // A narrowed integer operand is one `ir/floats.ts` bounded by 2^24, so it
842
+ // fits an int32: converting from that is one instruction, from a
843
+ // `long long` a library call on a 32-bit core.
844
+ const single = (operand) => isIntegerStorageValue(ctx, operand.value)
845
+ ? `static_cast<float>(static_cast<std::int32_t>(${operandText(ctx, operand)}))`
846
+ : `static_cast<float>(${operandText(ctx, operand)})`;
847
+ const computed = `(${single(first)} ${spelling.text} ${single(second)})`;
848
+ // A product is the half of a multiply-add GCC would fuse (`float32Product`).
849
+ lines.push(`${name} = ${spelling.text === '*' ? `gea::float32Product${computed}` : computed};`);
850
+ return;
851
+ }
852
+ const promotedText = (operand) => isFloatStorageValue(ctx, operand.value) ? `static_cast<double>(${operandText(ctx, operand)})` : operandText(ctx, operand);
836
853
  const integral = ctx.integerValues.has(first.value) && ctx.integerValues.has(second.value);
837
854
  // `/` is the one arithmetic operator whose C++ meaning CHANGES when both
838
855
  // operands are integers: `7 / 2` would become 3 rather than 3.5, so two
@@ -841,8 +858,8 @@ const emitCompute = (ctx, lines, operation) => {
841
858
  // remainder is the same answer without the fmod round trip, under its own
842
859
  // name rather than an overload (a mixed call would make a pair ambiguous).
843
860
  const widenForDivision = integral && operation.operator === '/';
844
- const left = widenForDivision ? `static_cast<double>(${operandText(ctx, first)})` : operandText(ctx, first);
845
- const right = widenForDivision ? `static_cast<double>(${operandText(ctx, second)})` : operandText(ctx, second);
861
+ const left = widenForDivision ? `static_cast<double>(${operandText(ctx, first)})` : promotedText(first);
862
+ const right = widenForDivision ? `static_cast<double>(${operandText(ctx, second)})` : promotedText(second);
846
863
  const bounded = integerBoundedComparison(ctx.integerValues, ctx.loopInvariantValues, operation, first, second, left, right);
847
864
  if (bounded !== null) {
848
865
  lines.push(`${name} = ${bounded};`);
@@ -2536,6 +2553,15 @@ virtualDispatch = new Map(), narrowedStorage = { reads: new Map(), integral: new
2536
2553
  !ctx.captures.isBoxed(declaration) &&
2537
2554
  !capturedQueryCells.has(declaration));
2538
2555
  },
2556
+ float32Cell: (declaration) => {
2557
+ const placement = ctx.placements.get(declaration);
2558
+ return (placement?.storage.kind === 'local' &&
2559
+ placement.storage.owner === body.sourceOwner &&
2560
+ placement.representation?.kind === 'scalar' &&
2561
+ placement.representation.domain === 'number' &&
2562
+ !ctx.captures.isBoxed(declaration) &&
2563
+ !capturedQueryCells.has(declaration));
2564
+ },
2539
2565
  spellConstants: () => spellConstants(ctx, body),
2540
2566
  formalStorage: (settled) => {
2541
2567
  // The collectors below read these off the context, so they are published
@@ -2570,6 +2596,12 @@ virtualDispatch = new Map(), narrowedStorage = { reads: new Map(), integral: new
2570
2596
  prepass.integerValues.add(value);
2571
2597
  for (const declaration of settled.integerBindings)
2572
2598
  prepass.integerBindings.add(declaration);
2599
+ for (const value of settled.float32.values)
2600
+ prepass.float32.values.add(value);
2601
+ for (const declaration of settled.float32.bindings)
2602
+ prepass.float32.bindings.add(declaration);
2603
+ for (const value of settled.float32.arithmetic)
2604
+ prepass.float32.arithmetic.add(value);
2573
2605
  for (const [value, form] of settled.remainderForms)
2574
2606
  prepass.remainderForms.set(value, form);
2575
2607
  for (const value of settled.roundingArithmetic)
@@ -2610,7 +2642,7 @@ virtualDispatch = new Map(), narrowedStorage = { reads: new Map(), integral: new
2610
2642
  collectDirectBindingSinks(prepass, body, hoists.relocated);
2611
2643
  // After the hoists, because a window's own bound is often the loop-invariant
2612
2644
  // read they relocate, and a relocated value is one this may name.
2613
- admitDenseWindows(ctx, prepass, body);
2645
+ admitDenseWindows(ctx, prepass, body, hoists);
2614
2646
  const isSingleBlock = body.blockOrder.length === 1;
2615
2647
  const orderLabels = isSingleBlock ? new Map() : blockLabelsOf(body.blockOrder);
2616
2648
  const owner = sectionOwnerOf(body);
@@ -1,7 +1,7 @@
1
1
  import { usesRealmStorage } from '../realm-storage.js';
2
2
  import { isOpenDocument, representationKey } from '../../../representation/model.js';
3
3
  import { hostMemberTemplateOf, isArrayConstantOf } from '../../../representation/host-templates.js';
4
- import { createCppEmitBlockedError, internSymbolKey, operandText, paddedArguments } from '../emit-context.js';
4
+ import { createCppEmitBlockedError, internSymbolKey, isFloatStorageValue, operandText, paddedArguments } from '../emit-context.js';
5
5
  import { consoleArgumentsText, toStringRefusal, toStringText, toStringTextOver } from '../emit-tostring.js';
6
6
  import { classToNumberText, classToPrimitiveOf, toNumberRefusal, toNumberText } from '../emit-tonumber.js';
7
7
  import { booleanTestText } from '../emit-presence.js';
@@ -1432,6 +1432,15 @@ export const hostCallText = (ctx, operation) => {
1432
1432
  !operation.arguments.every((argument) => argument.representation.kind === 'scalar' && argument.representation.domain === 'number')) {
1433
1433
  throw createCppEmitBlockedError(`host-invocation:${read.protocol}.${read.member}`, 'a deferred numeric host call disagrees with its fixed numeric argument frame');
1434
1434
  }
1435
+ // `Math.fround` of a value `ir/floats.ts` already holds in `float` is that
1436
+ // value: no double to round, and no software double conversion on a core
1437
+ // whose FPU is single-precision only.
1438
+ const only = operation.arguments[0];
1439
+ if (read.protocol === 'Math' &&
1440
+ read.member === 'fround' &&
1441
+ only !== undefined &&
1442
+ (isFloatStorageValue(ctx, only.value) || ctx.float32.arithmetic.has(only.value)))
1443
+ return `static_cast<float>(${operandText(ctx, only)})`;
1435
1444
  return fillHostTemplate(host.numericDirectCall.emit, receiverText, operation.arguments.map((argument) => `static_cast<double>(${operandText(ctx, argument)})`));
1436
1445
  }
1437
1446
  if (!host || host.kind !== 'method') {
@@ -51,6 +51,19 @@ const nativeHandleProperty = (protocol, emit) => ({
51
51
  emit,
52
52
  resultRepresentation: { kind: 'native-handle', protocol, version: 1, native: null, bases: [], call: null, construct: null }
53
53
  });
54
+ /**
55
+ * A `Math` function: a first-class read is the `HostFunction` value, and a
56
+ * call with numeric arguments is a direct call of the same `detail::*_invoke`
57
+ * the value would forward to. Without the direct spelling every call in a
58
+ * pixel loop materialized a `CallableObject` and called through it -- Bloom's
59
+ * Gray-Scott step made forty of those per cell per frame.
60
+ */
61
+ const mathDirect = (name, arity) => ({
62
+ kind: 'property',
63
+ store: null,
64
+ emit: `gea::host::Math::${name}`,
65
+ numericDirectCall: { arity, emit: `gea::host::Math::detail::${name}_invoke(nullptr, ${arity === 1 ? '{arg0}' : '{arg0}, {arg1}'})` }
66
+ });
54
67
  export const coreHostMembers = new Map([
55
68
  // Atomics is a finite language primitive, not an any-shaped Node shim. The
56
69
  // call-site renderer verifies the concrete typed-array element carrier and
@@ -149,7 +162,7 @@ export const coreHostMembers = new Map([
149
162
  // these). Borrowed Object.prototype.toString calls use ObjectTag and its
150
163
  // native @@toStringTag lookup instead of this direct member path.
151
164
  ['Math.toString', { kind: 'method', emit: 'std::string("[object Math]")', arity: 0 }],
152
- ['Math.floor', { kind: 'property', store: null, emit: 'gea::host::Math::floor' }],
165
+ ['Math.floor', mathDirect('floor', 1)],
153
166
  [
154
167
  'Math.round',
155
168
  {
@@ -159,20 +172,20 @@ export const coreHostMembers = new Map([
159
172
  numericDirectCall: { arity: 1, emit: 'gea::host::Math::detail::round_invoke(nullptr, {arg0})' }
160
173
  }
161
174
  ],
162
- ['Math.sin', { kind: 'property', store: null, emit: 'gea::host::Math::sin' }],
163
- ['Math.cos', { kind: 'property', store: null, emit: 'gea::host::Math::cos' }],
164
- ['Math.sqrt', { kind: 'property', store: null, emit: 'gea::host::Math::sqrt' }],
165
- ['Math.abs', { kind: 'property', store: null, emit: 'gea::host::Math::abs' }],
166
- ['Math.ceil', { kind: 'property', store: null, emit: 'gea::host::Math::ceil' }],
167
- ['Math.pow', { kind: 'property', store: null, emit: 'gea::host::Math::pow' }],
168
- ['Math.atan2', { kind: 'property', store: null, emit: 'gea::host::Math::atan2' }],
175
+ ['Math.sin', mathDirect('sin', 1)],
176
+ ['Math.cos', mathDirect('cos', 1)],
177
+ ['Math.sqrt', mathDirect('sqrt', 1)],
178
+ ['Math.abs', mathDirect('abs', 1)],
179
+ ['Math.ceil', mathDirect('ceil', 1)],
180
+ ['Math.pow', mathDirect('pow', 2)],
181
+ ['Math.atan2', mathDirect('atan2', 2)],
169
182
  ['Math.random', { kind: 'property', store: null, emit: 'gea::host::Math::random' }],
170
- ['Math.tan', { kind: 'property', store: null, emit: 'gea::host::Math::tan' }],
171
- ['Math.asin', { kind: 'property', store: null, emit: 'gea::host::Math::asin' }],
172
- ['Math.acos', { kind: 'property', store: null, emit: 'gea::host::Math::acos' }],
173
- ['Math.atan', { kind: 'property', store: null, emit: 'gea::host::Math::atan' }],
174
- ['Math.sinh', { kind: 'property', store: null, emit: 'gea::host::Math::sinh' }],
175
- ['Math.log', { kind: 'property', store: null, emit: 'gea::host::Math::log' }],
183
+ ['Math.tan', mathDirect('tan', 1)],
184
+ ['Math.asin', mathDirect('asin', 1)],
185
+ ['Math.acos', mathDirect('acos', 1)],
186
+ ['Math.atan', mathDirect('atan', 1)],
187
+ ['Math.sinh', mathDirect('sinh', 1)],
188
+ ['Math.log', mathDirect('log', 1)],
176
189
  // All three retain their array-parameter callable values. Direct numeric
177
190
  // max/min calls can additionally borrow a stack sequence without allocating
178
191
  // the rest array; aliases and spreads keep the ordinary value spelling.
@@ -186,22 +199,22 @@ export const coreHostMembers = new Map([
186
199
  // Each row names a symbol that header really declares, in the same
187
200
  // `CallableObject<double(double)>` shape as the rows above -- `imul` is the
188
201
  // one binary member.
189
- ['Math.cbrt', { kind: 'property', store: null, emit: 'gea::host::Math::cbrt' }],
190
- ['Math.sign', { kind: 'property', store: null, emit: 'gea::host::Math::sign' }],
191
- ['Math.trunc', { kind: 'property', store: null, emit: 'gea::host::Math::trunc' }],
192
- ['Math.exp', { kind: 'property', store: null, emit: 'gea::host::Math::exp' }],
193
- ['Math.expm1', { kind: 'property', store: null, emit: 'gea::host::Math::expm1' }],
194
- ['Math.log10', { kind: 'property', store: null, emit: 'gea::host::Math::log10' }],
195
- ['Math.log1p', { kind: 'property', store: null, emit: 'gea::host::Math::log1p' }],
196
- ['Math.log2', { kind: 'property', store: null, emit: 'gea::host::Math::log2' }],
197
- ['Math.cosh', { kind: 'property', store: null, emit: 'gea::host::Math::cosh' }],
198
- ['Math.tanh', { kind: 'property', store: null, emit: 'gea::host::Math::tanh' }],
199
- ['Math.acosh', { kind: 'property', store: null, emit: 'gea::host::Math::acosh' }],
200
- ['Math.asinh', { kind: 'property', store: null, emit: 'gea::host::Math::asinh' }],
201
- ['Math.atanh', { kind: 'property', store: null, emit: 'gea::host::Math::atanh' }],
202
- ['Math.fround', { kind: 'property', store: null, emit: 'gea::host::Math::fround' }],
203
- ['Math.clz32', { kind: 'property', store: null, emit: 'gea::host::Math::clz32' }],
204
- ['Math.imul', { kind: 'property', store: null, emit: 'gea::host::Math::imul' }],
202
+ ['Math.cbrt', mathDirect('cbrt', 1)],
203
+ ['Math.sign', mathDirect('sign', 1)],
204
+ ['Math.trunc', mathDirect('trunc', 1)],
205
+ ['Math.exp', mathDirect('exp', 1)],
206
+ ['Math.expm1', mathDirect('expm1', 1)],
207
+ ['Math.log10', mathDirect('log10', 1)],
208
+ ['Math.log1p', mathDirect('log1p', 1)],
209
+ ['Math.log2', mathDirect('log2', 1)],
210
+ ['Math.cosh', mathDirect('cosh', 1)],
211
+ ['Math.tanh', mathDirect('tanh', 1)],
212
+ ['Math.acosh', mathDirect('acosh', 1)],
213
+ ['Math.asinh', mathDirect('asinh', 1)],
214
+ ['Math.atanh', mathDirect('atanh', 1)],
215
+ ['Math.fround', mathDirect('fround', 1)],
216
+ ['Math.clz32', mathDirect('clz32', 1)],
217
+ ['Math.imul', mathDirect('imul', 2)],
205
218
  // `readonly PI: number` -- a data property, and the one member here that is
206
219
  // not a callable at all.
207
220
  ['Math.PI', { kind: 'property', store: null, emit: 'gea::host::Math::PI' }],
@@ -1516,7 +1516,7 @@ export const currentCppRuntimeCapabilities = Object.freeze({
1516
1516
  // filters its descriptors for enumerability, gets each value, then creates
1517
1517
  // a data property on the receiver. The `dynamic->dynamic` suffix is
1518
1518
  // mandatory: a dictionary receiver requires a different key-domain
1519
- // contract and remains deliberately unclaimed.
1519
+ // contract, claimed separately below as `dynamic->dictionary(string)`.
1520
1520
  'protocol:spread:next:dynamic->dynamic',
1521
1521
  'protocol:spread:next:indexed-record<-copyable',
1522
1522
  // The same field-by-field copy into a literal with NO index signature
@@ -1533,6 +1533,15 @@ export const currentCppRuntimeCapabilities = Object.freeze({
1533
1533
  // names is read and lands in its field through the checked conversion
1534
1534
  // from `dynamic` -- `carrier-keys.ts`'s `isDynamicCopyableIntoFieldRecord`.
1535
1535
  'protocol:spread:next:field-record<-dynamic',
1536
+ // A genuinely dynamic source into a STRING-keyed dictionary receiver --
1537
+ // mongodb's `mechanismProperties = { ...optionValue }` over an `unknown`
1538
+ // bounded only by `isRecord`. `emit-allocation.ts`'s
1539
+ // `emitDynamicSpreadIntoDictionary` walks the source's own enumerable
1540
+ // string keys and stores each value through the dictionary's checked
1541
+ // conversion from `dynamic`, the walk `Object.assign` of a dynamic source
1542
+ // into a typed dictionary already uses. The `(string)` suffix keeps a
1543
+ // number-keyed table, whose key contract differs, unclaimed.
1544
+ 'protocol:spread:next:dynamic->dictionary(string)',
1536
1545
  'protocol:spread:next:indexed-record(copyable)',
1537
1546
  'protocol:spread:next:optional(indexed-record(copyable))',
1538
1547
  // `yield x` inside a `function*`, and the resume point paired with it.
@@ -2971,7 +2971,14 @@ attributesConstant = false,
2971
2971
  */
2972
2972
  methodStateUntraced = false) => {
2973
2973
  const isNarrowed = (field) => narrowedSlots.has(integerStorageSlot(structName, field.key));
2974
- const tailFields = tailFieldsOf(layout, celled, reactive.cell, isNarrowed);
2974
+ // A class keeps every field inline. Its fields are stored by the
2975
+ // constructor views, the property-store emitter and callable frames, which
2976
+ // all address a class member by name; only the record paths spell a tail
2977
+ // block (`tailAwareFieldWriteText`). A tailed class therefore rendered
2978
+ // `gea_this->precision = ...` against a struct whose `precision` lived in
2979
+ // its tail -- three.js's `Material` crossed the sparse-layout threshold and
2980
+ // its own constructor no longer compiled.
2981
+ const tailFields = classDispatch ? emptyStringSet : tailFieldsOf(layout, celled, reactive.cell, isNarrowed);
2975
2982
  const tailStructName = cppRecordTailStructName(structName);
2976
2983
  const tailLines = [];
2977
2984
  if (tailFields.size > 0) {