From 6b25dc6218ea4914ca586a73e2df6a15c58576ae Mon Sep 17 00:00:00 2001 From: Spotandjake Date: Sat, 1 Nov 2025 20:16:06 -0400 Subject: [PATCH 1/2] feat: Check formatting in ci --- .github/workflows/esy.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/esy.yml b/.github/workflows/esy.yml index c7bb3ea..f94a977 100644 --- a/.github/workflows/esy.yml +++ b/.github/workflows/esy.yml @@ -83,3 +83,9 @@ jobs: - name: Run tests run: | esy test + + # Check formatting + - name: Check format + run: | + esy format + git diff --exit-code --name-only From e6b9ace4d01f784daba09bf3bb94e77ba6bfc8bc Mon Sep 17 00:00:00 2001 From: Spotandjake Date: Sat, 1 Nov 2025 20:22:35 -0400 Subject: [PATCH 2/2] chore: Run formatter & scope to ubuntu runner --- .github/workflows/esy.yml | 1 + dune | 2 +- src/expression.ml | 15 +++++++++---- src/import.ml | 12 ++++++---- src/memory.ml | 3 ++- src/passes.ml | 46 ++++++++++++++++++++++++++------------- src/passes.mli | 43 ++++++++++++++++++++++++------------ 7 files changed, 83 insertions(+), 39 deletions(-) diff --git a/.github/workflows/esy.yml b/.github/workflows/esy.yml index f94a977..414be34 100644 --- a/.github/workflows/esy.yml +++ b/.github/workflows/esy.yml @@ -86,6 +86,7 @@ jobs: # Check formatting - name: Check format + if: inputs.os == 'ubuntu-latest' run: | esy format git diff --exit-code --name-only diff --git a/dune b/dune index f9475a6..75edca9 100644 --- a/dune +++ b/dune @@ -1,3 +1,3 @@ (dirs :standard) -(data_only_dirs node_modules) \ No newline at end of file +(data_only_dirs node_modules) diff --git a/src/expression.ml b/src/expression.ml index 5738830..de83707 100644 --- a/src/expression.ml +++ b/src/expression.ml @@ -480,7 +480,8 @@ end module Switch = struct external make : Module.t -> string list -> string -> t -> t -> t = "caml_binaryen_switch" - (** Module, branch names, default branch name, condition, value. Value may be null. *) + (** Module, branch names, default branch name, condition, value. Value may be + null. *) external get_num_names : t -> int = "caml_binaryen_switch_get_num_names" external get_name_at : t -> int -> string = "caml_binaryen_switch_get_name_at" @@ -544,7 +545,8 @@ module Call_indirect = struct external make_return : Module.t -> string -> t -> t list -> Type.t -> Type.t -> t - = "caml_binaryen_return_call_indirect__bytecode" "caml_binaryen_return_call_indirect" + = "caml_binaryen_return_call_indirect__bytecode" + "caml_binaryen_return_call_indirect" (** Module, table, function value, params, params type, return type. *) external get_target : t -> t = "caml_binaryen_call_indirect_get_target" @@ -705,10 +707,13 @@ end module Memory_init = struct external make : Module.t -> string -> t -> t -> t -> string -> t = "caml_binaryen_memory_init__bytecode" "caml_binaryen_memory_init" - (** Module, segment, destination, offset, size, memory_name *) + external get_segment : t -> string = "caml_binaryen_memory_init_get_segment" + (** Module, segment, destination, offset, size, memory_name *) + external set_segment : t -> string -> unit = "caml_binaryen_memory_init_set_segment" + external get_dest : t -> t = "caml_binaryen_memory_init_get_dest" external set_dest : t -> t -> unit = "caml_binaryen_memory_init_set_dest" external get_offset : t -> t = "caml_binaryen_memory_init_get_offset" @@ -719,8 +724,10 @@ end module Data_drop = struct external make : Module.t -> string -> t = "caml_binaryen_data_drop" - (** Module, segment. *) + external get_segment : t -> string = "caml_binaryen_data_drop_get_segment" + (** Module, segment. *) + external set_segment : t -> string -> unit = "caml_binaryen_data_drop_set_segment" end diff --git a/src/import.ml b/src/import.ml index 33ccec1..d29bb18 100644 --- a/src/import.ml +++ b/src/import.ml @@ -1,7 +1,9 @@ external add_function_import : Module.t -> string -> string -> string -> Type.t -> Type.t -> unit - = "caml_binaryen_add_function_import__bytecode" "caml_binaryen_add_function_import" -(** Module, internal name, external module name, external base name, params type, results type. *) + = "caml_binaryen_add_function_import__bytecode" + "caml_binaryen_add_function_import" +(** Module, internal name, external module name, external base name, params + type, results type. *) external add_table_import : Module.t -> string -> string -> string -> unit = "caml_binaryen_add_table_import" @@ -14,8 +16,10 @@ external add_memory_import : external add_global_import : Module.t -> string -> string -> string -> Type.t -> bool -> unit - = "caml_binaryen_add_global_import__bytecode" "caml_binaryen_add_global_import" -(** Module, internal name, external module name, external base name, type, mutable. *) + = "caml_binaryen_add_global_import__bytecode" + "caml_binaryen_add_global_import" +(** Module, internal name, external module name, external base name, type, + mutable. *) external function_import_get_module : Function.t -> string = "caml_binaryen_function_import_get_module" diff --git a/src/memory.ml b/src/memory.ml index 4319c28..5f224b3 100644 --- a/src/memory.ml +++ b/src/memory.ml @@ -16,7 +16,8 @@ external set_memory : type segment = { name : string; data : bytes; kind : segment_kind; size : int } and segment_kind = Passive | Active of { offset : Expression.t } -(** Module, initial size, maximum size, export name, segments, shared, memory64, moduleName . *) +(** Module, initial size, maximum size, export name, segments, shared, memory64, + moduleName . *) let set_memory wasm_mod initial maximum export_name (segments : segment list) shared memory64 moduleName = let split_segments segments = diff --git a/src/passes.ml b/src/passes.ml index 4edc386..c553640 100644 --- a/src/passes.ml +++ b/src/passes.ml @@ -12,7 +12,8 @@ let avoid_reinterprets = "avoid-reinterprets" (** removes arguments to calls in an lto-like manner *) let dae = "dae" -(** removes arguments to calls in an lto-like manner, and optimizes where we removed *) +(** removes arguments to calls in an lto-like manner, and optimizes where we + removed *) let dae_optimizing = "dae-optimizing" (** refine and merge abstract (never-created) types *) @@ -75,7 +76,8 @@ let extract_function_index = "extract-function-index" (** flattens out code, removing nesting *) let flatten = "flatten" -(** emulates function pointer casts, allowing incorrect indirect calls to (sometimes) work *) +(** emulates function pointer casts, allowing incorrect indirect calls to + (sometimes) work *) let fpcast_emu = "fpcast-emu" (** reports function metrics *) @@ -84,7 +86,9 @@ let func_metrics = "func-metrics" (** generate dynCall fuctions used by emscripten ABI *) let generate_dyncalls = "generate-dyncalls" -(** generate dynCall functions used by emscripten ABI, but only for functions with i64 in their signature (which cannot be invoked via the wasm table without JavaScript BigInt support). *) +(** generate dynCall functions used by emscripten ABI, but only for functions + with i64 in their signature (which cannot be invoked via the wasm table + without JavaScript BigInt support). *) let generate_i64_dyncalls = "generate-i64-dyncalls" (** generate global effect info (helps later passes) *) @@ -102,7 +106,8 @@ let gsi = "gsi" (** globally optimize GC types *) let gto = "gto" -(** Grand Unified Flow Analysis: optimize the entire program using information about what content can actually appear in each location *) +(** Grand Unified Flow Analysis: optimize the entire program using information + about what content can actually appear in each location *) let gufa = "gufa" (** GUFA plus local optimizations in functions we modified *) @@ -132,7 +137,8 @@ let jspi = "jspi" (** legalizes i64 types on the import/export boundary *) let legalize_js_interface = "legalize-js-interface" -(** legalizes i64 types on the import/export boundary in a minimal manner, only on things only JS will call *) +(** legalizes i64 types on the import/export boundary in a minimal manner, only + on things only JS will call *) let legalize_js_interface_minimally = "legalize-js-interface-minimally" (** common subexpression elimination inside basic blocks *) @@ -177,17 +183,21 @@ let merge_locals = "merge-locals" (** reports metrics *) let metrics = "metrics" -(** minifies import names (only those, and not export names), and emits a mapping to the minified ones *) +(** minifies import names (only those, and not export names), and emits a + mapping to the minified ones *) let minify_imports = "minify-imports" -(** minifies both import and export names, and emits a mapping to the minified ones *) +(** minifies both import and export names, and emits a mapping to the minified + ones *) let minify_imports_and_exports = "minify-imports-and-exports" -(** minifies both import and export names, and emits a mapping to the minified ones, and minifies the modules as well *) +(** minifies both import and export names, and emits a mapping to the minified + ones, and minifies the modules as well *) let minify_imports_and_exports_and_modules = "minify-imports-and-exports-and-modules" -(** apply the assumption that asyncify imports always unwind, and we never rewind *) +(** apply the assumption that asyncify imports always unwind, and we never + rewind *) let mod_asyncify_always_and_only_unwind = "mod-asyncify-always-and-only-unwind" (** apply the assumption that asyncify never unwinds *) @@ -202,7 +212,8 @@ let monomorphize_always = "monomorphize-always" (** combines multiple memories into a single memory *) let multi_memory_lowering = "multi-memory-lowering" -(** combines multiple memories into a single memory, trapping if the read or write is larger than the length of the memory's data *) +(** combines multiple memories into a single memory, trapping if the read or + write is larger than the length of the memory's data *) let multi_memory_lowering_with_bounds_checks = "multi-memory-lowering-with-bounds-checks" @@ -218,7 +229,8 @@ let once_reduction = "once-reduction" (** optimizes added constants into load/store offsets *) let optimize_added_constants = "optimize-added-constants" -(** optimizes added constants into load/store offsets, propagating them across locals too *) +(** optimizes added constants into load/store offsets, propagating them across + locals too *) let optimize_added_constants_propagate = "optimize-added-constants-propagate" (** eliminate and reuse casts *) @@ -245,7 +257,8 @@ let optimize_for_js = "optimize-for-js" (** computes compile-time evaluatable expressions *) let precompute = "precompute" -(** computes compile-time evaluatable expressions and propagates them through locals *) +(** computes compile-time evaluatable expressions and propagates them through + locals *) let precompute_propagate = "precompute-propagate" (** print in s-expression format *) @@ -330,19 +343,22 @@ let signature_pruning = "signature-pruning" (** apply more specific subtypes to signature types where possible *) let signature_refining = "signature-refining" -(** lower sign-ext operations to wasm mvp and disable the sign extension feature *) +(** lower sign-ext operations to wasm mvp and disable the sign extension feature +*) let signext_lowering = "signext-lowering" (** miscellaneous globals-related optimizations *) let simplify_globals = "simplify-globals" -(** miscellaneous globals-related optimizations, and optimizes where we replaced global.gets with constants *) +(** miscellaneous globals-related optimizations, and optimizes where we replaced + global.gets with constants *) let simplify_globals_optimizing = "simplify-globals-optimizing" (** miscellaneous locals-related optimizations *) let simplify_locals = "simplify-locals" -(** miscellaneous locals-related optimizations (no nesting at all; preserves flatness) *) +(** miscellaneous locals-related optimizations (no nesting at all; preserves + flatness) *) let simplify_locals_nonesting = "simplify-locals-nonesting" (** miscellaneous locals-related optimizations (no tees) *) diff --git a/src/passes.mli b/src/passes.mli index 1110350..4c55e87 100644 --- a/src/passes.mli +++ b/src/passes.mli @@ -13,7 +13,8 @@ val dae : t (** removes arguments to calls in an lto-like manner *) val dae_optimizing : t -(** removes arguments to calls in an lto-like manner, and optimizes where we removed *) +(** removes arguments to calls in an lto-like manner, and optimizes where we + removed *) val abstract_type_refining : t (** refine and merge abstract (never-created) types *) @@ -76,7 +77,8 @@ val flatten : t (** flattens out code, removing nesting *) val fpcast_emu : t -(** emulates function pointer casts, allowing incorrect indirect calls to (sometimes) work *) +(** emulates function pointer casts, allowing incorrect indirect calls to + (sometimes) work *) val func_metrics : t (** reports function metrics *) @@ -85,7 +87,9 @@ val generate_dyncalls : t (** generate dynCall fuctions used by emscripten ABI *) val generate_i64_dyncalls : t -(** generate dynCall functions used by emscripten ABI, but only for functions with i64 in their signature (which cannot be invoked via the wasm table without JavaScript BigInt support). *) +(** generate dynCall functions used by emscripten ABI, but only for functions + with i64 in their signature (which cannot be invoked via the wasm table + without JavaScript BigInt support). *) val generate_global_effects : t (** generate global effect info (helps later passes) *) @@ -103,7 +107,8 @@ val gto : t (** globally optimize GC types *) val gufa : t -(** Grand Unified Flow Analysis: optimize the entire program using information about what content can actually appear in each location *) +(** Grand Unified Flow Analysis: optimize the entire program using information + about what content can actually appear in each location *) val gufa_optimizing : t (** GUFA plus local optimizations in functions we modified *) @@ -133,7 +138,8 @@ val legalize_js_interface : t (** legalizes i64 types on the import/export boundary *) val legalize_js_interface_minimally : t -(** legalizes i64 types on the import/export boundary in a minimal manner, only on things only JS will call *) +(** legalizes i64 types on the import/export boundary in a minimal manner, only + on things only JS will call *) val local_cse : t (** common subexpression elimination inside basic blocks *) @@ -178,16 +184,20 @@ val metrics : t (** reports metrics *) val minify_imports : t -(** minifies import names (only those, and not export names), and emits a mapping to the minified ones *) +(** minifies import names (only those, and not export names), and emits a + mapping to the minified ones *) val minify_imports_and_exports : t -(** minifies both import and export names, and emits a mapping to the minified ones *) +(** minifies both import and export names, and emits a mapping to the minified + ones *) val minify_imports_and_exports_and_modules : t -(** minifies both import and export names, and emits a mapping to the minified ones, and minifies the modules as well *) +(** minifies both import and export names, and emits a mapping to the minified + ones, and minifies the modules as well *) val mod_asyncify_always_and_only_unwind : t -(** apply the assumption that asyncify imports always unwind, and we never rewind *) +(** apply the assumption that asyncify imports always unwind, and we never + rewind *) val mod_asyncify_never_unwind : t (** apply the assumption that asyncify never unwinds *) @@ -202,7 +212,8 @@ val multi_memory_lowering : t (** combines multiple memories into a single memory *) val multi_memory_lowering_with_bounds_checks : t -(** combines multiple memories into a single memory, trapping if the read or write is larger than the length of the memory's data *) +(** combines multiple memories into a single memory, trapping if the read or + write is larger than the length of the memory's data *) val nm : t (** name list *) @@ -217,7 +228,8 @@ val optimize_added_constants : t (** optimizes added constants into load/store offsets *) val optimize_added_constants_propagate : t -(** optimizes added constants into load/store offsets, propagating them across locals too *) +(** optimizes added constants into load/store offsets, propagating them across + locals too *) val optimize_casts : t (** eliminate and reuse casts *) @@ -244,7 +256,8 @@ val precompute : t (** computes compile-time evaluatable expressions *) val precompute_propagate : t -(** computes compile-time evaluatable expressions and propagates them through locals *) +(** computes compile-time evaluatable expressions and propagates them through + locals *) val print : t (** print in s-expression format *) @@ -334,13 +347,15 @@ val simplify_globals : t (** miscellaneous globals-related optimizations *) val simplify_globals_optimizing : t -(** miscellaneous globals-related optimizations, and optimizes where we replaced global.gets with constants *) +(** miscellaneous globals-related optimizations, and optimizes where we replaced + global.gets with constants *) val simplify_locals : t (** miscellaneous locals-related optimizations *) val simplify_locals_nonesting : t -(** miscellaneous locals-related optimizations (no nesting at all; preserves flatness) *) +(** miscellaneous locals-related optimizations (no nesting at all; preserves + flatness) *) val simplify_locals_notee : t (** miscellaneous locals-related optimizations (no tees) *)