Skip to content

Refactor module loading API using Config-based entrypoint#30

Draft
jtakakura wants to merge 5 commits intoclojurewasm:mainfrom
jtakakura:refactor/module-instantiation-api
Draft

Refactor module loading API using Config-based entrypoint#30
jtakakura wants to merge 5 commits intoclojurewasm:mainfrom
jtakakura:refactor/module-instantiation-api

Conversation

@jtakakura
Copy link
Copy Markdown
Contributor

Summary

This PR refactors the WasmModule loading API to consolidate various loading parameters into a single Config structure, as proposed in #29. This change simplifies the API surface and ensures that all resource limits are applied consistently before module execution.

Major Changes

  • Unified Loading API: Introduced WasmModule.Config and loadWithOptions in src/types.zig. This replaces multiple specialized load functions with a single, extensible entry point.
  • Pre-execution Resource Limits: VM settings such as fuel, timeout, and memory limits are now applied before the module's start function or instantiation logic runs.
  • C API Expansion: Added zwasm_config_t setter functions for fuel, timeout, and memory limits, allowing C users to configure VM constraints before module creation.
  • Internal Migration: Updated the CLI and internal component logic to use the new unified API.

Rationale

The previous loading API was becoming complex as more configuration options were added. By moving parameters into a Config struct, we provide a cleaner interface for embedders and a more robust foundation for future features, such as execution cancellation.

This refactoring is a prerequisite for the cancellation mechanism currently in draft at #28.

Related Issue
Closes #29

@jtakakura jtakakura force-pushed the refactor/module-instantiation-api branch 4 times, most recently from 402fed8 to cfc7d53 Compare April 11, 2026 13:42
@jtakakura jtakakura force-pushed the refactor/module-instantiation-api branch from cfc7d53 to 1c672cc Compare April 11, 2026 23:34
@jtakakura jtakakura force-pushed the refactor/module-instantiation-api branch from 1c672cc to 23251b4 Compare April 11, 2026 23:58
@jtakakura jtakakura force-pushed the refactor/module-instantiation-api branch from 23251b4 to 931dec5 Compare April 12, 2026 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Centralize WasmModule parameters into a Config struct

1 participant