3 ms·
If you couldn't transfer data memory to code memory at all, how would it be possible to write an ordinary compiler? If it's possible to run a compiler on the sy
by ______-_-______ 5y ago
If you couldn't transfer data memory to code memory at all, how would it be possible to write an ordinary compiler? If it's possible to run a compiler on the system, just have your JIT do whatever the compiler does.
- gumby 5y agoWell you write a bytecode compiler and run an interpreter for it out of code space. It could be a JIT compiler, just not one that generated native code. This approach was pretty common in the 80s Lisp days IIRC.
- samus 5y agoJava already compiles to bytecode, which executes on the JVM. But this is too slow for most practical applications. JIT compilation to native code is crucial for execution of Java programs with competitive speed. It would be possible to compile everything to machine code ahead of time (pretty much what GraalVM does), but that would compile everything even if it would never end up being executed*. Without JIT compiler, it would not be possible to recompile code to take advantage of tracing information gathered at runtime. Also, newly loaded Java code would not be able to be optimized at all. There are workarounds for all of these. For example, the JIT compiler could generate a new executable with the optimized code and migrate execution state to a new process. But it seems very clunky. *: Not really an issue with microservices and stripped-down binaries. A huge deal for IDEs and environments with plugin architecture though.
- bronson 5y agoWrite it to the filesystem (ELF format presumably) and execute the file. Some Harvard architecture implementations provide ways of shoving data into executable space and back (like special copy instructions) but it's not general purpose. Generally you compile on Von Neumann and flash to Harvard.