Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions design/TmpWireFormat.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ defined with a list of arguments, these all become arguments of the WebAssembly
function. See the [ActorScript guide](https://hydra.oregon.dfinity.build//job/dfinity-ci-build/actorscript.pr-252/users-guide/latest/download/1/guide/#function-types) for the precise rules for function arities.


Specialized argument format: `Word32`
-------------------------------------

A message entry point with an argument of type `Word32` is directly represented
as a `I32`.

Specialized argument format: `Text`
-------------------------------------

Expand All @@ -36,6 +30,10 @@ A message entry point with an argument of type `Text` is represented as a `datab
Note that there is no terminating `\0`, and the length is implicit as the
length of the `databuf`.

Specialized argument format: `actor {…}` and `shared … -> …`
------------------------------------------------------------

A message entry point with an argument of actor type or of shared function type is represented as an `actorref` resp. `funcref.`

General argument format (without references)
--------------------------------------------
Expand Down
16 changes: 8 additions & 8 deletions src/compile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2621,9 +2621,9 @@ module Serialization = struct
Also see (and update) `design/TmpWireFormat.md`, which documents the format
in a “user-facing” way.

We have a specific serialization strategy for `Text`, `Word32` and
references for easier interop with the console and the nonce. This is a
stop-gap measure until we have nailed down IDL and Bidirectional Messaging.
We have a specific serialization strategy for `Text` and references for
easier interop with the console and the nonce. This is a stop-gap measure
until we have nailed down IDL and Bidirectional Messaging.

The general serialization strategy is as follows:
* We traverse the data to calculate the size needed for the data buffer and the
Expand Down Expand Up @@ -3017,8 +3017,8 @@ module Serialization = struct
else Func.share_code1 env name ("x", I32Type) [I32Type] (fun env get_x ->
match Type.normalize t with
| Type.Prim Type.Text -> get_x ^^ Dfinity.compile_databuf_of_text env
| Type.Prim Type.Word32 -> get_x ^^ BoxedSmallWord.unbox env
| Type.Obj (Type.Actor, _) -> get_x ^^ Dfinity.unbox_reference env
| Type.Obj (Type.Actor, _)
| Type.Func (Type.Sharable, _, _, _, _) -> get_x ^^ Dfinity.unbox_reference env
| _ ->
let (set_data_size, get_data_size) = new_local env "data_size" in
let (set_refs_size, get_refs_size) = new_local env "refs_size" in
Expand Down Expand Up @@ -3112,8 +3112,8 @@ module Serialization = struct
Func.share_code1 env name ("elembuf", I32Type) [I32Type] (fun env get_elembuf ->
match Type.normalize t with
| Type.Prim Type.Text -> deserialize_text env get_elembuf
| Type.Prim Type.Word32 -> get_elembuf ^^ BoxedSmallWord.box env
| Type.Obj (Type.Actor, _) -> get_elembuf ^^ Dfinity.box_reference env
| Type.Obj (Type.Actor, _)
| Type.Func (Type.Sharable, _, _, _, _) -> get_elembuf ^^ Dfinity.box_reference env
| _ ->
let (set_data_size, get_data_size) = new_local env "data_size" in
let (set_refs_size, get_refs_size) = new_local env "refs_size" in
Expand Down Expand Up @@ -3181,8 +3181,8 @@ module Serialization = struct

let dfinity_type t = match Type.normalize t with
| Type.Prim Type.Text -> CustomSections.DataBuf
| Type.Prim Type.Word32 -> CustomSections.I32
| Type.Obj (Type.Actor, _) -> CustomSections.ActorRef
| Type.Func (Type.Sharable, _, _, _, _) -> CustomSections.FuncRef
| t' when has_no_references t' -> CustomSections.DataBuf
| _ -> CustomSections.ElemBuf

Expand Down
3 changes: 2 additions & 1 deletion src/customSections.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* Some data type to represent custom sectoins *)

type type_ = I32 | DataBuf | ElemBuf | ActorRef
type type_ = I32 | DataBuf | ElemBuf | ActorRef | FuncRef

(* Some Code copied from encodeMap.ml *)
type stream =
Expand Down Expand Up @@ -81,6 +81,7 @@ let encode
| DataBuf -> vu32 0x6cl
| ElemBuf -> vu32 0x6bl
| ActorRef -> vu32 0x6fl
| FuncRef -> vu32 0x6dl
in

section 0 (fun _ ->
Expand Down