Skip to content

Commit 818b071

Browse files
committed
feat!: Upgrade to Binaryen v124
Full Diff: WebAssembly/binaryen@version_123...version_124
1 parent 1051aec commit 818b071

File tree

8 files changed

+31
-11
lines changed

8 files changed

+31
-11
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.0" < "124.0.0"}
19+
"libbinaryen" {>= "124.0.0" < "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: 2 additions & 2 deletions
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
},
@@ -17,7 +17,7 @@
1717
},
1818
"resolutions": {
1919
"@opam/ocp-indent": "1.7.0",
20-
"@grain/libbinaryen": "git+https://github.com/grain-lang/libbinaryen.git#cb37a909a8b27ab2f5ef89b5c5c346e2622424f0"
20+
"@grain/libbinaryen": "git+https://github.com/spotandjake/libbinaryen.git#193eb5ef9dbf89e3f6cb00a4730ffb23ea4ca699"
2121
},
2222
"esy": {
2323
"build": "dune build -p binaryen"

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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ external add_function :
77

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

10+
external get_start : Module.t -> t = "caml_binaryen_get_start"
11+
1012
external set_debug_location : t -> Expression.t -> int -> int -> int -> unit
1113
= "caml_binaryen_function_set_debug_location"
1214

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
@@ -107,12 +107,14 @@ let start =
107107

108108
let _ = Export.add_function_export wasm_mod "adder" "adder"
109109
let _ = Table.add_table wasm_mod "table" 1 1 Type.funcref
110-
let funcref_expr1 = Expression.Ref.func wasm_mod "adder" (Heap_type.func ())
110+
111+
(* TODO(#240): Re-enable after type-builder api is merged *)
112+
(* let funcref_expr1 = Expression.Ref.func wasm_mod "adder" (Heap_type.func ())
111113
112114
let _ =
113115
Expression.Table.set wasm_mod "table"
114116
(Expression.Const.make wasm_mod (Literal.int32 0l))
115-
funcref_expr1
117+
funcref_expr1 *)
116118

117119
let funcref_expr2 =
118120
Expression.Table.get wasm_mod "table"
@@ -149,6 +151,8 @@ let _ =
149151
(Expression.Const.make wasm_mod (Literal.int32 0l))
150152

151153
let _ = Function.set_start wasm_mod start
154+
let start_func = Function.get_start wasm_mod
155+
let _ = assert (Function.get_name start_func = "start")
152156

153157
let segment : Binaryen.Memory.segment =
154158
let data = Bytes.of_string "hello" in

0 commit comments

Comments
 (0)