Guest User

Untitled

a guest
Aug 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. HotSpot C2 on Linux/x64
  2.  
  3. `Compile::call_generator` -(bail out)-> `CallGenerator::for_virtual_call` -> `VirtualCallGenerator` -> `CallDynamicJavaNode`
  4.  
  5. ```
  6. // Call Java Dynamic Instruction
  7. // Note: If this code changes, the corresponding ret_addr_offset() and
  8. // compute_padding() functions will have to be adjusted.
  9. instruct CallDynamicJavaDirect(method meth)
  10. %{
  11. match(CallDynamicJava);
  12. effect(USE meth);
  13.  
  14. ins_cost(300);
  15. format %{ "movq rax, #Universe::non_oop_word()\n\t"
  16. "call,dynamic " %}
  17. opcode(0xE8); /* E8 cd */
  18. ins_encode(Java_Dynamic_Call(meth), call_epilog);
  19. ins_pipe(pipe_slow);
  20. ins_pc_relative(1);
  21. ins_alignment(4);
  22. %}
  23. ```
  24.  
  25. ```c++
  26. //-----------------------------------------------------------------------------
  27. // The CompiledIC represents a compiled inline cache.
  28. //
  29. // In order to make patching of the inline cache MT-safe, we only allow the following
  30. // transitions (when not at a safepoint):
  31. //
  32. //
  33. // [1] --<-- Clean -->--- [1]
  34. // / (null) \
  35. // / \ /-<-\
  36. // / [2] \ / \
  37. // Interpreted ---------> Monomorphic | [3]
  38. // (compiledICHolderOop) (klassOop) |
  39. // \ / \ /
  40. // [4] \ / [4] \->-/
  41. // \->- Megamorphic -<-/
  42. // (methodOop)
  43. //
  44. // The text in paranteses () refere to the value of the inline cache receiver (mov instruction)
  45. //
  46. // The numbers in square brackets refere to the kind of transition:
  47. // [1]: Initial fixup. Receiver it found from debug information
  48. // [2]: Compilation of a method
  49. // [3]: Recompilation of a method (note: only entry is changed. The klassOop must stay the same)
  50. // [4]: Inline cache miss. We go directly to megamorphic call.
  51. //
  52. // The class automatically inserts transition stubs (using the InlineCacheBuffer) when an MT-unsafe
  53. // transition is made to a stub.
  54. ```
  55.  
  56. The fallback of a monomorphic IC is `SharedRuntime::resolve_virtual_call_C`.
  57.  
  58. And there's `SharedRuntime::handle_ic_miss_helper`.
  59.  
  60. 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