@scriptc/compiler 0.2.8 → 0.2.9

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 (189) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +1 -0
  2. package/dist/backend/cycle-analysis.js +50 -17
  3. package/dist/backend/cycle-analysis.js.map +1 -1
  4. package/dist/backend/cycle-analysis.test.js +138 -14
  5. package/dist/backend/cycle-analysis.test.js.map +1 -1
  6. package/dist/backend/cycle-mutability.d.ts +31 -6
  7. package/dist/backend/cycle-mutability.js +120 -18
  8. package/dist/backend/cycle-mutability.js.map +1 -1
  9. package/dist/backend/llvm/alloc.d.ts +13 -3
  10. package/dist/backend/llvm/alloc.js +24 -10
  11. package/dist/backend/llvm/alloc.js.map +1 -1
  12. package/dist/backend/llvm/alloc.test.js +5 -5
  13. package/dist/backend/llvm/alloc.test.js.map +1 -1
  14. package/dist/backend/llvm/byte-numbers.js +2 -3
  15. package/dist/backend/llvm/byte-numbers.js.map +1 -1
  16. package/dist/backend/llvm/classes.js +7 -6
  17. package/dist/backend/llvm/classes.js.map +1 -1
  18. package/dist/backend/llvm/common.d.ts +17 -0
  19. package/dist/backend/llvm/common.js +28 -0
  20. package/dist/backend/llvm/common.js.map +1 -1
  21. package/dist/backend/llvm/dense-array-access.js +1 -1
  22. package/dist/backend/llvm/dense-array-access.test.js +1 -1
  23. package/dist/backend/llvm/dyn.d.ts +4 -4
  24. package/dist/backend/llvm/dyn.js +27 -11
  25. package/dist/backend/llvm/dyn.js.map +1 -1
  26. package/dist/backend/llvm/emitter.d.ts +45 -3
  27. package/dist/backend/llvm/emitter.js +333 -74
  28. package/dist/backend/llvm/emitter.js.map +1 -1
  29. package/dist/backend/llvm/emitter.test.js +36 -3
  30. package/dist/backend/llvm/emitter.test.js.map +1 -1
  31. package/dist/backend/llvm/expr-bytes.js +35 -28
  32. package/dist/backend/llvm/expr-bytes.js.map +1 -1
  33. package/dist/backend/llvm/expr-containers.js +1 -1
  34. package/dist/backend/llvm/expr-context.d.ts +2 -0
  35. package/dist/backend/llvm/expr-control.js +46 -5
  36. package/dist/backend/llvm/expr-control.js.map +1 -1
  37. package/dist/backend/llvm/expr-dynamic.js +3 -0
  38. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  39. package/dist/backend/llvm/expr-stream-bridges.d.ts +3 -0
  40. package/dist/backend/llvm/expr-stream-bridges.js +73 -11
  41. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  42. package/dist/backend/llvm/lib-filesystem.js +18 -2
  43. package/dist/backend/llvm/lib-filesystem.js.map +1 -1
  44. package/dist/backend/llvm/lib-shared.js +1 -0
  45. package/dist/backend/llvm/lib-shared.js.map +1 -1
  46. package/dist/backend/llvm/local-array-reads.d.ts +17 -6
  47. package/dist/backend/llvm/local-array-reads.js +155 -43
  48. package/dist/backend/llvm/local-array-reads.js.map +1 -1
  49. package/dist/backend/llvm/reference-effects.js +34 -1
  50. package/dist/backend/llvm/reference-effects.js.map +1 -1
  51. package/dist/backend/llvm/shapes.d.ts +14 -3
  52. package/dist/backend/llvm/shapes.js +43 -12
  53. package/dist/backend/llvm/shapes.js.map +1 -1
  54. package/dist/backend/llvm/shapes.test.js +5 -5
  55. package/dist/backend/llvm/shapes.test.js.map +1 -1
  56. package/dist/backend/llvm/string-reads.js +29 -26
  57. package/dist/backend/llvm/string-reads.js.map +1 -1
  58. package/dist/backend/llvm/string-slices.js +1 -1
  59. package/dist/backend/llvm/trunc.d.ts +8 -0
  60. package/dist/backend/llvm/trunc.js +28 -0
  61. package/dist/backend/llvm/trunc.js.map +1 -0
  62. package/dist/backend/loop-polls.d.ts +14 -0
  63. package/dist/backend/loop-polls.js +100 -0
  64. package/dist/backend/loop-polls.js.map +1 -0
  65. package/dist/backend/loop-polls.test.d.ts +1 -0
  66. package/dist/backend/loop-polls.test.js +86 -0
  67. package/dist/backend/loop-polls.test.js.map +1 -0
  68. package/dist/backend/may-throw.js +20 -1
  69. package/dist/backend/may-throw.js.map +1 -1
  70. package/dist/backend/may-throw.test.js +23 -0
  71. package/dist/backend/may-throw.test.js.map +1 -1
  72. package/dist/backend/native-codegen.d.ts +1 -3
  73. package/dist/backend/native-codegen.js +4 -32
  74. package/dist/backend/native-codegen.js.map +1 -1
  75. package/dist/backend/runtime-abi.d.ts +2 -2
  76. package/dist/backend/runtime-abi.js +2 -2
  77. package/dist/backend/runtime-abi.js.map +1 -1
  78. package/dist/backend/runtime-pack-targets.test.js +1 -1
  79. package/dist/backend/runtime-pack-targets.test.js.map +1 -1
  80. package/dist/backend/runtime-pack.test.js +1 -1
  81. package/dist/backend/runtime-pack.test.js.map +1 -1
  82. package/dist/cli/command.js +8 -1
  83. package/dist/cli/command.js.map +1 -1
  84. package/dist/cli/output-options.d.ts +1 -0
  85. package/dist/cli/output-options.js +3 -0
  86. package/dist/cli/output-options.js.map +1 -1
  87. package/dist/cli/usage.d.ts +5 -1
  88. package/dist/cli/usage.js +6 -0
  89. package/dist/cli/usage.js.map +1 -1
  90. package/dist/compile-types.d.ts +5 -0
  91. package/dist/executable/executable-cache.d.ts +2 -0
  92. package/dist/executable/executable-cache.js +3 -0
  93. package/dist/executable/executable-cache.js.map +1 -1
  94. package/dist/executable/executable-cache.test.js +1 -0
  95. package/dist/executable/executable-cache.test.js.map +1 -1
  96. package/dist/frontend/lowering/array-values.js +37 -1
  97. package/dist/frontend/lowering/array-values.js.map +1 -1
  98. package/dist/frontend/lowering/builtins/strings.js +4 -1
  99. package/dist/frontend/lowering/builtins/strings.js.map +1 -1
  100. package/dist/frontend/lowering/call-arguments.js +96 -4
  101. package/dist/frontend/lowering/call-arguments.js.map +1 -1
  102. package/dist/frontend/lowering/class-method-mutations.js +88 -0
  103. package/dist/frontend/lowering/class-method-mutations.js.map +1 -1
  104. package/dist/frontend/lowering/containers/bytes.js +15 -4
  105. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  106. package/dist/frontend/lowering/expressions/union-fields.d.ts +19 -0
  107. package/dist/frontend/lowering/expressions/union-fields.js +236 -0
  108. package/dist/frontend/lowering/expressions/union-fields.js.map +1 -0
  109. package/dist/frontend/lowering/lower-calls.js +12 -2
  110. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  111. package/dist/frontend/lowering/lower-exprs.d.ts +6 -0
  112. package/dist/frontend/lowering/lower-exprs.js +162 -3
  113. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  114. package/dist/frontend/lowering/lower-island.js +5 -19
  115. package/dist/frontend/lowering/lower-island.js.map +1 -1
  116. package/dist/frontend/lowering/lower-stmts.js +11 -1
  117. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  118. package/dist/frontend/lowering/lowerer.d.ts +5 -0
  119. package/dist/frontend/lowering/lowerer.js +174 -8
  120. package/dist/frontend/lowering/lowerer.js.map +1 -1
  121. package/dist/frontend/lowering/nan-coded-reads.d.ts +161 -0
  122. package/dist/frontend/lowering/nan-coded-reads.js +1342 -0
  123. package/dist/frontend/lowering/nan-coded-reads.js.map +1 -0
  124. package/dist/frontend/lowering/runtime-optional-bounds.d.ts +14 -2
  125. package/dist/frontend/lowering/runtime-optional-bounds.js +17 -11
  126. package/dist/frontend/lowering/runtime-optional-bounds.js.map +1 -1
  127. package/dist/frontend/lowering/runtime-optional-bounds.test.js +28 -0
  128. package/dist/frontend/lowering/runtime-optional-bounds.test.js.map +1 -1
  129. package/dist/frontend/lowering/surfaces.js +8 -0
  130. package/dist/frontend/lowering/surfaces.js.map +1 -1
  131. package/dist/index.d.ts +1 -1
  132. package/dist/index.js +20 -8
  133. package/dist/index.js.map +1 -1
  134. package/dist/ir/builtin-signatures.d.ts +1 -1
  135. package/dist/ir/builtin-signatures.js +2 -0
  136. package/dist/ir/builtin-signatures.js.map +1 -1
  137. package/dist/ir/constant-globals.d.ts +14 -0
  138. package/dist/ir/constant-globals.js +81 -0
  139. package/dist/ir/constant-globals.js.map +1 -0
  140. package/dist/ir/constant-globals.test.d.ts +1 -0
  141. package/dist/ir/constant-globals.test.js +97 -0
  142. package/dist/ir/constant-globals.test.js.map +1 -0
  143. package/dist/ir/final-fields.d.ts +35 -0
  144. package/dist/ir/final-fields.js +187 -0
  145. package/dist/ir/final-fields.js.map +1 -0
  146. package/dist/ir/final-fields.test.d.ts +1 -0
  147. package/dist/ir/final-fields.test.js +106 -0
  148. package/dist/ir/final-fields.test.js.map +1 -0
  149. package/dist/ir/int32-slots.d.ts +9 -0
  150. package/dist/ir/int32-slots.js +70 -57
  151. package/dist/ir/int32-slots.js.map +1 -1
  152. package/dist/ir/int32-slots.test.js +27 -0
  153. package/dist/ir/int32-slots.test.js.map +1 -1
  154. package/dist/ir/integer-loops.d.ts +5 -0
  155. package/dist/ir/integer-loops.js +20 -4
  156. package/dist/ir/integer-loops.js.map +1 -1
  157. package/dist/ir/integer-loops.test.js +17 -0
  158. package/dist/ir/integer-loops.test.js.map +1 -1
  159. package/dist/ir/ir.d.ts +6 -1
  160. package/dist/ir/ir.js +4 -0
  161. package/dist/ir/ir.js.map +1 -1
  162. package/dist/ir/serialize.d.ts +12 -2
  163. package/dist/ir/serialize.js +190 -39
  164. package/dist/ir/serialize.js.map +1 -1
  165. package/dist/ir/serialize.test.js +65 -1
  166. package/dist/ir/serialize.test.js.map +1 -1
  167. package/dist/native/cache.d.ts +8 -1
  168. package/dist/native/cache.js +38 -1
  169. package/dist/native/cache.js.map +1 -1
  170. package/dist/native/cache.test.js +11 -0
  171. package/dist/native/cache.test.js.map +1 -1
  172. package/dist/native/compiler.js +4 -3
  173. package/dist/native/compiler.js.map +1 -1
  174. package/dist/native/prepare.d.ts +3 -1
  175. package/dist/native/prepare.js +63 -28
  176. package/dist/native/prepare.js.map +1 -1
  177. package/dist/native/prepare.test.js +23 -1
  178. package/dist/native/prepare.test.js.map +1 -1
  179. package/dist/native/text-file.d.ts +10 -0
  180. package/dist/native/text-file.js +41 -0
  181. package/dist/native/text-file.js.map +1 -0
  182. package/dist/text-parts.d.ts +5 -0
  183. package/dist/text-parts.js +36 -0
  184. package/dist/text-parts.js.map +1 -0
  185. package/package.json +20 -20
  186. package/surface-manifest.json +7 -1
  187. package/dist/frontend/lowering/expressions/union-field-write.d.ts +0 -8
  188. package/dist/frontend/lowering/expressions/union-field-write.js +0 -108
  189. package/dist/frontend/lowering/expressions/union-field-write.js.map +0 -1
@@ -45,6 +45,10 @@ export interface LlvmTargetOptions {
45
45
  /** Emit retain/release fast paths inline (the `speed` posture). Off, every
46
46
  * retain and release is a runtime call. */
47
47
  inlineRc?: boolean;
48
+ /** Define `scr_detached_exit` so the Linux runtime hands the address-space
49
+ * teardown after `process.exit` to a helper process (`--detached-exit`).
50
+ * Executables only; the runtime's weak default keeps it off. */
51
+ detachedExit?: boolean;
48
52
  }
49
53
  export declare function emitLlvmModule(mod: IrModule, options?: LlvmTargetOptions): string;
50
54
  /** Keep large translation units below the host's single-string limit. */
@@ -73,12 +77,27 @@ export declare class LlEmitter {
73
77
  private debugScope;
74
78
  readonly sizeType: "i32" | "i64";
75
79
  readonly ffiExtendNarrowIntegers: boolean;
76
- readonly cycleColorOffset: number;
80
+ readonly cycleBufferedOffset: number;
81
+ /** Emitted ScrCycType descriptors so far (their collector statistics
82
+ * indices; see ShapeHost.nextCycKind). */
83
+ private cycKinds;
77
84
  readonly wasi: boolean;
85
+ /** The target lacks a rounding instruction at its baseline CPU (x86-64
86
+ * before SSE4.1), so `llvm.trunc` would lower to a libm call: emit
87
+ * truncation inline through an integer round trip instead. */
88
+ readonly inlineTrunc: boolean;
78
89
  /** ELF worker executables give thread-locals the executable TLS models. */
79
90
  private readonly executableTls;
91
+ /** Source loops enclosing the statement being emitted in the current
92
+ * function body. */
93
+ private loopDepth;
94
+ /** Darwin worker executables read the stack guard from a pthread
95
+ * thread-specific-data slot off the thread pointer (scr_runtime.h's
96
+ * SCR_STACK_GUARD_TSD): the architecture names the access sequence. */
97
+ private readonly stackGuardTsd;
80
98
  private readonly emitLibraryIdentity;
81
99
  private readonly runtimeAbiMarker;
100
+ private readonly detachedExit;
82
101
  /** Interned string literals: UTF-8 text → { symbol, byte length } —
83
102
  * first-use order, the runtime ABI’s determinism discipline. */
84
103
  private readonly literals;
@@ -286,6 +305,11 @@ export declare class LlEmitter {
286
305
  };
287
306
  }>;
288
307
  private countedLoopsEnabled;
308
+ /** Whole-program final reference fields (ir/final-fields.ts). */
309
+ private finalFields;
310
+ /** The current function may borrow final fields of borrowable objects:
311
+ * not a constructor (where they change), not async or a generator. */
312
+ private finalFieldBorrows;
289
313
  integerRanges: IntegerRanges;
290
314
  private byteWindowsEnabled;
291
315
  private byteWindowEntries;
@@ -486,6 +510,13 @@ export declare class LlEmitter {
486
510
  * unwind returns it as the dummy, so a call in tail position keeps a single
487
511
  * return and stays eligible for tail-call and recursion elimination. */
488
512
  private emitUnwind;
513
+ /** Loads the running thread's exact pending word (ELF worker
514
+ * executables, scr_exception.c): bit 0 mirrors the active cell, bit 1
515
+ * requests the context's stop. It lives in the executable's static TLS
516
+ * block, so the access is one thread-pointer-relative load. Monotonic by
517
+ * default: a loop must not hoist the load out and miss a cross-thread
518
+ * stop (see emitPendingCheck for the unordered tests). */
519
+ private loadExcFlag;
489
520
  /** Instructions (two-space indented) that set the i1 `dest` to "an
490
521
  * exception is pending in the active context" — scr_exc_pending()'s
491
522
  * meaning — for the helper and adapter bodies that test it outside
@@ -501,11 +532,12 @@ export declare class LlEmitter {
501
532
  * call's result temp must join its frame BEFORE this runs so the unwind
502
533
  * releases the dummy (NULL for refcounted kinds) harmlessly. A scalar
503
534
  * call result of the function's return type may be passed as the unwind's
504
- * dummy value (see emitUnwind). */
535
+ * dummy value (see emitUnwind). `poll` marks a worker termination poll
536
+ * (function entry or loop budget), whose test must stay ordered. */
505
537
  emitPendingCheck(passThrough?: {
506
538
  name: string;
507
539
  type: IrType;
508
- }): void;
540
+ }, poll?: boolean): void;
509
541
  /** After a runtime call that ALWAYS leaves an exception pending (the
510
542
  * compiler-resolved Node throws): the pending test would always answer
511
543
  * true, so unwind unconditionally. Emission continues in a block with no
@@ -515,6 +547,9 @@ export declare class LlEmitter {
515
547
  /** A recursive function's entry check: below the running stack's guard,
516
548
  * throw Node's RangeError and unwind like any other pending exception. */
517
549
  private emitStackCheck;
550
+ /** Whether the emitter follows this call with a pending test (the
551
+ * conditions in expr-calls.ts). */
552
+ private callTestsPending;
518
553
  private workerLoopBudget;
519
554
  private emitWorkerLoopCheck;
520
555
  /** Moves an already-evaluated value into the runtime's exception cell —
@@ -621,6 +656,13 @@ export declare class LlEmitter {
621
656
  * array cell holding the value and move it into the ARR-kind box
622
657
  * (set_ref releases nothing — the slot was the empty sentinel). */
623
658
  private tdzScalarInit;
659
+ /** The payload a TDZ box holds before its declaration runs, when that is
660
+ * not NULL. A nullable union's value is its arm pointer with NULL as a
661
+ * unit arm (nullable-unions.ts), so a stored `null`/`undefined` would
662
+ * read back as the temporal dead zone; such boxes start at the module's
663
+ * immortal NULLABLE_ABSENT sentinel instead, which no value of the
664
+ * binding can hold and every RC entry point and the collector skip. */
665
+ private tdzEmptySentinel;
624
666
  /** The TDZ-guarded read of a boxed binding: an empty payload slot is
625
667
  * the temporal dead zone — throw Node's exact catchable ReferenceError
626
668
  * (exprs.ts's varRef guard). Scalars then peek the one-element