jz 0.5.1 → 0.7.0
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.
- package/README.md +315 -318
- package/bench/README.md +369 -0
- package/bench/bench.svg +102 -0
- package/cli.js +104 -30
- package/dist/interop.js +1 -0
- package/dist/jz.js +6024 -0
- package/index.d.ts +126 -0
- package/index.js +362 -84
- package/interop.js +159 -186
- package/jz.svg +5 -0
- package/jzify/arguments.js +97 -0
- package/jzify/bundler.js +382 -0
- package/jzify/classes.js +328 -0
- package/jzify/hoist-vars.js +177 -0
- package/jzify/index.js +51 -0
- package/jzify/names.js +37 -0
- package/jzify/switch.js +106 -0
- package/jzify/transform.js +349 -0
- package/layout.js +184 -0
- package/module/array.js +377 -176
- package/module/collection.js +639 -145
- package/module/console.js +55 -43
- package/module/core.js +264 -153
- package/module/date.js +15 -3
- package/module/function.js +73 -6
- package/module/index.js +2 -1
- package/module/json.js +226 -61
- package/module/math.js +551 -187
- package/module/number.js +327 -60
- package/module/object.js +474 -184
- package/module/regex.js +255 -25
- package/module/schema.js +24 -6
- package/module/simd.js +117 -0
- package/module/string.js +621 -226
- package/module/symbol.js +1 -1
- package/module/timer.js +9 -14
- package/module/typedarray.js +459 -73
- package/package.json +58 -14
- package/src/abi/index.js +39 -23
- package/src/abi/string.js +38 -41
- package/src/ast.js +460 -0
- package/src/autoload.js +29 -24
- package/src/bridge.js +111 -0
- package/src/compile/analyze-scans.js +824 -0
- package/src/compile/analyze.js +1600 -0
- package/src/compile/emit-assign.js +411 -0
- package/src/compile/emit.js +3512 -0
- package/src/compile/flow-types.js +103 -0
- package/src/{compile.js → compile/index.js} +778 -128
- package/src/{infer.js → compile/infer.js} +62 -98
- package/src/compile/loop-divmod.js +155 -0
- package/src/{narrow.js → compile/narrow.js} +409 -106
- package/src/compile/peel-stencil.js +261 -0
- package/src/compile/plan/advise.js +370 -0
- package/src/compile/plan/common.js +150 -0
- package/src/compile/plan/index.js +122 -0
- package/src/compile/plan/inline.js +682 -0
- package/src/compile/plan/literals.js +1199 -0
- package/src/compile/plan/loops.js +472 -0
- package/src/compile/plan/scope.js +649 -0
- package/src/compile/program-facts.js +423 -0
- package/src/ctx.js +220 -64
- package/src/ir.js +589 -172
- package/src/kind-traits.js +132 -0
- package/src/kind.js +524 -0
- package/src/op-policy.js +57 -0
- package/src/{optimize.js → optimize/index.js} +1432 -473
- package/src/optimize/vectorize.js +4660 -0
- package/src/param-reps.js +65 -0
- package/src/parse.js +44 -0
- package/src/{prepare.js → prepare/index.js} +649 -205
- package/src/prepare/lift-iife.js +149 -0
- package/src/reps.js +116 -0
- package/src/resolve.js +12 -3
- package/src/static.js +208 -0
- package/src/type.js +651 -0
- package/src/{assemble.js → wat/assemble.js} +275 -55
- package/src/wat/optimize.js +3938 -0
- package/transform.js +21 -0
- package/wasi.js +47 -5
- package/src/analyze.js +0 -3818
- package/src/emit.js +0 -3040
- package/src/jzify.js +0 -1580
- package/src/plan.js +0 -2132
- package/src/vectorize.js +0 -1088
- /package/src/{codegen.js → wat/codegen.js} +0 -0
package/module/symbol.js
CHANGED
package/module/timer.js
CHANGED
|
@@ -27,17 +27,12 @@
|
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
29
|
import { typed, asF64, asI64, UNDEF_NAN, MAX_CLOSURE_ARITY, temp, tempI64 } from '../src/ir.js'
|
|
30
|
-
import { emit } from '../src/
|
|
31
|
-
import { inc, PTR, LAYOUT } from '../src/ctx.js'
|
|
30
|
+
import { emit, deps, hostImport } from '../src/bridge.js'
|
|
31
|
+
import { inc, PTR, LAYOUT, declGlobal } from '../src/ctx.js'
|
|
32
32
|
|
|
33
33
|
const MAX_TIMERS = 64
|
|
34
34
|
const ENTRY_SIZE = 40
|
|
35
35
|
|
|
36
|
-
const addImportOnce = (ctx, mod, name, fn) => {
|
|
37
|
-
if (ctx.module.imports.some(i => i[1] === `"${mod}"` && i[2] === `"${name}"`)) return
|
|
38
|
-
ctx.module.imports.push(['import', `"${mod}"`, `"${name}"`, fn])
|
|
39
|
-
}
|
|
40
|
-
|
|
41
36
|
// Shared "fire a NaN-boxed closure with 0 args" trampoline. Funcref index lives
|
|
42
37
|
// in upper 16 bits of the pointer payload; remaining $ftN slots get UNDEF_NAN.
|
|
43
38
|
// Closure is also passed as $__env so captures resolve via env-load.
|
|
@@ -55,7 +50,7 @@ const setupWasi = (ctx) => {
|
|
|
55
50
|
// Always include init + tick + loop when timer module loads (structural, not per-emitter)
|
|
56
51
|
inc('__timer_init', '__timer_tick', '__timer_loop')
|
|
57
52
|
|
|
58
|
-
|
|
53
|
+
deps({
|
|
59
54
|
__timer_init: ['__alloc'],
|
|
60
55
|
__timer_add: ['__time_ns'],
|
|
61
56
|
__timer_cancel: [],
|
|
@@ -68,7 +63,7 @@ const setupWasi = (ctx) => {
|
|
|
68
63
|
// call_indirect always matches the $ftN type (env, argc, a0..a7)
|
|
69
64
|
ctx.closure.floor = MAX_CLOSURE_ARITY
|
|
70
65
|
|
|
71
|
-
|
|
66
|
+
hostImport('wasi_snapshot_preview1', 'clock_time_get',
|
|
72
67
|
['func', '$__clock_time_get', ['param', 'i32'], ['param', 'i64'], ['param', 'i32'], ['result', 'i32']])
|
|
73
68
|
|
|
74
69
|
// __time_ns() → i64 — current monotonic nanoseconds
|
|
@@ -235,9 +230,9 @@ const setupWasi = (ctx) => {
|
|
|
235
230
|
// $__timer_queue: i32 — base address of timer array
|
|
236
231
|
// $__timer_next_id: i32 — next timer ID
|
|
237
232
|
// $__timer_count: i32 — number of active timers
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
233
|
+
declGlobal('__timer_queue', 'i32')
|
|
234
|
+
declGlobal('__timer_next_id', 'i32')
|
|
235
|
+
declGlobal('__timer_count', 'i32')
|
|
241
236
|
|
|
242
237
|
// Emitter: setTimeout(closure, delay) → timer_id
|
|
243
238
|
ctx.core.emit['setTimeout'] = (closureExpr, delayExpr) => {
|
|
@@ -279,9 +274,9 @@ const setupJsHost = (ctx) => {
|
|
|
279
274
|
// canonicalization at the wasm→JS boundary (same reason as env.print —
|
|
280
275
|
// see module/console.js header). delay is a real numeric f64 (no NaN-box
|
|
281
276
|
// hazard), repeat is i32, return is the timer id (numeric int).
|
|
282
|
-
const needSetTimeout = () =>
|
|
277
|
+
const needSetTimeout = () => hostImport('env', 'setTimeout',
|
|
283
278
|
['func', '$__set_timeout', ['param', 'i64'], ['param', 'f64'], ['param', 'i32'], ['result', 'f64']])
|
|
284
|
-
const needClearTimeout = () =>
|
|
279
|
+
const needClearTimeout = () => hostImport('env', 'clearTimeout',
|
|
285
280
|
['func', '$__clear_timeout', ['param', 'f64'], ['result', 'f64']])
|
|
286
281
|
|
|
287
282
|
ctx.core.stdlib['__invoke_closure'] = invokeClosureFn(true)
|