Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

124
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda