src/share/vm/code/codeBlob.hpp

Print this page
rev 4202 : 8008555: Debugging code in compiled method sometimes leaks memory
Summary: support for strings that have same life-time as code that uses them.
Reviewed-by:


  49 class DeoptimizationBlob;
  50 
  51 class CodeBlob VALUE_OBJ_CLASS_SPEC {
  52 
  53   friend class VMStructs;
  54 
  55  private:
  56   const char* _name;
  57   int        _size;                              // total size of CodeBlob in bytes
  58   int        _header_size;                       // size of header (depends on subclass)
  59   int        _relocation_size;                   // size of relocation
  60   int        _content_offset;                    // offset to where content region begins (this includes consts, insts, stubs)
  61   int        _code_offset;                       // offset to where instructions region begins (this includes insts, stubs)
  62   int        _frame_complete_offset;             // instruction offsets in [0.._frame_complete_offset) have
  63                                                  // not finished setting up their frame. Beware of pc's in
  64                                                  // that range. There is a similar range(s) on returns
  65                                                  // which we don't detect.
  66   int        _data_offset;                       // offset to where data region begins
  67   int        _frame_size;                        // size of stack frame
  68   OopMapSet* _oop_maps;                          // OopMap for this CodeBlob
  69   CodeComments _comments;
  70 
  71  public:
  72   // Returns the space needed for CodeBlob
  73   static unsigned int allocation_size(CodeBuffer* cb, int header_size);
  74 
  75   // Creation
  76   // a) simple CodeBlob
  77   // frame_complete is the offset from the beginning of the instructions
  78   // to where the frame setup (from stackwalk viewpoint) is complete.
  79   CodeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size);
  80 
  81   // b) full CodeBlob
  82   CodeBlob(
  83     const char* name,
  84     CodeBuffer* cb,
  85     int         header_size,
  86     int         size,
  87     int         frame_complete,
  88     int         frame_size,
  89     OopMapSet*  oop_maps


 169 
 170   // Returns true, if the next frame is responsible for GC'ing oops passed as arguments
 171   virtual bool caller_must_gc_arguments(JavaThread* thread) const { return false; }
 172 
 173   // Naming
 174   const char* name() const                       { return _name; }
 175   void set_name(const char* name)                { _name = name; }
 176 
 177   // Debugging
 178   virtual void verify();
 179   void print() const                             { print_on(tty); }
 180   virtual void print_on(outputStream* st) const;
 181   virtual void print_value_on(outputStream* st) const;
 182 
 183   // Deal with Disassembler, VTune, Forte, JvmtiExport, MemoryService.
 184   static void trace_new_stub(CodeBlob* blob, const char* name1, const char* name2 = "");
 185 
 186   // Print the comment associated with offset on stream, if there is one
 187   virtual void print_block_comment(outputStream* stream, address block_begin) const {
 188     intptr_t offset = (intptr_t)(block_begin - code_begin());
 189     _comments.print_block_comment(stream, offset);
 190   }
 191 
 192   // Transfer ownership of comments to this CodeBlob
 193   void set_comments(CodeComments& comments) {
 194     _comments.assign(comments);
 195   }
 196 };
 197 
 198 
 199 //----------------------------------------------------------------------------------------------------
 200 // BufferBlob: used to hold non-relocatable machine code such as the interpreter, stubroutines, etc.
 201 
 202 class BufferBlob: public CodeBlob {
 203   friend class VMStructs;
 204   friend class AdapterBlob;
 205   friend class MethodHandlesAdapterBlob;
 206 
 207  private:
 208   // Creation support
 209   BufferBlob(const char* name, int size);
 210   BufferBlob(const char* name, int size, CodeBuffer* cb);
 211 
 212   void* operator new(size_t s, unsigned size);
 213 
 214  public:




  49 class DeoptimizationBlob;
  50 
  51 class CodeBlob VALUE_OBJ_CLASS_SPEC {
  52 
  53   friend class VMStructs;
  54 
  55  private:
  56   const char* _name;
  57   int        _size;                              // total size of CodeBlob in bytes
  58   int        _header_size;                       // size of header (depends on subclass)
  59   int        _relocation_size;                   // size of relocation
  60   int        _content_offset;                    // offset to where content region begins (this includes consts, insts, stubs)
  61   int        _code_offset;                       // offset to where instructions region begins (this includes insts, stubs)
  62   int        _frame_complete_offset;             // instruction offsets in [0.._frame_complete_offset) have
  63                                                  // not finished setting up their frame. Beware of pc's in
  64                                                  // that range. There is a similar range(s) on returns
  65                                                  // which we don't detect.
  66   int        _data_offset;                       // offset to where data region begins
  67   int        _frame_size;                        // size of stack frame
  68   OopMapSet* _oop_maps;                          // OopMap for this CodeBlob
  69   CodeStrings _strings;
  70 
  71  public:
  72   // Returns the space needed for CodeBlob
  73   static unsigned int allocation_size(CodeBuffer* cb, int header_size);
  74 
  75   // Creation
  76   // a) simple CodeBlob
  77   // frame_complete is the offset from the beginning of the instructions
  78   // to where the frame setup (from stackwalk viewpoint) is complete.
  79   CodeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size);
  80 
  81   // b) full CodeBlob
  82   CodeBlob(
  83     const char* name,
  84     CodeBuffer* cb,
  85     int         header_size,
  86     int         size,
  87     int         frame_complete,
  88     int         frame_size,
  89     OopMapSet*  oop_maps


 169 
 170   // Returns true, if the next frame is responsible for GC'ing oops passed as arguments
 171   virtual bool caller_must_gc_arguments(JavaThread* thread) const { return false; }
 172 
 173   // Naming
 174   const char* name() const                       { return _name; }
 175   void set_name(const char* name)                { _name = name; }
 176 
 177   // Debugging
 178   virtual void verify();
 179   void print() const                             { print_on(tty); }
 180   virtual void print_on(outputStream* st) const;
 181   virtual void print_value_on(outputStream* st) const;
 182 
 183   // Deal with Disassembler, VTune, Forte, JvmtiExport, MemoryService.
 184   static void trace_new_stub(CodeBlob* blob, const char* name1, const char* name2 = "");
 185 
 186   // Print the comment associated with offset on stream, if there is one
 187   virtual void print_block_comment(outputStream* stream, address block_begin) const {
 188     intptr_t offset = (intptr_t)(block_begin - code_begin());
 189     _strings.print_block_comment(stream, offset);
 190   }
 191 
 192   // Transfer ownership of comments to this CodeBlob
 193   void set_strings(CodeStrings& strings) {
 194     _strings.assign(strings);
 195   }
 196 };
 197 
 198 
 199 //----------------------------------------------------------------------------------------------------
 200 // BufferBlob: used to hold non-relocatable machine code such as the interpreter, stubroutines, etc.
 201 
 202 class BufferBlob: public CodeBlob {
 203   friend class VMStructs;
 204   friend class AdapterBlob;
 205   friend class MethodHandlesAdapterBlob;
 206 
 207  private:
 208   // Creation support
 209   BufferBlob(const char* name, int size);
 210   BufferBlob(const char* name, int size, CodeBuffer* cb);
 211 
 212   void* operator new(size_t s, unsigned size);
 213 
 214  public: