Mavryk_webassembly_interpreter.Eval
type ('a, 'b) map_kont = {
origin : 'a Mavryk_webassembly_interpreter.Instance.Vector.t;
destination : 'b Mavryk_webassembly_interpreter.Instance.Vector.t;
offset : int32;
}
type 'a concat_kont = {
lv : 'a Mavryk_webassembly_interpreter.Instance.Vector.t;
rv : 'a Mavryk_webassembly_interpreter.Instance.Vector.t;
res : 'a Mavryk_webassembly_interpreter.Instance.Vector.t;
offset : int32;
}
exception Link of Source.region * string
exception Trap of Source.region * string
exception Crash of Source.region * string
exception Exhaustion of Source.region * string
exception Init_step_error of init_state
Exception raised on irreducible states of the small step initialization.
Possible erroneous states of the small-step evaluation, used for error reporting.
exception Evaluation_step_error of eval_state
Exception raised on irreducible states of the small step evaluation.
type frame = {
inst : Instance.module_key;
mutable locals : Values.value Mavryk_webassembly_interpreter.Instance.Vector.t;
}
type admin_instr = admin_instr' Source.phrase
and admin_instr' =
| From_block of Ast.block_label * int32
| Plain of Ast.instr'
| Refer of Values.ref_
| Invoke of Instance.func_inst
| Trapping of string
| Returning of Values.value Mavryk_webassembly_interpreter.Instance.Vector.t
| Breaking of int32
* Values.value Mavryk_webassembly_interpreter.Instance.Vector.t
| Table_init_meta of int32
* Values.ref_
* int32
* int32
* int32
* Ast.var
* Ast.var
| Table_fill_meta of int32 * int32 * int32 * Values.ref_ * Ast.var
| Table_copy_meta of int32 * int32 * int32 * int32 * Ast.var * Ast.var * bool
| Memory_init_meta of int32 * int32 * int32 * int32 * int32 * Ast.var
| Memory_fill_meta of int32 * int32 * Values.num * int32
| Memory_copy_meta of int32 * int32 * int32 * int32 * bool
type _ label_kont =
| Label_stack : label
* label Mavryk_webassembly_interpreter.Instance.Vector.t -> ongoing
label_kont
| Label_result : Values.value Mavryk_webassembly_interpreter.Instance.Vector.t ->
finished
label_kont
| Label_trapped : string Source.phrase -> finished label_kont
type 'a frame_stack = {
frame_arity : int32 option;
frame_specs : frame;
frame_label_kont : 'a label_kont;
}
type invoke_step_kont =
| Inv_start of {
func : Instance.func_inst;
code : code;
}
| Inv_prepare_locals of {
arity : int32;
args : Values.value Mavryk_webassembly_interpreter.Instance.Vector.t;
vs : Values.value Mavryk_webassembly_interpreter.Instance.Vector.t;
instructions : admin_instr Mavryk_webassembly_interpreter.Instance.Vector.t;
inst : Instance.module_key;
func : Ast.func;
locals_kont : (Types.value_type, Values.value) map_kont;
}
| Inv_prepare_args of {
arity : int32;
vs : Values.value Mavryk_webassembly_interpreter.Instance.Vector.t;
instructions : admin_instr Mavryk_webassembly_interpreter.Instance.Vector.t;
inst : Instance.module_key;
func : Ast.func;
locals : Values.value Mavryk_webassembly_interpreter.Instance.Vector.t;
args_kont : (Values.value, Values.value) map_kont;
}
| Inv_concat of {
arity : int32;
vs : Values.value Mavryk_webassembly_interpreter.Instance.Vector.t;
instructions : admin_instr Mavryk_webassembly_interpreter.Instance.Vector.t;
inst : Instance.module_key;
func : Ast.func;
concat_kont : Values.value concat_kont;
}
| Inv_reveal_tick of {
reveal : Host_funcs.reveal;
base_destination : int32;
max_bytes : int32;
code : code;
}
| Inv_stop of {
code : code;
fresh_frame : ongoing frame_stack option;
remaining_ticks : Z.t;
}
type label_step_kont =
| LS_Start : ongoing label_kont -> label_step_kont
| LS_Craft_frame of ongoing label_kont * invoke_step_kont
| LS_Push_frame of ongoing label_kont * ongoing frame_stack
| LS_Consolidate_top of label
* Values.value concat_kont
* admin_instr Mavryk_webassembly_interpreter.Instance.Vector.t
* label Mavryk_webassembly_interpreter.Instance.Vector.t
| LS_Modify_top : 'a label_kont -> label_step_kont
type step_kont =
| SK_Start : 'a frame_stack
* ongoing frame_stack Mavryk_webassembly_interpreter.Instance.Vector.t ->
step_kont
| SK_Next : 'a frame_stack
* ongoing frame_stack Mavryk_webassembly_interpreter.Instance.Vector.t
* label_step_kont -> step_kont
| SK_Consolidate_label_result of ongoing frame_stack
* ongoing frame_stack Mavryk_webassembly_interpreter.Instance.Vector.t
* label
* Values.value concat_kont
* admin_instr Mavryk_webassembly_interpreter.Instance.Vector.t
* label Mavryk_webassembly_interpreter.Instance.Vector.t
| SK_Result of Values.value Mavryk_webassembly_interpreter.Instance.Vector.t
| SK_Trapped of string Source.phrase
type ('a, 'b, 'acc) fold_right2_kont = {
acc : 'acc;
lv : 'a Mavryk_webassembly_interpreter.Instance.Vector.t;
rv : 'b Mavryk_webassembly_interpreter.Instance.Vector.t;
offset : int32;
}
type ('a, 'b) fold_left_kont = {
origin : 'a Mavryk_webassembly_interpreter.Instance.Vector.t;
acc : 'b;
offset : int32;
}
type create_global_kont = Types.global_type * eval_const_kont
type (_, _, _) init_section =
| Func : ((Ast.func, Instance.func_inst) Either.t, Ast.func, Instance.func_inst)
init_section
| Global : (create_global_kont, Ast.global, Instance.global_inst) init_section
| Table : ((Ast.table, Instance.table_inst) Either.t,
Ast.table,
Instance.table_inst)
init_section
| Memory : ((Ast.memory, Instance.memory_inst) Either.t,
Ast.memory,
Instance.memory_inst)
init_section
type 'b join_kont =
| J_Init of 'b Mavryk_webassembly_interpreter.Instance.Vector.t
Mavryk_webassembly_interpreter.Instance.Vector.t
| J_Next of 'b concat_kont
* 'b Mavryk_webassembly_interpreter.Instance.Vector.t
Mavryk_webassembly_interpreter.Instance.Vector.t
| J_Stop of 'b Mavryk_webassembly_interpreter.Instance.Vector.t
type ('a, 'b) map_concat_kont =
| MC_Map of ('a, 'b Mavryk_webassembly_interpreter.Instance.Vector.t) map_kont
| MC_Join of 'b join_kont
type create_elem_kont = (eval_const_kont, Ast.const, Values.ref_) tick_map_kont
type init_kont =
| IK_Start of Instance.extern Mavryk_webassembly_interpreter.Instance.Vector.t
Very first tick of the init
function
| IK_Add_import of (Instance.extern, Ast.import, Instance.module_inst)
fold_right2_kont
| IK_Type of Instance.module_inst * (Ast.type_, Types.func_type) map_kont
| IK_Aggregate : Instance.module_inst
* ('kont, 'a, 'b) init_section
* ('kont, 'a, 'b) tick_map_kont -> init_kont
| IK_Aggregate_concat : Instance.module_inst
* ('kont, 'a, 'b) init_section
* 'b concat_kont -> init_kont
| IK_Exports of Instance.module_inst * (Ast.export, exports_acc) fold_left_kont
| IK_Elems of Instance.module_inst
* (create_elem_kont, Ast.elem_segment, Instance.elem_inst) tick_map_kont
| IK_Datas of Instance.module_inst
* (Ast.data_segment, Instance.data_inst) map_kont
| IK_Es_elems of Instance.module_inst
* (Ast.elem_segment, admin_instr) map_concat_kont
| IK_Es_datas of Instance.module_inst
* (Ast.data_segment, admin_instr) map_concat_kont
* admin_instr Mavryk_webassembly_interpreter.Instance.Vector.t
| IK_Join_admin of Instance.module_inst * admin_instr join_kont
| IK_Eval of config
| IK_Stop
Witness that there is no more tick to execute to complete the init
process.
This is raised when an initialisation function detects that the module does not export its main memory.
val init_step :
stack_size_limit:int ->
filter_exports:bool ->
?check_module_exports:memory_export_rules ->
module_reg:Instance.module_reg ->
self:Instance.module_key ->
buffers ->
Host_funcs.registry ->
Ast.module_ ->
init_kont ->
init_kont Lwt.t
Small-step execution of the init
process. See init
.
val init :
?stack_size_limit:int ->
module_reg:Instance.module_reg ->
self:Instance.module_key ->
buffers ->
Host_funcs.registry ->
Ast.module_ ->
Instance.extern list ->
Instance.module_inst Lwt.t
val invoke :
?stack_size_limit:int ->
module_reg:Instance.module_reg ->
caller:Instance.module_key ->
?input:Input_buffer.t ->
?output:Output_buffer.t ->
?durable:Durable_storage.t ->
?init:bool ->
Host_funcs.registry ->
Instance.func_inst ->
Values.value list ->
(Durable_storage.t * Values.value list) Lwt.t
val step :
?init:bool ->
?durable:Durable_storage.t ->
host_funcs:Host_funcs.registry ->
Instance.module_reg ->
config ->
buffers ->
(Durable_storage.t * config) Lwt.t
exception Reveal_error of reveal_error
val is_reveal_tick : config -> Host_funcs.reveal option
is_reveal_tick config
returns Some hash
if the evalutation is in a state expecting the payload of a given hash, and returns None
otherwise.
val reveal_step :
(memory:Instance.memory_inst ->
dst:int32 ->
max_bytes:int32 ->
payload:bytes ->
int32 Lwt.t) ->
Instance.module_reg ->
bytes ->
config ->
config Lwt.t
reveal_step reveal module_reg payload config
loads payload
in the memory of the module whose function is being evaluated with config
.
This function can only be used when is_reveal_tick
returns something (i.e., not None
).
val config :
stack_size_limit:int ->
?frame_arity:int32 ->
Instance.module_key ->
Values.value Mavryk_webassembly_interpreter.Instance.Vector.t ->
admin_instr Mavryk_webassembly_interpreter.Instance.Vector.t ->
config
val default_output_buffer : unit -> Instance.output_inst
val buffers :
?input:Instance.input_inst ->
?output:Instance.output_inst ->
unit ->
buffers