samth
2018-5-16 18:00:38

@mflatt right now, @cadr and I are thinking about how to support bytecode or something like it in Pycket. I see a few options 1. Write a bunch of RPython code to implement bytecode reading and writing (this doesn’t seem to be part of the current read implementation in the expander linklet 2. Port the relevant C code to Racket code, and integrate that into the expander linklet (or a separate linklet) 3. Implement something like the compiled-load handler from expander/run inside Pycket 4. Do something like whatever the Racket-on-Chez code does, which I don’t fully understand Our preference is to do something that’s most likely to be usable long-term, which sort of depends on your thoughts on bytecode going forward. Is that something you want to move to Racket code? Do you have other thoughts on the options here?


mflatt
2018-5-16 18:14:43

I think you want to do something like Racket-on-Chez, which doesn’t try to deal with the old bytecode format (so it initializes current-compiled-file-paths differently). Is there some reason that fasled linklet S-expressions isn’t the right format?


samth
2018-5-16 19:38:37

@mflatt that sounds reasonable, and linklet s-expressions seem fine, but I don’t know where to find the relevant Racket-on-Chez code. In particular, current-compiled-file-paths doesn’t appear in the “racket/src/cs” code.


mflatt
2018-5-16 19:39:42

Should have been use-compiled-file-paths


samth
2018-5-16 19:50:37

Ok, I see that now. But I’m still confused. Does the expander automatically manage the files in “compiled/cs/” when that is the value of (use-compiled-file-paths)? Where is the decision about caching and serialization of compiled code made? In expander/run.rkt, that’s in the current-load parameter, but the CS code seems not to set current-load (or current-load/use-compiled).


mflatt
2018-5-16 20:10:37

The linklet-implementation layer determines how #~ is parsed by supplying read-compiled-linklet. So, for example, “linklet.sls” is where Racket-on-Chez knows about reading Chez machine code (usually wrapped in an interpreter layer) or JIT-compiled S-expressions, depending on the Racket-on-Chez mode. The expander/reader/module layer calls read-compiled-linklet when it sees #~. And it looks in places specified by use-compiled-file-paths, which are normally the places that have #~.


mflatt
2018-5-16 20:11:35

raco make and raco setup similarly decide where to put “bytecode” based on use-compiled-file-paths.


samth
2018-5-16 20:50:31

Ok. The one other piece that I see is that serialization is handled by calling write on a linklet-bundle or a linklet-directory


samth
2018-5-16 20:59:42

@cadr so what we need to do is implement most of what’s in linklet.sls


cadr
2018-5-16 21:00:18

@samth agreed


samth
2018-5-16 21:01:33

lots of it is already implemented in pycket, but we just need to implement serialization and deserialization as part of write/read-compiled-linklet


samth
2018-5-16 21:02:28

One other thing to note is that we could re-use racket/fasl by extracting it to a linklet (that requires playing a little with ++knot arguments and removing keywords from the exports)