3 ms·
V8 uses runtime type/value information to specialize methods in some cases[1]. I find it hard to believe that HotSpot doesn’t either. Obviously complex objects
by orf 7y ago
V8 uses runtime type/value information to specialize methods in some cases[1]. I find it hard to believe that HotSpot doesn’t either.
Obviously complex objects are impossible to handle, but branching on an integer that’s always the same value isn’t. Same for constant folding, if an argument is determined to be constant at runtime then that’s going to affect the choices the JIT makes.
1. https://ponyfoo.com/articles/an-introduction-to-speculative-optimization-in-v8 https://ponyfoo.com/articles/an-introduction-to-speculative-...
- saagarjha 7y agoHotSpot will monomorphize polymorphic method calls if it detects that only one type is being used, FWIW.
- kllrnohj 7y agoThat's specializing on type, not on a given specific value. Being JS the value influences the type, but it's only looking at a coarse binning (int vs. double vs. string etc..) not specializing for a single specific value. A form of de-virtualization if you will. Hotspot wouldn't even need to bother with that most of the time since it's primarily running statically typed languages for which that doesn't apply in the first place.