Commit Graph
978 Commits
Author SHA1 Message Date
Malte Ubl d5c31a933c Read class property bags without creating them
A class instance keeps its own dynamic properties in a lazily created bag
(`%dynProperties`). Untyped reads went through the bag accessor that
creates and stores the bag on first use: selecting a method checks the bag
for an own property shadowing it, and the named and computed fallbacks,
`in`/own probes, Reflect.get, for-in and accessor reads all looked their key
up there. So a pure read stored into the object. On a published object the
frozen-object guard rejects that store with "Cannot assign to read only
property '%dynProperties'", where Node reads without error.

Read-only bag accessors now never store. The untyped
%dyn.class.readProperties is rebuilt from the settled bag dispatch without
its lazy stores, and typed read helpers return a prototype-backed bag
instead of storing it. Every read path uses the read-only accessor: key
tests treat an absent bag as having no own keys, and lookups that must see
Object.prototype read from a fresh, unstored empty object. Writes keep the
storing accessor.

Found with tsc-ts at --checkers 8 on vercel/eve: a checker thread read
`host.commonSourceDirectory()` through an untyped interface value whose
object is the published Program.
2026-10-12 08:29:56 -07:00
Chris Tate bfbe047cbb Read SCR_COLD as an attribute in the runtime ABI guard 2026-10-12 09:21:23 -05:00
Chris Tate 2391b0ebf3 Merge pull request #869 from vercel-labs/perf/parse-round4
Read charCodeAt at proven integer indices without a double round trip
2026-10-12 08:59:12 -05:00
Chris Tate 1f98312881 Merge pull request #880 from vercel-labs/feat/acyclic-contract
Acyclic contract type
2026-10-12 08:58:49 -05:00
Chris Tate 936e9c5dae Merge main into perf/parse-round4 2026-10-12 08:51:31 -05:00
Chris Tate da309e1655 Identity bitwise forms over proven int32 operands return the operand (#878) 2026-10-12 08:49:35 -05:00
Chris Tate 7cf57f9ed5 Merge main into feat/acyclic-contract 2026-10-12 08:43:05 -05:00
Malte Ubl e1ccfeeb84 codegen: signed conversions for array counters and lengths
Integer induction counters live in unsigned 64-bit slots, so every read
as a number was a uitofp i64 (a 6-7 instruction sequence on x86-64) and
every nested start an fptoui. The runtime's push path also round-tripped
the array length through a double for its bound check.

The values are at most 2^32 - 1: on 64-bit targets convert counters with
sitofp and loop starts with fptosi, convert array lengths and validated
indices through int64_t in scr_array.c, and test the push bound on the
integer length. 32-bit targets keep the unsigned conversions.

tsc-ts Excalidraw: uitofp i64 sequences 32.5 M -> 4.0 M, -0.66%
instructions on top of the throw-path change.
2026-10-12 06:40:50 -07:00
Malte Ubl b5e4bcb54e runtime: keep throw entry points cold and out of line
With runtime bitcode import, scr_throw_obj, scr_error_new and the other
throw entry points were inlined into the error paths of small compiled
functions. The inlined bodies needed callee-saved registers that every
call then saved and restored, and they made the helpers too large to
inline into their callers (1047 inlined throw bodies in tsc-ts).

Mark the 25 functions that only run while raising a JS exception
cold and noinline. The LLVM helper never imports noinline bodies, so
the throw paths stay calls. tsc-ts Excalidraw: -0.44% instructions.
2026-10-12 06:40:50 -07:00
Chris Tate 0b239089e7 Cover the integer-index charCodeAt helper in the borrowed-input ABI test 2026-10-12 08:25:43 -05:00
Chris Tate 0d2bcf9d97 Merge main into feat/acyclic-contract 2026-10-12 08:10:24 -05:00
Chris Tate 88b4e89e55 Merge main into feat/nothrow-try-catch 2026-10-12 08:07:54 -05:00
Chris Tate 0a4bf78d4a Merge main into perf/int32-or-zero-peephole 2026-10-12 08:05:16 -05:00
Chris Tate 83248651e2 Publish Immutable factory arrays only after provable index writes 2026-10-12 02:33:29 -05:00
Chris Tate f77d68f600 Keep the RC entry points of array elements in one shared descriptor (#882) 2026-10-12 01:59:44 -05:00
Chris Tate 48b5935337 Unshare repeated IR nodes before emission and contract checks 2026-10-12 01:47:05 -05:00
Chris Tate 72cc828ab0 Merge main into perf/compact-array-header-2 2026-10-12 01:12:21 -05:00
Chris Tate 2ea30ede5b Merge main into perf/static-immutability 2026-10-12 01:09:18 -05:00
Chris Tate 0dee8207bb Keep self-hosting emission tests from blocking the test worker (#883) 2026-10-12 01:06:52 -05:00
Chris Tate 5e5ec89c76 Run the emission test's compiler passes off the test worker 2026-10-12 00:32:48 -05:00
Chris Tate 2933ebc985 Store order-parity baselines one file per fixture 2026-10-12 00:08:53 -05:00
Chris Tate 0874739c02 Run the frontend services test's compiler and processes off the test worker 2026-10-12 00:07:55 -05:00
Chris Tate 4184028663 Keep self-hosting emission tests from blocking the test worker 2026-10-11 23:39:43 -05:00
Chris Tate 1c4b34d2da Keep publication guards after self-stores and own borrowed-result call arguments 2026-10-11 22:40:27 -05:00
Chris Tate 063a3c7956 Merge main into fix/narrowed-property-calls 2026-10-11 22:29:21 -05:00
Malte Ubl fa55ce6b07 Keep the RC entry points of array elements in one shared descriptor
Every SCR_ELEM_REF array stored its element type's retain, release and trace entry points in its own header (24 bytes), so ScrArr was 80 bytes: an 80-byte block for arrays of acyclic elements and a 96-byte block for cycle-capable ones. The three pointers now live in one constant ScrArrOps descriptor per element type, which the compiler emits once per module (@sc_arrops.*) and the runtime keeps static, and the header holds a pointer to it plus a 4-byte `cyc` flag beside `elem` that the inline RC fast paths test. ScrArr is 64 bytes: arrays take 64- and 80-byte blocks.

scr_arr_new_ref(retain, release, trace, cap) becomes scr_arr_new_ops(ops, cap); scr_set_to_arr_ref takes the result's descriptor from its caller instead of building an array from the set's key adapters. The backend names the %ScrArr fields in SCR_ARR_FIELD. The layout change bumps the runtime ABI marker to scr_runtime_abi_v13.
2026-10-11 19:46:48 -07:00
Chris Tate aa4fa790a3 Merge main into fix/narrowed-property-calls 2026-10-11 21:37:45 -05:00
Chris Tate 31aaefb4c6 Merge main into perf/map-get-inline-retain 2026-10-11 21:31:11 -05:00
Malte Ubl 3c26a85d9c Merge branch 'feat/contract-types' into feat/acyclic-contract 2026-10-11 16:32:31 -07:00
Malte Ubl 3d7e8e731c Merge branch 'feat/contract-types' into feat/nothrow-try-catch 2026-10-11 16:32:27 -07:00
Malte Ubl f00e312d76 Merge branch 'feat/contract-types' into perf/int32-or-zero-peephole 2026-10-11 16:32:24 -07:00
Malte Ubl 448860dc94 Merge branch 'main' into perf/codegen 2026-10-11 16:32:03 -07:00
Malte Ubl 15af413acd Merge branch 'main' into feat/contract-types 2026-10-11 16:32:00 -07:00
Malte Ubl 02114c6064 Merge branch 'main' into perf/parse-round4 2026-10-11 16:31:57 -07:00
Malte Ubl 7027039809 Merge branch 'main' into perf/map-get-inline-retain 2026-10-11 16:31:53 -07:00
Malte Ubl b9d391fc8d Merge branch 'main' into fix/narrowed-property-calls 2026-10-11 16:31:49 -07:00
Malte Ubl f88830c4be Merge branch 'main' into perf/static-immutability 2026-10-11 16:31:46 -07:00
Malte Ubl 73ee5e17e9 Acyclic: a dedicated default interface; shortest cycle in explanations
`implements Acyclic` resolved to Record<never, never>, and the frontend
indexes implemented types as class protocols by symbol, so every Record
value in the program took checked identity (on tsc-ts: Int32 field
contracts failed with SC7003). The default is now AcyclicObject, an empty
interface only @scriptc/types declares, and type arguments in heritage
clauses are reported (they would make a class implement its own type).
Corpus 4642 stores an Acyclic class with an Int32 field in a Record.

explainCycle picks the shortest cycle through the unit and a mutable
edge (BFS distances forward and backward within the component): on
tsc-ts `Node.parent -> Node` instead of a 20-step path through the
checker.
2026-10-11 16:30:25 -07:00
Malte Ubl ad2fcfbc27 try/catch discharges NoThrow: handlers take what they catch
The may-throw analysis now models handlers. A throwing operation or call
inside a `try` with a `catch`, or inside a try/catch whose `finally`
never completes normally (it returns, breaks or continues, discarding the
pending exception), adds no seed and no call edge. The catch and finally
bodies are analyzed like any other code, so rethrows and a finally that
re-raises stay exact. Worker programs (a termination request unwinds
through catch) and generator bodies (a `.return()` does too) keep the
conservative answer.

Unreachable statements no longer seed: the frontend's SC9002 trap after a
body that returns from both its try and its catch (or ends in a switch
with a default, or an infinite loop) is dead code. On tsc-ts this drops
14 functions from the may-throw set and 44 pending-exception checks.

A NoThrow function may now contain handled calls; the SC7001 hint names
the remedy that applies (catch it, remove the recursion, or the worker
exception).
2026-10-11 16:30:24 -07:00
Malte Ubl 3ce9370b35 Acyclic contract type: classes and object types that cannot lie on a cycle
`class C implements Acyclic`, `interface I extends Acyclic` and
`type T = Acyclic<{ ... }>` promise that no chain of references leads
from such an object back to itself. The check is the cycle analysis that
decides tracing, so a proven type carries no cycle-collector header. When
it does not hold, SC7007 shows the cycle: the path of fields, and why it
can close (a field assigned after construction, with the first such
write; an array, Map or Set; a function, dynamic or promise field; a
subclass sharing the layout). cycle-analysis.ts gains explainCycle over
the same graph with edge labels; computeTraced is unchanged.

Acyclic elsewhere is reported with SC7006. Docs, @scriptc/types,
corpus 4642, diagnostics snapshots and TypeScript baselines included.
2026-10-11 16:30:24 -07:00
Chris Tate 3bf0d0b9a5 Give the sanitized emitter job swap and a larger stack
The sanitized native emitter peaks near 13 GB while it emits the
compiler and then compiles the 348 MB module with clang under
AddressSanitizer, which together exceed the 16 GB runner. Back the
rebuild-emit job with a 24 GiB swap file and lift its stack limit,
since the instrumented emitter's recursion can exceed 8 MiB.
2026-10-11 16:45:12 -05:00
Malte Ubl 2162b0af65 Identity bitwise forms over proven int32 operands return the operand
`x | 0`, `x ^ 0`, `x & -1`, `x << 0`, `x >> 0` (and `x >>> 0` for a
uint32) over an operand the integer range analysis proves an int32 now
return the operand's number and its integer views instead of converting
to i32 and back: ranges exclude -0, so the result is the operand bit for
bit. The range analysis computes bitwise result ranges from the operand
ranges (exact ToInt32/ToUint32 views, shift-count ranges) instead of the
blanket int32 range, so `(n & 0xff) | 0`, `s.length >> 1` or `x >>> 1`
keep tight bounds for later integer consumers.
2026-10-11 14:24:59 -07:00
Malte Ubl 9899c4014b Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	packages/compiler/test/ts7/baselines/order-parity.json
2026-10-11 13:39:52 -07:00
Malte Ubl bb274adc5d Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	packages/compiler/test/ts7/baselines/order-parity.json
2026-10-11 13:27:39 -07:00
Malte Ubl d57b7c4b63 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	packages/compiler/test/ts7/baselines/order-parity.json
2026-10-11 13:27:32 -07:00
Malte Ubl eae8e02481 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	packages/compiler/test/ts7/baselines/order-parity.json
2026-10-11 13:27:25 -07:00
Malte Ubl 5ac6252916 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	packages/compiler/test/ts7/baselines/order-parity.json
2026-10-11 13:27:18 -07:00
Malte Ubl 0148f6b741 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	packages/compiler/test/ts7/baselines/order-parity.json
2026-10-11 13:27:11 -07:00
Chris Tate c9452c8c33 Merge pull request #867 from vercel-labs/perf/checker-round4
PR: Read nullable-union array elements inline and borrow them for preserving live ranges
2026-10-11 15:25:09 -05:00
Chris Tate d761cb530d Merge main into perf/static-immutability 2026-10-11 15:19:32 -05:00