-
Couldn't load subscription status.
- Fork 198
Runtime: allow one to directly access values exported in the runtime #2086
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
base: master
Are you sure you want to change the base?
Conversation
|
@hhugo Ping |
|
@vouillon, how do you want to implement such feature ? |
|
I have pushed something. It only works with whole-program compilation, though. With separate compilation, only the JavaScript primitives used in the Wasm runtime are linked-in. I'm not sure what to do about that. |
Could we add a syntax to re-export js value to the wasm runtime ? |
IIUC, we just need a way to tell the wasmoo compiler that additional js value must be included when building the js runtime. |
compiler/lib/specialize_js.ml
Outdated
| let i = | ||
| match i with | ||
| | Let (x, Apply { f; args; exact = false }) -> ( | ||
| match Info.def info f with | ||
| | None -> i | ||
| | Some (Prim (Extern "caml_jsoo_runtime", [ name ])) -> ( | ||
| let name = | ||
| match name with | ||
| | Pc (String name) -> Some name | ||
| | Pc _ -> None | ||
| | Pv x -> ( | ||
| match Info.def info x with | ||
| | Some (Constant (String name)) -> Some name | ||
| | Some _ | None -> None) | ||
| in | ||
| match name with | ||
| | None -> i | ||
| | Some name -> ( | ||
| let name = Primitive.resolve name in | ||
| match Primitive.arity name with | ||
| | exception Not_found -> i | ||
| | n -> | ||
| if List.compare_length_with args ~len:n = 0 | ||
| then | ||
| Let (x, Prim (Extern name, List.map args ~f:(fun x -> Pv x))) | ||
| else i)) | ||
| | Some _ -> i) | ||
| | _ -> i | ||
| in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should remove this change (and the associated change in compiler/lib/flow.ml.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Can you push this change ? I'm away from keyboard
The goal is to address LexiFi/gen_js_api#177
cc mlasson
@vouillon, can this work with wasmoo ?