< prev index next >

src/hotspot/share/code/codeBlob.hpp

Print this page

 41 
 42 // CodeBlob Types
 43 // Used in the CodeCache to assign CodeBlobs to different CodeHeaps
 44 enum class CodeBlobType {
 45   MethodNonProfiled   = 0,    // Execution level 1 and 4 (non-profiled) nmethods (including native nmethods)
 46   MethodProfiled      = 1,    // Execution level 2 and 3 (profiled) nmethods
 47   NonNMethod          = 2,    // Non-nmethods like Buffers, Adapters and Runtime Stubs
 48   All                 = 3,    // All types (No code cache segmentation)
 49   NumTypes            = 4     // Number of CodeBlobTypes
 50 };
 51 
 52 // CodeBlob - superclass for all entries in the CodeCache.
 53 //
 54 // Subtypes are:
 55 //  nmethod              : JIT Compiled Java methods
 56 //  RuntimeBlob          : Non-compiled method code; generated glue code
 57 //   BufferBlob          : Used for non-relocatable code such as interpreter, stubroutines, etc.
 58 //    AdapterBlob        : Used to hold C2I/I2C adapters
 59 //    VtableBlob         : Used for holding vtable chunks
 60 //    MethodHandlesAdapterBlob : Used to hold MethodHandles adapters

 61 //   RuntimeStub         : Call to VM runtime methods
 62 //   SingletonBlob       : Super-class for all blobs that exist in only one instance
 63 //    DeoptimizationBlob : Used for deoptimization
 64 //    ExceptionBlob      : Used for stack unrolling
 65 //    SafepointBlob      : Used to handle illegal instruction exceptions
 66 //    UncommonTrapBlob   : Used to handle uncommon traps
 67 //   UpcallStub  : Used for upcalls from native code
 68 //
 69 //
 70 // Layout : continuous in the CodeCache
 71 //   - header
 72 //   - relocation
 73 //   - content space
 74 //     - instruction space
 75 //   - data space
 76 
 77 enum class CodeBlobKind : u1 {
 78   None,
 79   Nmethod,
 80   Buffer,
 81   Adapter,
 82   Vtable,
 83   MH_Adapter,

 84   Runtime_Stub,
 85   Deoptimization,
 86   Exception,
 87   Safepoint,
 88   Uncommon_Trap,
 89   Upcall,
 90   Number_Of_Kinds
 91 };
 92 
 93 class UpcallStub;      // for as_upcall_stub()
 94 class RuntimeStub;     // for as_runtime_stub()
 95 class JavaFrameAnchor; // for UpcallStub::jfa_for_frame
 96 
 97 class CodeBlob {
 98   friend class VMStructs;
 99   friend class JVMCIVMStructs;
100   friend class CodeCacheDumper;
101 
102 protected:
103   // order fields from large to small to minimize padding between fields

144   }
145 
146   // Returns the space needed for CodeBlob
147   static unsigned int allocation_size(CodeBuffer* cb, int header_size);
148   static unsigned int align_code_offset(int offset);
149 
150   // Deletion
151   void purge();
152 
153   // Typing
154   bool is_nmethod() const                     { return _kind == CodeBlobKind::Nmethod; }
155   bool is_buffer_blob() const                 { return _kind == CodeBlobKind::Buffer; }
156   bool is_runtime_stub() const                { return _kind == CodeBlobKind::Runtime_Stub; }
157   bool is_deoptimization_stub() const         { return _kind == CodeBlobKind::Deoptimization; }
158   bool is_uncommon_trap_stub() const          { return _kind == CodeBlobKind::Uncommon_Trap; }
159   bool is_exception_stub() const              { return _kind == CodeBlobKind::Exception; }
160   bool is_safepoint_stub() const              { return _kind == CodeBlobKind::Safepoint; }
161   bool is_adapter_blob() const                { return _kind == CodeBlobKind::Adapter; }
162   bool is_vtable_blob() const                 { return _kind == CodeBlobKind::Vtable; }
163   bool is_method_handles_adapter_blob() const { return _kind == CodeBlobKind::MH_Adapter; }

164   bool is_upcall_stub() const                 { return _kind == CodeBlobKind::Upcall; }
165 
166   // Casting
167   nmethod* as_nmethod_or_null()               { return is_nmethod() ? (nmethod*) this : nullptr; }
168   nmethod* as_nmethod()                       { assert(is_nmethod(), "must be nmethod"); return (nmethod*) this; }
169   CodeBlob* as_codeblob_or_null() const       { return (CodeBlob*) this; }
170   UpcallStub* as_upcall_stub() const          { assert(is_upcall_stub(), "must be upcall stub"); return (UpcallStub*) this; }
171   RuntimeStub* as_runtime_stub() const        { assert(is_runtime_stub(), "must be runtime blob"); return (RuntimeStub*) this; }
172 
173   // Boundaries
174   address    header_begin() const             { return (address)    this; }
175   address    header_end() const               { return ((address)   this) + _header_size; }
176   relocInfo* relocation_begin() const         { return (relocInfo*) header_end(); }
177   relocInfo* relocation_end() const           { return (relocInfo*)(header_end()   + _relocation_size); }
178   address    content_begin() const            { return (address)    header_begin() + _content_offset; }
179   address    content_end() const              { return (address)    header_begin() + _data_offset; }
180   address    code_begin() const               { return (address)    header_begin() + _code_offset; }
181   // code_end == content_end is true for all types of blobs for now, it is also checked in the constructor
182   address    code_end() const                 { return (address)    header_begin() + _data_offset; }
183   address    data_begin() const               { return (address)    header_begin() + _data_offset; }

285     int         frame_size,
286     OopMapSet*  oop_maps,
287     bool        caller_must_gc_arguments = false
288   );
289 
290   static void free(RuntimeBlob* blob);
291 
292   // Deal with Disassembler, VTune, Forte, JvmtiExport, MemoryService.
293   static void trace_new_stub(RuntimeBlob* blob, const char* name1, const char* name2 = "");
294 };
295 
296 class WhiteBox;
297 //----------------------------------------------------------------------------------------------------
298 // BufferBlob: used to hold non-relocatable machine code such as the interpreter, stubroutines, etc.
299 
300 class BufferBlob: public RuntimeBlob {
301   friend class VMStructs;
302   friend class AdapterBlob;
303   friend class VtableBlob;
304   friend class MethodHandlesAdapterBlob;

305   friend class UpcallStub;
306   friend class WhiteBox;
307 
308  private:
309   // Creation support
310   BufferBlob(const char* name, CodeBlobKind kind, int size);
311   BufferBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size);

312 
313   void* operator new(size_t s, unsigned size) throw();
314 
315  public:
316   // Creation
317   static BufferBlob* create(const char* name, uint buffer_size);
318   static BufferBlob* create(const char* name, CodeBuffer* cb);
319 
320   static void free(BufferBlob* buf);
321 
322   // Verification support
323   void verify() override;
324 
325   void print_on(outputStream* st) const override;
326   void print_value_on(outputStream* st) const override;
327 };
328 
329 
330 //----------------------------------------------------------------------------------------------------
331 // AdapterBlob: used to hold C2I/I2C adapters
332 
333 class AdapterBlob: public BufferBlob {
334 private:
335   AdapterBlob(int size, CodeBuffer* cb);
336 
337 public:
338   // Creation
339   static AdapterBlob* create(CodeBuffer* cb);






340 };
341 
342 //---------------------------------------------------------------------------------------------------
343 class VtableBlob: public BufferBlob {
344 private:
345   VtableBlob(const char*, int);
346 
347   void* operator new(size_t s, unsigned size) throw();
348 
349 public:
350   // Creation
351   static VtableBlob* create(const char* name, int buffer_size);
352 };
353 
354 //----------------------------------------------------------------------------------------------------
355 // MethodHandlesAdapterBlob: used to hold MethodHandles adapters
356 
357 class MethodHandlesAdapterBlob: public BufferBlob {
358 private:
359   MethodHandlesAdapterBlob(int size): BufferBlob("MethodHandles adapters", CodeBlobKind::MH_Adapter, size) {}
360 
361 public:
362   // Creation
363   static MethodHandlesAdapterBlob* create(int buffer_size);
364 };
365 



















366 
367 //----------------------------------------------------------------------------------------------------
368 // RuntimeStub: describes stubs used by compiled code to call a (static) C++ runtime routine
369 
370 class RuntimeStub: public RuntimeBlob {
371   friend class VMStructs;
372  private:
373   // Creation support
374   RuntimeStub(
375     const char* name,
376     CodeBuffer* cb,
377     int         size,
378     int16_t     frame_complete,
379     int         frame_size,
380     OopMapSet*  oop_maps,
381     bool        caller_must_gc_arguments
382   );
383 
384   void* operator new(size_t s, unsigned size) throw();
385 

 41 
 42 // CodeBlob Types
 43 // Used in the CodeCache to assign CodeBlobs to different CodeHeaps
 44 enum class CodeBlobType {
 45   MethodNonProfiled   = 0,    // Execution level 1 and 4 (non-profiled) nmethods (including native nmethods)
 46   MethodProfiled      = 1,    // Execution level 2 and 3 (profiled) nmethods
 47   NonNMethod          = 2,    // Non-nmethods like Buffers, Adapters and Runtime Stubs
 48   All                 = 3,    // All types (No code cache segmentation)
 49   NumTypes            = 4     // Number of CodeBlobTypes
 50 };
 51 
 52 // CodeBlob - superclass for all entries in the CodeCache.
 53 //
 54 // Subtypes are:
 55 //  nmethod              : JIT Compiled Java methods
 56 //  RuntimeBlob          : Non-compiled method code; generated glue code
 57 //   BufferBlob          : Used for non-relocatable code such as interpreter, stubroutines, etc.
 58 //    AdapterBlob        : Used to hold C2I/I2C adapters
 59 //    VtableBlob         : Used for holding vtable chunks
 60 //    MethodHandlesAdapterBlob : Used to hold MethodHandles adapters
 61 //    BufferedInlineTypeBlob   : used for pack/unpack handlers
 62 //   RuntimeStub         : Call to VM runtime methods
 63 //   SingletonBlob       : Super-class for all blobs that exist in only one instance
 64 //    DeoptimizationBlob : Used for deoptimization
 65 //    ExceptionBlob      : Used for stack unrolling
 66 //    SafepointBlob      : Used to handle illegal instruction exceptions
 67 //    UncommonTrapBlob   : Used to handle uncommon traps
 68 //   UpcallStub  : Used for upcalls from native code
 69 //
 70 //
 71 // Layout : continuous in the CodeCache
 72 //   - header
 73 //   - relocation
 74 //   - content space
 75 //     - instruction space
 76 //   - data space
 77 
 78 enum class CodeBlobKind : u1 {
 79   None,
 80   Nmethod,
 81   Buffer,
 82   Adapter,
 83   Vtable,
 84   MH_Adapter,
 85   BufferedInlineType,
 86   Runtime_Stub,
 87   Deoptimization,
 88   Exception,
 89   Safepoint,
 90   Uncommon_Trap,
 91   Upcall,
 92   Number_Of_Kinds
 93 };
 94 
 95 class UpcallStub;      // for as_upcall_stub()
 96 class RuntimeStub;     // for as_runtime_stub()
 97 class JavaFrameAnchor; // for UpcallStub::jfa_for_frame
 98 
 99 class CodeBlob {
100   friend class VMStructs;
101   friend class JVMCIVMStructs;
102   friend class CodeCacheDumper;
103 
104 protected:
105   // order fields from large to small to minimize padding between fields

146   }
147 
148   // Returns the space needed for CodeBlob
149   static unsigned int allocation_size(CodeBuffer* cb, int header_size);
150   static unsigned int align_code_offset(int offset);
151 
152   // Deletion
153   void purge();
154 
155   // Typing
156   bool is_nmethod() const                     { return _kind == CodeBlobKind::Nmethod; }
157   bool is_buffer_blob() const                 { return _kind == CodeBlobKind::Buffer; }
158   bool is_runtime_stub() const                { return _kind == CodeBlobKind::Runtime_Stub; }
159   bool is_deoptimization_stub() const         { return _kind == CodeBlobKind::Deoptimization; }
160   bool is_uncommon_trap_stub() const          { return _kind == CodeBlobKind::Uncommon_Trap; }
161   bool is_exception_stub() const              { return _kind == CodeBlobKind::Exception; }
162   bool is_safepoint_stub() const              { return _kind == CodeBlobKind::Safepoint; }
163   bool is_adapter_blob() const                { return _kind == CodeBlobKind::Adapter; }
164   bool is_vtable_blob() const                 { return _kind == CodeBlobKind::Vtable; }
165   bool is_method_handles_adapter_blob() const { return _kind == CodeBlobKind::MH_Adapter; }
166   bool is_buffered_inline_type_blob() const   { return _kind == CodeBlobKind::BufferedInlineType; }
167   bool is_upcall_stub() const                 { return _kind == CodeBlobKind::Upcall; }
168 
169   // Casting
170   nmethod* as_nmethod_or_null()               { return is_nmethod() ? (nmethod*) this : nullptr; }
171   nmethod* as_nmethod()                       { assert(is_nmethod(), "must be nmethod"); return (nmethod*) this; }
172   CodeBlob* as_codeblob_or_null() const       { return (CodeBlob*) this; }
173   UpcallStub* as_upcall_stub() const          { assert(is_upcall_stub(), "must be upcall stub"); return (UpcallStub*) this; }
174   RuntimeStub* as_runtime_stub() const        { assert(is_runtime_stub(), "must be runtime blob"); return (RuntimeStub*) this; }
175 
176   // Boundaries
177   address    header_begin() const             { return (address)    this; }
178   address    header_end() const               { return ((address)   this) + _header_size; }
179   relocInfo* relocation_begin() const         { return (relocInfo*) header_end(); }
180   relocInfo* relocation_end() const           { return (relocInfo*)(header_end()   + _relocation_size); }
181   address    content_begin() const            { return (address)    header_begin() + _content_offset; }
182   address    content_end() const              { return (address)    header_begin() + _data_offset; }
183   address    code_begin() const               { return (address)    header_begin() + _code_offset; }
184   // code_end == content_end is true for all types of blobs for now, it is also checked in the constructor
185   address    code_end() const                 { return (address)    header_begin() + _data_offset; }
186   address    data_begin() const               { return (address)    header_begin() + _data_offset; }

288     int         frame_size,
289     OopMapSet*  oop_maps,
290     bool        caller_must_gc_arguments = false
291   );
292 
293   static void free(RuntimeBlob* blob);
294 
295   // Deal with Disassembler, VTune, Forte, JvmtiExport, MemoryService.
296   static void trace_new_stub(RuntimeBlob* blob, const char* name1, const char* name2 = "");
297 };
298 
299 class WhiteBox;
300 //----------------------------------------------------------------------------------------------------
301 // BufferBlob: used to hold non-relocatable machine code such as the interpreter, stubroutines, etc.
302 
303 class BufferBlob: public RuntimeBlob {
304   friend class VMStructs;
305   friend class AdapterBlob;
306   friend class VtableBlob;
307   friend class MethodHandlesAdapterBlob;
308   friend class BufferedInlineTypeBlob;
309   friend class UpcallStub;
310   friend class WhiteBox;
311 
312  private:
313   // Creation support
314   BufferBlob(const char* name, CodeBlobKind kind, int size);
315   BufferBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size, int header_size);
316   BufferBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size, int frame_complete, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments = false);
317 
318   void* operator new(size_t s, unsigned size) throw();
319 
320  public:
321   // Creation
322   static BufferBlob* create(const char* name, uint buffer_size);
323   static BufferBlob* create(const char* name, CodeBuffer* cb);
324 
325   static void free(BufferBlob* buf);
326 
327   // Verification support
328   void verify() override;
329 
330   void print_on(outputStream* st) const override;
331   void print_value_on(outputStream* st) const override;
332 };
333 
334 
335 //----------------------------------------------------------------------------------------------------
336 // AdapterBlob: used to hold C2I/I2C adapters
337 
338 class AdapterBlob: public BufferBlob {
339 private:
340   AdapterBlob(int size, CodeBuffer* cb, int frame_complete, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments = false);
341 
342 public:
343   // Creation
344   static AdapterBlob* create(CodeBuffer* cb,
345                              int frame_complete,
346                              int frame_size,
347                              OopMapSet* oop_maps,
348                              bool caller_must_gc_arguments = false);
349 
350   bool caller_must_gc_arguments(JavaThread* thread) const { return true; }
351 };
352 
353 //---------------------------------------------------------------------------------------------------
354 class VtableBlob: public BufferBlob {
355 private:
356   VtableBlob(const char*, int);
357 
358   void* operator new(size_t s, unsigned size) throw();
359 
360 public:
361   // Creation
362   static VtableBlob* create(const char* name, int buffer_size);
363 };
364 
365 //----------------------------------------------------------------------------------------------------
366 // MethodHandlesAdapterBlob: used to hold MethodHandles adapters
367 
368 class MethodHandlesAdapterBlob: public BufferBlob {
369 private:
370   MethodHandlesAdapterBlob(int size): BufferBlob("MethodHandles adapters", CodeBlobKind::MH_Adapter, size) {}
371 
372 public:
373   // Creation
374   static MethodHandlesAdapterBlob* create(int buffer_size);
375 };
376 
377 //----------------------------------------------------------------------------------------------------
378 // BufferedInlineTypeBlob : used for pack/unpack handlers
379 
380 class BufferedInlineTypeBlob: public BufferBlob {
381 private:
382   const int _pack_fields_off;
383   const int _pack_fields_jobject_off;
384   const int _unpack_fields_off;
385 
386   BufferedInlineTypeBlob(int size, CodeBuffer* cb, int pack_fields_off, int pack_fields_jobject_off, int unpack_fields_off);
387 
388 public:
389   // Creation
390   static BufferedInlineTypeBlob* create(CodeBuffer* cb, int pack_fields_off, int pack_fields_jobject_off, int unpack_fields_off);
391 
392   address pack_fields() const { return code_begin() + _pack_fields_off; }
393   address pack_fields_jobject() const { return code_begin() + _pack_fields_jobject_off; }
394   address unpack_fields() const { return code_begin() + _unpack_fields_off; }
395 };
396 
397 //----------------------------------------------------------------------------------------------------
398 // RuntimeStub: describes stubs used by compiled code to call a (static) C++ runtime routine
399 
400 class RuntimeStub: public RuntimeBlob {
401   friend class VMStructs;
402  private:
403   // Creation support
404   RuntimeStub(
405     const char* name,
406     CodeBuffer* cb,
407     int         size,
408     int16_t     frame_complete,
409     int         frame_size,
410     OopMapSet*  oop_maps,
411     bool        caller_must_gc_arguments
412   );
413 
414   void* operator new(size_t s, unsigned size) throw();
415 
< prev index next >