Skip to content
Open
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
12 changes: 6 additions & 6 deletions esy.lock/index.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"resolutions": {
"@opam/ocp-indent": "1.9.0",
"@opam/ocamlfind": "1.9.8",
"@grain/libbinaryen": "git+https://github.com/grain-lang/libbinaryen.git#f795f89bcb8acfa33320ced2f9721de3823858ba"
"@grain/libbinaryen": "git+https://github.com/grain-lang/libbinaryen.git#e06fac15ef19f9b9bb784b2be980f03618a27ced"
},
"esy": {
"build": "dune build -p binaryen"
Expand Down
10 changes: 10 additions & 0 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ caml_binaryen_module_parse(value _text) {
CAMLreturn(alloc_BinaryenModuleRef(module));
}


CAMLprim value
caml_binaryen_module_parse_with_features(value _text, value _features) {
CAMLparam2(_text, _features);
const char* text = Safe_String_val(_text);
BinaryenFeatures features = Int_val(_features);
BinaryenModuleRef module = BinaryenModuleParseWithFeatures(text, features);
CAMLreturn(alloc_BinaryenModuleRef(module));
}

CAMLprim value
caml_binaryen_module_print(value module) {
CAMLparam1(module);
Expand Down
7 changes: 7 additions & 0 deletions src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ function caml_binaryen_module_parse(text) {
return Binaryen.parseText(caml_jsstring_of_string(text));
}

//Provides: caml_binaryen_module_parse_with_features
//Requires: Binaryen
//Requires: caml_jsstring_of_string
function caml_binaryen_module_parse_with_features(text, features) {
return Binaryen.parseText(caml_jsstring_of_string(text), features);
}

//Provides: caml_binaryen_module_print
//Requires: caml_ml_output_str_stdout
function caml_binaryen_module_print(wasm_mod) {
Expand Down
8 changes: 8 additions & 0 deletions src/module.ml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ module Feature = struct

let wide_arithmetic = wide_arithmetic ()

external compact_imports : unit -> t = "caml_binaryen_feature_compact_imports"

let compact_imports = compact_imports ()

external all : unit -> t = "caml_binaryen_feature_all"

let all = all ()
Expand All @@ -127,6 +131,10 @@ external add_custom_section : t -> string -> string -> unit
= "caml_binaryen_add_custom_section"

external parse : string -> t = "caml_binaryen_module_parse"

external parse_with_features : string -> Feature.t -> t
= "caml_binaryen_module_parse_with_features"

external print : t -> unit = "caml_binaryen_module_print"
external print_asmjs : t -> unit = "caml_binaryen_module_print_asmjs"
external print_stack_ir : t -> unit = "caml_binaryen_module_print_stack_ir"
Expand Down
2 changes: 2 additions & 0 deletions src/module.mli
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ module Feature : sig
val multibyte : t
val custom_page_sizes : t
val wide_arithmetic : t
val compact_imports : t
val all : t
end

val create : unit -> t
val dispose : t -> unit
val add_custom_section : t -> string -> string -> unit
val parse : string -> t
val parse_with_features : string -> Feature.t -> t
val print : t -> unit
val print_asmjs : t -> unit
val print_stack_ir : t -> unit
Expand Down
6 changes: 6 additions & 0 deletions src/module_feature.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ caml_binaryen_feature_wide_arithmetic(value unit) {
CAMLreturn(Val_int(BinaryenFeatureWideArithmetic()));
}

CAMLprim value
caml_binaryen_feature_compact_imports(value unit) {
CAMLparam1(unit);
CAMLreturn(Val_int(BinaryenFeatureCompactImports()));
}

CAMLprim value
caml_binaryen_feature_all(value unit) {
CAMLparam1(unit);
Expand Down
6 changes: 6 additions & 0 deletions src/module_feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ function caml_binaryen_feature_wide_arithmetic() {
return Binaryen.Features.WideArithmetic;
}

//Provides: caml_binaryen_feature_compact_imports
//Requires: Binaryen
function caml_binaryen_feature_compact_imports() {
return Binaryen.Features.CompactImports;
}

//Provides: caml_binaryen_feature_all
//Requires: Binaryen
function caml_binaryen_feature_all() {
Expand Down
3 changes: 3 additions & 0 deletions src/passes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ let cfp = "cfp"
(** propagate constant struct field values, using ref.test *)
let cfp_reftest = "cfp-reftest"

(** finds and uses mathematical constraints on locals *)
let constraint_analysis = "constraint-analysis"

(** removes unreachable code *)
let dce = "dce"

Expand Down
3 changes: 3 additions & 0 deletions src/passes.mli
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ val cfp : t
val cfp_reftest : t
(** propagate constant struct field values, using ref.test *)

val constraint_analysis : t
(** finds and uses mathematical constraints on locals *)

val dce : t
(** removes unreachable code *)

Expand Down
Loading