Skip to content

Effects: introduce primitive caml_cps_trampoline #1922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

vouillon
Copy link
Member

@vouillon vouillon commented Apr 7, 2025

This is a better name for the primitive that sets up a trampoline to switch to CPS.

This is a better name for the primitive that sets up a trampoline to
switch to CPS.
@@ -86,6 +86,7 @@ var caml_callback = caml_call_gen;
//If: !doubletranslate
//Requires: caml_stack_depth, caml_call_gen, caml_wrap_exception
//Requires: caml_current_stack
//Alias: caml_cps_trampoline
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this make the CI fail because wasmoo will "resolve" caml_cps_trampoline to caml_callback

@hhugo
Copy link
Member

hhugo commented Apr 10, 2025

The following diff is missing from the PR. It would be nice if we could check that import/export are coherent instead of relying on bad error reporting such as

File "compiler/tests-wasm_of_ocaml/dune", line 2, characters 8-12:
2 |  (names gh38 gh46 gh107 gh112 gh1904)
            ^^^^
(cd _build/default/compiler/tests-wasm_of_ocaml && ../../.bin/node gh38.bc.wasm.js)
node:internal/process/promises:394
    triggerUncaughtException(err, true /* fromPromise */);
    ^

[TypeError: WebAssembly.instantiate(): Import #110 "effect": module is not an object or function]
 (func $caml_is_continuation (param (ref eq)) (result i32)))
(@if (= effects "cps")
(@then
-   (import "effect" "caml_trampoline"
-      (func $caml_trampoline (param (ref eq) (ref eq)) (result (ref eq))))
+   (import "effect" "caml_cps_trampoline"
+      (func $caml_cps_trampoline (param (ref eq) (ref eq)) (result (ref eq))))
))


@@ -460,14 +460,14 @@
(@then
   (func $caml_callback_1 (export "caml_callback_1")
      (param $f (ref eq)) (param $x (ref eq)) (result (ref eq))
-      (return_call $caml_trampoline
+      (return_call $caml_cps_trampoline
         (local.get $f)
         (array.new_fixed $block 2 (ref.i31 (i32.const 0)) (local.get $x))))

   (func (export "caml_callback_2")
      (param $f (ref eq)) (param $x (ref eq)) (param $y (ref eq))
      (result (ref eq))
-      (return_call $caml_trampoline
+      (return_call $caml_cps_trampoline
         (local.get $f)
         (array.new_fixed $block 3 (ref.i31 (i32.const 0))
           (local.get $x) (local.get $y))))

@vouillon
Copy link
Member Author

The following diff is missing from the PR.

That's because this code was added in master since the PR was made.

It would be nice if we could check that import/export are coherent instead of relying on bad error reporting such as
[...]

See #1931

@hhugo
Copy link
Member

hhugo commented Apr 11, 2025

included in #1915

@hhugo hhugo closed this Apr 11, 2025
@hhugo hhugo deleted the cps-trampoline branch April 16, 2025 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants