Skip to content

Commit ebb9e48

Browse files
vouillonhhugo
authored andcommitted
Wasm runtime: use syntactic sugar rather than array.new_data
1 parent 77af124 commit ebb9e48

File tree

2 files changed

+8
-25
lines changed

2 files changed

+8
-25
lines changed

runtime/wasm/effect.wat

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@
9696
(struct.get $thunk 1 (local.get $t))
9797
(struct.get $thunk 0 (local.get $t))))
9898

99-
(data $unsupported
100-
"Effect handlers are not supported: "
101-
"the JavaScript Promise Integration API is not enabled")
99+
(@string $unsupported
100+
"Effect handlers are not supported: the JavaScript Promise Integration API is not enabled")
102101

103102
(func $capture_continuation
104103
(param $f (ref $called_with_continuation))
@@ -110,8 +109,7 @@
110109
(call $suspend_fiber
111110
(ref.func $apply_continuation)
112111
(struct.new $thunk (local.get $f) (local.get $v)))))))
113-
(call $caml_failwith
114-
(array.new_data $bytes $unsupported (i32.const 0) (i32.const 88)))
112+
(call $caml_failwith (global.get $unsupported))
115113
(ref.i31 (i32.const 0)))
116114

117115
;; Stack of fibers

runtime/wasm/unix.wat

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,6 @@
493493
(local.get $cmd)
494494
(global.get $no_arg))))
495495

496-
(data $readdir "readdir")
497-
498496
(func $readdir_helper (param $dir (ref eq)) (result (ref eq))
499497
(block $end
500498
(return
@@ -506,15 +504,11 @@
506504
(call $readdir (call $unwrap (local.get $dir)))))))
507505
(catch $javascript_exception
508506
(drop (pop externref))
509-
(call $throw_ebadf
510-
(array.new_data $bytes $readdir
511-
(i32.const 0) (i32.const 7)))
507+
(call $throw_ebadf (@string "readdir"))
512508
(ref.i31 (i32.const 0))))))
513509
(call $caml_raise_end_of_file)
514510
(ref.i31 (i32.const 0)))
515511

516-
(data $closedir "closedir")
517-
518512
(func $unix_closedir (export "unix_closedir") (export "caml_unix_closedir")
519513
(export "win_findclose") (export "caml_unix_findclose")
520514
(param $dir (ref eq)) (result (ref eq))
@@ -523,8 +517,7 @@
523517
(call $closedir (call $unwrap (local.get $dir))))
524518
(catch $javascript_exception
525519
(drop (pop externref))
526-
(call $throw_ebadf
527-
(array.new_data $bytes $closedir (i32.const 0) (i32.const 8)))))
520+
(call $throw_ebadf (@string "closedir"))))
528521
(ref.i31 (i32.const 0)))
529522

530523
(func (export "unix_readdir") (export "caml_unix_readdir")
@@ -558,13 +551,9 @@
558551
(call $win_find_next (local.get $dir))
559552
(local.get $dir)))
560553

561-
(data $rewinddir_not_implemented "rewinddir not implemented")
562-
563554
(func (export "unix_rewinddir") (export "caml_unix_rewinddir")
564555
(param (ref eq)) (result (ref eq))
565-
(call $caml_invalid_argument
566-
(array.new_data $bytes $rewinddir_not_implemented
567-
(i32.const 0) (i32.const 25)))
556+
(call $caml_invalid_argument (@string "rewinddir not implemented"))
568557
(ref.i31 (i32.const 0)))
569558

570559
(func (export "unix_unlink") (export "caml_unix_unlink")
@@ -587,8 +576,6 @@
587576
(call $caml_unix_error (pop externref) (ref.null eq))))
588577
(ref.i31 (i32.const 0)))
589578

590-
(data $link "link")
591-
592579
(func (export "unix_link") (export "caml_unix_link")
593580
(param $follow (ref eq)) (param $d (ref eq)) (param $s (ref eq))
594581
(result (ref eq))
@@ -599,7 +586,7 @@
599586
(ref.i31 (i32.const 0))
600587
(call $get_unix_error_exn)
601588
(ref.i31 (i32.const 25)) ;; ENOSYS
602-
(array.new_data $bytes $link (i32.const 0) (i32.const 4))
589+
(@string "link")
603590
(global.get $no_arg)))))
604591
(try
605592
(do
@@ -999,14 +986,12 @@
999986
(i64.add (local.get $offset) (i64.extend_i32_s (local.get $n))))
1000987
(ref.i31 (local.get $n)))
1001988

1002-
(@string $lseek "lseek")
1003-
1004989
(func $lseek_exn (param $errno i32) (result (ref eq))
1005990
(array.new_fixed $block 5
1006991
(ref.i31 (i32.const 0))
1007992
(call $get_unix_error_exn)
1008993
(ref.i31 (local.get $errno))
1009-
(global.get $lseek)
994+
(@string "lseek")
1010995
(global.get $no_arg)))
1011996

1012997
(func $lseek

0 commit comments

Comments
 (0)