Skip to content

Commit dac49d1

Browse files
committed
WIP
1 parent 4bd12bc commit dac49d1

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

compiler/lib-wasm/generate.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,7 @@ end
11691169
let init () =
11701170
let l =
11711171
[ "caml_ensure_stack_capacity", "%identity"
1172+
; "caml_process_pending_actions_with_root", "%identity"
11721173
; "caml_callback", "caml_trampoline"
11731174
; "caml_array_of_uniform_array", "caml_make_array"
11741175
]

runtime/wasm/array.wat

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
(array.set $block (local.get $b) (i32.const 0) (ref.i31 (i32.const 0)))
5252
(local.get $b))
5353

54-
;; ZZZ Unboxed version
5554
(func (export "caml_floatarray_make")
5655
(param $n (ref eq)) (param $v (ref eq)) (result (ref eq))
5756
(local $sz i32) (local $f f64)
@@ -67,8 +66,9 @@
6766
(ref.cast (ref $float) (local.get $v))))
6867
(array.new $float_array (local.get $f) (local.get $sz)))
6968

70-
(export "caml_make_float_vect" (func $caml_floatarray_create))
71-
(func $caml_floatarray_create (export "caml_floatarray_create")
69+
(func $caml_floatarray_create
70+
(export "caml_make_float_vect") (export "caml_floatarray_create")
71+
(export "caml_array_create_float")
7272
(param $n (ref eq)) (result (ref eq))
7373
(local $sz i32)
7474
(local.set $sz (i31.get_s (ref.cast (ref i31) (local.get $n))))
@@ -219,6 +219,30 @@
219219
(return (local.get $fa))))
220220
(return_call $caml_floatarray_dup (local.get $fa1)))
221221

222+
(func (export "caml_floatarray_append")
223+
(param $va1 (ref eq)) (param $va2 (ref eq)) (result (ref eq))
224+
(local $fa1 (ref $float_array)) (local $fa2 (ref $float_array))
225+
(local $fa (ref $float_array))
226+
(local $l1 i32) (local $l2 i32)
227+
(local.set $fa1 (ref.cast (ref $float_array) (local.get $va1)))
228+
(drop (block $a2_not_float_array (result (ref eq))
229+
(local.set $fa2
230+
(br_on_cast_fail $a2_not_float_array (ref eq) (ref $float_array)
231+
(local.get $va2)))
232+
(local.set $l1 (array.len (local.get $fa1)))
233+
(local.set $l2 (array.len (local.get $fa2)))
234+
(local.set $fa
235+
(array.new $float_array (f64.const 0)
236+
(i32.add (local.get $l1) (local.get $l2))))
237+
(array.copy $float_array $float_array
238+
(local.get $fa) (i32.const 0) (local.get $fa1) (i32.const 0)
239+
(local.get $l1))
240+
(array.copy $float_array $float_array
241+
(local.get $fa) (local.get $l1) (local.get $fa2) (i32.const 0)
242+
(local.get $l2))
243+
(return (local.get $fa))))
244+
(return_call $caml_floatarray_dup (local.get $fa1)))
245+
222246
(func (export "caml_array_concat") (param (ref eq)) (result (ref eq))
223247
(local $i i32) (local $len i32)
224248
(local $l (ref eq)) (local $v (ref eq))
@@ -365,4 +389,18 @@
365389
(struct.get $float 0 (ref.cast (ref $float) (local.get $v)))
366390
(local.get $len))))
367391
(ref.i31 (i32.const 0)))
392+
393+
(func (export "caml_floatarray_fill")
394+
(param $a (ref eq)) (param $i (ref eq)) (param $vlen (ref eq))
395+
(param $v (ref eq)) (result (ref eq))
396+
(local $len i32)
397+
(local.set $len (i31.get_u (ref.cast (ref i31) (local.get $vlen))))
398+
(if (local.get $len)
399+
(then
400+
(array.fill $float_array
401+
(ref.cast (ref $float_array) (local.get $a))
402+
(i31.get_u (ref.cast (ref i31) (local.get $i)))
403+
(struct.get $float 0 (ref.cast (ref $float) (local.get $v)))
404+
(local.get $len))))
405+
(ref.i31 (i32.const 0)))
368406
)

runtime/wasm/domain.wat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@
9595
(global $caml_domain_latest_id (export "caml_domain_latest_id") (mut i32)
9696
(i32.const 1))
9797

98-
(func (export "caml_ml_domain_id") (param (ref eq)) (result (ref eq))
98+
(func (export "caml_ml_domain_id") (export "caml_ml_domain_index")
99+
(param (ref eq)) (result (ref eq))
99100
(ref.i31 (global.get $caml_domain_id)))
100101

101102
(func (export "caml_ml_domain_cpu_relax") (param (ref eq)) (result (ref eq))

runtime/wasm/runtime_events.wat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,7 @@
6262
(func (export "caml_runtime_events_read_poll")
6363
(param (ref eq)) (param (ref eq)) (param (ref eq)) (result (ref eq))
6464
(ref.i31 (i32.const 0)))
65+
66+
(func (export "caml_ml_runtime_events_path") (param (ref eq))
67+
(ref.i31 (i32.const 0)))
6568
)

0 commit comments

Comments
 (0)