Component-model-aware WebAssembly analyzer, optimizer, and profiler
// See README.md and src/lib.mbt for usage.pub suberror WiteError {
UnexpectedEof
InvalidMagic
UnsupportedVersion(String)
InvalidFormat(String)
}pub struct CallGraphReport {
imported_function_count : UInt
local_function_count : UInt
roots : Array[UInt]
has_indirect_calls : Bool
partial : Bool
reachable_body_bytes : UInt
dead_body_bytes : UInt
nodes : Array[CallGraphNode]
}pub struct CallGraphSummary {
imported_function_count : UInt
local_function_count : UInt
roots : Array[UInt]
has_indirect_calls : Bool
partial : Bool
reachable_function_count : UInt
dead_function_count : UInt
reachable_body_bytes : UInt
dead_body_bytes : UInt
}pub struct CodeBlockSize {
function_index : UInt
function_name : String?
export_names : Array[String]
block_index : UInt
depth : UInt
kind : String
start_offset : UInt
end_offset : UInt
instruction_count : UInt
total_bytes : UInt
}pub struct CodeBlockSizeReport {
partial : Bool
function_count : UInt
block_count : UInt
total_body_bytes : UInt
total_instruction_bytes : UInt
blocks : Array[CodeBlockSize]
}pub struct ComponentCoreOptimizeReport {
total_component_bytes : UInt
core_module_count : UInt
total_core_before_bytes : UInt
total_core_after_bytes : UInt
entries : Array[ComponentCoreOptimizeEntry]
}pub struct ComponentFunctionSizeReport {
module_index : UInt
function_count : UInt
total_body_bytes : UInt
functions : Array[FunctionSize]
}pub struct ComponentProfile {
total_bytes : UInt
import_count : UInt
export_count : UInt
core_module_count : UInt
nested_component_count : UInt
sections : Array[SectionSize]
core_modules : Array[ModuleProfile]
}pub struct CustomSectionBreakdown {
name : String
count : UInt
total_bytes : UInt
payload_bytes : UInt
content_bytes : UInt
}pub struct DceReport {
roots : Array[UInt]
partial : Bool
removable_function_count : UInt
removable_body_bytes : UInt
removable_functions : Array[FunctionSize]
}pub struct FunctionGapEntry {
match_kind : String
match_key : String
left_function_index : UInt?
right_function_index : UInt?
left_name : String?
right_name : String?
left_export_names : Array[String]
right_export_names : Array[String]
left_body_bytes : UInt
right_body_bytes : UInt
left_minus_right_bytes : Int
abs_gap_bytes : UInt
}pub struct FunctionGapReport {
left_total_body_bytes : UInt
right_total_body_bytes : UInt
left_minus_right_total_bytes : Int
unmatched_left_count : UInt
unmatched_right_count : UInt
entries : Array[FunctionGapEntry]
}pub struct FunctionSize {
function_index : UInt
body_bytes : UInt
name : String?
export_names : Array[String]
}pub struct FunctionSizeDiff {
function_index : UInt
before_body_bytes : UInt
after_body_bytes : UInt
gain_bytes : UInt
regression_bytes : UInt
before_name : String?
after_name : String?
export_names : Array[String]
}pub struct HostCodeHint {
kind : String
function_index : UInt
function_name : String?
target_function_index : UInt
target_function_name : String?
export_names : Array[String]
appended_i32_const_count : UInt
dropped_param_count : UInt
}pub struct HostGeneratedCodeReport {
imported_function_count : UInt
local_function_count : UInt
param_forwarding_thunk_count : UInt
const_forwarding_thunk_count : UInt
signature_refinable_thunk_count : UInt
directize_candidate_call_count : UInt
dce_removable_function_count : UInt
dce_removable_body_bytes : UInt
dce_partial : Bool
hints : Array[HostCodeHint]
}pub struct HotnessSizeBucket {
bucket : String
count : UInt
body_bytes : UInt
total_ns : UInt64
}pub struct HotnessSizeEntry {
export_name : String
function_index : UInt?
function_name : String?
body_bytes : UInt
calls : UInt
total_ns : UInt64
average_ns : UInt64
bucket : String
unresolved_reason : String?
unresolved_detail : String?
}pub struct HotnessSizeMatrixReport {
iterations : UInt
instantiate_ns : UInt64
hot_threshold_ns : UInt64
large_threshold_bytes : UInt
unresolved_exports : Array[String]
unresolved_reason_counts : Array[HotnessUnresolvedReasonCount]
buckets : Array[HotnessSizeBucket]
entries : Array[HotnessSizeEntry]
}pub struct HotnessUnresolvedReasonCount {
reason : String
count : UInt
}pub struct ModuleProfile {
total_bytes : UInt
function_count : UInt
import_count : UInt
export_count : UInt
code_body_count : UInt
code_body_bytes : UInt
sections : Array[SectionSize]
}pub struct OpcodeStat {
key : String
mnemonic : String
count : UInt
total_bytes : UInt
}pub struct OptimizeConfig {
strip_all_custom : Bool
strip_name_section : Bool
strip_producers_section : Bool
strip_debug_sections : Bool
strip_dwarf_sections : Bool
strip_target_features_section : Bool
keep_custom_sections : Array[String]
pass_rounds : UInt
enable_peephole : Bool
peephole_remove_nop : Bool
peephole_remove_const_drop : Bool
enable_vacuum : Bool
enable_merge_blocks : Bool
enable_remove_unused_brs : Bool
enable_dce : Bool
enable_dfe : Bool
enable_merge_similar_functions : Bool
enable_remove_unused_module_elements : Bool
closed_world : Bool
closed_world_root_exports : Array[String]
safe_mode : Bool
}pub struct OptimizeMetadataReport {
before_size : UInt
after_size : UInt
total_gain_bytes : UInt
total_regression_bytes : UInt
stages : Array[OptimizeStageMetadata]
}pub struct OptimizeStageMetadata {
stage : String
before_size : UInt
after_size : UInt
gain_bytes : UInt
regression_bytes : UInt
function_gain_bytes : UInt
function_regression_bytes : UInt
function_diffs : Array[FunctionSizeDiff]
removed_sections : Array[String]
no_change_reasons : Array[String]
}pub struct RuntimeFunctionProfile {
name : String
calls : UInt
total_ns : UInt64
average_ns : UInt64
}pub struct RuntimeProfile {
instantiate_ns : UInt64
iterations : UInt
functions : Array[RuntimeFunctionProfile]
skipped_exports : Array[String]
unresolved_exports : Array[RuntimeUnresolvedExport]
}pub struct RuntimeUnresolvedExport {
export_name : String
reason : String
detail : String
}pub struct WasmBreakdownReport {
total_bytes : UInt
sections : Array[SectionSize]
custom_sections : Array[CustomSectionBreakdown]
imported_function_count : UInt
local_function_count : UInt
top_functions : Array[FunctionSize]
block_count : UInt
top_blocks : Array[CodeBlockSize]
instruction_count : UInt
instruction_bytes : UInt
opcode_partial : Bool
opcodes : Array[OpcodeStat]
callgraph_partial : Bool
has_indirect_calls : Bool
reachable_body_bytes : UInt
dead_body_bytes : UInt
}fn analyze_component_contract(bytes : Bytes, resolved : ResolveInput) -> Result[ContractReport, String]fn analyze_component_core_optimize(bytes : Bytes, config? : OptimizeConfig, exclude? : Array[String]) -> Result[ComponentCoreOptimizeReport, String]fn analyze_component_function_sizes(bytes : Bytes) -> Result[Array[ComponentFunctionSizeReport], String]fn analyze_component_root_policy(bytes : Bytes, resolved_wit? : ResolveInput?, exclude? : Array[String]) -> Result[ComponentRootPolicyReport, String]fn analyze_function_size_gap(left_bytes : Bytes, right_bytes : Bytes, top_limit? : UInt) -> Result[FunctionGapReport, WiteError]fn analyze_hotness_size_matrix(bytes : Bytes, iterations? : UInt, scenarios? : Array[RuntimeProfileScenario]) -> Result[HotnessSizeMatrixReport, String]fn analyze_keep_reasons(bytes : Bytes, config? : OptimizeConfig) -> Result[KeepReasonReport, WiteError]fn analyze_optimize_metadata(bytes : Bytes, config? : OptimizeConfig, function_diff_limit? : UInt) -> Result[OptimizeMetadataReport, WiteError]fn analyze_retain_paths(bytes : Bytes, config? : OptimizeConfig) -> Result[RetainPathReport, WiteError]fn analyze_wasm_breakdown(bytes : Bytes, top_limit? : UInt) -> Result[WasmBreakdownReport, WiteError]fn make_component_optimize_config(base? : OptimizeConfig, root_name_candidates? : Array[String], exclude? : Array[String]) -> OptimizeConfigfn make_optimize_config(strip_all_custom? : Bool, strip_name_section? : Bool, strip_producers_section? : Bool, strip_debug_sections? : Bool, strip_dwarf_sections? : Bool, strip_target_features_section? : Bool, keep_custom_sections? : Array[String], pass_rounds? : UInt, enable_peephole? : Bool, peephole_remove_nop? : Bool, peephole_remove_const_drop? : Bool, enable_vacuum? : Bool, enable_merge_blocks? : Bool, enable_remove_unused_brs? : Bool, enable_dce? : Bool, enable_dfe? : Bool, enable_merge_similar_functions? : Bool, enable_remove_unused_module_elements? : Bool, closed_world? : Bool, closed_world_root_exports? : Array[String], safe_mode? : Bool) -> OptimizeConfigfn make_runtime_profile_scenario(export_name : String, args? : Array[Int]) -> RuntimeProfileScenariofn optimize_binary_for_size(bytes : Bytes, config? : OptimizeConfig, exclude? : Array[String]) -> Result[OptimizeResult, String]fn optimize_component_for_size(bytes : Bytes, config? : OptimizeConfig, exclude? : Array[String]) -> Result[OptimizeResult, String]fn profile_runtime_exports(bytes : Bytes, iterations? : UInt, scenarios? : Array[RuntimeProfileScenario]) -> Result[RuntimeProfile, String]fn profile_runtime_zero_arg_exports(bytes : Bytes, iterations? : UInt) -> Result[RuntimeProfile, String]Install
Download zipComponent-model-aware WebAssembly analyzer, optimizer, and profiler