< prev index next >

src/share/vm/code/codeBlob.hpp

Print this page




  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_CODE_CODEBLOB_HPP
  26 #define SHARE_VM_CODE_CODEBLOB_HPP
  27 
  28 #include "asm/codeBuffer.hpp"
  29 #include "compiler/oopMap.hpp"
  30 #include "runtime/frame.hpp"
  31 #include "runtime/handles.hpp"
  32 









  33 // CodeBlob - superclass for all entries in the CodeCache.
  34 //
  35 // Suptypes are:
  36 //   nmethod            : Compiled Java methods (include method that calls to native code)
  37 //   RuntimeStub        : Call to VM runtime methods
  38 //   DeoptimizationBlob : Used for deoptimizatation
  39 //   ExceptionBlob      : Used for stack unrolling
  40 //   SafepointBlob      : Used to handle illegal instruction exceptions
  41 //
  42 //
  43 // Layout:
  44 //   - header
  45 //   - relocation
  46 //   - content space
  47 //     - instruction space
  48 //   - data space
  49 class DeoptimizationBlob;
  50 
  51 class CodeBlob VALUE_OBJ_CLASS_SPEC {
  52 


  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
  90   );
  91 
  92   // Deletion
  93   void flush();


 188   virtual void print_block_comment(outputStream* stream, address block_begin) const {
 189     intptr_t offset = (intptr_t)(block_begin - code_begin());
 190     _strings.print_block_comment(stream, offset);
 191   }
 192 
 193   // Transfer ownership of comments to this CodeBlob
 194   void set_strings(CodeStrings& strings) {
 195     _strings.assign(strings);
 196   }
 197 };
 198 
 199 
 200 //----------------------------------------------------------------------------------------------------
 201 // BufferBlob: used to hold non-relocatable machine code such as the interpreter, stubroutines, etc.
 202 
 203 class BufferBlob: public CodeBlob {
 204   friend class VMStructs;
 205   friend class AdapterBlob;
 206   friend class VtableBlob;
 207   friend class MethodHandlesAdapterBlob;

 208 
 209  private:
 210   // Creation support
 211   BufferBlob(const char* name, int size);
 212   BufferBlob(const char* name, int size, CodeBuffer* cb);
 213 
 214   void* operator new(size_t s, unsigned size, bool is_critical = false) throw();
 215 
 216  public:
 217   // Creation
 218   static BufferBlob* create(const char* name, int buffer_size);
 219   static BufferBlob* create(const char* name, CodeBuffer* cb);
 220 
 221   static void free(BufferBlob* buf);
 222 
 223   // Typing
 224   virtual bool is_buffer_blob() const            { return true; }
 225 
 226   // GC/Verification support
 227   void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f)  { /* nothing to do */ }




  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_CODE_CODEBLOB_HPP
  26 #define SHARE_VM_CODE_CODEBLOB_HPP
  27 
  28 #include "asm/codeBuffer.hpp"
  29 #include "compiler/oopMap.hpp"
  30 #include "runtime/frame.hpp"
  31 #include "runtime/handles.hpp"
  32 
  33 // CodeBlob Types
  34 // Used in the CodeCache to assign CodeBlobs to different CodeHeaps
  35 struct CodeBlobType {
  36   enum {
  37     All                 = 0,    // All types (No code cache segmentation)
  38     NumTypes            = 1     // Number of CodeBlobTypes
  39   };
  40 };
  41 
  42 // CodeBlob - superclass for all entries in the CodeCache.
  43 //
  44 // Suptypes are:
  45 //   nmethod            : Compiled Java methods (include method that calls to native code)
  46 //   RuntimeStub        : Call to VM runtime methods
  47 //   DeoptimizationBlob : Used for deoptimizatation
  48 //   ExceptionBlob      : Used for stack unrolling
  49 //   SafepointBlob      : Used to handle illegal instruction exceptions
  50 //
  51 //
  52 // Layout:
  53 //   - header
  54 //   - relocation
  55 //   - content space
  56 //     - instruction space
  57 //   - data space
  58 class DeoptimizationBlob;
  59 
  60 class CodeBlob VALUE_OBJ_CLASS_SPEC {
  61 


  63 
  64  private:
  65   const char* _name;
  66   int        _size;                              // total size of CodeBlob in bytes
  67   int        _header_size;                       // size of header (depends on subclass)
  68   int        _relocation_size;                   // size of relocation
  69   int        _content_offset;                    // offset to where content region begins (this includes consts, insts, stubs)
  70   int        _code_offset;                       // offset to where instructions region begins (this includes insts, stubs)
  71   int        _frame_complete_offset;             // instruction offsets in [0.._frame_complete_offset) have
  72                                                  // not finished setting up their frame. Beware of pc's in
  73                                                  // that range. There is a similar range(s) on returns
  74                                                  // which we don't detect.
  75   int        _data_offset;                       // offset to where data region begins
  76   int        _frame_size;                        // size of stack frame
  77   OopMapSet* _oop_maps;                          // OopMap for this CodeBlob
  78   CodeStrings _strings;
  79 
  80  public:
  81   // Returns the space needed for CodeBlob
  82   static unsigned int allocation_size(CodeBuffer* cb, int header_size);
  83   static unsigned int align_code_offset(int offset);
  84 
  85   // Creation
  86   // a) simple CodeBlob
  87   // frame_complete is the offset from the beginning of the instructions
  88   // to where the frame setup (from stackwalk viewpoint) is complete.
  89   CodeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size);
  90 
  91   // b) full CodeBlob
  92   CodeBlob(
  93     const char* name,
  94     CodeBuffer* cb,
  95     int         header_size,
  96     int         size,
  97     int         frame_complete,
  98     int         frame_size,
  99     OopMapSet*  oop_maps
 100   );
 101 
 102   // Deletion
 103   void flush();


 198   virtual void print_block_comment(outputStream* stream, address block_begin) const {
 199     intptr_t offset = (intptr_t)(block_begin - code_begin());
 200     _strings.print_block_comment(stream, offset);
 201   }
 202 
 203   // Transfer ownership of comments to this CodeBlob
 204   void set_strings(CodeStrings& strings) {
 205     _strings.assign(strings);
 206   }
 207 };
 208 
 209 
 210 //----------------------------------------------------------------------------------------------------
 211 // BufferBlob: used to hold non-relocatable machine code such as the interpreter, stubroutines, etc.
 212 
 213 class BufferBlob: public CodeBlob {
 214   friend class VMStructs;
 215   friend class AdapterBlob;
 216   friend class VtableBlob;
 217   friend class MethodHandlesAdapterBlob;
 218   friend class WhiteBox;
 219 
 220  private:
 221   // Creation support
 222   BufferBlob(const char* name, int size);
 223   BufferBlob(const char* name, int size, CodeBuffer* cb);
 224 
 225   void* operator new(size_t s, unsigned size, bool is_critical = false) throw();
 226 
 227  public:
 228   // Creation
 229   static BufferBlob* create(const char* name, int buffer_size);
 230   static BufferBlob* create(const char* name, CodeBuffer* cb);
 231 
 232   static void free(BufferBlob* buf);
 233 
 234   // Typing
 235   virtual bool is_buffer_blob() const            { return true; }
 236 
 237   // GC/Verification support
 238   void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f)  { /* nothing to do */ }


< prev index next >