Git Product home page Git Product logo

Comments (4)

wingo avatar wingo commented on May 5, 2024

I think the ideal solution goes like this. I think these points correspond to PR-sized chunks.

  1. We add a new AST kind, literal, and we use it for all literals (booleans, numbers, characters, strings, symbols, quoted pairs, etc). We extend the simplifier to be able to know how to get e.g. a raw i32 from a number. Late in the compiler we convert into calls to %make-false, %make-number, and so on.
  2. Instead of converting to %make-number calls, the compiler changes to collects all literals, de-duplicates them, then assigns each one an index. Literals lower instead to table.get calls of the corresponding index. We add a start function to Schism's modules which initializes the table by calling into the runtime to allocate the JS string/number/pair/whatever.
  3. We add support for more sensible string literals. For that we will ideally need a data section, and to give schism a memory again; strings will be created by a run-time callout to (%make-string offset-to-bytes byte-len).

This approach also has the advantage of testing the table.get etc instructions from the anyref work.

from schism.

eholk avatar eholk commented on May 5, 2024

This plan sounds good to me!

As an alternative to table.get, could we use globals instead? Overall, I think tables are a better solution (we'd end up with a ridiculous number of globals!), but perhaps globals make sense for particularly well known values like #f and #t? I'm guessing table.get these days is pretty fast, but I suspect it has a bounds check that globals might not.

I think bringing back the Wasm memory opens up some other interesting possibilities. I've been thinking a little about how we'd want to do bytevectors (#37), and keeping the contents in linear memory might let Schism do some relatively fast processing while staying purely within Wasm. Then we could do a bulk copy out into JS when needed.

from schism.

eholk avatar eholk commented on May 5, 2024

This seems finished now.

from schism.

eholk avatar eholk commented on May 5, 2024

Well, except for the newer string literal format...

from schism.

Related Issues (20)

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.