[plt-scheme] Why is the JIT Written in C?
Hello all,
I have a quick (mostly academic) question for the PLT maintainers: why is the JIT written in C? I think that it takes advantage of GNU Lightning (which is a collection of CPP macros, right?) for generating the actual assembly code. However, based on the length (and complexity) of the jit.c file, it hardly seems like generating your own assembly would add much to the difficulty of the JIT when compared to the other issues dealt with in that file. If PLT Scheme generated its own assembly, wouldn't it be easier (or at least more fun?) to write the JIT entirely in scheme (i.e. reading in bytecode and dumping raw assembly bits out to the bytestring that eventually gets packed---perhaps by a short, comprehensible bit of C code---into a function object)?
Don't take this the wrong way; I'm not complaining *at all* about the wonderful JIT, and I *really* appreciate the obviously large amount of effort that the developers have put into it. (I really appreciate the performance benefits that come out of this effort, of course.) I am mostly asking because I'm curious about the rationale for the choice of C (performance, maybe? lightning, maybe? fear of bootstrapping issues with scheme code, maybe? something else entirely?).
Another reason for asking is that I occasionally think about implementing a (numeric-mode ...) macro that compiles simple numeric loops, vector/f64vector accesses, and floating/integer arithmetic directly with boxing only occurring on entry/exit (kind of like Chicken scheme's crunch, or a MCL/OpenMCL double-float arithmetic package whose name I have forgotten, or OCaml's local unboxing strategy, etc...). I don't think there's any hope of me managing to implement this as long as the JIT is in its current state. (Though it's not terribly likely that I would ever get around to this in any case, so, again, this is not a request to change anything about the JIT.) So, I am curious about the design choices in the construction of the current JIT.
I understand that answers to questions purely to satisfy my curiosity are low-priority compared to getting actual work done; nevertheless, I'd appreciate anything the people on this list could tell me regarding this issue.
Thanks,
Will