Code Monkey home page Code Monkey logo

web49's People

Contributors

0xflotus avatar qgcarver avatar shawsumma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

web49's Issues

setjmp support

There is a lot code require setjmp to build into wasm, emcc support it by build into javascript backend. (and all mainstream browser support setjmp and exception). https://webassembly.org/roadmap/

I can see FastVM use goto every where, maybe microwasm can add setjmp/longjmp support base on goto ?

a lot library don't use exception but require setjmp, add setjmp will allow a lot wasm only run in browser/nodejs work for web49.

unknown opcodes print as decimal

memory.copy seems not to be implemented in the binary parser.
however the error message is:

unknown opcode sequence: 0xFC 0x10

which should be 0xFC 0x0A.
It looks like it's printed decimal in table.c (web49_bytes_to_opcode):

unknown opcode sequence: 0xFC 0x%" PRIu8

same for the other sequences.

How to use raywasm?

So, I downloaded the mac asset from last successful action workflow, and compiled this:

#include "raylib.h"

int main(void) {
  const int screenWidth = 800;
  const int screenHeight = 450;

  InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture loading and drawing");
  Texture2D texture = LoadTexture("raylib_logo.png");

  while (!WindowShouldClose()) {
    BeginDrawing();
    ClearBackground(RAYWHITE);
    DrawTexture(texture, screenWidth / 2 - texture.width / 2, screenHeight / 2 - texture.height / 2, WHITE);
    DrawText("this IS a texture!", 360, 370, 10, GRAY);
    EndDrawing();
  }

  UnloadTexture(texture);
  CloseWindow();
  return 0;
}

with ./emraylib textures_logo_raylib.c -o textures_logo_raylib then ran ./raywasm textures_logo_raylib.wasm, and it opens and closes, without error. Do I need to structure my code differently?

libsodium tests/benchmarks are segfaulting/producing wrong results

Hi!

I'd like to add web49 to the lists of runtimes libsodium can support for testing wasm32-wasi.

web49 currently doesn't implement wasi_random_get, which I added a simple implementation for.
But in benchmark mode, it's not even required by most tests.

However, many tests, when run under web49, either cause the interpreter to segfault, or return incorrect values.

For example scalarmult.wasm segfaults, and xchacha20.wasm trips on many assertions due to incorrect computations.

The benchmark files used for the most recent round of the libsodium benchmark can be downloaded here.

These benchmarks, or the test files that are faster to execute and still trigger the issues with web49, can be created simply by running the zig build -Drelease-fast -Dtarget=wasm32-wasi command in the root directory of the libsodium source code.

'isnanf' is invalid in C99

on mac 13.0.1 intel, if I run make or make CC=gcc

I get this error:

main/miniwasm.c:127:73: error: implicit declaration of function 'isnanf' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                                        if (data[n].f32 == expected || (isnanf(expected) && isnanf(data[n].f32))) {
                                                                        ^
1 error generated.

Does WASI stdio work?

I am using this to route WASI calls to web49_api_wasi

web49_env_func_t web49_main_import_func(void* state, const char* mod, const char* func) {
  printf("called: %s.%s\n", mod, func);

  if (strcmp(mod, "null0") == 0) {
    return web49_api_null0(state, mod, func);
  } else if (strcmp(mod, "wasi_snapshot_preview1") == 0) {
    return web49_api_wasi(state, mod, func);
  }
  fprintf(stderr, "Unhandled import: %s.%s\n", mod, func);
  return NULL;
}

and for a printf from the wasm, it seems to just output huge chunks of memory. Do I need to put more in state?

address.wast hits error

I'm on macOS Ventura; I did the following:

  1. Cloned the source
  2. Built ("make all")
  3. Tried to run "./bin/wat2wasm test/core/address.wast"

The output I get is this:

$$$ ./bin/wat2wasm test/core/address.wast
unexpected word: `` byte=256

wasm export arguments

How do I provide an argument to a function? I looked around in code, and didn't really see anything.

For example, I want to expose malloc from my wasm, it has 1 arg (size):

// How to insert an arg here?
web49_interp_data_t* data = web49_interp_block_run(interp, &interp->funcs[mallocID]);
uint32_t wptr = data->i32_u;

Related sidenote: is there a better way to allocate a buffer in wasm-memory?

Help with passing string to imported function

I have a function that takes a string param, like this:

uint32_t font_measure(uint32_t fontID, char* text);

That I am trying to expose, like this:

static web49_interp_data_t wasi_import_font_measure(void* wasi_untyped, web49_interp_t interp) {
  uint32_t fontID = interp.locals[0].i32_u;
  uint32_t textPtr = interp.locals[1].i32_u;
  char text[512];
  memcpy(text, WEB49_INTERP_ADDR(void *, interp, textPtr, 512), 512);
  return (web49_interp_data_t){.i32_u = font_measure(fontID, text)};
}

This works, but seems like the wrong way to me (using max-length of 512 to pull the whole thing.) Is this the right way to pull the string? Is there a better way to get the string-length up-front? Should I rewrite all functions that take string params to include length param, too?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.