6 ms·
Why is an interpreter desirable when JIT compilers create significantly faster code? Is this primarily about embedded use?
by CharlesW 7y ago
Why is an interpreter desirable when JIT compilers create significantly faster code? Is this primarily about embedded use?
- Koshkin 7y agoOn the embedded side, I'd rather see a hardware interpreter.
- leetrout 7y agoI'm hardware ignorant... would that be a system on a chip?
- newnewpdro 7y agoI suspect they're just saying they'd rather see a CPU implementing the wasm isa, in a facetious way.
- sebcat 7y agoAVR32 with JEM does this to some extent for Java. http://ww1.microchip.com/downloads/en/devicedoc/doc32000.pdf http://ww1.microchip.com/downloads/en/devicedoc/doc32000.pdf 3. Java Extension Module The AVR32 architecture can optionally support execution of Java bytecodes by including a JavaExtension Module (JEM). This support is included with minimal hardware overhead. EDIT: Not by implementing the ISA verbatim, but still neat though
- saagarjha 7y agoARM tried to do this with Jazelle, but the effort floundered: https://en.wikipedia.org/wiki/Jazelle https://en.wikipedia.org/wiki/Jazelle
- MaxBarraclough 7y agoIt doesn't make much sense to build hardware to run an intermediate language. Java bytecode isn't optimised; almost all optimisation is meant to happen in the JIT. If you build a processor that runs bytecode directly, when does the optimisation occur? Presumably never. Low-horsepower platforms are probably the best place to give it a go, as they may struggle to run a respectable JIT compiler, but as you say, Jazelle didn't catch on.
- naasking 7y agoThe hardware would perform the optimisation using typical means. Instruction lookahead can be used for caching the stack slots to be used in registers, for instance.
- MaxBarraclough 7y ago> The hardware would perform the optimisation using typical means. The HotSpot JIT is an impressive feat of compiler engineering. The advanced optimisations it performs cannot practically be performed in hardware. Modern CPUs are capable of, for instance, loop-detection, but they haven't put optimising compilers out of a job, and never will. Jazelle would add no value on a modern ARM server, for instance. You'd get far better performance out of HotSpot, or some other modern JVM.
- verall 7y agoNo, a "system on a chip" means the chip includes things that are not typically part of the CPU but were always parts of computer systems: busses, I/O, sometimes memory, auxillary HW functions like audio, image/video processing or codecs. Nowadays CPU's often have a bunch of these things anyways and you'll hear that all CPU's sort of resemble SoCs. They also tend to have auxillary, lower-power processors that manage power and other things for the main processor.
- Matthias247 7y agoBesides that it can help with startup time. If the script that needs to be executed is a one-off thing the removal of compilation time might be save more time than a JIT could save during execution.
- ridiculous_fish 7y ago1. Some platforms do not have wasm JITs available, because nobody has written one. 2. Some platforms prohibit creating new executable pages, which prevents JITing. 3. Memory savings!
- saagarjha 7y agoPlus some platforms allow all of the above, but need something that can run while the JIT warms up.
- vijaybritto 7y agoFrom what I know, its because JIT uses a lot more memory than an interpreter. Also in LUAJIT it uses very little memory and thats why people have their minds blown all the time.
- w0utert 7y agoAny JIT needs an interpreter to run code sections that are not compiled (yet), and large sections (I don't have any statistics, but I would guess a very sizable majority) of the code is 'cold' and will never get compiled at all. Compiling bytecode to machine code is a relatively expensive operation in itself so it only makes sense to do it for 'hot' sections (loops, functions that get called many times, etc).
- pjmlp 7y agoThere JIT implementations without interpreter phase, .NET being one of them.
- saagarjha 7y agoIt appears that Mono has added the interpreter back: https://www.mono-project.com/news/2017/11/13/mono-interpreter/ https://www.mono-project.com/news/2017/11/13/mono-interprete.... I think the CLR has one too, but I haven't looked into it much: https://github.com/dotnet/runtime/blob/master/src/coreclr/src/vm/interpreter.cpp https://github.com/dotnet/runtime/blob/master/src/coreclr/sr...
- kbumsik 7y agoiOS prohibits JIT for example.
- saagarjha 7y agoMore specifically, apps submitted to the App Store may not utilize JIT.
- vips7L 7y agoIs there any specific reason for this?
- jdashg 7y agoAllegedly security. Apple only trusts Apple.
- kbumsik 7y agoExecuting instructions dynamically from memory (JIT does this) exposes potential security issues. A good example is the famous Specter vulnerability. Specter itself is not JIT-specific but it is known to very hard to reproduce that the only current viable target environment is JIT. So JavaScript was affected by Specter.
- vshymanskyy 7y agoRight. Wasm3 targets iOS as well