Skip to content

Declaring more locals when using the CODE word #50

Description

@nature-0

Hi remko,

First off, thank you for this very nice piece of software. I've been struggling for weeks to get anything like emscripten/llvm setup on my OpenBSD computer running without any success. I then came accross your project and a simple npm install gave me the possibility to develop with forth on the browser directly and without any issues! Just for that I am grateful!

Background

Anywho, I am currently porting the uxn vm to the web using WAForth and so far I've pretty much succeeded, one issue is that as soon as I run slightly more involved uxn programs performance becomes a big issue, something like the game of life in a 64x64 grid takes more that 2sec to compute. My forth code probably isn't the most optimized, but my idea was to leverage the CODE in order to write the performance critical piece in raw wasm.

Issue

I've had success creating small words that loop and fetch parts of the memory, but now I want to do a slightly more involved word that will require more than 1 local (which seems to be the default with CODE and :), I am not sure how to do that, I checked the WAT code for WAForth and I guess you do something with the $firstTemporaryLocal and $lastLocal globals, modifying those might give me access to more locals, but I have 2 issues with this:

  1. I have no idea what the index of those globals are?
  2. Even if I could modify them, I think I'll only have more i32 locals, what if I want a v128 local?

Note: I am aware the CODE word is highly experimental, I just found myself really needing it for my project, so if I can help out figuring out how to provide a way to write raw wasm with WAForth, it'll be my pleasure!
Note2: If you want to see the kind of performance issue we are talking about: https://demo.blazebone.com Warning: this will use a lot of CPU as it's pretty inefficient

Thanks again for the work you've been putting on WAForth!

Cheers,
n

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions