< prev index next >

src/hotspot/share/code/codeBlob.hpp

Print this page




  91 protected:
  92 
  93   const CompilerType _type;                      // CompilerType
  94   int        _size;                              // total size of CodeBlob in bytes
  95   int        _header_size;                       // size of header (depends on subclass)
  96   int        _frame_complete_offset;             // instruction offsets in [0.._frame_complete_offset) have
  97                                                  // not finished setting up their frame. Beware of pc's in
  98                                                  // that range. There is a similar range(s) on returns
  99                                                  // which we don't detect.
 100   int        _data_offset;                       // offset to where data region begins
 101   int        _frame_size;                        // size of stack frame
 102 
 103   address    _code_begin;
 104   address    _code_end;
 105   address    _content_begin;                     // address to where content region begins (this includes consts, insts, stubs)
 106                                                  // address    _content_end - not required, for all CodeBlobs _code_end == _content_end for now
 107   address    _data_end;
 108   address    _relocation_begin;
 109   address    _relocation_end;
 110 


 111   ImmutableOopMapSet* _oop_maps;                 // OopMap for this CodeBlob
 112   bool                _caller_must_gc_arguments;
 113   CodeStrings         _strings;
 114   const char*         _name;
 115   S390_ONLY(int       _ctable_offset;)
 116 
 117   CodeBlob(const char* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments);
 118   CodeBlob(const char* name, CompilerType type, const CodeBlobLayout& layout, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments);
 119 
 120 public:
 121   // Only used by unit test.
 122   CodeBlob()
 123     : _type(compiler_none) {}
 124 
 125   // Returns the space needed for CodeBlob
 126   static unsigned int allocation_size(CodeBuffer* cb, int header_size);
 127   static unsigned int align_code_offset(int offset);
 128 
 129   // Deletion
 130   virtual void flush();
 131 
 132   // Typing
 133   virtual bool is_buffer_blob() const                 { return false; }
 134   virtual bool is_nmethod() const                     { return false; }
 135   virtual bool is_runtime_stub() const                { return false; }
 136   virtual bool is_deoptimization_stub() const         { return false; }
 137   virtual bool is_uncommon_trap_stub() const          { return false; }
 138   virtual bool is_exception_stub() const              { return false; }
 139   virtual bool is_safepoint_stub() const              { return false; }
 140   virtual bool is_adapter_blob() const                { return false; }
 141   virtual bool is_vtable_blob() const                 { return false; }
 142   virtual bool is_method_handles_adapter_blob() const { return false; }
 143   virtual bool is_aot() const                         { return false; }
 144   virtual bool is_compiled() const                    { return false; }

 145 
 146   inline bool is_compiled_by_c1() const    { return _type == compiler_c1; };
 147   inline bool is_compiled_by_c2() const    { return _type == compiler_c2; };
 148   inline bool is_compiled_by_jvmci() const { return _type == compiler_jvmci; };
 149   const char* compiler_name() const;
 150 
 151   // Casting
 152   nmethod* as_nmethod_or_null()                { return is_nmethod() ? (nmethod*) this : NULL; }
 153   nmethod* as_nmethod()                        { assert(is_nmethod(), "must be nmethod"); return (nmethod*) this; }
 154   CompiledMethod* as_compiled_method_or_null() { return is_compiled() ? (CompiledMethod*) this : NULL; }
 155   CompiledMethod* as_compiled_method()         { assert(is_compiled(), "must be compiled"); return (CompiledMethod*) this; }
 156   CodeBlob* as_codeblob_or_null() const        { return (CodeBlob*) this; }
 157 
 158   // Boundaries
 159   address header_begin() const        { return (address) this; }
 160   relocInfo* relocation_begin() const { return (relocInfo*) _relocation_begin; };
 161   relocInfo* relocation_end() const   { return (relocInfo*) _relocation_end; }
 162   address content_begin() const       { return _content_begin; }
 163   address content_end() const         { return _code_end; } // _code_end == _content_end is true for all types of blobs for now, it is also checked in the constructor
 164   address code_begin() const          { return _code_begin;    }


 191   bool contains(address addr) const              { return content_begin()      <= addr && addr < content_end();    }
 192   bool is_frame_complete_at(address addr) const  { return _frame_complete_offset != CodeOffsets::frame_never_safe &&
 193                                                           code_contains(addr) && addr >= code_begin() + _frame_complete_offset; }
 194   int frame_complete_offset() const              { return _frame_complete_offset; }
 195 
 196   // CodeCache support: really only used by the nmethods, but in order to get
 197   // asserts and certain bookkeeping to work in the CodeCache they are defined
 198   // virtual here.
 199   virtual bool is_zombie() const                 { return false; }
 200   virtual bool is_locked_by_vm() const           { return false; }
 201 
 202   virtual bool is_unloaded() const               { return false; }
 203   virtual bool is_not_entrant() const            { return false; }
 204 
 205   // GC support
 206   virtual bool is_alive() const                  = 0;
 207 
 208   // OopMap for frame
 209   ImmutableOopMapSet* oop_maps() const           { return _oop_maps; }
 210   void set_oop_maps(OopMapSet* p);
 211   const ImmutableOopMap* oop_map_for_return_address(address return_address);







 212   virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) = 0;
 213 
 214   // Frame support. Sizes are in word units.
 215   int  frame_size() const                        { return _frame_size; }
 216   void set_frame_size(int size)                  { _frame_size = size; }
 217 
 218   // Returns true, if the next frame is responsible for GC'ing oops passed as arguments
 219   bool caller_must_gc_arguments(JavaThread* thread) const { return _caller_must_gc_arguments; }
 220 
 221   // Naming
 222   const char* name() const                       { return _name; }
 223   void set_name(const char* name)                { _name = name; }
 224 
 225   // Debugging
 226   virtual void verify() = 0;
 227   virtual void print() const;
 228   virtual void print_on(outputStream* st) const;
 229   virtual void print_value_on(outputStream* st) const;
 230   void dump_for_addr(address addr, outputStream* st, bool verbose) const;
 231   void print_code();


 236   }
 237   // Print the comment associated with offset on stream, if there is one
 238   virtual void print_block_comment(outputStream* stream, address block_begin) const {
 239     intptr_t offset = (intptr_t)(block_begin - code_begin());
 240     _strings.print_block_comment(stream, offset);
 241   }
 242 
 243   // Transfer ownership of comments to this CodeBlob
 244   void set_strings(CodeStrings& strings) {
 245     assert(!is_aot(), "invalid on aot");
 246     _strings.assign(strings);
 247   }
 248 
 249   static ByteSize name_field_offset() {
 250     return byte_offset_of(CodeBlob, _name);
 251   }
 252 
 253   static ByteSize oop_maps_field_offset() {
 254     return byte_offset_of(CodeBlob, _oop_maps);
 255   }





 256 };
 257 
 258 class CodeBlobLayout : public StackObj {
 259 private:
 260   int _size;
 261   int _header_size;
 262   int _relocation_size;
 263   int _content_offset;
 264   int _code_offset;
 265   int _data_offset;
 266   address _code_begin;
 267   address _code_end;
 268   address _content_begin;
 269   address _content_end;
 270   address _data_end;
 271   address _relocation_begin;
 272   address _relocation_end;
 273 
 274 public:
 275   CodeBlobLayout(address code_begin, address code_end, address content_begin, address content_end, address data_end, address relocation_begin, address relocation_end) :




  91 protected:
  92 
  93   const CompilerType _type;                      // CompilerType
  94   int        _size;                              // total size of CodeBlob in bytes
  95   int        _header_size;                       // size of header (depends on subclass)
  96   int        _frame_complete_offset;             // instruction offsets in [0.._frame_complete_offset) have
  97                                                  // not finished setting up their frame. Beware of pc's in
  98                                                  // that range. There is a similar range(s) on returns
  99                                                  // which we don't detect.
 100   int        _data_offset;                       // offset to where data region begins
 101   int        _frame_size;                        // size of stack frame
 102 
 103   address    _code_begin;
 104   address    _code_end;
 105   address    _content_begin;                     // address to where content region begins (this includes consts, insts, stubs)
 106                                                  // address    _content_end - not required, for all CodeBlobs _code_end == _content_end for now
 107   address    _data_end;
 108   address    _relocation_begin;
 109   address    _relocation_end;
 110 
 111   bool       _is_compiled;
 112 
 113   ImmutableOopMapSet* _oop_maps;                 // OopMap for this CodeBlob
 114   bool                _caller_must_gc_arguments;
 115   CodeStrings         _strings;
 116   const char*         _name;
 117   S390_ONLY(int       _ctable_offset;)
 118 
 119   CodeBlob(const char* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments, bool compiled = false);
 120   CodeBlob(const char* name, CompilerType type, const CodeBlobLayout& layout, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments, bool compiled = false);

 121 public:
 122   // Only used by unit test.
 123   CodeBlob()
 124     : _type(compiler_none) {}
 125 
 126   // Returns the space needed for CodeBlob
 127   static unsigned int allocation_size(CodeBuffer* cb, int header_size);
 128   static unsigned int align_code_offset(int offset);
 129 
 130   // Deletion
 131   virtual void flush();
 132 
 133   // Typing
 134   virtual bool is_buffer_blob() const                 { return false; }
 135   virtual bool is_nmethod() const                     { return false; }
 136   virtual bool is_runtime_stub() const                { return false; }
 137   virtual bool is_deoptimization_stub() const         { return false; }
 138   virtual bool is_uncommon_trap_stub() const          { return false; }
 139   virtual bool is_exception_stub() const              { return false; }
 140   virtual bool is_safepoint_stub() const              { return false; }
 141   virtual bool is_adapter_blob() const                { return false; }
 142   virtual bool is_vtable_blob() const                 { return false; }
 143   virtual bool is_method_handles_adapter_blob() const { return false; }
 144   virtual bool is_aot() const                         { return false; }
 145   bool is_compiled() const                            { return _is_compiled; }
 146   const bool* is_compiled_addr() const                      { return &_is_compiled; }
 147 
 148   inline bool is_compiled_by_c1() const    { return _type == compiler_c1; };
 149   inline bool is_compiled_by_c2() const    { return _type == compiler_c2; };
 150   inline bool is_compiled_by_jvmci() const { return _type == compiler_jvmci; };
 151   const char* compiler_name() const;
 152 
 153   // Casting
 154   nmethod* as_nmethod_or_null()                { return is_nmethod() ? (nmethod*) this : NULL; }
 155   nmethod* as_nmethod()                        { assert(is_nmethod(), "must be nmethod"); return (nmethod*) this; }
 156   CompiledMethod* as_compiled_method_or_null() { return is_compiled() ? (CompiledMethod*) this : NULL; }
 157   CompiledMethod* as_compiled_method()         { assert(is_compiled(), "must be compiled"); return (CompiledMethod*) this; }
 158   CodeBlob* as_codeblob_or_null() const        { return (CodeBlob*) this; }
 159 
 160   // Boundaries
 161   address header_begin() const        { return (address) this; }
 162   relocInfo* relocation_begin() const { return (relocInfo*) _relocation_begin; };
 163   relocInfo* relocation_end() const   { return (relocInfo*) _relocation_end; }
 164   address content_begin() const       { return _content_begin; }
 165   address content_end() const         { return _code_end; } // _code_end == _content_end is true for all types of blobs for now, it is also checked in the constructor
 166   address code_begin() const          { return _code_begin;    }


 193   bool contains(address addr) const              { return content_begin()      <= addr && addr < content_end();    }
 194   bool is_frame_complete_at(address addr) const  { return _frame_complete_offset != CodeOffsets::frame_never_safe &&
 195                                                           code_contains(addr) && addr >= code_begin() + _frame_complete_offset; }
 196   int frame_complete_offset() const              { return _frame_complete_offset; }
 197 
 198   // CodeCache support: really only used by the nmethods, but in order to get
 199   // asserts and certain bookkeeping to work in the CodeCache they are defined
 200   // virtual here.
 201   virtual bool is_zombie() const                 { return false; }
 202   virtual bool is_locked_by_vm() const           { return false; }
 203 
 204   virtual bool is_unloaded() const               { return false; }
 205   virtual bool is_not_entrant() const            { return false; }
 206 
 207   // GC support
 208   virtual bool is_alive() const                  = 0;
 209 
 210   // OopMap for frame
 211   ImmutableOopMapSet* oop_maps() const           { return _oop_maps; }
 212   void set_oop_maps(OopMapSet* p);
 213 
 214   const ImmutableOopMap* oop_map_for_slot(int slot, address return_address) const {
 215     assert(_oop_maps != NULL, "nope");
 216     return _oop_maps->find_map_at_slot(slot, (intptr_t) return_address - (intptr_t) code_begin());
 217   }
 218 
 219   //const ImmutableOopMap* oop_map_for_slot(int slot, address return_address) const;
 220   const ImmutableOopMap* oop_map_for_return_address(address return_address) const;
 221   virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) = 0;
 222 
 223   // Frame support. Sizes are in word units.
 224   int  frame_size() const                        { return _frame_size; }
 225   void set_frame_size(int size)                  { _frame_size = size; }
 226 
 227   // Returns true, if the next frame is responsible for GC'ing oops passed as arguments
 228   bool caller_must_gc_arguments(JavaThread* thread) const { return _caller_must_gc_arguments; }
 229 
 230   // Naming
 231   const char* name() const                       { return _name; }
 232   void set_name(const char* name)                { _name = name; }
 233 
 234   // Debugging
 235   virtual void verify() = 0;
 236   virtual void print() const;
 237   virtual void print_on(outputStream* st) const;
 238   virtual void print_value_on(outputStream* st) const;
 239   void dump_for_addr(address addr, outputStream* st, bool verbose) const;
 240   void print_code();


 245   }
 246   // Print the comment associated with offset on stream, if there is one
 247   virtual void print_block_comment(outputStream* stream, address block_begin) const {
 248     intptr_t offset = (intptr_t)(block_begin - code_begin());
 249     _strings.print_block_comment(stream, offset);
 250   }
 251 
 252   // Transfer ownership of comments to this CodeBlob
 253   void set_strings(CodeStrings& strings) {
 254     assert(!is_aot(), "invalid on aot");
 255     _strings.assign(strings);
 256   }
 257 
 258   static ByteSize name_field_offset() {
 259     return byte_offset_of(CodeBlob, _name);
 260   }
 261 
 262   static ByteSize oop_maps_field_offset() {
 263     return byte_offset_of(CodeBlob, _oop_maps);
 264   }
 265 };
 266 
 267 class CodeBlobLookup {
 268 public:
 269   virtual CodeBlob* find_blob(address addr) const { return NULL; }
 270 };
 271 
 272 class CodeBlobLayout : public StackObj {
 273 private:
 274   int _size;
 275   int _header_size;
 276   int _relocation_size;
 277   int _content_offset;
 278   int _code_offset;
 279   int _data_offset;
 280   address _code_begin;
 281   address _code_end;
 282   address _content_begin;
 283   address _content_end;
 284   address _data_end;
 285   address _relocation_begin;
 286   address _relocation_end;
 287 
 288 public:
 289   CodeBlobLayout(address code_begin, address code_end, address content_begin, address content_end, address data_end, address relocation_begin, address relocation_end) :


< prev index next >