Comment by orangeboats

22 days ago

My point was that while you can implement any performant program (be it V8 or Spidermonkey, Blink or Servo) in any language, the effort required to reach a certain performance level differs between the languages.

>v8 is fast because it emits assembly

It emits machine code afaik. And secondly, do you _really_ want to implement the intermediate layers of a JIT in assembly?

I take your point that code organization in assembly is hard, and not worth the performance gains over higher level languages. It’s true, we don’t write much complex software completely in assembly.

However the point I was trying to make is still relevant I think, which is that machine instruction abstraction layer (whether it is serialized as binary machine code or as assembly text) remains a critical piece of what makes high performance software fast even today.

There is a recurring myth I see on HN that suggests abstraction layers are progressive, as though humanity had evolved past the assembly/machine instructions abstraction layer to C to higher level languages leaving lower abstraction layers behind completely. That is simply untrue, and a project like V8 is actually a great example of this, since it not only will have hand tuned assembly routines, but also needs to ship a bespoke compiler which will emit machine instructions.

So even though it’s true we don’t organize our software with assembly language, it remains a key to performance. It could be a custom JIT compiler, hand tuned SIMD code (eg to handle string parsing), or even just checking what the compiler emitted (eg in compiler explorer). Machine instructions remain key to high performance.

  • You don't seem to know where the machine code are generated from. A big part of a compiler is optimizing intermediate representations of the source code.

    I am not going to waste my time with you.

    • I’m not sure what you hope to prove by bringing up ir. I am quite familiar with it, but I don’t see how it’s relevant. Chrome v8 will have inline assembly routines for specific architectures for various fast paths as is pretty much standard in most high performance code. Compilers are not as good as hand tuned assembly especially when SIMD is involved. Just as a basic example strlen or memcpy in a libc implementation work this way on most targets.

      As for ir in the Jit compiler, that is an implementation detail as far as I’m concerned, because the V8 guys had to write the bit that goes from IR to target machine instructions. My point there is that compiler authors need to understand assembly, which is just as true with IR as not. IR is just more convenient for implementing optimizer passes that may be common across architectures (ie where the abstractions hold)