hotspot/src/share/vm/jvmci/jvmciCodeInstaller.hpp
changeset 42650 1f304d0c888b
parent 41697 94ef14db8a20
child 42861 1d4dfdf4390b
equal deleted inserted replaced
42649:28238583a459 42650:1f304d0c888b
    41   size_t _size;
    41   size_t _size;
    42   char _static_buffer[stack_size];
    42   char _static_buffer[stack_size];
    43   char *_buffer;
    43   char *_buffer;
    44 };
    44 };
    45 
    45 
       
    46 class AOTOopRecorder : public OopRecorder {
       
    47 public:
       
    48   AOTOopRecorder(Arena* arena = NULL, bool deduplicate = false);
       
    49 
       
    50   virtual int find_index(Metadata* h);
       
    51   virtual int find_index(jobject h);
       
    52   int nr_meta_strings() const;
       
    53   const char* meta_element(int pos) const;
       
    54 
       
    55 private:
       
    56   void record_meta_string(const char* name, int index);
       
    57 
       
    58   GrowableArray<const char*>* _meta_strings;
       
    59 };
       
    60 
    46 class CodeMetadata {
    61 class CodeMetadata {
    47 public:
    62 public:
    48   CodeMetadata() {}
    63   CodeMetadata() {}
    49 
    64 
    50   CodeBlob* get_code_blob() const { return _cb; }
    65   CodeBlob* get_code_blob() const { return _cb; }
    54 
    69 
    55   u_char* get_scopes_desc() const { return _scopes_desc; }
    70   u_char* get_scopes_desc() const { return _scopes_desc; }
    56   int get_scopes_size() const { return _nr_scopes_desc; }
    71   int get_scopes_size() const { return _nr_scopes_desc; }
    57 
    72 
    58   RelocBuffer* get_reloc_buffer() { return &_reloc_buffer; }
    73   RelocBuffer* get_reloc_buffer() { return &_reloc_buffer; }
       
    74 
       
    75   AOTOopRecorder* get_oop_recorder() { return _oop_recorder; }
    59 
    76 
    60   ExceptionHandlerTable* get_exception_table() { return _exception_table; }
    77   ExceptionHandlerTable* get_exception_table() { return _exception_table; }
    61 
    78 
    62   void set_pc_desc(PcDesc* desc, int count) {
    79   void set_pc_desc(PcDesc* desc, int count) {
    63     _pc_desc = desc;
    80     _pc_desc = desc;
    67   void set_scopes(u_char* scopes, int size) {
    84   void set_scopes(u_char* scopes, int size) {
    68     _scopes_desc = scopes;
    85     _scopes_desc = scopes;
    69     _nr_scopes_desc = size;
    86     _nr_scopes_desc = size;
    70   }
    87   }
    71 
    88 
       
    89   void set_oop_recorder(AOTOopRecorder* recorder) {
       
    90     _oop_recorder = recorder;
       
    91   }
       
    92 
    72   void set_exception_table(ExceptionHandlerTable* table) {
    93   void set_exception_table(ExceptionHandlerTable* table) {
    73     _exception_table = table;
    94     _exception_table = table;
    74   }
    95   }
    75 
    96 
    76 private:
    97 private:
    80 
   101 
    81   u_char* _scopes_desc;
   102   u_char* _scopes_desc;
    82   int _nr_scopes_desc;
   103   int _nr_scopes_desc;
    83 
   104 
    84   RelocBuffer _reloc_buffer;
   105   RelocBuffer _reloc_buffer;
       
   106   AOTOopRecorder* _oop_recorder;
    85   ExceptionHandlerTable* _exception_table;
   107   ExceptionHandlerTable* _exception_table;
    86 };
   108 };
    87 
   109 
    88 /*
   110 /*
    89  * This class handles the conversion from a InstalledCode to a CodeBlob or an nmethod.
   111  * This class handles the conversion from a InstalledCode to a CodeBlob or an nmethod.
    90  */
   112  */
    91 class CodeInstaller : public StackObj {
   113 class CodeInstaller : public StackObj {
    92   friend class JVMCIVMStructs;
   114   friend class JVMCIVMStructs;
    93 private:
   115 private:
    94   enum MarkId {
   116   enum MarkId {
    95     VERIFIED_ENTRY             = 1,
   117     VERIFIED_ENTRY                         = 1,
    96     UNVERIFIED_ENTRY           = 2,
   118     UNVERIFIED_ENTRY                       = 2,
    97     OSR_ENTRY                  = 3,
   119     OSR_ENTRY                              = 3,
    98     EXCEPTION_HANDLER_ENTRY    = 4,
   120     EXCEPTION_HANDLER_ENTRY                = 4,
    99     DEOPT_HANDLER_ENTRY        = 5,
   121     DEOPT_HANDLER_ENTRY                    = 5,
   100     INVOKEINTERFACE            = 6,
   122     INVOKEINTERFACE                        = 6,
   101     INVOKEVIRTUAL              = 7,
   123     INVOKEVIRTUAL                          = 7,
   102     INVOKESTATIC               = 8,
   124     INVOKESTATIC                           = 8,
   103     INVOKESPECIAL              = 9,
   125     INVOKESPECIAL                          = 9,
   104     INLINE_INVOKE              = 10,
   126     INLINE_INVOKE                          = 10,
   105     POLL_NEAR                  = 11,
   127     POLL_NEAR                              = 11,
   106     POLL_RETURN_NEAR           = 12,
   128     POLL_RETURN_NEAR                       = 12,
   107     POLL_FAR                   = 13,
   129     POLL_FAR                               = 13,
   108     POLL_RETURN_FAR            = 14,
   130     POLL_RETURN_FAR                        = 14,
   109     CARD_TABLE_ADDRESS         = 15,
   131     CARD_TABLE_ADDRESS                     = 15,
   110     CARD_TABLE_SHIFT           = 16,
   132     CARD_TABLE_SHIFT                       = 16,
   111     HEAP_TOP_ADDRESS           = 17,
   133     HEAP_TOP_ADDRESS                       = 17,
   112     HEAP_END_ADDRESS           = 18,
   134     HEAP_END_ADDRESS                       = 18,
   113     NARROW_KLASS_BASE_ADDRESS  = 19,
   135     NARROW_KLASS_BASE_ADDRESS              = 19,
   114     CRC_TABLE_ADDRESS          = 20,
   136     CRC_TABLE_ADDRESS                      = 20,
   115     INVOKE_INVALID             = -1
   137     LOG_OF_HEAP_REGION_GRAIN_BYTES         = 21,
       
   138     INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED = 22,
       
   139     INVOKE_INVALID                         = -1
   116   };
   140   };
   117 
   141 
   118   Arena         _arena;
   142   Arena         _arena;
   119 
   143 
   120   jobject       _data_section_handle;
   144   jobject       _data_section_handle;
   144   OopRecorder*              _oop_recorder;
   168   OopRecorder*              _oop_recorder;
   145   DebugInformationRecorder* _debug_recorder;
   169   DebugInformationRecorder* _debug_recorder;
   146   Dependencies*             _dependencies;
   170   Dependencies*             _dependencies;
   147   ExceptionHandlerTable     _exception_handler_table;
   171   ExceptionHandlerTable     _exception_handler_table;
   148 
   172 
       
   173   bool _immutable_pic_compilation;  // Installer is called for Immutable PIC compilation.
       
   174 
   149   static ConstantOopWriteValue* _oop_null_scope_value;
   175   static ConstantOopWriteValue* _oop_null_scope_value;
   150   static ConstantIntValue*    _int_m1_scope_value;
   176   static ConstantIntValue*    _int_m1_scope_value;
   151   static ConstantIntValue*    _int_0_scope_value;
   177   static ConstantIntValue*    _int_0_scope_value;
   152   static ConstantIntValue*    _int_1_scope_value;
   178   static ConstantIntValue*    _int_1_scope_value;
   153   static ConstantIntValue*    _int_2_scope_value;
   179   static ConstantIntValue*    _int_2_scope_value;
   171 
   197 
   172   oop word_kind() { return (oop) JNIHandles::resolve(_word_kind_handle); }
   198   oop word_kind() { return (oop) JNIHandles::resolve(_word_kind_handle); }
   173 
   199 
   174 public:
   200 public:
   175 
   201 
   176   CodeInstaller() : _arena(mtCompiler) {}
   202   CodeInstaller(bool immutable_pic_compilation) : _arena(mtCompiler), _immutable_pic_compilation(immutable_pic_compilation) {}
   177 
   203 
   178   JVMCIEnv::CodeInstallResult gather_metadata(Handle target, Handle compiled_code, CodeMetadata& metadata, TRAPS);
   204   JVMCIEnv::CodeInstallResult gather_metadata(Handle target, Handle compiled_code, CodeMetadata& metadata, TRAPS);
   179   JVMCIEnv::CodeInstallResult install(JVMCICompiler* compiler, Handle target, Handle compiled_code, CodeBlob*& cb, Handle installed_code, Handle speculation_log, TRAPS);
   205   JVMCIEnv::CodeInstallResult install(JVMCICompiler* compiler, Handle target, Handle compiled_code, CodeBlob*& cb, Handle installed_code, Handle speculation_log, TRAPS);
   180 
   206 
   181   static address runtime_call_target_address(oop runtime_call);
   207   static address runtime_call_target_address(oop runtime_call);