Skip to content

Commit 50f6c1c

Browse files
authored
Update internal ABI to zero/sign-extend where necessary only (AssemblyScript#87)
1 parent ce2bf00 commit 50f6c1c

File tree

72 files changed

+8738
-9351
lines changed

Some content is hidden

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

72 files changed

+8738
-9351
lines changed

examples/i64-polyfill/i64.untouched.wat

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
(module
22
(type $i (func (result i32)))
3+
(type $F (func (result f64)))
34
(type $iiv (func (param i32 i32)))
45
(type $iiiiv (func (param i32 i32 i32 i32)))
56
(global $assembly/i64/lo (mut i32) (i32.const 0))
67
(global $assembly/i64/hi (mut i32) (i32.const 0))
8+
(global $NaN f64 (f64.const nan:0x8000000000000))
9+
(global $Infinity f64 (f64.const inf))
710
(export "getLo" (func $assembly/i64/getLo))
811
(export "getHi" (func $assembly/i64/getHi))
912
(export "clz" (func $assembly/i64/clz))
@@ -178,7 +181,10 @@
178181
;;@ assembly/i64.ts:38:2
179182
(set_global $assembly/i64/lo
180183
;;@ assembly/i64.ts:38:7
181-
(get_local $2)
184+
(i32.and
185+
(get_local $2)
186+
(i32.const 1)
187+
)
182188
)
183189
;;@ assembly/i64.ts:39:2
184190
(set_global $assembly/i64/hi
-2 Bytes
Binary file not shown.

examples/mandelbrot/build/optimized.wat

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,9 @@
297297
(if (result i32)
298298
(f64.eq
299299
(f64.sub
300-
(tee_local $7
300+
(tee_local $4
301301
;;@ assembly/index.ts:36:4
302-
(tee_local $8
302+
(tee_local $7
303303
;;@ assembly/index.ts:36:15
304304
(f64.div
305305
;;@ assembly/index.ts:36:20
@@ -330,7 +330,7 @@
330330
)
331331
)
332332
)
333-
(get_local $7)
333+
(get_local $4)
334334
)
335335
(f64.const 0)
336336
)
@@ -341,25 +341,23 @@
341341
(f64.const 2047)
342342
(f64.min
343343
(f64.max
344-
(tee_local $7
345-
;;@ assembly/index.ts:38:39
346-
(f64.div
347-
(f64.sub
348-
(f64.convert_u/i32
349-
;;@ assembly/index.ts:38:40
350-
(i32.add
351-
(get_local $6)
352-
;;@ assembly/index.ts:38:52
353-
(i32.const 1)
354-
)
355-
)
356-
;;@ assembly/index.ts:38:56
357-
(get_local $8)
358-
)
344+
;;@ assembly/index.ts:38:39
345+
(f64.div
346+
(f64.sub
359347
(f64.convert_u/i32
360-
;;@ assembly/index.ts:38:64
361-
(get_local $3)
348+
;;@ assembly/index.ts:38:40
349+
(i32.add
350+
(get_local $6)
351+
;;@ assembly/index.ts:38:52
352+
(i32.const 1)
353+
)
362354
)
355+
;;@ assembly/index.ts:38:56
356+
(get_local $7)
357+
)
358+
(f64.convert_u/i32
359+
;;@ assembly/index.ts:38:64
360+
(get_local $3)
363361
)
364362
)
365363
(f64.const 0)

examples/mandelbrot/build/untouched.wat

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
(export "computeLine" (func $assembly/index/computeLine))
1414
(export "memory" (memory $0))
1515
(func $isFinite<f64> (; 2 ;) (type $Fi) (param $0 f64) (result i32)
16-
;;@ ~lib/builtins.ts:20:26
16+
;;@ ~lib/builtins.ts:22:26
1717
(return
18-
;;@ ~lib/builtins.ts:20:9
18+
;;@ ~lib/builtins.ts:22:9
1919
(f64.eq
2020
(f64.sub
2121
(get_local $0)
22-
;;@ ~lib/builtins.ts:20:17
22+
;;@ ~lib/builtins.ts:22:17
2323
(get_local $0)
2424
)
25-
;;@ ~lib/builtins.ts:20:26
25+
;;@ ~lib/builtins.ts:22:26
2626
(f64.const 0)
2727
)
2828
)
@@ -58,7 +58,9 @@
5858
(local $14 i32)
5959
(local $15 f64)
6060
(local $16 f64)
61-
(local $17 i32)
61+
(local $17 f64)
62+
(local $18 f64)
63+
(local $19 i32)
6264
;;@ assembly/index.ts:8:2
6365
(set_local $4
6466
;;@ assembly/index.ts:8:19
@@ -265,7 +267,7 @@
265267
;;@ assembly/index.ts:27:4
266268
(block $break|2
267269
;;@ assembly/index.ts:27:9
268-
(set_local $15
270+
(set_local $16
269271
;;@ assembly/index.ts:27:29
270272
(f64.min
271273
;;@ assembly/index.ts:27:33
@@ -284,12 +286,12 @@
284286
(get_local $14)
285287
)
286288
;;@ assembly/index.ts:27:56
287-
(get_local $15)
289+
(get_local $16)
288290
)
289291
(block
290292
(block
291293
;;@ assembly/index.ts:28:6
292-
(set_local $16
294+
(set_local $17
293295
;;@ assembly/index.ts:28:18
294296
(f64.add
295297
(f64.sub
@@ -329,7 +331,7 @@
329331
;;@ assembly/index.ts:30:6
330332
(set_local $10
331333
;;@ assembly/index.ts:30:11
332-
(get_local $16)
334+
(get_local $17)
333335
)
334336
)
335337
;;@ assembly/index.ts:27:71
@@ -346,7 +348,7 @@
346348
)
347349
)
348350
;;@ assembly/index.ts:36:4
349-
(set_local $15
351+
(set_local $18
350352
;;@ assembly/index.ts:36:15
351353
(f64.div
352354
;;@ assembly/index.ts:36:20
@@ -377,12 +379,12 @@
377379
)
378380
)
379381
;;@ assembly/index.ts:37:4
380-
(set_local $17
382+
(set_local $19
381383
;;@ assembly/index.ts:37:15
382384
(if (result i32)
383385
(call $isFinite<f64>
384386
;;@ assembly/index.ts:37:24
385-
(get_local $15)
387+
(get_local $18)
386388
)
387389
;;@ assembly/index.ts:38:8
388390
(i32.trunc_u/f64
@@ -410,7 +412,7 @@
410412
)
411413
)
412414
;;@ assembly/index.ts:38:56
413-
(get_local $15)
415+
(get_local $18)
414416
)
415417
(f64.convert_u/i32
416418
;;@ assembly/index.ts:38:64
@@ -450,7 +452,7 @@
450452
(i32.const 1)
451453
)
452454
;;@ assembly/index.ts:40:37
453-
(get_local $17)
455+
(get_local $19)
454456
)
455457
)
456458
;;@ assembly/index.ts:12:34

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function asmFunc(global, env, buffer) {
8282
if ($2 >>> 0 <= 8 >>> 0) return;
8383
$4 = (0 - $0 | 0) & 3 | 0;
8484
$0 = $0 + $4 | 0;
85-
$1 = Math_imul($1, 16843009);
85+
$1 = Math_imul($1 & 255 | 0, 16843009);
8686
HEAP32[$0 >> 2] = $1;
8787
$2 = ($2 - $4 | 0) & 4294967292 | 0;
8888
HEAP32[(($0 + $2 | 0) - 4 | 0) >> 2] = $1;
4 Bytes
Binary file not shown.

examples/n-body/build/optimized.wat

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,10 @@
265265
)
266266
(tee_local $1
267267
(i32.mul
268-
(get_local $1)
268+
(i32.and
269+
(get_local $1)
270+
(i32.const 255)
271+
)
269272
(i32.const 16843009)
270273
)
271274
)

examples/n-body/build/untouched.wat

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,8 +687,11 @@
687687
;;@ ~lib/memory.ts:216:27
688688
(i32.const 255)
689689
)
690-
;;@ ~lib/memory.ts:216:33
691-
(get_local $1)
690+
(i32.and
691+
;;@ ~lib/memory.ts:216:33
692+
(get_local $1)
693+
(i32.const 255)
694+
)
692695
)
693696
)
694697
;;@ ~lib/memory.ts:219:2

0 commit comments

Comments
 (0)