Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HotSpot C2 on Linux/x64
- `Compile::call_generator` -(bail out)-> `CallGenerator::for_virtual_call` -> `VirtualCallGenerator` -> `CallDynamicJavaNode`
- ```
- // Call Java Dynamic Instruction
- // Note: If this code changes, the corresponding ret_addr_offset() and
- // compute_padding() functions will have to be adjusted.
- instruct CallDynamicJavaDirect(method meth)
- %{
- match(CallDynamicJava);
- effect(USE meth);
- ins_cost(300);
- format %{ "movq rax, #Universe::non_oop_word()\n\t"
- "call,dynamic " %}
- opcode(0xE8); /* E8 cd */
- ins_encode(Java_Dynamic_Call(meth), call_epilog);
- ins_pipe(pipe_slow);
- ins_pc_relative(1);
- ins_alignment(4);
- %}
- ```
- ```c++
- //-----------------------------------------------------------------------------
- // The CompiledIC represents a compiled inline cache.
- //
- // In order to make patching of the inline cache MT-safe, we only allow the following
- // transitions (when not at a safepoint):
- //
- //
- // [1] --<-- Clean -->--- [1]
- // / (null) \
- // / \ /-<-\
- // / [2] \ / \
- // Interpreted ---------> Monomorphic | [3]
- // (compiledICHolderOop) (klassOop) |
- // \ / \ /
- // [4] \ / [4] \->-/
- // \->- Megamorphic -<-/
- // (methodOop)
- //
- // The text in paranteses () refere to the value of the inline cache receiver (mov instruction)
- //
- // The numbers in square brackets refere to the kind of transition:
- // [1]: Initial fixup. Receiver it found from debug information
- // [2]: Compilation of a method
- // [3]: Recompilation of a method (note: only entry is changed. The klassOop must stay the same)
- // [4]: Inline cache miss. We go directly to megamorphic call.
- //
- // The class automatically inserts transition stubs (using the InlineCacheBuffer) when an MT-unsafe
- // transition is made to a stub.
- ```
- The fallback of a monomorphic IC is `SharedRuntime::resolve_virtual_call_C`.
- And there's `SharedRuntime::handle_ic_miss_helper`.
- In a true polymorphic call site, this kind of strategy may perform worse than just a plain v-table virtual call. The example in this gist shows that it `+UseFastAccessorMethods` may still be faster than going through the compiled VEP
Add Comment
Please, Sign In to add comment