|
56 | 56 | (func $ta_set_ui8 (param (ref extern)) (param i32) (param i32))) ;; ZZZ ?? |
57 | 57 | (import "bindings" "ta_get_ui8" |
58 | 58 | (func $ta_get_ui8 (param (ref extern)) (param i32) (result i32))) |
| 59 | + (import "bindings" "ta_blit_from_string" |
| 60 | + (func $ta_blit_from_string |
| 61 | + (param (ref $string)) (param i32) (param (ref extern)) (param i32) |
| 62 | + (param i32))) |
| 63 | + (import "bindings" "ta_blit_to_string" |
| 64 | + (func $ta_blit_to_string |
| 65 | + (param (ref extern)) (param i32) (param (ref $string)) (param i32) |
| 66 | + (param i32))) |
59 | 67 | (import "custom" "custom_compare_id" |
60 | 68 | (func $custom_compare_id |
61 | 69 | (param (ref eq)) (param (ref eq)) (param i32) (result i32))) |
|
330 | 338 | (i64.add (local.get $offset) (i64.extend_i32_u (local.get $n)))) |
331 | 339 | (local.get $n)) |
332 | 340 |
|
333 | | - (func $copy_from_buffer |
334 | | - (param $buf (ref extern)) (param $curr i32) |
335 | | - (param $s (ref $string)) (param $pos i32) (param $len i32) |
336 | | - (local $i i32) |
337 | | - (loop $loop |
338 | | - (if (i32.lt_u (local.get $i) (local.get $len)) |
339 | | - (then |
340 | | - (array.set $string (local.get $s) |
341 | | - (i32.add (local.get $pos) (local.get $i)) |
342 | | - (call $ta_get_ui8 (local.get $buf) |
343 | | - (i32.add (local.get $curr) (local.get $i)))) |
344 | | - (local.set $i (i32.add (local.get $i) (i32.const 1))) |
345 | | - (br $loop))))) |
346 | | - |
347 | 341 | (func $caml_refill (param $ch (ref $channel)) (result i32) |
348 | 342 | (local $n i32) |
349 | 343 | (local $buf (ref extern)) |
|
374 | 368 | (then |
375 | 369 | (if (i32.gt_u (local.get $len) (local.get $avail)) |
376 | 370 | (then (local.set $len (local.get $avail)))) |
377 | | - (call $copy_from_buffer |
| 371 | + (call $ta_blit_to_string |
378 | 372 | (struct.get $channel $buffer (local.get $ch)) |
379 | 373 | (struct.get $channel $curr (local.get $ch)) |
380 | 374 | (local.get $s) (local.get $pos) |
|
389 | 383 | (struct.set $channel $max (local.get $ch) (local.get $nread)) |
390 | 384 | (if (i32.gt_u (local.get $len) (local.get $nread)) |
391 | 385 | (then (local.set $len (local.get $nread)))) |
392 | | - (call $copy_from_buffer |
| 386 | + (call $ta_blit_to_string |
393 | 387 | (struct.get $channel $buffer (local.get $ch)) |
394 | 388 | (i32.const 0) |
395 | 389 | (local.get $s) (local.get $pos) |
|
445 | 439 | (local.set $curr (i32.const 0)) |
446 | 440 | (if (i32.gt_u (local.get $len) (local.get $nread)) |
447 | 441 | (then (local.set $len (local.get $nread)))))))) |
448 | | - (call $copy_from_buffer |
| 442 | + (call $ta_blit_to_string |
449 | 443 | (local.get $buf) (local.get $curr) |
450 | 444 | (local.get $s) (local.get $pos) (local.get $len)) |
451 | 445 | (struct.set $channel $curr (local.get $ch) |
|
730 | 724 | (func $caml_putblock |
731 | 725 | (param $ch (ref $channel)) (param $s (ref $string)) (param $pos i32) |
732 | 726 | (param $len i32) (result i32) |
733 | | - (local $free i32) (local $curr i32) (local $i i32) |
| 727 | + (local $free i32) (local $curr i32) |
734 | 728 | (local $buf (ref extern)) |
735 | 729 | (local.set $curr (struct.get $channel $curr (local.get $ch))) |
736 | 730 | (local.set $free |
737 | 731 | (i32.sub (struct.get $channel $size (local.get $ch)) (local.get $curr))) |
738 | 732 | (if (i32.ge_u (local.get $len) (local.get $free)) |
739 | 733 | (then (local.set $len (local.get $free)))) |
740 | 734 | (local.set $buf (struct.get $channel $buffer (local.get $ch))) |
741 | | - (loop $loop |
742 | | - (if (i32.lt_u (local.get $i) (local.get $len)) |
743 | | - (then |
744 | | - (call $ta_set_ui8 (local.get $buf) |
745 | | - (i32.add (local.get $curr) (local.get $i)) |
746 | | - (array.get_u $string (local.get $s) |
747 | | - (i32.add (local.get $pos) (local.get $i)))) |
748 | | - (local.set $i (i32.add (local.get $i) (i32.const 1))) |
749 | | - (br $loop)))) |
| 735 | + (call $ta_blit_from_string |
| 736 | + (local.get $s) (local.get $pos) |
| 737 | + (local.get $buf) (local.get $curr) (local.get $len)) |
750 | 738 | (struct.set $channel $curr (local.get $ch) |
751 | 739 | (i32.add (local.get $curr) (local.get $len))) |
752 | 740 | (if (i32.ge_u (local.get $len) (local.get $free)) |
|
0 commit comments