mflatt
2020-7-17 12:00:15

I’m planning an experiment to change the CS bootstrap: add a portable bytecode backend to Chez Scheme, where the bytecode is interpreted and similar to machine code, but using an even simpler encoding to cover the handful of instructions that we need.

If I guess correctly that interpreting bytecode is 5–10 times as slow as machine code, then it will provide a simpler and faster way to build Chez Scheme. We’d have to check bytecode boot files into the ChezScheme repo, and also check in schemified thread, io, regexp, expander, and schemify layers in the racket repo. But then CS would build without building BC, although the old bootstrap path can remain as a fallback (because bootstrapping Chez Scheme with Chez Scheme is painful after certain kinds of changes).

If I guess wrong and bytecode is 100 times as slow, then this idea probably won’t work.


samth
2020-7-17 13:49:13

Why would you need the bytecode versions of the Racket layers? Wouldn’t the schemified s-expressions be sufficient, since you’d go bytecode chez -> regular chez -> racketcs (using the s-exps)?


samth
2020-7-17 13:49:56

I also like this idea because it seems like a good target for compiling to JS/Wasm


mflatt
2020-7-17 14:44:47

Right: no bytecode for the Racket layers, just the schemified form.


samth
2020-7-17 14:45:29

Oh yes, I now see that’s what you wrote.


pocmatos
2020-7-17 16:45:55

Currently Chez compiles the boot files to machine code. So the idea is to have a machine independent bytecode that you checkin to avoid generating the machine files. Then the bytecode interpreter, written in Chez. uses those bytecode boot files to bootstrap itself to machine code bootfiles. Thus avoiding using racket during the bootstrap. Did I make sense?


mflatt
2020-7-17 17:16:29

Yes, that’s right.


mflatt
2020-7-17 17:18:47

Well, a clarification: the bytecode interpreter (as opposed to compiler) will be implemented in C and part of the Chez Scheme kernel, so you can get it running using just a C compiler. I expect it to be very small, though.


pocmatos
2020-7-17 20:40:38

Nice! :slightly_smiling_face: