xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

WebAssembly get_local error All In One

WebAssembly get_local error All In One

WebAssembly method define

bug? typo? version upgrade?

-    (f32.sqrt (get_local $num))
+    (f32.sqrt (local.get $num))

https://github.com/guybedford/wasm-intro/blob/master/1-loading-wasm-fn/test.wast#L6

https://egghead.io/lessons/javascript-create-and-run-a-native-webassembly-function

https://embed.plnkr.co/tFyR689ChxLsH6QtRiS8?autoCloseSidebar=true&show=test.wast,index.html

why it works in this env ???

solution & version diff ✅

WebAssembly Draft vs WebAssembly Specification

https://github.com/WebAssembly/wabt/issues/1802#issuecomment-1236657208

error ❌

WebAssembly get_local

(module
  (export "sqrt" (func $sqrt))
  (func $sqrt
    (param $num f32)
    (result f32)
    (f32.sqrt (get_local $num))
  )
)

solution ✅

WebAssembly local.get

(module
  (export "sqrt" (func $sqrt))
  (func $sqrt
    (param $num f32)
    (result f32)
    (f32.sqrt (local.get $num))
  )
)

https://webassembly.github.io/wabt/demo/wat2wasm/

WABT

The WebAssembly Binary Toolkit / WebAssembly 二进制工具包

https://github.com/WebAssembly/wabt

WABT: The WebAssembly Binary Toolkit

WABT (we pronounce it "wabbit") is a suite of tools for WebAssembly, including:

  • wat2wasm: translate from WebAssembly text format to the WebAssembly binary format
  • wasm2wat: the inverse of wat2wasm, translate from the binary format back to the text format (also known as a .wat)
  • wasm-objdump: print information about a wasm binary. Similiar to objdump.
  • wasm-interp: decode and run a WebAssembly binary file using a stack-based interpreter
  • wasm-decompile: decompile a wasm binary into readable C-like syntax.
  • wat-desugar: parse .wat text form as supported by the spec interpreter (s-expressions, flat syntax, or mixed) and print "canonical" flat format
  • wasm2c: convert a WebAssembly binary file to a C source and header
  • wasm-strip: remove sections of a WebAssembly binary file
  • wasm-validate: validate a file in the WebAssembly binary format
  • wast2json: convert a file in the wasm spec test format to a JSON file and associated wasm binary files
  • wasm-opcodecnt: count opcode usage for instructions
  • spectest-interp: read a Spectest JSON file, and run its tests in the interpreter

These tools are intended for use in (or for development of) toolchains or other systems that want to manipulate WebAssembly files.
Unlike the WebAssembly spec interpreter (which is written to be as simple, declarative and "speccy" as possible), they are written in C/C++ and designed for easier integration into other systems.
Unlike Binaryen these tools do not aim to provide an optimization platform or a higher-level compiler target; instead they aim for full fidelity and compliance with the spec (e.g. 1:1 round-trips with no changes to instructions).

这些工具旨在用于(或用于开发)工具链或其他想要操作 WebAssembly 文件的系统。
与 WebAssembly 规范解释器(其编写得尽可能简单、声明性和“规范”)不同,它们是用 C/C++ 编写的,旨在更容易地集成到其他系统中。
与 Binaryen 不同,这些工具的目的不是提供优化平台或更高级别的编译器目标;
相反,他们的目标是完全保真和遵守规范(例如,1:1 往返而不更改说明)。

refs

https://github.com/guybedford/wasm-intro/issues/3

https://github.com/WebAssembly/wabt/issues/1802

https://github.com/WebAssembly/wabt/issues/1802#issuecomment-1236657208



©xgqfrms 2012-2020

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2022-09-05 14:43  xgqfrms  阅读(102)  评论(1编辑  收藏  举报