< prev index next >

src/hotspot/share/runtime/sharedRuntime.hpp

Print this page
@@ -23,23 +23,26 @@
   */
  
  #ifndef SHARE_RUNTIME_SHAREDRUNTIME_HPP
  #define SHARE_RUNTIME_SHAREDRUNTIME_HPP
  
+ #include "asm/codeBuffer.hpp"
  #include "code/codeBlob.hpp"
  #include "code/vmreg.hpp"
  #include "interpreter/bytecodeTracer.hpp"
  #include "interpreter/linkResolver.hpp"
  #include "memory/allocation.hpp"
  #include "memory/resourceArea.hpp"
+ #include "runtime/signature.hpp"
  #include "utilities/hashtable.hpp"
  #include "utilities/macros.hpp"
  
  class AdapterHandlerEntry;
  class AdapterHandlerTable;
  class AdapterFingerPrint;
  class vframeStream;
+ class SigEntry;
  
  // Runtime is the base class for various runtime interfaces
  // (InterpreterRuntime, CompilerRuntime, etc.). It provides
  // shared functionality such as exception forwarding (C++ to
  // Java exceptions), locking/unlocking mechanisms, statistical

@@ -50,21 +53,20 @@
  
   private:
    static bool resolve_sub_helper_internal(methodHandle callee_method, const frame& caller_frame,
                                            CompiledMethod* caller_nm, bool is_virtual, bool is_optimized,
                                            Handle receiver, CallInfo& call_info, Bytecodes::Code invoke_code, TRAPS);
-   static methodHandle resolve_sub_helper(bool is_virtual, bool is_optimized, TRAPS);
+   static methodHandle resolve_sub_helper(bool is_virtual, bool is_optimized, bool* caller_is_c1, TRAPS);
  
    // Shared stub locations
  
    static RuntimeStub*        _wrong_method_blob;
    static RuntimeStub*        _wrong_method_abstract_blob;
    static RuntimeStub*        _ic_miss_blob;
    static RuntimeStub*        _resolve_opt_virtual_call_blob;
    static RuntimeStub*        _resolve_virtual_call_blob;
    static RuntimeStub*        _resolve_static_call_blob;
-   static address             _resolve_static_call_entry;
  
    static DeoptimizationBlob* _deopt_blob;
  
    static SafepointBlob*      _polling_page_vectors_safepoint_handler_blob;
    static SafepointBlob*      _polling_page_safepoint_handler_blob;

@@ -81,11 +83,10 @@
  
   private:
    enum { POLL_AT_RETURN,  POLL_AT_LOOP, POLL_AT_VECTOR_LOOP };
    static SafepointBlob* generate_handler_blob(address call_ptr, int poll_type);
    static RuntimeStub*   generate_resolve_blob(address destination, const char* name);
- 
   public:
    static void generate_stubs(void);
  
    // max bytes for each dtrace string parameter
    enum { max_dtrace_string_size = 256 };

@@ -312,37 +313,50 @@
    //
    static char* generate_class_cast_message(Klass* caster_klass, Klass* target_klass, Symbol* target_klass_name = NULL);
  
    // Resolves a call site- may patch in the destination of the call into the
    // compiled code.
-   static methodHandle resolve_helper(bool is_virtual, bool is_optimized, TRAPS);
+   static methodHandle resolve_helper(bool is_virtual, bool is_optimized, bool* caller_is_c1, TRAPS);
  
   private:
    // deopt blob
    static void generate_deopt_blob(void);
  
    static bool handle_ic_miss_helper_internal(Handle receiver, CompiledMethod* caller_nm, const frame& caller_frame,
                                               methodHandle callee_method, Bytecodes::Code bc, CallInfo& call_info,
-                                              bool& needs_ic_stub_refill, TRAPS);
+                                              bool& needs_ic_stub_refill, bool& is_optimized, bool caller_is_c1, TRAPS);
  
   public:
    static DeoptimizationBlob* deopt_blob(void)      { return _deopt_blob; }
  
    // Resets a call-site in compiled code so it will get resolved again.
-   static methodHandle reresolve_call_site(TRAPS);
+   static methodHandle reresolve_call_site(bool& is_static_call, bool& is_optimized, bool& caller_is_c1, TRAPS);
  
    // In the code prolog, if the klass comparison fails, the inline cache
    // misses and the call site is patched to megamorphic
-   static methodHandle handle_ic_miss_helper(TRAPS);
+   static methodHandle handle_ic_miss_helper(bool& is_optimized, bool& caller_is_c1, TRAPS);
  
    // Find the method that called us.
    static methodHandle find_callee_method(TRAPS);
  
    static void monitor_enter_helper(oopDesc* obj, BasicLock* lock, JavaThread* thread);
  
    static void monitor_exit_helper(oopDesc* obj, BasicLock* lock, JavaThread* current);
  
+   static address entry_for_handle_wrong_method(methodHandle callee_method, bool is_static_call, bool is_optimized, bool caller_is_c1) {
+     assert(callee_method->verified_code_entry() != NULL, "Jump to zero!");
+     assert(callee_method->verified_inline_code_entry() != NULL, "Jump to zero!");
+     assert(callee_method->verified_inline_ro_code_entry() != NULL, "Jump to zero!");
+     if (caller_is_c1) {
+       return callee_method->verified_inline_code_entry();
+     } else if (is_static_call || is_optimized) {
+       return callee_method->verified_code_entry();
+     } else {
+       return callee_method->verified_inline_ro_code_entry();
+     }
+   }
+ 
   private:
    static Handle find_callee_info(Bytecodes::Code& bc, CallInfo& callinfo, TRAPS);
    static Handle find_callee_info_helper(vframeStream& vfst, Bytecodes::Code& bc, CallInfo& callinfo, TRAPS);
  
    static Method* extract_attached_method(vframeStream& vfst);

@@ -361,10 +375,18 @@
    // based off of the window top.  SharedInfo::stack0 refers to the first usable
    // slot in the bottom of the frame. SharedInfo::stack0+1 refers to the memory word
    // 4-bytes higher.
    // return value is the maximum number of VMReg stack slots the convention will use.
    static int java_calling_convention(const BasicType* sig_bt, VMRegPair* regs, int total_args_passed);
+   static int java_calling_convention(const GrowableArray<SigEntry>* sig, VMRegPair* regs) {
+     BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, sig->length());
+     int total_args_passed = SigEntry::fill_sig_bt(sig, sig_bt);
+     return java_calling_convention(sig_bt, regs, total_args_passed);
+   }
+   static int java_return_convention(const BasicType* sig_bt, VMRegPair* regs, int total_args_passed);
+   static const uint java_return_convention_max_int;
+   static const uint java_return_convention_max_float;
  
    static void check_member_name_argument_is_last_argument(const methodHandle& method,
                                                            const BasicType* sig_bt,
                                                            const VMRegPair* regs) NOT_DEBUG_RETURN;
  

@@ -410,21 +432,25 @@
    // that the interpreter before it does any call dispatch will record the current
    // stack pointer in the interpreter frame. On return it will restore the stack
    // pointer as needed. This means the i2c adapter code doesn't need any special
    // handshaking path with compiled code to keep the stack walking correct.
  
-   static AdapterHandlerEntry* generate_i2c2i_adapters(MacroAssembler *_masm,
-                                                       int total_args_passed,
-                                                       int max_arg,
-                                                       const BasicType *sig_bt,
-                                                       const VMRegPair *regs,
-                                                       AdapterFingerPrint* fingerprint);
+   static AdapterHandlerEntry* generate_i2c2i_adapters(MacroAssembler *masm,
+                                                       int comp_args_on_stack,
+                                                       const GrowableArray<SigEntry>* sig,
+                                                       const VMRegPair* regs,
+                                                       const GrowableArray<SigEntry>* sig_cc,
+                                                       const VMRegPair* regs_cc,
+                                                       const GrowableArray<SigEntry>* sig_cc_ro,
+                                                       const VMRegPair* regs_cc_ro,
+                                                       AdapterFingerPrint* fingerprint,
+                                                       AdapterBlob*& new_adapter,
+                                                       bool allocate_code_blob);
  
    static void gen_i2c_adapter(MacroAssembler *_masm,
-                               int total_args_passed,
                                int comp_args_on_stack,
-                               const BasicType *sig_bt,
+                               const GrowableArray<SigEntry>* sig,
                                const VMRegPair *regs);
  
    // OSR support
  
    // OSR_migration_begin will extract the jvm state from an interpreter

@@ -495,23 +521,29 @@
    // Resolving of calls
    static address resolve_static_call_C     (JavaThread* current);
    static address resolve_virtual_call_C    (JavaThread* current);
    static address resolve_opt_virtual_call_C(JavaThread* current);
  
+   static void load_inline_type_fields_in_regs(JavaThread* current, oopDesc* res);
+   static void store_inline_type_fields_to_buf(JavaThread* current, intptr_t res);
+ 
    // arraycopy, the non-leaf version.  (See StubRoutines for all the leaf calls.)
    static void slow_arraycopy_C(oopDesc* src,  jint src_pos,
                                 oopDesc* dest, jint dest_pos,
                                 jint length, JavaThread* thread);
  
    // handle ic miss with caller being compiled code
    // wrong method handling (inline cache misses, zombie methods)
    static address handle_wrong_method(JavaThread* current);
    static address handle_wrong_method_abstract(JavaThread* current);
    static address handle_wrong_method_ic_miss(JavaThread* current);
+   static void allocate_inline_types(JavaThread* current, Method* callee, bool allocate_receiver);
+   static oop allocate_inline_types_impl(JavaThread* current, methodHandle callee, bool allocate_receiver, TRAPS);
  
    static address handle_unsafe_access(JavaThread* thread, address next_pc);
  
+   static BufferedInlineTypeBlob* generate_buffered_inline_type_adapter(const InlineKlass* vk);
  #ifdef COMPILER2
    static RuntimeStub* make_native_invoker(address call_target,
                                            int shadow_space_bytes,
                                            const GrowableArray<VMReg>& input_registers,
                                            const GrowableArray<VMReg>& output_registers);

@@ -633,26 +665,37 @@
  
   private:
    AdapterFingerPrint* _fingerprint;
    address _i2c_entry;
    address _c2i_entry;
+   address _c2i_inline_entry;
+   address _c2i_inline_ro_entry;
    address _c2i_unverified_entry;
+   address _c2i_unverified_inline_entry;
    address _c2i_no_clinit_check_entry;
  
+   // Support for scalarized inline type calling convention
+   const GrowableArray<SigEntry>* _sig_cc;
+ 
  #ifdef ASSERT
    // Captures code and signature used to generate this adapter when
    // verifying adapter equivalence.
    unsigned char* _saved_code;
    int            _saved_code_length;
  #endif
  
-   void init(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_unverified_entry, address c2i_no_clinit_check_entry) {
+   void init(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_inline_entry,
+             address c2i_inline_ro_entry, address c2i_unverified_entry, address c2i_unverified_inline_entry, address c2i_no_clinit_check_entry) {
      _fingerprint = fingerprint;
      _i2c_entry = i2c_entry;
      _c2i_entry = c2i_entry;
+     _c2i_inline_entry = c2i_inline_entry;
+     _c2i_inline_ro_entry = c2i_inline_ro_entry;
      _c2i_unverified_entry = c2i_unverified_entry;
+     _c2i_unverified_inline_entry = c2i_unverified_inline_entry;
      _c2i_no_clinit_check_entry = c2i_no_clinit_check_entry;
+     _sig_cc = NULL;
  #ifdef ASSERT
      _saved_code_length = 0;
  #endif
    }
  

@@ -660,18 +703,25 @@
  
    // should never be used
    AdapterHandlerEntry();
  
   public:
-   address get_i2c_entry()                  const { return _i2c_entry; }
-   address get_c2i_entry()                  const { return _c2i_entry; }
-   address get_c2i_unverified_entry()       const { return _c2i_unverified_entry; }
-   address get_c2i_no_clinit_check_entry()  const { return _c2i_no_clinit_check_entry; }
+   address get_i2c_entry()                   const { return _i2c_entry; }
+   address get_c2i_entry()                   const { return _c2i_entry; }
+   address get_c2i_inline_entry()            const { return _c2i_inline_entry; }
+   address get_c2i_inline_ro_entry()         const { return _c2i_inline_ro_entry; }
+   address get_c2i_unverified_entry()        const { return _c2i_unverified_entry; }
+   address get_c2i_unverified_inline_entry() const { return _c2i_unverified_inline_entry; }
+   address get_c2i_no_clinit_check_entry()   const { return _c2i_no_clinit_check_entry; }
  
    address base_address();
    void relocate(address new_base);
  
+   // Support for scalarized inline type calling convention
+   void set_sig_cc(const GrowableArray<SigEntry>* sig)  { _sig_cc = sig; }
+   const GrowableArray<SigEntry>* get_sig_cc()    const { return _sig_cc; }
+ 
    AdapterFingerPrint* fingerprint() const { return _fingerprint; }
  
    AdapterHandlerEntry* next() {
      return (AdapterHandlerEntry*)BasicHashtableEntry<mtCode>::next();
    }

@@ -684,10 +734,12 @@
  
    //virtual void print_on(outputStream* st) const;  DO NOT USE
    void print_adapter_on(outputStream* st) const;
  };
  
+ class CompiledEntrySignature;
+ 
  class AdapterHandlerLibrary: public AllStatic {
    friend class SharedRuntime;
   private:
    static BufferBlob* _buffer; // the temporary code buffer in CodeCache
    static AdapterHandlerTable* _adapters;

@@ -699,21 +751,18 @@
    static AdapterHandlerEntry* _obj_obj_arg_handler;
  
    static BufferBlob* buffer_blob();
    static void initialize();
    static AdapterHandlerEntry* create_adapter(AdapterBlob*& new_adapter,
-                                              int total_args_passed,
-                                              BasicType* sig_bt,
+                                              CompiledEntrySignature& ces,
                                               bool allocate_code_blob);
    static AdapterHandlerEntry* get_simple_adapter(const methodHandle& method);
   public:
  
    static AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint,
-                                         address i2c_entry,
-                                         address c2i_entry,
-                                         address c2i_unverified_entry,
-                                         address c2i_no_clinit_check_entry = NULL);
+                                         address i2c_entry, address c2i_entry, address c2i_inline_entry, address c2i_inline_ro_entry,
+                                         address c2i_unverified_entry, address c2i_unverified_inline_entry, address c2i_no_clinit_check_entry = NULL);
    static void create_native_wrapper(const methodHandle& method);
    static AdapterHandlerEntry* get_adapter(const methodHandle& method);
  
    static void print_handler(const CodeBlob* b) { print_handler_on(tty, b); }
    static void print_handler_on(outputStream* st, const CodeBlob* b);

@@ -722,6 +771,65 @@
    static void print_statistics();
  #endif // PRODUCT
  
  };
  
+ // Utility class for computing the calling convention of the 3 types
+ // of compiled method entries:
+ //     Method::_from_compiled_entry               - sig_cc
+ //     Method::_from_compiled_inline_ro_entry     - sig_cc_ro
+ //     Method::_from_compiled_inline_entry        - sig
+ class CompiledEntrySignature : public StackObj {
+   Method* _method;
+   int  _num_inline_args;
+   bool _has_inline_recv;
+   GrowableArray<SigEntry> *_sig;
+   GrowableArray<SigEntry> *_sig_cc;
+   GrowableArray<SigEntry> *_sig_cc_ro;
+   VMRegPair* _regs;
+   VMRegPair* _regs_cc;
+   VMRegPair* _regs_cc_ro;
+ 
+   int _args_on_stack;
+   int _args_on_stack_cc;
+   int _args_on_stack_cc_ro;
+ 
+   bool _c1_needs_stack_repair;
+   bool _c2_needs_stack_repair;
+ 
+ public:
+   Method* method()                     const { return _method; }
+ 
+   // Used by Method::_from_compiled_inline_entry
+   GrowableArray<SigEntry>& sig()       const { return *_sig; }
+ 
+   // Used by Method::_from_compiled_entry
+   GrowableArray<SigEntry>& sig_cc()    const { return *_sig_cc; }
+ 
+   // Used by Method::_from_compiled_inline_ro_entry
+   GrowableArray<SigEntry>& sig_cc_ro() const { return *_sig_cc_ro; }
+ 
+   VMRegPair* regs()                    const { return _regs; }
+   VMRegPair* regs_cc()                 const { return _regs_cc; }
+   VMRegPair* regs_cc_ro()              const { return _regs_cc_ro; }
+ 
+   int args_on_stack()                  const { return _args_on_stack; }
+   int args_on_stack_cc()               const { return _args_on_stack_cc; }
+   int args_on_stack_cc_ro()            const { return _args_on_stack_cc_ro; }
+ 
+   int  num_inline_args()               const { return _num_inline_args; }
+   bool has_inline_arg()                const { return _num_inline_args > 0; }
+   bool has_inline_recv()               const { return _has_inline_recv; }
+ 
+   bool has_scalarized_args()           const { return _sig != _sig_cc; }
+   bool c1_needs_stack_repair()         const { return _c1_needs_stack_repair; }
+   bool c2_needs_stack_repair()         const { return _c2_needs_stack_repair; }
+   CodeOffsets::Entries c1_inline_ro_entry_type() const;
+ 
+   CompiledEntrySignature(Method* method = NULL);
+   void compute_calling_conventions();
+ 
+ private:
+   int compute_scalarized_cc(GrowableArray<SigEntry>*& sig_cc, VMRegPair*& regs_cc, bool scalar_receiver);
+ };
+ 
  #endif // SHARE_RUNTIME_SHAREDRUNTIME_HPP
< prev index next >