Unsafe vs MemorySegments / Bounds checking...

Jorn Vernee jorn.vernee at oracle.com
Tue Nov 5 15:50:10 UTC 2024


>> I also tested how VarHandle access behaves in deeply nested code and
>> I'm not seeing any evidence that VHs & MHs have extended inlining
>> budgets or any kind of special "inlining bubble/horizon" within which
>> EA is guaranteed to scalar-replace allocations.
>
> I will leave this topic to those more knowledgeable (Vlad, Jorn?)


MethodHandle intrinsics (which are used in the implementation of var 
handles as well) are inlined incrementally [1]. This means that the 
calls are not inlined during parsing, based on a budget of bytecode 
counts, like regular methods. Essentially, C2 will hold off on inlining 
these calls, and then does a sequence of optimize, inline, optimize, 
inline, to try and inline as much as possible, based on a budget of 
total  live nodes in the compilation. This works well for method handles 
(and by extension var handles), because a lot of the code will 
evaporate/be optimized away. While C2 is inlining incrementally, the 
cutoff is temporarily increased as well [2].

Jorn

[1]: 
https://github.com/openjdk/jdk/blob/c799cad1de93aadfe60d9cbccb0499d7299f0598/src/hotspot/share/opto/callGenerator.cpp#L1020
[2]: 
https://github.com/openjdk/jdk/blob/0b733e9a22fd786f3fd133faae3b00d31258e755/src/hotspot/share/opto/compile.hpp#L1109-L1113



More information about the panama-dev mailing list