Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
Why arguments are zeroed at WebAssembly imported function call?

I manually generated a WASM module that decompiles by wasm2wat into the following code.

(module
  (type (;0;) (func))
  (type (;1;) (func (param i32 i32)))
  (import "std" "print" (func (;0;) (type 1)))
  (func (;1;) (type 0)
    i32.const 0
    i32.const 13
    call 0)
  (memory (;0;) 13)
  (export "main" (func 0))
  (export "data" (memory 0))
  (data (;0;) (i32.const 0) "Hello, world!"))

At Node site I instantiate the module, supplying the following imports.

const imports = {
  std: {
    print: (utf8Offset, utf8Length) => {
      console.log([utf8Offset, utf8Length]);
      ...
    },
  },
};

When main function runs, console.log reports two zeros instead of 0 and 13. Why?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The problem was solved. I didn't take into account that functions are numbered starting from imports, not from in-module definitions.

main export should look like this:

(export "main" (func 1))
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!