Skip to content

Commit 26e46f6

Browse files
committed
Reintroduce builtin decorator so these can appear anywhere in stdlib again
Avoids wrapping an undocumented function within 'memory.size' for example.
1 parent 96411c7 commit 26e46f6

File tree

80 files changed

+6890
-7158
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+6890
-7158
lines changed
0 Bytes
Binary file not shown.

examples/game-of-life/build/optimized.wat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
(global $assembly/index/w (mut i32) (i32.const 0))
1212
(global $assembly/index/h (mut i32) (i32.const 0))
1313
(global $assembly/index/s (mut i32) (i32.const 0))
14+
(export "memory" (memory $0))
1415
(export "init" (func $assembly/index/init))
1516
(export "step" (func $assembly/index/step))
1617
(export "fill" (func $assembly/index/fill))
17-
(export "memory" (memory $0))
1818
(func $assembly/index/init (; 1 ;) (type $iiv) (param $0 i32) (param $1 i32)
1919
(local $2 i32)
2020
;;@ assembly/index.ts:29:2

examples/game-of-life/build/untouched.wat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
(global $assembly/index/h (mut i32) (i32.const 0))
1313
(global $assembly/index/s (mut i32) (i32.const 0))
1414
(global $HEAP_BASE i32 (i32.const 8))
15+
(export "memory" (memory $0))
1516
(export "init" (func $assembly/index/init))
1617
(export "step" (func $assembly/index/step))
1718
(export "fill" (func $assembly/index/fill))
18-
(export "memory" (memory $0))
1919
(func $assembly/index/init (; 1 ;) (type $iiv) (param $0 i32) (param $1 i32)
2020
(local $2 i32)
2121
(local $3 i32)

examples/i64-polyfill/build/optimized.wat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
(global $assembly/i64/lo (mut i32) (i32.const 0))
66
(global $assembly/i64/hi (mut i32) (i32.const 0))
77
(memory $0 0)
8+
(export "memory" (memory $0))
89
(export "getLo" (func $assembly/i64/getLo))
910
(export "getHi" (func $assembly/i64/getHi))
1011
(export "clz" (func $assembly/i64/clz))
@@ -36,7 +37,6 @@
3637
(export "gt_u" (func $assembly/i64/gt_u))
3738
(export "ge_s" (func $assembly/i64/ge_s))
3839
(export "ge_u" (func $assembly/i64/ge_u))
39-
(export "memory" (memory $0))
4040
(func $assembly/i64/getLo (; 0 ;) (type $i) (result i32)
4141
;;@ assembly/i64.ts:4:9
4242
(get_global $assembly/i64/lo)

examples/i64-polyfill/build/untouched.wat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
(global $Infinity f64 (f64.const inf))
99
(global $HEAP_BASE i32 (i32.const 8))
1010
(memory $0 0)
11+
(export "memory" (memory $0))
1112
(export "getLo" (func $assembly/i64/getLo))
1213
(export "getHi" (func $assembly/i64/getHi))
1314
(export "clz" (func $assembly/i64/clz))
@@ -39,7 +40,6 @@
3940
(export "gt_u" (func $assembly/i64/gt_u))
4041
(export "ge_s" (func $assembly/i64/ge_s))
4142
(export "ge_u" (func $assembly/i64/ge_u))
42-
(export "memory" (memory $0))
4343
(func $assembly/i64/getLo (; 0 ;) (type $i) (result i32)
4444
;;@ assembly/i64.ts:4:9
4545
(get_global $assembly/i64/lo)
0 Bytes
Binary file not shown.

examples/mandelbrot/build/optimized.wat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
(import "JSMath" "log" (func $~lib/math/JSMath.log (param f64) (result f64)))
66
(import "JSMath" "LN2" (global $~lib/math/JSMath.LN2 f64))
77
(import "env" "memory" (memory $0 0))
8-
(export "computeLine" (func $assembly/index/computeLine))
98
(export "memory" (memory $0))
9+
(export "computeLine" (func $assembly/index/computeLine))
1010
(func $assembly/index/computeLine (; 2 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
1111
(local $4 f64)
1212
(local $5 f64)

examples/mandelbrot/build/untouched.wat

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@
99
(import "env" "memory" (memory $0 0))
1010
(global $assembly/index/NUM_COLORS i32 (i32.const 2048))
1111
(global $HEAP_BASE i32 (i32.const 8))
12-
(export "computeLine" (func $assembly/index/computeLine))
1312
(export "memory" (memory $0))
14-
(func $isFinite<f64> (; 2 ;) (type $Fi) (param $0 f64) (result i32)
15-
;;@ ~lib/builtins.ts:26:26
13+
(export "computeLine" (func $assembly/index/computeLine))
14+
(func $~lib/builtins/isFinite<f64> (; 2 ;) (type $Fi) (param $0 f64) (result i32)
15+
;;@ ~lib/builtins.ts:16:70
1616
(f64.eq
17-
;;@ ~lib/builtins.ts:26:9
17+
;;@ ~lib/builtins.ts:16:53
1818
(f64.sub
1919
(get_local $0)
20-
;;@ ~lib/builtins.ts:26:17
20+
;;@ ~lib/builtins.ts:16:61
2121
(get_local $0)
2222
)
23-
;;@ ~lib/builtins.ts:26:26
23+
;;@ ~lib/builtins.ts:16:70
2424
(f64.const 0)
2525
)
2626
)
@@ -375,7 +375,7 @@
375375
(set_local $17
376376
;;@ assembly/index.ts:37:15
377377
(if (result i32)
378-
(call $isFinite<f64>
378+
(call $~lib/builtins/isFinite<f64>
379379
;;@ assembly/index.ts:37:24
380380
(get_local $15)
381381
)
@@ -386,7 +386,7 @@
386386
(f64.convert_s/i32
387387
(i32.sub
388388
;;@ assembly/index.ts:38:15
389-
(i32.const 2048)
389+
(get_global $assembly/index/NUM_COLORS)
390390
;;@ assembly/index.ts:38:28
391391
(i32.const 1)
392392
)
@@ -421,7 +421,7 @@
421421
)
422422
;;@ assembly/index.ts:39:8
423423
(i32.sub
424-
(i32.const 2048)
424+
(get_global $assembly/index/NUM_COLORS)
425425
;;@ assembly/index.ts:39:21
426426
(i32.const 1)
427427
)

examples/n-body/build/index.asm.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ function asmFunc(global, env, buffer) {
2424
var $lib_allocator_arena_startOffset = 0;
2525
var $lib_allocator_arena_offset = 0;
2626
var assembly_index_system = 0;
27-
var HEAP_BASE = 40;
2827
var i64toi32_i32$HIGH_BITS = 0;
2928
function $lib_allocator_arena___memory_allocate($0) {
3029
$0 = $0 | 0;
@@ -81,7 +80,7 @@ function asmFunc(global, env, buffer) {
8180
return $0 | 0;
8281
}
8382

84-
function $lib_memory_memory_fill($0, $1, $2) {
83+
function $lib_memory_memset($0, $1, $2) {
8584
$0 = $0 | 0;
8685
$1 = $1 | 0;
8786
$2 = $2 | 0;
@@ -272,7 +271,7 @@ function asmFunc(global, env, buffer) {
272271
wasm2asm_i32$0 = $0;
273272
wasm2asm_i32$1 = $1;
274273
HEAP32[(wasm2asm_i32$0 + 4 | 0) >> 2] = wasm2asm_i32$1;
275-
$lib_memory_memory_fill($3 + 8 | 0 | 0, 0 | 0, $2 | 0);
274+
$lib_memory_memset($3 + 8 | 0 | 0, 0 | 0, $2 | 0);
276275
return $0 | 0;
277276
}
278277

@@ -492,7 +491,7 @@ function asmFunc(global, env, buffer) {
492491
}
493492

494493
function start() {
495-
$lib_allocator_arena_startOffset = (HEAP_BASE + 7 | 0) & 4294967288 | 0;
494+
$lib_allocator_arena_startOffset = 40;
496495
$lib_allocator_arena_offset = $lib_allocator_arena_startOffset;
497496
}
498497

@@ -522,10 +521,6 @@ function asmFunc(global, env, buffer) {
522521
}
523522

524523
return {
525-
init: assembly_index_init,
526-
getBody: assembly_index_getBody,
527-
step: assembly_index_step,
528-
bench: assembly_index_bench,
529524
memory: Object.create(Object.prototype, {
530525
grow: {
531526
value: __wasm_grow_memory
@@ -536,6 +531,10 @@ function asmFunc(global, env, buffer) {
536531
}
537532

538533
}
539-
})
534+
}),
535+
init: assembly_index_init,
536+
getBody: assembly_index_getBody,
537+
step: assembly_index_step,
538+
bench: assembly_index_bench
540539
};
541540
}

examples/n-body/build/optimized.wasm

-11 Bytes
Binary file not shown.

examples/n-body/build/optimized.wat

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@
1313
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
1414
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
1515
(global $assembly/index/system (mut i32) (i32.const 0))
16-
(global $HEAP_BASE i32 (i32.const 40))
1716
(memory $0 1)
1817
(data (i32.const 8) "\0d\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s")
18+
(export "memory" (memory $0))
1919
(export "init" (func $assembly/index/init))
2020
(export "getBody" (func $assembly/index/getBody))
2121
(export "step" (func $assembly/index/step))
2222
(export "bench" (func $assembly/index/bench))
23-
(export "memory" (memory $0))
2423
(start $start)
2524
(func $~lib/allocator/arena/__memory_allocate (; 1 ;) (type $ii) (param $0 i32) (result i32)
2625
(local $1 i32)
@@ -150,7 +149,7 @@
150149
)
151150
(get_local $0)
152151
)
153-
(func $~lib/memory/memory.fill (; 3 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
152+
(func $~lib/memory/memset (; 3 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
154153
(local $3 i32)
155154
(local $4 i64)
156155
(if
@@ -549,7 +548,7 @@
549548
(get_local $0)
550549
(get_local $1)
551550
)
552-
(call $~lib/memory/memory.fill
551+
(call $~lib/memory/memset
553552
(i32.add
554553
(get_local $3)
555554
(i32.const 8)
@@ -1403,13 +1402,7 @@
14031402
)
14041403
(func $start (; 12 ;) (type $v)
14051404
(set_global $~lib/allocator/arena/startOffset
1406-
(i32.and
1407-
(i32.add
1408-
(get_global $HEAP_BASE)
1409-
(i32.const 7)
1410-
)
1411-
(i32.const -8)
1412-
)
1405+
(i32.const 40)
14131406
)
14141407
(set_global $~lib/allocator/arena/offset
14151408
(get_global $~lib/allocator/arena/startOffset)

0 commit comments

Comments
 (0)