src/share/vm/interpreter/interpreter.hpp

Print this page
rev 6670 : 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
Reviewed-by: lfoltan, coleenp, dholmes
   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  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_INTERPRETER_INTERPRETER_HPP
  26 #define SHARE_VM_INTERPRETER_INTERPRETER_HPP
  27 
  28 #include "code/stubs.hpp"
  29 #include "interpreter/cppInterpreter.hpp"
  30 #include "interpreter/templateInterpreter.hpp"
  31 #ifdef ZERO
  32 #ifdef TARGET_ARCH_zero
  33 # include "entry_zero.hpp"
  34 #endif
  35 #endif
  36 
  37 // This file contains the platform-independent parts
  38 // of the interpreter and the interpreter generator.
  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  private:
  48   int         _size;                             // the size in bytes
  49   const char* _description;                      // a description of the codelet, for debugging & printing
  50   Bytecodes::Code _bytecode;                     // associated bytecode if any
  51   DEBUG_ONLY(CodeStrings _strings;)              // Comments for annotating assembler output.
  52 
  53  public:
  54   // Initialization/finalization
  55   void    initialize(int size,
  56                      CodeStrings& strings)       { _size = size; DEBUG_ONLY(_strings.assign(strings);) }
  57   void    finalize()                             { ShouldNotCallThis(); }
  58 
  59   // General info/converters


  82 DEF_STUB_INTERFACE(InterpreterCodelet);
  83 
  84 
  85 //------------------------------------------------------------------------------------------------------------------------
  86 // A CodeletMark serves as an automatic creator/initializer for Codelets
  87 // (As a subclass of ResourceMark it automatically GC's the allocated
  88 // code buffer and assemblers).
  89 
  90 class CodeletMark: ResourceMark {
  91  private:
  92   InterpreterCodelet*         _clet;
  93   InterpreterMacroAssembler** _masm;
  94   CodeBuffer                  _cb;
  95 
  96   int codelet_size() {
  97     // Request the whole code buffer (minus a little for alignment).
  98     // The commit call below trims it back for each codelet.
  99     int codelet_size = AbstractInterpreter::code()->available_space() - 2*K;
 100 
 101     // Guarantee there's a little bit of code space left.
 102     guarantee (codelet_size > 0 && (size_t)codelet_size >  2*K,
 103                "not enough space for interpreter generation");
 104 
 105     return codelet_size;
 106   }
 107 
 108  public:
 109   CodeletMark(
 110     InterpreterMacroAssembler*& masm,
 111     const char* description,
 112     Bytecodes::Code bytecode = Bytecodes::_illegal):
 113     _clet((InterpreterCodelet*)AbstractInterpreter::code()->request(codelet_size())),
 114     _cb(_clet->code_begin(), _clet->code_size())
 115 
 116   { // request all space (add some slack for Codelet data)
 117     assert (_clet != NULL, "we checked not enough space already");
 118 
 119     // initialize Codelet attributes
 120     _clet->initialize(description, bytecode);
 121     // create assembler for code generation
 122     masm  = new InterpreterMacroAssembler(&_cb);
 123     _masm = &masm;
 124   }
 125 
 126   ~CodeletMark() {
 127     // align so printing shows nop's instead of random code at the end (Codelets are aligned)
 128     (*_masm)->align(wordSize);
 129     // make sure all code is in code buffer
 130     (*_masm)->flush();
 131 
 132 
 133     // commit Codelet
 134     AbstractInterpreter::code()->commit((*_masm)->code()->pure_insts_size(), (*_masm)->code()->strings());
 135     // make sure nobody can use _masm outside a CodeletMark lifespan
 136     *_masm = NULL;
 137   }
 138 };
 139 
 140 // Wrapper classes to produce Interpreter/InterpreterGenerator from either
 141 // the c++ interpreter or the template interpreter.
 142 
 143 class Interpreter: public CC_INTERP_ONLY(CppInterpreter) NOT_CC_INTERP(TemplateInterpreter) {
 144 
 145   public:
 146   // Debugging/printing
 147   static InterpreterCodelet* codelet_containing(address pc)     { return (InterpreterCodelet*)_code->stub_containing(pc); }

 148 #ifdef TARGET_ARCH_x86
 149 # include "interpreter_x86.hpp"
 150 #endif
 151 #ifdef TARGET_ARCH_sparc
 152 # include "interpreter_sparc.hpp"
 153 #endif
 154 #ifdef TARGET_ARCH_zero
 155 # include "interpreter_zero.hpp"
 156 #endif
 157 #ifdef TARGET_ARCH_arm
 158 # include "interpreter_arm.hpp"
 159 #endif
 160 #ifdef TARGET_ARCH_ppc
 161 # include "interpreter_ppc.hpp"
 162 #endif
 163 
 164 };
 165 
 166 #endif // SHARE_VM_INTERPRETER_INTERPRETER_HPP
   1 /*
   2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  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_INTERPRETER_INTERPRETER_HPP
  26 #define SHARE_VM_INTERPRETER_INTERPRETER_HPP
  27 
  28 #include "code/stubs.hpp"
  29 #include "interpreter/cppInterpreter.hpp"
  30 #include "interpreter/templateInterpreter.hpp"
  31 #ifdef ZERO
  32 #ifdef TARGET_ARCH_zero
  33 # include "entry_zero.hpp"
  34 #endif
  35 #endif
  36 
  37 // This file contains the platform-independent parts
  38 // of the interpreter and the interpreter generator.
  39 
  40 class InterpreterMacroAssembler;
  41 
  42 //------------------------------------------------------------------------------------------------------------------------
  43 // An InterpreterCodelet is a piece of interpreter code. All
  44 // interpreter code is generated into little codelets which
  45 // contain extra information for debugging and printing purposes.
  46 
  47 class InterpreterCodelet: public Stub {
  48   friend class VMStructs;
  49  private:
  50   int         _size;                             // the size in bytes
  51   const char* _description;                      // a description of the codelet, for debugging & printing
  52   Bytecodes::Code _bytecode;                     // associated bytecode if any
  53   DEBUG_ONLY(CodeStrings _strings;)              // Comments for annotating assembler output.
  54 
  55  public:
  56   // Initialization/finalization
  57   void    initialize(int size,
  58                      CodeStrings& strings)       { _size = size; DEBUG_ONLY(_strings.assign(strings);) }
  59   void    finalize()                             { ShouldNotCallThis(); }
  60 
  61   // General info/converters


  84 DEF_STUB_INTERFACE(InterpreterCodelet);
  85 
  86 
  87 //------------------------------------------------------------------------------------------------------------------------
  88 // A CodeletMark serves as an automatic creator/initializer for Codelets
  89 // (As a subclass of ResourceMark it automatically GC's the allocated
  90 // code buffer and assemblers).
  91 
  92 class CodeletMark: ResourceMark {
  93  private:
  94   InterpreterCodelet*         _clet;
  95   InterpreterMacroAssembler** _masm;
  96   CodeBuffer                  _cb;
  97 
  98   int codelet_size() {
  99     // Request the whole code buffer (minus a little for alignment).
 100     // The commit call below trims it back for each codelet.
 101     int codelet_size = AbstractInterpreter::code()->available_space() - 2*K;
 102 
 103     // Guarantee there's a little bit of code space left.
 104     guarantee(codelet_size > 0 && (size_t)codelet_size > 2*K,
 105               "not enough space for interpreter generation");
 106 
 107     return codelet_size;
 108   }
 109 
 110  public:
 111   CodeletMark(InterpreterMacroAssembler*& masm,

 112               const char* description,
 113               Bytecodes::Code bytecode = Bytecodes::_illegal);
 114   ~CodeletMark();
























 115 };
 116 
 117 // Wrapper classes to produce Interpreter/InterpreterGenerator from either
 118 // the c++ interpreter or the template interpreter.
 119 
 120 class Interpreter: public CC_INTERP_ONLY(CppInterpreter) NOT_CC_INTERP(TemplateInterpreter) {
 121 
 122  public:
 123   // Debugging/printing
 124   static InterpreterCodelet* codelet_containing(address pc) { return (InterpreterCodelet*)_code->stub_containing(pc); }
 125 
 126 #ifdef TARGET_ARCH_x86
 127 # include "interpreter_x86.hpp"
 128 #endif
 129 #ifdef TARGET_ARCH_sparc
 130 # include "interpreter_sparc.hpp"
 131 #endif
 132 #ifdef TARGET_ARCH_zero
 133 # include "interpreter_zero.hpp"
 134 #endif
 135 #ifdef TARGET_ARCH_arm
 136 # include "interpreter_arm.hpp"
 137 #endif
 138 #ifdef TARGET_ARCH_ppc
 139 # include "interpreter_ppc.hpp"
 140 #endif
 141 
 142 };
 143 
 144 #endif // SHARE_VM_INTERPRETER_INTERPRETER_HPP