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
2 changes: 1 addition & 1 deletion binaryen.opam
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ depends: [
"dune" {>= "3.0.0"}
"dune-configurator" {>= "3.0.0"}
"js_of_ocaml-compiler" {>= "6.4.0" < "7.0.0"}
"libbinaryen" {>= "131.0.0" < "132.0.0"}
"libbinaryen" {>= "132.0.0" < "133.0.0"}
]
x-maintenance-intent: ["0.(latest)"]
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 @@ -13,7 +13,7 @@
},
"dependencies": {
"ocaml": ">= 4.14.0 < 6.0.0",
"@grain/libbinaryen": ">= 131.0.0 < 132.0.0",
"@grain/libbinaryen": ">= 132.0.0 < 133.0.0",
"@opam/dune": ">= 3.0.0",
"@opam/dune-configurator": ">= 3.0.0"
},
Expand Down
11 changes: 11 additions & 0 deletions src/expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -2228,6 +2228,17 @@ caml_binaryen_array_init_elem__bytecode(value * argv) {
return caml_binaryen_array_init_elem(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
}

// Strings

CAMLprim value
caml_binaryen_string_const(value _module, value _val) {
CAMLparam2(_module, _val);
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
char* val = Safe_String_val(_val);
BinaryenExpressionRef exp = BinaryenStringConst(module, val);
CAMLreturn(alloc_BinaryenExpressionRef(exp));
}

// Exception handling operations
CAMLprim value
caml_binaryen_try(value _module, value _name, value _body, value _catchTags, value _catchBodies, value _delegateTarget) {
Expand Down
8 changes: 8 additions & 0 deletions src/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -1939,6 +1939,14 @@ function caml_binaryen_array_copy__bytecode() {
);
}

// Strings

//Provides: caml_binaryen_string_const
//Requires: caml_jsstring_of_string
function caml_binaryen_string_const(wasm_mod, value) {
return wasm_mod.string.const(caml_jsstring_of_string(value));
}

// Exception handling operations

//Provides: caml_binaryen_try
Expand Down
5 changes: 5 additions & 0 deletions src/expression.ml
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,11 @@ module Array = struct
(** Module, seg, ref, index, offset, size *)
end

module String = struct
external make : Module.t -> string -> t = "caml_binaryen_string_const"
(** Module, value *)
end

(** Bindings for `try_table` instruction. *)
module Try = struct
external make :
Expand Down
5 changes: 5 additions & 0 deletions src/expression.mli
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,11 @@ module Array : sig
(** Module, seg, ref, index, offset, size *)
end

module String : sig
val make : Module.t -> string -> t
(** Module, value *)
end

(** Bindings for `try` instruction. *)
module Try : sig
val make :
Expand Down
2 changes: 1 addition & 1 deletion src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function caml_binaryen_module_read(bytes) {
//Requires: caml_uint8_array_of_bytes
function caml_binaryen_module_read_with_features(bytes, features) {
var data = caml_uint8_array_of_bytes(bytes);
return Binaryen.readBinaryWithFeatures(data, features);
return Binaryen.readBinary(data, features);
}

//Provides: caml_binaryen_module_interpret
Expand Down
9 changes: 7 additions & 2 deletions src/module.ml
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ module Feature = struct

let call_indirect_overlong = call_indirect_overlong ()

external relaxed_atomics : unit -> t = "caml_binaryen_feature_relaxed_atomics"
external acquire_release_atomics : unit -> t
= "caml_binaryen_feature_acquire_release_atomics"

let relaxed_atomics = relaxed_atomics ()
let acquire_release_atomics = acquire_release_atomics ()

external multibyte : unit -> t = "caml_binaryen_feature_multibyte"

Expand All @@ -119,6 +120,10 @@ module Feature = struct

let compact_imports = compact_imports ()

external relaxed_atomics : unit -> t = "caml_binaryen_feature_relaxed_atomics"

let relaxed_atomics = relaxed_atomics ()

external all : unit -> t = "caml_binaryen_feature_all"

let all = all ()
Expand Down
3 changes: 2 additions & 1 deletion src/module.mli
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ module Feature : sig
val fp16 : t
val bulk_memory_opt : t
val call_indirect_overlong : t
val relaxed_atomics : t
val acquire_release_atomics : t
val multibyte : t
val custom_page_sizes : t
val wide_arithmetic : t
val compact_imports : t
val relaxed_atomics : t
val all : t
end

Expand Down
10 changes: 8 additions & 2 deletions src/module_feature.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ caml_binaryen_feature_call_indirect_overlong(value unit) {
}

CAMLprim value
caml_binaryen_feature_relaxed_atomics(value unit) {
caml_binaryen_feature_acquire_release_atomics(value unit) {
CAMLparam1(unit);
CAMLreturn(Val_int(BinaryenFeatureRelaxedAtomics()));
CAMLreturn(Val_int(BinaryenFeatureAcquireReleaseAtomics()));
}

CAMLprim value
Expand All @@ -185,6 +185,12 @@ caml_binaryen_feature_compact_imports(value unit) {
CAMLreturn(Val_int(BinaryenFeatureCompactImports()));
}

CAMLprim value
caml_binaryen_feature_relaxed_atomics(value unit) {
CAMLparam1(unit);
CAMLreturn(Val_int(BinaryenFeatureRelaxedAtomics()));
}

CAMLprim value
caml_binaryen_feature_all(value unit) {
CAMLparam1(unit);
Expand Down
12 changes: 9 additions & 3 deletions src/module_feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ function caml_binaryen_feature_call_indirect_overlong() {
return Binaryen.Features.BulkMemoryOpt;
}

//Provides: caml_binaryen_feature_relaxed_atomics
//Provides: caml_binaryen_feature_acquire_release_atomics
//Requires: Binaryen
function caml_binaryen_feature_relaxed_atomics() {
return Binaryen.Features.RelaxedAtomics;
function caml_binaryen_feature_acquire_release_atomics() {
return Binaryen.Features.AcquireReleaseAtomics;
}

//Provides: caml_binaryen_feature_multibyte
Expand All @@ -170,6 +170,12 @@ function caml_binaryen_feature_compact_imports() {
return Binaryen.Features.CompactImports;
}

//Provides: caml_binaryen_feature_relaxed_atomics
//Requires: Binaryen
function caml_binaryen_feature_relaxed_atomics() {
return Binaryen.Features.RelaxedAtomics;
}

//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 @@ -194,6 +194,9 @@ let licm = "licm"
(** attempt to merge segments to fit within web limits *)
let limit_segments = "limit-segments"

(** Make structs and arrays shared and functions unshared *)
let make_shared_objects = "make-shared-objects"

(** mark js called functions (using configureAll) as doing so *)
let mark_js_called = "mark-js-called"

Expand Down
3 changes: 3 additions & 0 deletions src/passes.mli
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ val licm : t
val limit_segments : t
(** attempt to merge segments to fit within web limits *)

val make_shared_objects : t
(** Make structs and arrays shared and functions unshared *)

val mark_js_called : t
(** mark js called functions (using configureAll) as doing so *)

Expand Down
Loading