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
135 changes: 135 additions & 0 deletions src/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,36 @@ caml_binaryen_set_debug_info(value _on) {
CAMLreturn(Val_unit);
}

CAMLprim value
caml_binaryen_get_traps_never_happen(value unit) {
CAMLparam1(unit);
bool res = BinaryenGetTrapsNeverHappen();
CAMLreturn(Val_bool(res));
}

CAMLprim value
caml_binaryen_set_traps_never_happen(value _on) {
CAMLparam1(_on);
bool on = Bool_val(_on);
BinaryenSetTrapsNeverHappen(on);
CAMLreturn(Val_unit);
}

CAMLprim value
caml_binaryen_get_closed_world(value unit) {
CAMLparam1(unit);
bool res = BinaryenGetClosedWorld();
CAMLreturn(Val_bool(res));
}

CAMLprim value
caml_binaryen_set_closed_world(value _on) {
CAMLparam1(_on);
bool on = Bool_val(_on);
BinaryenSetClosedWorld(on);
CAMLreturn(Val_unit);
}

CAMLprim value
caml_binaryen_get_low_memory_unused(value unit) {
CAMLparam1(unit);
Expand All @@ -67,6 +97,66 @@ caml_binaryen_set_low_memory_unused(value _on) {
CAMLreturn(Val_unit);
}

CAMLprim value
caml_binaryen_get_zero_filled_memory(value unit) {
CAMLparam1(unit);
bool res = BinaryenGetZeroFilledMemory();
CAMLreturn(Val_bool(res));
}

CAMLprim value
caml_binaryen_set_zero_filled_memory(value _on) {
CAMLparam1(_on);
bool on = Bool_val(_on);
BinaryenSetZeroFilledMemory(on);
CAMLreturn(Val_unit);
}

CAMLprim value
caml_binaryen_get_fast_math(value unit) {
CAMLparam1(unit);
bool res = BinaryenGetFastMath();
CAMLreturn(Val_bool(res));
}

CAMLprim value
caml_binaryen_set_fast_math(value _on) {
CAMLparam1(_on);
bool on = Bool_val(_on);
BinaryenSetFastMath(on);
CAMLreturn(Val_unit);
}

CAMLprim value
caml_binaryen_get_generate_stack_ir(value unit) {
CAMLparam1(unit);
bool res = BinaryenGetGenerateStackIR();
CAMLreturn(Val_bool(res));
}

CAMLprim value
caml_binaryen_set_generate_stack_ir(value _on) {
CAMLparam1(_on);
bool on = Bool_val(_on);
BinaryenSetGenerateStackIR(on);
CAMLreturn(Val_unit);
}

CAMLprim value
caml_binaryen_get_optimize_stack_ir(value unit) {
CAMLparam1(unit);
bool res = BinaryenGetOptimizeStackIR();
CAMLreturn(Val_bool(res));
}

CAMLprim value
caml_binaryen_set_optimize_stack_ir(value _on) {
CAMLparam1(_on);
bool on = Bool_val(_on);
BinaryenSetOptimizeStackIR(on);
CAMLreturn(Val_unit);
}

CAMLprim value
caml_binaryen_get_pass_argument(value _name) {
CAMLparam1(_name);
Expand All @@ -88,6 +178,36 @@ caml_binaryen_set_pass_argument(value _name, value _val) {
CAMLreturn(Val_unit);
}

CAMLprim value
caml_binaryen_clear_pass_arguments(value unit) {
CAMLparam1(unit);
BinaryenClearPassArguments();
CAMLreturn(Val_unit);
}

CAMLprim value
caml_binaryen_has_pass_to_skip(value _pass) {
CAMLparam1(_pass);
const char* pass = Safe_String_val(_pass);
bool res = BinaryenHasPassToSkip(pass);
CAMLreturn(Val_bool(res));
}

CAMLprim value
caml_binaryen_add_pass_to_skip(value _pass) {
CAMLparam1(_pass);
const char* pass = Safe_String_val(_pass);
BinaryenAddPassToSkip(pass);
CAMLreturn(Val_unit);
}

CAMLprim value
caml_binaryen_clear_passes_to_skip(value unit) {
CAMLparam1(unit);
BinaryenClearPassesToSkip();
CAMLreturn(Val_unit);
}

CAMLprim value
caml_binaryen_get_always_inline_max_size(value unit) {
CAMLparam1(unit);
Expand Down Expand Up @@ -133,6 +253,21 @@ caml_binaryen_set_one_caller_inline_max_size(value _size) {
CAMLreturn(Val_unit);
}

CAMLprim value
caml_binaryen_get_allow_inlining_functions_with_loops(value unit) {
CAMLparam1(unit);
bool res = BinaryenGetAllowInliningFunctionsWithLoops();
CAMLreturn(Val_bool(res));
}

CAMLprim value
caml_binaryen_set_allow_inlining_functions_with_loops(value _size) {
CAMLparam1(_size);
int on = Bool_val(_size);
BinaryenSetAllowInliningFunctionsWithLoops(on);
CAMLreturn(Val_unit);
}

CAMLprim value
caml_binaryen_set_colors_enabled(value _on) {
CAMLparam1(_on);
Expand Down
131 changes: 131 additions & 0 deletions src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,34 @@ function caml_binaryen_set_debug_info(on) {
return Binaryen._BinaryenSetDebugInfo(on);
}

//Provides: caml_binaryen_get_traps_never_happen
//Requires: Binaryen
function caml_binaryen_get_traps_never_happen() {
// Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
return Binaryen._BinaryenGetTrapsNeverHappen();
}

//Provides: caml_binaryen_set_traps_never_happen
//Requires: Binaryen
function caml_binaryen_set_traps_never_happen(on) {
// Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
return Binaryen._BinaryenSetTrapsNeverHappen(on);
}

//Provides: caml_binaryen_get_closed_world
//Requires: Binaryen
function caml_binaryen_get_closed_world() {
// Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
return Binaryen._BinaryenGetClosedWorld();
}

//Provides: caml_binaryen_set_closed_world
//Requires: Binaryen
function caml_binaryen_set_closed_world(on) {
// Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
return Binaryen._BinaryenSetClosedWorld(on);
}

//Provides: caml_binaryen_get_low_memory_unused
//Requires: Binaryen
function caml_binaryen_get_low_memory_unused() {
Expand All @@ -50,6 +78,62 @@ function caml_binaryen_set_low_memory_unused(on) {
return Binaryen._BinaryenSetLowMemoryUnused(on);
}

//Provides: caml_binaryen_get_zero_filled_memory
//Requires: Binaryen
function caml_binaryen_get_zero_filled_memory() {
// Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
return Binaryen._BinaryenGetZeroFilledMemory();
}

//Provides: caml_binaryen_set_zero_filled_memory
//Requires: Binaryen
function caml_binaryen_set_zero_filled_memory(on) {
// Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
return Binaryen._BinaryenSetZeroFilledMemory(on);
}

//Provides: caml_binaryen_get_fast_math
//Requires: Binaryen
function caml_binaryen_get_fast_math() {
// Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
return Binaryen._BinaryenGetFastMath();
}

//Provides: caml_binaryen_set_fast_math
//Requires: Binaryen
function caml_binaryen_set_fast_math(on) {
// Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
return Binaryen._BinaryenSetFastMath(on);
}

//Provides: caml_binaryen_get_generate_stack_ir
//Requires: Binaryen
function caml_binaryen_get_generate_stack_ir() {
// Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
return Binaryen._BinaryenGetGenerateStackIR();
}

//Provides: caml_binaryen_set_generate_stack_ir
//Requires: Binaryen
function caml_binaryen_set_generate_stack_ir(on) {
// Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
return Binaryen._BinaryenSetGenerateStackIR(on);
}

//Provides: caml_binaryen_get_optimize_stack_ir
//Requires: Binaryen
function caml_binaryen_get_optimize_stack_ir() {
// Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
return Binaryen._BinaryenGetOptimizeStackIR();
}

//Provides: caml_binaryen_set_optimize_stack_ir
//Requires: Binaryen
function caml_binaryen_set_optimize_stack_ir(on) {
// Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
return Binaryen._BinaryenSetOptimizeStackIR(on);
}

//Provides: caml_binaryen_get_pass_argument
//Requires: Binaryen
//Requires: caml_jsstring_of_string
Expand All @@ -70,6 +154,39 @@ function caml_binaryen_set_pass_argument(name, value) {
);
}

//Provides: caml_binaryen_clear_pass_arguments
//Requires: Binaryen
function caml_binaryen_clear_pass_arguments() {
return Binaryen.clearPassArguments();
}

//Provides: caml_binaryen_has_pass_to_skip
//Requires: Binaryen
//Requires: caml_jsstring_of_string
//Requires: caml_js_to_bool
function caml_binaryen_has_pass_to_skip(pass) {
return caml_js_to_bool(
Binaryen.hasPassToSkip(
caml_jsstring_of_string(pass)
)
);
}

//Provides: caml_binaryen_add_pass_to_skip
//Requires: Binaryen
//Requires: caml_jsstring_of_string
function caml_binaryen_add_pass_to_skip(pass) {
return Binaryen.addPassToSkip(
caml_jsstring_of_string(pass)
);
}

//Provides: caml_binaryen_clear_passes_to_skip
//Requires: Binaryen
function caml_binaryen_clear_passes_to_skip(pass) {
return Binaryen.clearPassesToSkip();
}

//Provides: caml_binaryen_get_always_inline_max_size
//Requires: Binaryen
function caml_binaryen_get_always_inline_max_size() {
Expand Down Expand Up @@ -106,6 +223,20 @@ function caml_binaryen_set_one_caller_inline_max_size(size) {
return Binaryen.setOneCallerInlineMaxSize(size);
}

//Provides: caml_binaryen_get_allow_inlining_functions_with_loops
//Requires: Binaryen
function caml_binaryen_get_allow_inlining_functions_with_loops() {
// Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
return Binaryen._BinaryenGetAllowInliningFunctionsWithLoops();
}

//Provides: caml_binaryen_set_allow_inlining_functions_with_loops
//Requires: Binaryen
function caml_binaryen_set_allow_inlining_functions_with_loops(on) {
// Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
return Binaryen._BinaryenSetAllowInliningFunctionsWithLoops(on);
}

//Provides: caml_binaryen_set_colors_enabled
//Requires: Binaryen
function caml_binaryen_set_colors_enabled(on) {
Expand Down
45 changes: 45 additions & 0 deletions src/settings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,57 @@ external set_shrink_level : int -> unit = "caml_binaryen_set_shrink_level"
external get_debug_info : unit -> bool = "caml_binaryen_get_debug_info"
external set_debug_info : bool -> unit = "caml_binaryen_set_debug_info"

external get_traps_never_happen : unit -> bool
= "caml_binaryen_get_traps_never_happen"

external set_traps_never_happen : bool -> unit
= "caml_binaryen_set_traps_never_happen"

external get_closed_world : unit -> bool = "caml_binaryen_get_closed_world"
external set_closed_world : bool -> unit = "caml_binaryen_set_closed_world"

external get_low_memory_unused : unit -> bool
= "caml_binaryen_get_low_memory_unused"

external set_low_memory_unused : bool -> unit
= "caml_binaryen_set_low_memory_unused"

external get_zero_filled_memory : unit -> bool
= "caml_binaryen_get_zero_filled_memory"

external set_zero_filled_memory : bool -> unit
= "caml_binaryen_set_zero_filled_memory"

external get_fast_math : unit -> bool = "caml_binaryen_get_fast_math"
external set_fast_math : bool -> unit = "caml_binaryen_set_fast_math"

external get_generate_stack_ir : unit -> bool
= "caml_binaryen_get_generate_stack_ir"

external set_generate_stack_ir : bool -> unit
= "caml_binaryen_set_generate_stack_ir"

external get_optimize_stack_ir : unit -> bool
= "caml_binaryen_get_optimize_stack_ir"

external set_optimize_stack_ir : bool -> unit
= "caml_binaryen_set_optimize_stack_ir"

external get_pass_argument : string -> string option
= "caml_binaryen_get_pass_argument"

external set_pass_argument : string -> string -> unit
= "caml_binaryen_set_pass_argument"

external clear_pass_arguments : unit -> unit
= "caml_binaryen_clear_pass_arguments"

external has_pass_to_skip : string -> bool = "caml_binaryen_has_pass_to_skip"
external add_pass_to_skip : string -> unit = "caml_binaryen_add_pass_to_skip"

external clear_passes_to_skip : unit -> unit
= "caml_binaryen_clear_passes_to_skip"

external get_always_inline_max_size : unit -> int
= "caml_binaryen_get_always_inline_max_size"

Expand All @@ -35,5 +74,11 @@ external get_one_caller_inline_max_size : unit -> int
external set_one_caller_inline_max_size : int -> unit
= "caml_binaryen_set_one_caller_inline_max_size"

external get_allow_inlining_functions_with_loops : unit -> bool
= "caml_binaryen_get_allow_inlining_functions_with_loops"

external set_allow_inlining_functions_with_loops : bool -> unit
= "caml_binaryen_set_allow_inlining_functions_with_loops"

external set_colors_enabled : bool -> unit = "caml_binaryen_set_colors_enabled"
external are_colors_enabled : unit -> bool = "caml_binaryen_are_colors_enabled"
Loading