Skip to content

Generate handle table wasm functions in fused module #71

@avrabe

Description

@avrabe

Part of #69, depends on #70

Task

For each re-exporter, generate three wasm functions in the fused core module that operate on the handle table allocated in #70.

Implementation

Files: meld-core/src/merger.rs (or new meld-core/src/handle_table.rs)

Generate using wasm_encoder::Function + wasm_encoder::Instruction:

;; ht_new: store rep, return aligned handle
(func (param i32) (result i32)
  global.get $next_ptr
  local.tee $handle
  local.get 0        ;; rep
  i32.store           ;; store in memory N at handle addr
  local.get $handle
  i32.const 4
  i32.add
  global.set $next_ptr
  local.get $handle)

;; ht_rep: load rep from handle address
(func (param i32) (result i32)
  local.get 0
  i32.load)           ;; load from memory N

;; ht_drop: zero out entry
(func (param i32)
  local.get 0
  i32.const 0
  i32.store)          ;; store in memory N

Critical: i32.load/i32.store must specify the correct memory index for multi-memory mode.

Add new_func, rep_func, drop_func merged function indices to HandleTableInfo.

Branch

feat/per-component-handle-tables

Acceptance

cargo test --package meld-core passes. Functions generated but not yet wired.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions