GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Conversation

Notices

  1. Embed this notice
    mcc (mcc@mastodon.social)'s status on Wednesday, 28-May-2025 09:12:17 JST mcc mcc
    • ✧✦Catherine✦✧
    • danielle 🏳️‍🌈

    @endocrimes @whitequark Say I'm running some MDN sample code https://developer.mozilla.org/en-US/docs/WebAssembly/Guides/Understanding_the_text_format#importing_functions_from_javascript which loads and invokes console.log. Neither wasm-interp nor wasmtime are able to locate console.log. What is the most reasonable / most browser-compatible way to print a string from code running in one or either of these programs?

    In conversation about 3 days ago from mastodon.social permalink

    Attachments


    1. https://files.mastodon.social/media_attachments/files/114/582/494/428/922/884/original/67635b95169faaa1.png
    2. Domain not in remote thumbnail source whitelist: developer.mozilla.org
      Understanding WebAssembly text format - WebAssembly | MDN
      from MozDevNet
      To enable WebAssembly to be read and edited by humans, there is a textual representation of the Wasm binary format. This is an intermediate form designed to be exposed in text editors, browser developer tools, etc. This article explains how that text format works, in terms of the raw syntax, and how it is related to the underlying bytecode it represents — and the wrapper objects representing Wasm in JavaScript.
    • Embed this notice
      ✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Wednesday, 28-May-2025 09:12:16 JST ✧✦Catherine✦✧ ✧✦Catherine✦✧
      in reply to

      @mcc first off: nothing but browser and node.js will provide you with the ability to interoperate with JS

      second: if you want specifically `console.log` as an import, you'll probably have to write some adapter code to run it with wasmtime, because you are now the embedder who is in control (and you get all the drawbacks of having total control)

      wasmtime isn't a browser thing and it makes no attempt to emulate a browser environment

      In conversation about 3 days ago permalink
    • Embed this notice
      ✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Wednesday, 28-May-2025 09:13:12 JST ✧✦Catherine✦✧ ✧✦Catherine✦✧
      in reply to

      @mcc third: the browser doesn't provide anything by default either, you have to tell it to provide a `console.log` export explicitly

      anyway, i would probably use the wasmtime python bindings and add the functions you want via Python. there are examples on doing so, ping me if you have issues

      In conversation about 3 days ago permalink
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Wednesday, 28-May-2025 09:14:18 JST mcc mcc
      in reply to
      • ✧✦Catherine✦✧

      @whitequark Okay. Imagine it doesn't need to be console.log— what is the shortest path to printing a string to STDOUT from inside of a binary running in wasmtime? Or is the shortest path actually python?

      In conversation about 3 days ago permalink
    • Embed this notice
      ✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Wednesday, 28-May-2025 09:18:53 JST ✧✦Catherine✦✧ ✧✦Catherine✦✧
      in reply to

      @mcc consider that wasmtime doesn't have a conception of strings (strings aren't first-class in wasm), so any print method would involve accessing the linear memory directly and parsing your specific string format (is it null terminated? length prefixed? length passed explicitly? etc)

      this means you have to build an embedding, yeah

      In conversation about 3 days ago permalink
    • Embed this notice
      ✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Wednesday, 28-May-2025 09:19:05 JST ✧✦Catherine✦✧ ✧✦Catherine✦✧
      in reply to

      @mcc (this actually holds true for the browser as well)

      In conversation about 3 days ago permalink
    • Embed this notice
      ✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Wednesday, 28-May-2025 09:20:32 JST ✧✦Catherine✦✧ ✧✦Catherine✦✧
      in reply to

      @mcc without writing the entire thing for you, this wasmtime-py example is the closest to "extract a string from linear memory and print it" I think https://github.com/bytecodealliance/wasmtime-py/blob/main/examples/memory.py

      In conversation about 3 days ago permalink

      Attachments

      1. Domain not in remote thumbnail source whitelist: opengraph.githubassets.com
        wasmtime-py/examples/memory.py at main · bytecodealliance/wasmtime-py
        Python WebAssembly runtime powered by Wasmtime. Contribute to bytecodealliance/wasmtime-py development by creating an account on GitHub.
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Wednesday, 28-May-2025 09:23:26 JST mcc mcc
      in reply to
      • ✧✦Catherine✦✧

      @whitequark Okay. Let me take a different tack.

      I would like to be able to examine the state of my program while it is running, so I can tell if it is running correctly. Usually, printfs are the easiest way to do this.

      Do either wasmtime, or the wabt utilities, to your knowledge offer an interpreter with a non-painful memory debugger?

      In conversation about 3 days ago permalink

      Attachments


    • Embed this notice
      ✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Wednesday, 28-May-2025 09:25:00 JST ✧✦Catherine✦✧ ✧✦Catherine✦✧
      in reply to

      @mcc
      - you can debug wasmtime-generated code with gdb or lldb or what other native code debugger you have. however, this requires you to emit DWARF debug information, which i think doesn't even survive a roundtrip through the text format, so it's probably off the table
      - you can examine the linear memory yourself
      - you can do printfs

      that's about it

      In conversation about 3 days ago permalink
    • Embed this notice
      ✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Wednesday, 28-May-2025 09:25:56 JST ✧✦Catherine✦✧ ✧✦Catherine✦✧
      in reply to

      @mcc Wasm is a very low-level API, it's better to think about it like "an instruction set built for virtualization" than "it's a web thing that runs programs"; the former more accurately reflects the kind of integration you'll have to work on

      In conversation about 3 days ago permalink
      clacke@libranet.de is my main likes this.
    • Embed this notice
      ✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Wednesday, 28-May-2025 09:26:49 JST ✧✦Catherine✦✧ ✧✦Catherine✦✧
      in reply to

      @mcc I would suggest looking at WASI and also building some C programs using wasi-sdk to see how they use the WASI APIs, this might be the most illustrative at this point

      In conversation about 3 days ago permalink
      clacke@libranet.de is my main likes this.
    • Embed this notice
      Ted Mielczarek (tedmielczarek@mastodon.social)'s status on Wednesday, 28-May-2025 09:29:17 JST Ted Mielczarek Ted Mielczarek
      in reply to
      • ✧✦Catherine✦✧

      @whitequark @mcc wasmtime *does* implement the component model, FWIW: https://component-model.bytecodealliance.org/runtimes/wasmtime.html
      https://docs.wasmtime.dev/examples-rust-wasi.html

      In conversation about 3 days ago permalink

      Attachments

      1. No result found on File_thumbnail lookup.
        Wasmtime - The WebAssembly Component Model
      2. No result found on File_thumbnail lookup.
        WASI - Wasmtime
    • Embed this notice
      ✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Wednesday, 28-May-2025 09:30:18 JST ✧✦Catherine✦✧ ✧✦Catherine✦✧
      in reply to
      • Ted Mielczarek

      @tedmielczarek @mcc it does but if I start telling Andi about components she'll probably give up because of the dazzling level of complexity those involve (and how difficult it is to write those manually in the text format)

      In conversation about 3 days ago permalink
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Wednesday, 28-May-2025 09:31:10 JST mcc mcc
      in reply to
      • ✧✦Catherine✦✧

      @whitequark "you can examine the linear memory yourself"

      Can I? How?

      This project is based entirely around the state of a single array of integers, because I intentionally though that would be the easiest sort of project to do in handwritten wasm. If I can identify a location in memory and read it as sequential bytes/integers that's good enough. Doing this with wasm-interp sounds less scary as I assume the VM memory is better contained than wasmtime (which I think creates a native executable?)

      In conversation about 3 days ago permalink
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Wednesday, 28-May-2025 09:31:57 JST mcc mcc
      in reply to
      • Ted Mielczarek
      • ✧✦Catherine✦✧

      @whitequark @tedmielczarek The output of this program is a single integer, which is easy to export by just writing a function that returns an integer, so killing debuggability is an option D:

      In conversation about 3 days ago permalink
    • Embed this notice
      ✧✦Catherine✦✧ (whitequark@mastodon.social)'s status on Wednesday, 28-May-2025 09:33:38 JST ✧✦Catherine✦✧ ✧✦Catherine✦✧
      in reply to

      @mcc wasmtime is a JIT compiler; it abstracts away the details of how it runs your code though (also creating a static native executable isn't really an option with it)

      I'm not aware of a way to get wasmtime to dump the memory contents via the command line. it's trivial if you embed it though

      In conversation about 3 days ago permalink

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.