5 ms·
Not quite, but close, is the relatively new ARM instruction FJCVTZS which implements the rounding required by JavaScript.
by formerly_proven 2y ago
Not quite, but close, is the relatively new ARM instruction FJCVTZS which implements the rounding required by JavaScript.
- mort96 2y agoFJCVTZS has JavaScript in the name, and is useful for implementing JavaScript yes, but as you say, it's just a float -> int conversion with a particular rounding mode. "Convert float to int, rounding towards zero" is a typical scalar type instruction, very different from the kind of instruction you'd want to optimize parsing. I swear the only reason people pay FJCVTZS any attention at all is that it has "JavaScript" in its name. If it was just a "convert float to int, round towards zero" instruction, everyone would see it as a normal, boring part of the ISA.
- jsheard 2y agoFJCVTZS is really just "float to int with x86 semantics", which also happens to be the semantics that were baked into JavaScript. The name is probably just ARM dancing around mentioning a competing ISA.
- mananaysiempre 2y ago> I swear the only reason people pay FJCVTZS any attention at all is that it has "JavaScript" in its name. You’re not wrong, and yet— > convert float to int, round towards zero ... and take the result modulo 2^32 as two’s complement. That’s still rather specific and likely useless for numeric computing, which is the canonical application area for this kind of thing. So the “JavaScript” in the name is fair, if only to dispel confusion around why one would ever want this. (The normal, saturating conversion is FCVTZS.)