Skip to content

Commit c1937e5

Browse files
committed
Restore reviewed standard-library safety fixes for PR #449
1 parent 2a9098a commit c1937e5

10 files changed

Lines changed: 1030 additions & 61 deletions

File tree

‎usvm-ts/UNKNOWN_CALL_MODELS.md‎

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,56 @@ Built-ins are `object` implementations of the sealed `TsBuiltInUnknownCallModel`
6060
`org.usvm.machine.call.intrinsic` package. Kotlin's sealed-subclass metadata discovers them automatically; adding a
6161
model requires no manual registry entry. Discovery and the default catalog are computed once.
6262

63-
The built-in catalog currently contains:
63+
The built-in catalog includes the following public APIs and their internal storage primitives. Enumerate
64+
`TsBuiltInUnknownCallModels.catalog().modelIds` for the exact IDs in a build.
6465

6566
| ID | Implementation | Accepted calls |
6667
| --- | --- | --- |
6768
| `ts.array.shift` | Kotlin intrinsic using symbolic-memory `memcpy` | Zero-argument `shift` on a definitely one-dimensional array. |
69+
| `ts.array.isArray` | Kotlin runtime-type primitive | The genuine global Array predicate, including null, undefined and fake-value wrappers. |
6870
| `ts.array.pop` | TypeScript/EtsIR body | Zero-argument `pop` on a definitely one-dimensional array that also satisfies the symbolic runtime type guard. |
71+
| `ts.array.includes`, `ts.array.indexOf`, `ts.array.lastIndexOf` | TypeScript/EtsIR bodies | One-dimensional arrays and numeric positions, with the missing-slot exclusions below. |
72+
| `ts.array.push`, `ts.array.fill`, `ts.array.reverse`, `ts.array.unshift`, `ts.array.slice`, `ts.array.concat` | TypeScript/EtsIR bodies with storage growth/allocation primitives | One-dimensional arrays with length/result at most 16. Push/unshift accept up to three arguments; resolved-sort arrays require matching element sorts, while mixed arrays retain runtime value kinds. Concat accepts one same-type array. Except push, these operations require a current dense-array proof. |
73+
| `ts.string.charAt`, `ts.string.charCodeAt`, `ts.string.includes`, `ts.string.indexOf`, `ts.string.lastIndexOf`, `ts.string.startsWith`, `ts.string.endsWith` | TypeScript/EtsIR bodies | Strings in initialized UTF-16 storage, including symbolic code units and numeric positions. |
74+
| `ts.string.slice`, `ts.string.substring`, `ts.string.trim`, `ts.string.trimStart`, `ts.string.trimEnd` | TypeScript/EtsIR bodies | UTF-16 range copying; substring clamps/swaps bounds, and trim uses the ECMAScript whitespace set. |
75+
| `ts.string.toLowerCase`, `ts.string.toUpperCase` | TypeScript/EtsIR bodies | ASCII strings of at most 16 code units; other strings use residual fallback. |
76+
| `ts.math.abs`, `ts.math.ceil`, `ts.math.floor`, `ts.math.max`, `ts.math.min`, `ts.math.round`, `ts.math.sqrt`, `ts.math.trunc` | Kotlin FP primitives | Numeric arguments; dynamic coercions use fallback. |
77+
| `ts.number.isFinite`, `ts.number.isInteger`, `ts.number.isNaN`, `ts.number.isSafeInteger` | Kotlin FP/type primitives | Non-coercing Number predicates, including runtime-kind guards. |
78+
| `ts.date.*` (38 IDs) | TypeScript/EtsIR bodies | Numeric Date construction, `UTC`, fixed-clock `now`, getters, setters, `valueOf`, and source `toISOString`; see the Date boundary below. |
79+
80+
Matching standard calls are assumed to refer to genuine builtins. Monkey patching and prototype replacement are
81+
outside this experiment; no runtime provenance protocol is imposed. Receiver and argument checks establish the
82+
memory representation and supported input domain.
83+
84+
The September 2026 corpus census contains 22,769 call/constructor sites. Its 49-API shortlist accounts for 1,026
85+
sites: Number/Math (275), new Array/String searches (130), existing pop/shift (52), and Date (569). Every shortlisted
86+
API name has a catalog entry. Eleven adjacent APIs add 280 census sites; `setUTCMinutes` and `setUTCMilliseconds`
87+
complete the numeric UTC setter family but have no sites in this census. These 1,306 associated sites are
88+
an inventory count, **not executed or replay-confirmed coverage**: imports, input representation, fallback domains,
89+
and other unsupported operations can still prevent execution. The wider research inventory contains 271
90+
unambiguous standard/host API names over 7,720 sites; most are not implemented by this catalog.
6991

7092
The common instance-call pipeline splits fake-value wrappers and conditional references under their runtime-kind
7193
and branch guards before selecting an approximation or resolving a method. A wrapped array can therefore use the
7294
model, including through an `any` alias. An unknown or non-array receiver does not become an array merely because
7395
the method is named `shift`. A definitely-array receiver with an unresolved element sort remains applicable and uses
7496
the fake-value representation described below.
7597

98+
Dense input proofs retain snapshots of the array length and element storage regions. A later write invalidates the
99+
proof conservatively, including writes to another array sharing a region. Consequently, a chain of individually
100+
modeled array methods can still use fallback after its first mutation or copy.
101+
102+
### Runtime limitations and experimental outcomes
103+
104+
`TsInterpreterObserver.onRuntimeFeatureLimitation` records feasible paths stopped by bounded array storage, such as
105+
named-property writes or unsupported length growth. These events are separate from unknown-call model decisions.
106+
Exhaustion after a runtime limitation does not establish that a source target is unreachable; a reached target
107+
still requires original-source replay.
108+
109+
Calls preflight checks input binding and source/IR target mapping before choosing a model/fallback profile. Excluded functions remain in the corpus support ledger. Comparative runs use a frozen common
110+
target set; failures discovered after that freeze remain scheduled failures. The analysis budget is 30 seconds per
111+
target and seed; JVM/frontend startup and original-source replay have separate recorded limits.
112+
76113
### `unknownCallFallback`
77114

78115
The fallback is applied when:

0 commit comments

Comments
 (0)