Skip to content

Commit f913981

Browse files
committed
feat!: Upgrade to Binaryen v124
Full Diff: WebAssembly/binaryen@version_123...version_124
1 parent aefe600 commit f913981

File tree

8 files changed

+29
-10
lines changed

8 files changed

+29
-10
lines changed

binaryen.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ depends: [
1616
"dune" {>= "3.0.0"}
1717
"dune-configurator" {>= "3.0.0"}
1818
"js_of_ocaml-compiler" {>= "6.0.0" < "7.0.0"}
19-
"libbinaryen" {>= "123.0.1" < "124.0.0"}
19+
"libbinaryen" {>= "124.0.1" < "125.0.0"}
2020
]
2121
x-maintenance-intent: ["0.(latest)"]

esy.lock/index.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "Apache-2.0",
77
"dependencies": {
88
"ocaml": ">= 4.13.0 < 5.4.0",
9-
"@grain/libbinaryen": ">= 123.0.0 < 124.0.0",
9+
"@grain/libbinaryen": ">= 124.0.0 < 125.0.0",
1010
"@opam/dune": ">= 3.0.0",
1111
"@opam/dune-configurator": ">= 3.0.0"
1212
},

src/function.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ caml_binaryen_set_start(value _module, value _fun) {
7373
CAMLreturn(Val_unit);
7474
}
7575

76+
CAMLprim value
77+
caml_binaryen_get_start(value _module) {
78+
CAMLparam1(_module);
79+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
80+
BinaryenFunctionRef fun = BinaryenGetStart(module);
81+
CAMLreturn(alloc_BinaryenFunctionRef(fun));
82+
}
83+
7684
CAMLprim value
7785
caml_binaryen_function_set_debug_location(value _fun, value _exp, value _file, value _line, value _column) {
7886
CAMLparam5(_fun, _exp, _file, _line, _column);

src/function.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ function caml_binaryen_set_start(wasm_mod, func) {
5656
return wasm_mod.setStart(func);
5757
}
5858

59+
//Provides: caml_binaryen_get_start
60+
function caml_binaryen_get_start(wasm_mod) {
61+
return wasm_mod.getStart();
62+
}
63+
5964
//Provides: caml_binaryen_function_set_debug_location
6065
//Requires: Binaryen
6166
function caml_binaryen_function_set_debug_location(

src/function.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ external add_function :
66
(** Module, name, params type, results type, locals types, body. *)
77

88
external set_start : Module.t -> t -> unit = "caml_binaryen_set_start"
9+
external get_start : Module.t -> t = "caml_binaryen_get_start"
910

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

src/function.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ val add_function :
44
Module.t -> string -> Type.t -> Type.t -> Type.t array -> Expression.t -> t
55

66
val set_start : Module.t -> t -> unit
7+
val get_start : Module.t -> t
78
val set_debug_location : t -> Expression.t -> int -> int -> int -> unit
89
val get_function : Module.t -> string -> t
910
val get_function_by_index : Module.t -> int -> t

test/test.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,14 @@ let start =
170170

171171
let _ = Export.add_function_export wasm_mod "adder" "adder"
172172
let _ = Table.add_table wasm_mod "table" 1 1 Type.funcref
173-
let funcref_expr1 = Expression.Ref.func wasm_mod "adder" (Heap_type.func ())
173+
174+
(* TODO(#240): Re-enable after type-builder api is merged *)
175+
(* let funcref_expr1 = Expression.Ref.func wasm_mod "adder" (Heap_type.func ())
174176
175177
let _ =
176178
Expression.Table.set wasm_mod "table"
177179
(Expression.Const.make wasm_mod (Literal.int32 0l))
178-
funcref_expr1
180+
funcref_expr1 *)
179181

180182
let funcref_expr2 =
181183
Expression.Table.get wasm_mod "table"
@@ -212,6 +214,8 @@ let _ =
212214
(Expression.Const.make wasm_mod (Literal.int32 0l))
213215

214216
let _ = Function.set_start wasm_mod start
217+
let start_func = Function.get_start wasm_mod
218+
let _ = assert (Function.get_name start_func = "start")
215219

216220
let segment : Binaryen.Memory.segment =
217221
let data = Bytes.of_string "hello" in

0 commit comments

Comments
 (0)