Closed Blaisorblade closed 9 years ago
90.19%
Merging #220 into wip will change coverage by 0% by
dd91fbe
Powered by Codecov
Thanks @Blaisorblade! It makes a lot of sense to update the conversions, as we want the fastest version possible. I will update the remaining ones in a later commit.
Still, the default miniboxing transformation now uses three classes per type parameter:
Object
, similar to the erased versionUnit
, Boolean
... Long
) using long integers as storage Float
and Double
) using double-precision fp numbers as storageThis way we avoid jumping from integral to floating-point and back, which is costly (Rex benchmarked this and it's 4 times slower than a conversion from int to long or from float to double). Also, it seems to be handled differently by the JVM, causing some loop unswitching optimizations not to kick in.
Thanks @VladUreche! I was indeed looking at your miniboxing for guidance on casting on the JVM ;-), so good to know!
Well, you have to thank @ichoran for that benchmark!
Warning: don't merge yet.
Double.doubleToLongBits and Float.floatToIntBits are documented to not be fully invertible, because they take extra effort to collapse different NaN values together. Hence, it appears miniboxing could conceivably interfere with (admittedly strange) code that distinguishes different NaNs (say, code also casting across Long and Double, like in some JavaScript engines). Using the
Raw
variants prevents the issue (and has no overhead at all).This is untested, done from the browser, and I'm guessing that the goal of this code is to "box" primitives as Long to pass them to the specialized-for-all-primitives version of the interface.
There are more uses of these primitives to review and probably fix. https://github.com/miniboxing/miniboxing-plugin/search?q=doubleToLongBits&type=Code&utf8=%E2%9C%93