Comment by soegaard
13 hours ago
Hi All,
It's still early days for the WebRacket project.
Racket is a huge language, so be patient wrt features.
To keep motivation high I decided to implement a subset that can be used to built practical applications - and then extend the supported features from there. Hopefully, this strategy will also lead to some early adopters that can help me prioritize which features to add.
Some features are simply "more of the same". In this category falls more types of hash tables. Supporting bignums are also a matter of just doing it.
Other features require more work. I have already done some work on implementing modules in terms of linklets. When linklets/modules work, we can reuse the existing implementation of regular expressions.
Adding continuation marks and delimited continuations require adding a CPS-pass. This is certainly doable. Postponing it has been great though. Having a direct style compiler means the generated code follows the structure in the input source code. And that makes debugging easier. Now that bugs have become rarer, it makes sense to look at CPS.
Enjoy.
/Jens Axel
> Adding continuation marks and delimited continuations require adding a CPS-pass.
Have you considered targeting the stack switching proposal?
Another idea, wasm_of_ocaml [1] compiles effects using either a CPS transform or the JS Promise integration proposal for Wasm [2].
[1]: https://github.com/ocsigen/js_of_ocaml/blob/1b1fcf7b06c12324... [2]: https://github.com/WebAssembly/js-promise-integration/blob/7...
Maybe. My main problem is to get light-weight support for continuation marks.
If I need a CPS-pass for continuation marks, I might as well use it for continuations as well.
It would be great if it were possible to avoid a CPS-pass though.
With stack-switching you won't (shouldn't?) need a CPS pass.
1 reply →
Are there any architectural similarities or crossover with Hoot (Guile Scheme -> Wasm) or are you taking a completely different approach?
I am using a similar representation of immediates as Hoot and wasm_of_ocaml.
The representation is explained here:
https://github.com/soegaard/webracket/blob/main/compiler.rkt...
Internally the compiler uses a series of passes implemented using Nanopass.
The code generator is inspired by "Destination-driven Code Generation" by Dybvig, Hieb and Butler. There are some differences however. The code generator in the paper generates "flat" code (assembler) whereas I generate nested Web Assembly instructions.
This approach generates reasonable code without having to implement a register allocator. Also, I believe I saw a Wasm to Wasm compiler that improved register allocation (maybe it was a switch for wasm-tools?).
If (when?) WebRacket becomes a success, we can always switch out individual passes.