• rumschlumpel@feddit.org
    link
    fedilink
    arrow-up
    14
    ·
    edit-2
    6 days ago

    Hardware acceleration for an interpreted programming language? Can you point me to a specific example or clarify what you mean, because I find that hard to believe.

    • UnfortunateShort@lemmy.world
      link
      fedilink
      English
      arrow-up
      3
      ·
      edit-2
      5 days ago

      Tbf, it’s not really like processors have ‘DO JS STUFF’ instructions, they are not made for one language or data format specifically of course. But ultimately, instructions are shaped by things people use.

      JSON for example requires searching strings for structural characters: ,, {, } etc. Iirc you can use VPSHUFB (‘Packed Shuffle Bytes’ or so, AVX >=2) to map 32 bytes (or 64 on AVX-512 I guess) to any structural character in one instruction. That’s quite the speedup compared to comparing all of them to all special characters one at a time, even considering SIMD kinda moves on its own pace. And it’s exactly the kind of stuff you would use in your JS engine to make parsing JSON crazy fast, even when it’s plain text, which is obviously less than ideal for a computer.

      I remember there was some instruction that was introduced specifically because of something JS does all the time tought. I forgot what it was, maybe someone else can help out.