< prev index next >

src/hotspot/share/code/codeBlob.hpp

Print this page

 43 struct CodeBlobType {
 44   enum {
 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 
 53 // CodeBlob - superclass for all entries in the CodeCache.
 54 //
 55 // Subtypes are:
 56 //  CompiledMethod       : Compiled Java methods (include method that calls to native code)
 57 //   nmethod             : JIT Compiled Java methods
 58 //  RuntimeBlob          : Non-compiled method code; generated glue code
 59 //   BufferBlob          : Used for non-relocatable code such as interpreter, stubroutines, etc.
 60 //    AdapterBlob        : Used to hold C2I/I2C adapters
 61 //    VtableBlob         : Used for holding vtable chunks
 62 //    MethodHandlesAdapterBlob : Used to hold MethodHandles adapters
 63 //    OptimizedEntryBlob : Used for upcalls from native code
 64 //   RuntimeStub         : Call to VM runtime methods
 65 //   SingletonBlob       : Super-class for all blobs that exist in only one instance
 66 //    DeoptimizationBlob : Used for deoptimization
 67 //    ExceptionBlob      : Used for stack unrolling
 68 //    SafepointBlob      : Used to handle illegal instruction exceptions
 69 //    UncommonTrapBlob   : Used to handle uncommon traps

 70 //
 71 //
 72 // Layout : continuous in the CodeCache
 73 //   - header
 74 //   - relocation
 75 //   - content space
 76 //     - instruction space
 77 //   - data space
 78 
 79 
 80 class CodeBlobLayout;
 81 class OptimizedEntryBlob; // for as_optimized_entry_blob()
 82 class JavaFrameAnchor; // for OptimizedEntryBlob::jfa_for_frame
 83 
 84 class CodeBlob {
 85   friend class VMStructs;
 86   friend class JVMCIVMStructs;
 87   friend class CodeCacheDumper;
 88 
 89 protected:

354  public:
355 
356   // Creation
357   // a) simple CodeBlob
358   // frame_complete is the offset from the beginning of the instructions
359   // to where the frame setup (from stackwalk viewpoint) is complete.
360   RuntimeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size);
361 
362   // b) full CodeBlob
363   RuntimeBlob(
364     const char* name,
365     CodeBuffer* cb,
366     int         header_size,
367     int         size,
368     int         frame_complete,
369     int         frame_size,
370     OopMapSet*  oop_maps,
371     bool        caller_must_gc_arguments = false
372   );
373 


374   // GC support
375   virtual bool is_alive() const                  = 0;
376 
377   void verify();
378 
379   // OopMap for frame
380   virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f)  { ShouldNotReachHere(); }
381 
382   // Debugging
383   virtual void print_on(outputStream* st) const { CodeBlob::print_on(st); }
384   virtual void print_value_on(outputStream* st) const { CodeBlob::print_value_on(st); }
385 
386   // Deal with Disassembler, VTune, Forte, JvmtiExport, MemoryService.
387   static void trace_new_stub(RuntimeBlob* blob, const char* name1, const char* name2 = "");
388 };
389 
390 class WhiteBox;
391 //----------------------------------------------------------------------------------------------------
392 // BufferBlob: used to hold non-relocatable machine code such as the interpreter, stubroutines, etc.
393 

448 //---------------------------------------------------------------------------------------------------
449 class VtableBlob: public BufferBlob {
450 private:
451   VtableBlob(const char*, int);
452 
453   void* operator new(size_t s, unsigned size) throw();
454 
455 public:
456   // Creation
457   static VtableBlob* create(const char* name, int buffer_size);
458 
459   // Typing
460   virtual bool is_vtable_blob() const { return true; }
461 };
462 
463 //----------------------------------------------------------------------------------------------------
464 // MethodHandlesAdapterBlob: used to hold MethodHandles adapters
465 
466 class MethodHandlesAdapterBlob: public BufferBlob {
467 private:
468   MethodHandlesAdapterBlob(int size)                 : BufferBlob("MethodHandles adapters", size) {}
469 
470 public:
471   // Creation
472   static MethodHandlesAdapterBlob* create(int buffer_size);
473 
474   // Typing
475   virtual bool is_method_handles_adapter_blob() const { return true; }
476 };
477 
478 
479 //----------------------------------------------------------------------------------------------------
480 // RuntimeStub: describes stubs used by compiled code to call a (static) C++ runtime routine
481 
482 class RuntimeStub: public RuntimeBlob {
483   friend class VMStructs;
484  private:
485   // Creation support
486   RuntimeStub(
487     const char* name,
488     CodeBuffer* cb,

723 
724  public:
725   // Creation
726   static SafepointBlob* create(
727     CodeBuffer* cb,
728     OopMapSet*  oop_maps,
729     int         frame_size
730   );
731 
732   // GC for args
733   void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f)  { /* nothing to do */ }
734 
735   // Typing
736   bool is_safepoint_stub() const                 { return true; }
737 };
738 
739 //----------------------------------------------------------------------------------------------------
740 
741 class ProgrammableUpcallHandler;
742 
743 class OptimizedEntryBlob: public BufferBlob {
744   friend class ProgrammableUpcallHandler;
745  private:
746   intptr_t _exception_handler_offset;
747   jobject _receiver;
748   ByteSize _frame_data_offset;
749 
750   OptimizedEntryBlob(const char* name, int size, CodeBuffer* cb, intptr_t exception_handler_offset,

751                      jobject receiver, ByteSize frame_data_offset);
752 


753   struct FrameData {
754     JavaFrameAnchor jfa;
755     JavaThread* thread;
756     JNIHandleBlock* old_handles;
757     JNIHandleBlock* new_handles;
758     bool should_detach;
759   };
760 
761   // defined in frame_ARCH.cpp
762   FrameData* frame_data_for_frame(const frame& frame) const;
763  public:
764   // Creation
765   static OptimizedEntryBlob* create(const char* name, CodeBuffer* cb,
766                                     intptr_t exception_handler_offset, jobject receiver,
767                                     ByteSize frame_data_offset);


768 
769   address exception_handler() { return code_begin() + _exception_handler_offset; }
770   jobject receiver() { return _receiver; }
771 
772   JavaFrameAnchor* jfa_for_frame(const frame& frame) const;
773 
774   void oops_do(OopClosure* f, const frame& frame);
775 
776   // Typing
777   virtual bool is_optimized_entry_blob() const override { return true; }










778 };
779 
780 #endif // SHARE_CODE_CODEBLOB_HPP

 43 struct CodeBlobType {
 44   enum {
 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 
 53 // CodeBlob - superclass for all entries in the CodeCache.
 54 //
 55 // Subtypes are:
 56 //  CompiledMethod       : Compiled Java methods (include method that calls to native code)
 57 //   nmethod             : JIT Compiled Java methods
 58 //  RuntimeBlob          : Non-compiled method code; generated glue code
 59 //   BufferBlob          : Used for non-relocatable code such as interpreter, stubroutines, etc.
 60 //    AdapterBlob        : Used to hold C2I/I2C adapters
 61 //    VtableBlob         : Used for holding vtable chunks
 62 //    MethodHandlesAdapterBlob : Used to hold MethodHandles adapters

 63 //   RuntimeStub         : Call to VM runtime methods
 64 //   SingletonBlob       : Super-class for all blobs that exist in only one instance
 65 //    DeoptimizationBlob : Used for deoptimization
 66 //    ExceptionBlob      : Used for stack unrolling
 67 //    SafepointBlob      : Used to handle illegal instruction exceptions
 68 //    UncommonTrapBlob   : Used to handle uncommon traps
 69 //   OptimizedEntryBlob  : Used for upcalls from native code
 70 //
 71 //
 72 // Layout : continuous in the CodeCache
 73 //   - header
 74 //   - relocation
 75 //   - content space
 76 //     - instruction space
 77 //   - data space
 78 
 79 
 80 class CodeBlobLayout;
 81 class OptimizedEntryBlob; // for as_optimized_entry_blob()
 82 class JavaFrameAnchor; // for OptimizedEntryBlob::jfa_for_frame
 83 
 84 class CodeBlob {
 85   friend class VMStructs;
 86   friend class JVMCIVMStructs;
 87   friend class CodeCacheDumper;
 88 
 89 protected:

354  public:
355 
356   // Creation
357   // a) simple CodeBlob
358   // frame_complete is the offset from the beginning of the instructions
359   // to where the frame setup (from stackwalk viewpoint) is complete.
360   RuntimeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size);
361 
362   // b) full CodeBlob
363   RuntimeBlob(
364     const char* name,
365     CodeBuffer* cb,
366     int         header_size,
367     int         size,
368     int         frame_complete,
369     int         frame_size,
370     OopMapSet*  oop_maps,
371     bool        caller_must_gc_arguments = false
372   );
373 
374   static void free(RuntimeBlob* blob);
375 
376   // GC support
377   virtual bool is_alive() const                  = 0;
378 
379   void verify();
380 
381   // OopMap for frame
382   virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f)  { ShouldNotReachHere(); }
383 
384   // Debugging
385   virtual void print_on(outputStream* st) const { CodeBlob::print_on(st); }
386   virtual void print_value_on(outputStream* st) const { CodeBlob::print_value_on(st); }
387 
388   // Deal with Disassembler, VTune, Forte, JvmtiExport, MemoryService.
389   static void trace_new_stub(RuntimeBlob* blob, const char* name1, const char* name2 = "");
390 };
391 
392 class WhiteBox;
393 //----------------------------------------------------------------------------------------------------
394 // BufferBlob: used to hold non-relocatable machine code such as the interpreter, stubroutines, etc.
395 

450 //---------------------------------------------------------------------------------------------------
451 class VtableBlob: public BufferBlob {
452 private:
453   VtableBlob(const char*, int);
454 
455   void* operator new(size_t s, unsigned size) throw();
456 
457 public:
458   // Creation
459   static VtableBlob* create(const char* name, int buffer_size);
460 
461   // Typing
462   virtual bool is_vtable_blob() const { return true; }
463 };
464 
465 //----------------------------------------------------------------------------------------------------
466 // MethodHandlesAdapterBlob: used to hold MethodHandles adapters
467 
468 class MethodHandlesAdapterBlob: public BufferBlob {
469 private:
470   MethodHandlesAdapterBlob(int size): BufferBlob("MethodHandles adapters", size) {}
471 
472 public:
473   // Creation
474   static MethodHandlesAdapterBlob* create(int buffer_size);
475 
476   // Typing
477   virtual bool is_method_handles_adapter_blob() const { return true; }
478 };
479 
480 
481 //----------------------------------------------------------------------------------------------------
482 // RuntimeStub: describes stubs used by compiled code to call a (static) C++ runtime routine
483 
484 class RuntimeStub: public RuntimeBlob {
485   friend class VMStructs;
486  private:
487   // Creation support
488   RuntimeStub(
489     const char* name,
490     CodeBuffer* cb,

725 
726  public:
727   // Creation
728   static SafepointBlob* create(
729     CodeBuffer* cb,
730     OopMapSet*  oop_maps,
731     int         frame_size
732   );
733 
734   // GC for args
735   void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f)  { /* nothing to do */ }
736 
737   // Typing
738   bool is_safepoint_stub() const                 { return true; }
739 };
740 
741 //----------------------------------------------------------------------------------------------------
742 
743 class ProgrammableUpcallHandler;
744 
745 class OptimizedEntryBlob: public RuntimeBlob {
746   friend class ProgrammableUpcallHandler;
747  private:
748   intptr_t _exception_handler_offset;
749   jobject _receiver;
750   ByteSize _frame_data_offset;
751 
752   OptimizedEntryBlob(const char* name, CodeBuffer* cb, int size,
753                      intptr_t exception_handler_offset,
754                      jobject receiver, ByteSize frame_data_offset);
755 
756   void* operator new(size_t s, unsigned size) throw();
757 
758   struct FrameData {
759     JavaFrameAnchor jfa;
760     JavaThread* thread;
761     JNIHandleBlock* old_handles;
762     JNIHandleBlock* new_handles;
763     bool should_detach;
764   };
765 
766   // defined in frame_ARCH.cpp
767   FrameData* frame_data_for_frame(const frame& frame) const;
768  public:
769   // Creation
770   static OptimizedEntryBlob* create(const char* name, CodeBuffer* cb,
771                                     intptr_t exception_handler_offset,
772                                     jobject receiver, ByteSize frame_data_offset);
773 
774   static void free(OptimizedEntryBlob* blob);
775 
776   address exception_handler() { return code_begin() + _exception_handler_offset; }
777   jobject receiver() { return _receiver; }
778 
779   JavaFrameAnchor* jfa_for_frame(const frame& frame) const;
780 


781   // Typing
782   virtual bool is_optimized_entry_blob() const override { return true; }
783 
784   // GC/Verification support
785   void oops_do(OopClosure* f, const frame& frame);
786   virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) override;
787   virtual bool is_alive() const override { return true; }
788   virtual void verify() override;
789 
790   // Misc.
791   virtual void print_on(outputStream* st) const override;
792   virtual void print_value_on(outputStream* st) const override;
793 };
794 
795 #endif // SHARE_CODE_CODEBLOB_HPP
< prev index next >