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
10 changes: 2 additions & 8 deletions .github/workflows/opam.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: "recursive"

- name: Setup node.js
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
Expand All @@ -36,15 +36,9 @@ jobs:
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}

# Necessary until using libbinaryen v122
- name: Override C Compiler Flags For Windows
if: ${{ startsWith(matrix.os, 'windows-') }}
run: |
echo "CC=x86_64-w64-mingw32-gcc" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "CXX=x86_64-w64-mingw32-g++" | Out-File -FilePath $env:GITHUB_ENV -Append

- name: Install local dependencies
run: |
opam repo add ospencer https://github.com/ospencer/opam-repository.git
opam install . --deps-only --with-test

- name: Build project
Expand Down
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.0.0" < "7.0.0"}
"libbinaryen" {> "121.0.0" < "122.0.0"}
"libbinaryen" {>= "124.0.0" < "125.0.0"}
]
x-maintenance-intent: ["0.(latest)"]
13 changes: 6 additions & 7 deletions esy.lock/index.json

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

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "Apache-2.0",
"dependencies": {
"ocaml": ">= 4.13.0 < 5.4.0",
"@grain/libbinaryen": "121.0.0-b",
"@grain/libbinaryen": ">= 124.0.0 < 125.0.0",
"@opam/dune": ">= 3.0.0",
"@opam/dune-configurator": ">= 3.0.0"
},
Expand All @@ -16,7 +16,8 @@
"@opam/ocaml-lsp-server": ">= 1.9.1 < 2.0.0"
},
"resolutions": {
"@opam/ocp-indent": "1.7.0"
"@opam/ocp-indent": "1.7.0",
"@grain/libbinaryen": "git+https://github.com/spotandjake/libbinaryen.git#193eb5ef9dbf89e3f6cb00a4730ffb23ea4ca699"
},
"esy": {
"build": "dune build -p binaryen"
Expand Down
2 changes: 1 addition & 1 deletion src/expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,7 @@ caml_binaryen_ref_func(value _module, value _name, value _ty) {
CAMLparam3(_module, _name, _ty);
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
char* name = Safe_String_val(_name);
BinaryenType ty = BinaryenType_val(_ty);
BinaryenHeapType ty = BinaryenHeapType_val(_ty);
BinaryenExpressionRef exp = BinaryenRefFunc(module, name, ty);
CAMLreturn(alloc_BinaryenExpressionRef(exp));
}
Expand Down
3 changes: 2 additions & 1 deletion src/expression.ml
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,8 @@ module Ref = struct
external as_ : Module.t -> Op.t -> t -> t = "caml_binaryen_ref_as"
(** Module, op, value *)

external func : Module.t -> string -> Type.t -> t = "caml_binaryen_ref_func"
external func : Module.t -> string -> Heap_type.t -> t
= "caml_binaryen_ref_func"
(** Module, func, type *)

external eq : Module.t -> t -> t -> t = "caml_binaryen_ref_eq"
Expand Down
2 changes: 1 addition & 1 deletion src/expression.mli
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ module Ref : sig
val as_ : Module.t -> Op.t -> t -> t
(** Module, op, value *)

val func : Module.t -> string -> Type.t -> t
val func : Module.t -> string -> Heap_type.t -> t
(** Module, func, type *)

val eq : Module.t -> t -> t -> t
Expand Down
8 changes: 8 additions & 0 deletions src/function.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ caml_binaryen_set_start(value _module, value _fun) {
CAMLreturn(Val_unit);
}

CAMLprim value
caml_binaryen_get_start(value _module) {
CAMLparam1(_module);
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
BinaryenFunctionRef fun = BinaryenGetStart(module);
CAMLreturn(alloc_BinaryenFunctionRef(fun));
}

CAMLprim value
caml_binaryen_function_set_debug_location(value _fun, value _exp, value _file, value _line, value _column) {
CAMLparam5(_fun, _exp, _file, _line, _column);
Expand Down
5 changes: 5 additions & 0 deletions src/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ function caml_binaryen_set_start(wasm_mod, func) {
return wasm_mod.setStart(func);
}

//Provides: caml_binaryen_get_start
function caml_binaryen_get_start(wasm_mod) {
return wasm_mod.getStart();
}

//Provides: caml_binaryen_function_set_debug_location
//Requires: Binaryen
function caml_binaryen_function_set_debug_location(
Expand Down
2 changes: 2 additions & 0 deletions src/function.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ external add_function :

external set_start : Module.t -> t -> unit = "caml_binaryen_set_start"

external get_start : Module.t -> t = "caml_binaryen_get_start"

external set_debug_location : t -> Expression.t -> int -> int -> int -> unit
= "caml_binaryen_function_set_debug_location"

Expand Down
1 change: 1 addition & 0 deletions src/function.mli
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ val add_function :
Module.t -> string -> Type.t -> Type.t -> Type.t array -> Expression.t -> t

val set_start : Module.t -> t -> unit
val get_start : Module.t -> t
val set_debug_location : t -> Expression.t -> int -> int -> int -> unit
val get_function : Module.t -> string -> t
val get_function_by_index : Module.t -> int -> t
Expand Down
38 changes: 30 additions & 8 deletions src/module.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ module Feature = struct

let atomics = atomics ()

external bulk_memory : unit -> t = "caml_binaryen_feature_bulk_memory"

let bulk_memory = bulk_memory ()

external mutable_globals : unit -> t = "caml_binaryen_feature_mutable_globals"

let mutable_globals = mutable_globals ()
Expand All @@ -27,14 +23,18 @@ module Feature = struct

let nontrapping_fp_to_int = nontrapping_fp_to_int ()

external sign_ext : unit -> t = "caml_binaryen_feature_sign_ext"

let sign_ext = sign_ext ()

external simd128 : unit -> t = "caml_binaryen_feature_simd128"

let simd128 = simd128 ()

external bulk_memory : unit -> t = "caml_binaryen_feature_bulk_memory"

let bulk_memory = bulk_memory ()

external sign_ext : unit -> t = "caml_binaryen_feature_sign_ext"

let sign_ext = sign_ext ()

external exception_handling : unit -> t
= "caml_binaryen_feature_exception_handling"

Expand Down Expand Up @@ -76,6 +76,28 @@ module Feature = struct

let multi_memory = multi_memory ()

external stack_switching : unit -> t = "caml_binaryen_feature_stack_switching"

let stack_switching = stack_switching ()

external shared_everything : unit -> t
= "caml_binaryen_feature_shared_everything"

let shared_everything = shared_everything ()

external fp16 : unit -> t = "caml_binaryen_feature_fp16"

let fp16 = fp16 ()

external bulk_memory_opt : unit -> t = "caml_binaryen_feature_bulk_memory_opt"

let bulk_memory_opt = bulk_memory_opt ()

external call_indirect_overlong : unit -> t
= "caml_binaryen_feature_call_indirect_overlong"

let call_indirect_overlong = call_indirect_overlong ()

external all : unit -> t = "caml_binaryen_feature_all"

let all = all ()
Expand Down
9 changes: 7 additions & 2 deletions src/module.mli
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ module Feature : sig

val mvp : t
val atomics : t
val bulk_memory : t
val mutable_globals : t
val nontrapping_fp_to_int : t
val sign_ext : t
val simd128 : t
val bulk_memory : t
val sign_ext : t
val exception_handling : t
val tail_call : t
val reference_types : t
Expand All @@ -20,6 +20,11 @@ module Feature : sig
val extended_const : t
val strings : t
val multi_memory : t
val stack_switching : t
val shared_everything : t
val fp16 : t
val bulk_memory_opt : t
val call_indirect_overlong : t
val all : t
end

Expand Down
50 changes: 40 additions & 10 deletions src/module_feature.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ caml_binaryen_feature_atomics(value unit) {
CAMLreturn(Val_int(BinaryenFeatureAtomics()));
}

CAMLprim value
caml_binaryen_feature_bulk_memory(value unit) {
CAMLparam1(unit);
CAMLreturn(Val_int(BinaryenFeatureBulkMemory()));
}

CAMLprim value
caml_binaryen_feature_mutable_globals(value unit) {
CAMLparam1(unit);
Expand All @@ -54,15 +48,21 @@ caml_binaryen_feature_nontrapping_fp_to_int(value unit) {
}

CAMLprim value
caml_binaryen_feature_sign_ext(value unit) {
caml_binaryen_feature_simd128(value unit) {
CAMLparam1(unit);
CAMLreturn(Val_int(BinaryenFeatureSignExt()));
CAMLreturn(Val_int(BinaryenFeatureSIMD128()));
}

CAMLprim value
caml_binaryen_feature_simd128(value unit) {
caml_binaryen_feature_bulk_memory(value unit) {
CAMLparam1(unit);
CAMLreturn(Val_int(BinaryenFeatureSIMD128()));
CAMLreturn(Val_int(BinaryenFeatureBulkMemory()));
}

CAMLprim value
caml_binaryen_feature_sign_ext(value unit) {
CAMLparam1(unit);
CAMLreturn(Val_int(BinaryenFeatureSignExt()));
}

CAMLprim value
Expand Down Expand Up @@ -125,6 +125,36 @@ caml_binaryen_feature_multi_memory(value unit) {
CAMLreturn(Val_int(BinaryenFeatureMultiMemory()));
}

CAMLprim value
caml_binaryen_feature_stack_switching(value unit) {
CAMLparam1(unit);
CAMLreturn(Val_int(BinaryenFeatureStackSwitching()));
}

CAMLprim value
caml_binaryen_feature_shared_everything(value unit) {
CAMLparam1(unit);
CAMLreturn(Val_int(BinaryenFeatureSharedEverything()));
}

CAMLprim value
caml_binaryen_feature_fp16(value unit) {
CAMLparam1(unit);
CAMLreturn(Val_int(BinaryenFeatureFP16()));
}

CAMLprim value
caml_binaryen_feature_bulk_memory_opt(value unit) {
CAMLparam1(unit);
CAMLreturn(Val_int(BinaryenFeatureBulkMemoryOpt()));
}

CAMLprim value
caml_binaryen_feature_call_indirect_overlong(value unit) {
CAMLparam1(unit);
CAMLreturn(Val_int(BinaryenFeatureCallIndirectOverlong()));
}

CAMLprim value
caml_binaryen_feature_all(value unit) {
CAMLparam1(unit);
Expand Down
Loading
Loading