< prev index next >

src/hotspot/share/interpreter/interpreter.hpp

Print this page

 28 #include "code/stubs.hpp"
 29 #include "interpreter/interp_masm.hpp"
 30 #include "interpreter/templateInterpreter.hpp"
 31 #include "interpreter/zero/zeroInterpreter.hpp"
 32 #include "memory/resourceArea.hpp"
 33 #include "utilities/align.hpp"
 34 
 35 // This file contains the platform-independent parts
 36 // of the interpreter and the interpreter generator.
 37 
 38 class InterpreterMacroAssembler;
 39 
 40 //------------------------------------------------------------------------------------------------------------------------
 41 // An InterpreterCodelet is a piece of interpreter code. All
 42 // interpreter code is generated into little codelets which
 43 // contain extra information for debugging and printing purposes.
 44 
 45 class InterpreterCodelet: public Stub {
 46   friend class VMStructs;
 47   friend class CodeCacheDumper; // possible extension [do not remove]




 48  private:
 49   int         _size;                      // the size in bytes

 50   const char* _description;               // a description of the codelet, for debugging & printing
 51   Bytecodes::Code _bytecode;              // associated bytecode if any
 52   NOT_PRODUCT(AsmRemarks _asm_remarks;)   // Comments for annotating assembler output.
 53   NOT_PRODUCT(DbgStrings _dbg_strings;)   // Debug strings used in generated code.
 54 
 55  public:
 56   // Initialization/finalization
 57   void    initialize(int size)                   { _size = size; }
 58   void    finalize()                             { ShouldNotCallThis(); }
 59 
 60   // General info/converters
 61   int     size() const                           { return _size; }
 62   static  int code_size_to_size(int code_size)   { return align_up((int)sizeof(InterpreterCodelet), CodeEntryAlignment) + code_size; }
 63 
 64   // Code info
 65   address code_begin() const                     { return (address)this + align_up(sizeof(InterpreterCodelet), CodeEntryAlignment); }
 66   address code_end() const                       { return (address)this + size(); }
 67 
 68   // Debugging
 69   void    verify();
 70   void    print_on(outputStream* st) const;
 71   void    print() const;
 72 
 73   // Interpreter-specific initialization
 74   void    initialize(const char* description, Bytecodes::Code bytecode);
 75 
 76   // Interpreter-specific attributes
 77   int         code_size() const                  { return code_end() - code_begin(); }

 78   const char* description() const                { return _description; }
 79   Bytecodes::Code bytecode() const               { return _bytecode; }
 80 #ifndef PRODUCT
 81  ~InterpreterCodelet() {
 82     // InterpreterCodelets reside in the StubQueue and should not be deleted,
 83     // nor are they ever finalized (see above).
 84     ShouldNotCallThis();
 85   }
 86   void use_remarks(AsmRemarks &remarks) { _asm_remarks.share(remarks); }
 87   void use_strings(DbgStrings &strings) { _dbg_strings.share(strings); }
 88 #endif
 89 };
 90 
 91 // Define a prototype interface
 92 DEF_STUB_INTERFACE(InterpreterCodelet);
 93 
 94 
 95 //------------------------------------------------------------------------------------------------------------------------
 96 // A CodeletMark serves as an automatic creator/initializer for Codelets
 97 // (As a subclass of ResourceMark it automatically GC's the allocated

101  private:
102   InterpreterCodelet*         _clet;
103   InterpreterMacroAssembler** _masm;
104   CodeBuffer                  _cb;
105 
106   int codelet_size() {
107     // Request the whole code buffer (minus a little for alignment).
108     // The commit call below trims it back for each codelet.
109     int codelet_size = AbstractInterpreter::code()->available_space() - 2*K;
110 
111     // Guarantee there's a little bit of code space left.
112     guarantee(codelet_size > 0 && (size_t)codelet_size > 2*K,
113               "not enough space for interpreter generation");
114 
115     return codelet_size;
116   }
117 
118  public:
119   CodeletMark(InterpreterMacroAssembler*& masm,
120               const char* description,

121               Bytecodes::Code bytecode = Bytecodes::_illegal);
122   ~CodeletMark();
123 };
124 
125 // Wrapper typedef to use the name Interpreter to mean either
126 // the Zero interpreter or the template interpreter.
127 
128 typedef ZERO_ONLY(ZeroInterpreter) NOT_ZERO(TemplateInterpreter) Interpreter;
129 
130 #endif // SHARE_INTERPRETER_INTERPRETER_HPP

 28 #include "code/stubs.hpp"
 29 #include "interpreter/interp_masm.hpp"
 30 #include "interpreter/templateInterpreter.hpp"
 31 #include "interpreter/zero/zeroInterpreter.hpp"
 32 #include "memory/resourceArea.hpp"
 33 #include "utilities/align.hpp"
 34 
 35 // This file contains the platform-independent parts
 36 // of the interpreter and the interpreter generator.
 37 
 38 class InterpreterMacroAssembler;
 39 
 40 //------------------------------------------------------------------------------------------------------------------------
 41 // An InterpreterCodelet is a piece of interpreter code. All
 42 // interpreter code is generated into little codelets which
 43 // contain extra information for debugging and printing purposes.
 44 
 45 class InterpreterCodelet: public Stub {
 46   friend class VMStructs;
 47   friend class CodeCacheDumper; // possible extension [do not remove]
 48  public:
 49   enum Kind {
 50     codelet_other, codelet_bytecode, codelet_method_entry, codelet_safepoint_entry
 51   };
 52  private:
 53   int         _size;                      // the size in bytes
 54   Kind        _kind;
 55   const char* _description;               // a description of the codelet, for debugging & printing
 56   Bytecodes::Code _bytecode;              // associated bytecode if any
 57   NOT_PRODUCT(AsmRemarks _asm_remarks;)   // Comments for annotating assembler output.
 58   NOT_PRODUCT(DbgStrings _dbg_strings;)   // Debug strings used in generated code.
 59 
 60  public:
 61   // Initialization/finalization
 62   void    initialize(int size)                   { _size = size; }
 63   void    finalize()                             { ShouldNotCallThis(); }
 64 
 65   // General info/converters
 66   int     size() const                           { return _size; }
 67   static  int code_size_to_size(int code_size)   { return align_up((int)sizeof(InterpreterCodelet), CodeEntryAlignment) + code_size; }
 68 
 69   // Code info
 70   address code_begin() const                     { return (address)this + align_up(sizeof(InterpreterCodelet), CodeEntryAlignment); }
 71   address code_end() const                       { return (address)this + size(); }
 72 
 73   // Debugging
 74   void    verify();
 75   void    print_on(outputStream* st) const;
 76   void    print() const;
 77 
 78   // Interpreter-specific initialization
 79   void    initialize(const char* description, Kind kind, Bytecodes::Code bytecode);
 80 
 81   // Interpreter-specific attributes
 82   int         code_size() const                  { return code_end() - code_begin(); }
 83   Kind kind() const                              { return _kind; }
 84   const char* description() const                { return _description; }
 85   Bytecodes::Code bytecode() const               { return _bytecode; }
 86 #ifndef PRODUCT
 87  ~InterpreterCodelet() {
 88     // InterpreterCodelets reside in the StubQueue and should not be deleted,
 89     // nor are they ever finalized (see above).
 90     ShouldNotCallThis();
 91   }
 92   void use_remarks(AsmRemarks &remarks) { _asm_remarks.share(remarks); }
 93   void use_strings(DbgStrings &strings) { _dbg_strings.share(strings); }
 94 #endif
 95 };
 96 
 97 // Define a prototype interface
 98 DEF_STUB_INTERFACE(InterpreterCodelet);
 99 
100 
101 //------------------------------------------------------------------------------------------------------------------------
102 // A CodeletMark serves as an automatic creator/initializer for Codelets
103 // (As a subclass of ResourceMark it automatically GC's the allocated

107  private:
108   InterpreterCodelet*         _clet;
109   InterpreterMacroAssembler** _masm;
110   CodeBuffer                  _cb;
111 
112   int codelet_size() {
113     // Request the whole code buffer (minus a little for alignment).
114     // The commit call below trims it back for each codelet.
115     int codelet_size = AbstractInterpreter::code()->available_space() - 2*K;
116 
117     // Guarantee there's a little bit of code space left.
118     guarantee(codelet_size > 0 && (size_t)codelet_size > 2*K,
119               "not enough space for interpreter generation");
120 
121     return codelet_size;
122   }
123 
124  public:
125   CodeletMark(InterpreterMacroAssembler*& masm,
126               const char* description,
127               InterpreterCodelet::Kind kind = InterpreterCodelet::codelet_other,
128               Bytecodes::Code bytecode = Bytecodes::_illegal);
129   ~CodeletMark();
130 };
131 
132 // Wrapper typedef to use the name Interpreter to mean either
133 // the Zero interpreter or the template interpreter.
134 
135 typedef ZERO_ONLY(ZeroInterpreter) NOT_ZERO(TemplateInterpreter) Interpreter;
136 
137 #endif // SHARE_INTERPRETER_INTERPRETER_HPP
< prev index next >