Decline to marshal custom blocks or closures
commit8220d5ede7ed796903cbbd0b1eebcadcf72749fe
authorJake Bailey <jakebailey@fb.com>
Mon, 29 Aug 2022 16:49:22 +0000 (29 09:49 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Mon, 29 Aug 2022 16:49:22 +0000 (29 09:49 -0700)
tree6e8fb73b7d78a41dc3b8d19671af49587d1629f4
parent2e26b382d2945ed1b9c012f1fac76638405cd3f8
Decline to marshal custom blocks or closures

Summary:
We want this library to function independently of the caml runtime, and it's not possible to achieve that goal and support marshaling of custom blocks or closures.

Custom blocks can implement their own `serialize` and `deserialize` functions, which would be fine but for the fact that they're expected to do so using functions like [`caml_serialize_int_1`](https://github.com/ocaml/ocaml/blob/0e09dc477c131a404f28be373effc3508c99ff6f/runtime/extern.c#L1070) or [`caml_serialize_block_1`](https://github.com/ocaml/ocaml/blob/0e09dc477c131a404f28be373effc3508c99ff6f/runtime/extern.c#L1112), which use `get_extern_state` to fetch the current caml extern state from the `Caml_state` domain. We could write our custom-block-serializers such that they interact with `ocamlrep_marshal` instead, but then they would not be serializable using the `Marshal` module.

Marshaling closures also involves interacting with the caml runtime to fetch code fragments, so that isn't feasible for us either.

Neither of these are a problem for serialization of decls (`ocamlrep` does not currently support custom blocks or closures anyway).

Reviewed By: shayne-fletcher

Differential Revision: D39076281

fbshipit-source-id: 80373741e171fe480bbf2d331151120a8331a35f
hphp/hack/src/ocamlrep_marshal/ser.rs