Commit 9efbbc5
Add opt-in Tier-0 no-eval compiled validation fast path
safeParseCompiled compiles a schema into a closure tree at construction time
(no eval / no new Function / no codegen), so it runs where JIT tiers cannot:
strict-CSP pages and edge runtimes (Cloudflare Workers, Deno Deploy, Vercel
Edge). It removes the interpreter's megamorphic per-node dispatch and per-value
dataset allocation, winning ~1.1-2.4x on container schemas across both V8 and
JSC, while staying byte-identical to safeParse on success and error paths.
The interpreter remains the SSoT; this is an opt-in parallel path. Piped, async,
and non-specialized nodes fall back to ~run (defense-in-depth against an
accept-invalid bypass), an invariant locked by a test. A bare top-level
primitive should use safeParse directly (documented entry overhead).
- packages/tskm/src/compile.ts: closure compiler, getCompiledValidate (WeakMap
keyed off the schema value), safeParseCompiled
- packages/tskm/src/index.ts: opt-in exports
- packages/tskm/test/compile.test.ts: byte-identical conformance + piped/refined
child bypass guards + fast-path-only-for-bare-leaf invariant (Stryker oracle)
- bench/validator: full-materializing per-fixture sink, no-regression gate,
30-schema interleaved shared-IC guard (zero V8 deopts)
- test/workerd/smoke.ts: no-eval property proven by execution under
node --disallow-code-generation-from-strings
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 02f5520 commit 9efbbc5
8 files changed
Lines changed: 2206 additions & 0 deletions
File tree
- bench/validator
- packages/tskm
- src
- test
- test/workerd
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
0 commit comments