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
681 changes: 375 additions & 306 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ rust-version = "1.85"

[workspace.dependencies]
# WebAssembly parsing and encoding
wasmparser = { version = "0.230", features = ["component-model"] }
wasm-encoder = { version = "0.230", features = ["component-model"] }
wasmprinter = "0.230"
wasmparser = { version = "0.246", features = ["component-model"] }
wasm-encoder = { version = "0.246", features = ["component-model"] }
wasmprinter = "0.246"

# CLI
clap = { version = "4.5", features = ["derive", "cargo"] }
Expand Down
7 changes: 5 additions & 2 deletions meld-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,12 @@ fn write_import_map(wasm_bytes: &[u8], path: &str) -> Result<()> {
for payload in parser.parse_all(wasm_bytes) {
let payload = payload.context("Parse error while reading imports")?;
if let Payload::ImportSection(reader) = payload {
for import in reader {
for import in reader.into_imports() {
let import = import.context("Failed to read import entry")?;
if matches!(import.ty, wasmparser::TypeRef::Func(_)) {
if matches!(
import.ty,
wasmparser::TypeRef::Func(_) | wasmparser::TypeRef::FuncExact(_)
) {
imports.push(serde_json::json!({
"index": func_index,
"module": import.module,
Expand Down
25 changes: 23 additions & 2 deletions meld-core/src/adapter/fact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,10 @@ impl FactStyleGenerator {
return self.generate_params_ptr_adapter(site, options, target_func, caller_type_idx);
}

// --- Non-retptr path: use caller's type for declared signature ---
let adapter_type_idx = caller_type_idx;
// --- Non-retptr path: use callee's type so body is valid ---
// wire_adapter_indices generates a widening wrapper if caller expects
// wider result types (P3 async i64 vs i32).
let adapter_type_idx = callee_type_idx;
let param_count = callee_param_count;
let result_count = callee_result_count;
let result_types = callee_result_types;
Expand Down Expand Up @@ -3173,6 +3175,25 @@ impl AdapterGenerator for FactStyleGenerator {
let mut adapters = Vec::new();

for (idx, site) in graph.adapter_sites.iter().enumerate() {
if site.is_async_lift {
// Async adapter sites are preserved as component-level canon
// lift/lower pairs. Generate a dummy (unreachable) adapter to
// maintain 1:1 correspondence with adapter_sites.
let mut body = Function::new([]);
body.instruction(&Instruction::Unreachable);
body.instruction(&Instruction::End);
adapters.push(AdapterFunction {
name: format!("$async_stub_{}", idx),
type_idx: 0,
body,
source_component: site.from_component,
source_module: site.from_module,
target_component: site.to_component,
target_module: site.to_module,
target_function: 0,
});
continue;
}
let adapter = self.generate_adapter(
site,
merged,
Expand Down
Loading
Loading