News for hackers. Stuff that matters.
Re:Wasm3 – A high performance WebAssembly interpreter in C by CharlesW on Sunday January 12, 2020 @10:27PM (#22031588)
Why is an interpreter desirable when JIT compilers create significantly faster code? Is this primarily about embedded use?
Re:Wasm3 – A high performance WebAssembly interpreter in C by ridiculous_fish on Monday January 13, 2020 @12:02AM (#22031960)
1. 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!

Re:Wasm3 – A high performance WebAssembly interpreter in C by saagarjha on Monday January 13, 2020 @06:27AM (#22033500)
Plus some platforms allow all of the above, but need something that can run while the JIT warms up.
Re:Wasm3 – A high performance WebAssembly interpreter in C by w0utert on Monday January 13, 2020 @04:08AM (#22032954)
Any 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).
Re:Wasm3 – A high performance WebAssembly interpreter in C by pjmlp on Monday January 13, 2020 @06:27AM (#22033503)
There JIT implementations without interpreter phase, .NET being one of them.
Re:Wasm3 – A high performance WebAssembly interpreter in C by saagarjha on Monday January 13, 2020 @06:34AM (#22033527)
It appears that Mono has added the interpreter back: 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/sr...
Re:Wasm3 – A high performance WebAssembly interpreter in C by pjmlp on Monday January 13, 2020 @06:46AM (#22033599)
From Microsoft side, regular CLR never had one, only the .NET MF variant.
Re:Wasm3 – A high performance WebAssembly interpreter in C by saagarjha on Monday January 13, 2020 @06:50AM (#22033614)
Shows what I know; I just searched for "interpreter" in the repository. I'm curious how C# runs on iOS, though.
Re:Wasm3 – A high performance WebAssembly interpreter in C by pjmlp on Monday January 13, 2020 @07:48AM (#22033944)
AOT compiled to native code.
Re:Wasm3 – A high performance WebAssembly interpreter in C by Matthias247 on Sunday January 12, 2020 @11:56PM (#22031931)
Besides 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.
Re:Wasm3 – A high performance WebAssembly interpreter in C by vijaybritto on Monday January 13, 2020 @01:11AM (#22032222)
From 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.
Re:Wasm3 – A high performance WebAssembly interpreter in C by kbumsik on Monday January 13, 2020 @04:27AM (#22033036)
iOS prohibits JIT for example.
Re:Wasm3 – A high performance WebAssembly interpreter in C by saagarjha on Monday January 13, 2020 @06:16AM (#22033465)
More specifically, apps submitted to the App Store may not utilize JIT.
Re:Wasm3 – A high performance WebAssembly interpreter in C by vips7L on Monday January 13, 2020 @01:57PM (#22037399)
Is there any specific reason for this?
Re:Wasm3 – A high performance WebAssembly interpreter in C by kbumsik on Monday January 13, 2020 @07:35PM (#22040500)
Executing 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.

Re:Wasm3 – A high performance WebAssembly interpreter in C by jdashg on Monday January 13, 2020 @02:06PM (#22037479)
Allegedly security. Apple only trusts Apple.
Re:Wasm3 – A high performance WebAssembly interpreter in C by vshymanskyy on Monday January 13, 2020 @07:04AM (#22033686)
Right. Wasm3 targets iOS as well
Re:Wasm3 – A high performance WebAssembly interpreter in C by Koshkin on Sunday January 12, 2020 @10:34PM (#22031609)
On the embedded side, I'd rather see a hardware interpreter.
Re:Wasm3 – A high performance WebAssembly interpreter in C by leetrout on Sunday January 12, 2020 @10:51PM (#22031663)
I'm hardware ignorant... would that be a system on a chip?
Re:Wasm3 – A high performance WebAssembly interpreter in C by verall on Monday January 13, 2020 @04:47AM (#22033110)
No, 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.

Re:Wasm3 – A high performance WebAssembly interpreter in C by newnewpdro on Sunday January 12, 2020 @11:38PM (#22031879)
I suspect they're just saying they'd rather see a CPU implementing the wasm isa, in a facetious way.
Re:Wasm3 – A high performance WebAssembly interpreter in C by sebcat on Monday January 13, 2020 @02:57AM (#22032664)
AVR32 with JEM does this to some extent for Java.

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
Re:Wasm3 – A high performance WebAssembly interpreter in C by saagarjha on Monday January 13, 2020 @06:17AM (#22033467)
ARM tried to do this with Jazelle, but the effort floundered: https://en.wikipedia.org/wiki/Jazelle
Re:Wasm3 – A high performance WebAssembly interpreter in C by MaxBarraclough on Monday January 13, 2020 @02:47PM (#22037865)
It 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.

Re:Wasm3 – A high performance WebAssembly interpreter in C by naasking on Monday January 13, 2020 @08:25PM (#22040870)
The 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.
Re:Wasm3 – A high performance WebAssembly interpreter in C by MaxBarraclough on Tuesday January 14, 2020 @06:29PM (#22050303)
> 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.