< prev index next >

src/hotspot/share/code/codeBlob.hpp

Print this page

  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_CODE_CODEBLOB_HPP
 26 #define SHARE_CODE_CODEBLOB_HPP
 27 
 28 #include "asm/codeBuffer.hpp"

 29 #include "compiler/compilerDefinitions.hpp"
 30 #include "compiler/oopMap.hpp"
 31 #include "runtime/javaFrameAnchor.hpp"
 32 #include "runtime/frame.hpp"
 33 #include "runtime/handles.hpp"
 34 #include "utilities/align.hpp"
 35 #include "utilities/macros.hpp"
 36 
 37 class ImmutableOopMap;
 38 class ImmutableOopMapSet;
 39 class JNIHandleBlock;
 40 class OopMapSet;
 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)

158 
159   static const Vptr* vptr(CodeBlobKind kind);
160   const Vptr* vptr() const;
161 
162   CodeBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size, uint16_t header_size,
163            int16_t frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments,
164            int mutable_data_size);
165 
166   // Simple CodeBlob used for simple BufferBlob.
167   CodeBlob(const char* name, CodeBlobKind kind, int size, uint16_t header_size);
168 
169 
170   void operator delete(void* p) { }
171 
172   void prepare_for_archiving_impl();
173   void post_restore_impl();
174 
175 public:
176 
177   ~CodeBlob() {
178     assert(_oop_maps == nullptr, "Not flushed");
179   }
180 
181   // Returns the space needed for CodeBlob
182   static unsigned int allocation_size(CodeBuffer* cb, int header_size);
183   static unsigned int align_code_offset(int offset);
184 
185   // Deletion
186   void purge();
187 
188   // Typing
189   bool is_nmethod() const                     { return _kind == CodeBlobKind::Nmethod; }
190   bool is_buffer_blob() const                 { return _kind == CodeBlobKind::Buffer; }
191   bool is_runtime_stub() const                { return _kind == CodeBlobKind::RuntimeStub; }
192   bool is_deoptimization_stub() const         { return _kind == CodeBlobKind::Deoptimization; }
193 #ifdef COMPILER2
194   bool is_uncommon_trap_stub() const          { return _kind == CodeBlobKind::UncommonTrap; }
195   bool is_exception_stub() const              { return _kind == CodeBlobKind::Exception; }
196 #else
197   bool is_uncommon_trap_stub() const          { return false; }
198   bool is_exception_stub() const              { return false; }

301   DbgStrings &dbg_strings() { return _dbg_strings; }
302 
303   void use_remarks(AsmRemarks &remarks) { _asm_remarks.share(remarks); }
304   void use_strings(DbgStrings &strings) { _dbg_strings.share(strings); }
305 #endif
306 
307   void copy_to(address buffer) {
308     memcpy(buffer, this, this->size());
309   }
310 
311   // methods to archive a blob into AOT code cache
312   void prepare_for_archiving();
313   static void archive_blob(CodeBlob* blob, address archive_buffer);
314 
315   // methods to restore a blob from AOT code cache into the CodeCache
316   void post_restore();
317   CodeBlob* restore(address code_cache_buffer, const char* name, address archived_reloc_data, ImmutableOopMapSet* archived_oop_maps);
318   static CodeBlob* create(CodeBlob* archived_blob,
319                           const char* name,
320                           address archived_reloc_data,
321                           ImmutableOopMapSet* archived_oop_maps
322 #ifndef PRODUCT
323                           , AsmRemarks& archived_asm_remarks
324                           , DbgStrings& archived_dbg_strings
325 #endif // PRODUCT
326                          );
327 };
328 
329 //----------------------------------------------------------------------------------------------------
330 // RuntimeBlob: used for non-compiled method code (adapters, stubs, blobs)
331 
332 class RuntimeBlob : public CodeBlob {
333   friend class VMStructs;
334  public:
335 
336   // Creation
337   // a) simple CodeBlob
338   RuntimeBlob(const char* name, CodeBlobKind kind, int size, uint16_t header_size)
339     : CodeBlob(name, kind, size, header_size)
340   {}
341 
342   // b) full CodeBlob
343   // frame_complete is the offset from the beginning of the instructions
344   // to where the frame setup (from stackwalk viewpoint) is complete.
345   RuntimeBlob(
346     const char* name,

  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_CODE_CODEBLOB_HPP
 26 #define SHARE_CODE_CODEBLOB_HPP
 27 
 28 #include "asm/codeBuffer.hpp"
 29 #include "code/aotCodeCache.hpp"
 30 #include "compiler/compilerDefinitions.hpp"
 31 #include "compiler/oopMap.hpp"
 32 #include "runtime/javaFrameAnchor.hpp"
 33 #include "runtime/frame.hpp"
 34 #include "runtime/handles.hpp"
 35 #include "utilities/align.hpp"
 36 #include "utilities/macros.hpp"
 37 
 38 class ImmutableOopMap;
 39 class ImmutableOopMapSet;
 40 class JNIHandleBlock;
 41 class OopMapSet;
 42 
 43 // CodeBlob Types
 44 // Used in the CodeCache to assign CodeBlobs to different CodeHeaps
 45 enum class CodeBlobType {
 46   MethodNonProfiled   = 0,    // Execution level 1 and 4 (non-profiled) nmethods (including native nmethods)
 47   MethodProfiled      = 1,    // Execution level 2 and 3 (profiled) nmethods
 48   NonNMethod          = 2,    // Non-nmethods like Buffers, Adapters and Runtime Stubs
 49   All                 = 3,    // All types (No code cache segmentation)

159 
160   static const Vptr* vptr(CodeBlobKind kind);
161   const Vptr* vptr() const;
162 
163   CodeBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size, uint16_t header_size,
164            int16_t frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments,
165            int mutable_data_size);
166 
167   // Simple CodeBlob used for simple BufferBlob.
168   CodeBlob(const char* name, CodeBlobKind kind, int size, uint16_t header_size);
169 
170 
171   void operator delete(void* p) { }
172 
173   void prepare_for_archiving_impl();
174   void post_restore_impl();
175 
176 public:
177 
178   ~CodeBlob() {
179     assert(_oop_maps == nullptr || AOTCodeCache::is_address_in_aot_cache((address)_oop_maps), "Not flushed");
180   }
181 
182   // Returns the space needed for CodeBlob
183   static unsigned int allocation_size(CodeBuffer* cb, int header_size);
184   static unsigned int align_code_offset(int offset);
185 
186   // Deletion
187   void purge();
188 
189   // Typing
190   bool is_nmethod() const                     { return _kind == CodeBlobKind::Nmethod; }
191   bool is_buffer_blob() const                 { return _kind == CodeBlobKind::Buffer; }
192   bool is_runtime_stub() const                { return _kind == CodeBlobKind::RuntimeStub; }
193   bool is_deoptimization_stub() const         { return _kind == CodeBlobKind::Deoptimization; }
194 #ifdef COMPILER2
195   bool is_uncommon_trap_stub() const          { return _kind == CodeBlobKind::UncommonTrap; }
196   bool is_exception_stub() const              { return _kind == CodeBlobKind::Exception; }
197 #else
198   bool is_uncommon_trap_stub() const          { return false; }
199   bool is_exception_stub() const              { return false; }

302   DbgStrings &dbg_strings() { return _dbg_strings; }
303 
304   void use_remarks(AsmRemarks &remarks) { _asm_remarks.share(remarks); }
305   void use_strings(DbgStrings &strings) { _dbg_strings.share(strings); }
306 #endif
307 
308   void copy_to(address buffer) {
309     memcpy(buffer, this, this->size());
310   }
311 
312   // methods to archive a blob into AOT code cache
313   void prepare_for_archiving();
314   static void archive_blob(CodeBlob* blob, address archive_buffer);
315 
316   // methods to restore a blob from AOT code cache into the CodeCache
317   void post_restore();
318   CodeBlob* restore(address code_cache_buffer, const char* name, address archived_reloc_data, ImmutableOopMapSet* archived_oop_maps);
319   static CodeBlob* create(CodeBlob* archived_blob,
320                           const char* name,
321                           address archived_reloc_data,
322                           ImmutableOopMapSet* archived_oop_maps);





323 };
324 
325 //----------------------------------------------------------------------------------------------------
326 // RuntimeBlob: used for non-compiled method code (adapters, stubs, blobs)
327 
328 class RuntimeBlob : public CodeBlob {
329   friend class VMStructs;
330  public:
331 
332   // Creation
333   // a) simple CodeBlob
334   RuntimeBlob(const char* name, CodeBlobKind kind, int size, uint16_t header_size)
335     : CodeBlob(name, kind, size, header_size)
336   {}
337 
338   // b) full CodeBlob
339   // frame_complete is the offset from the beginning of the instructions
340   // to where the frame setup (from stackwalk viewpoint) is complete.
341   RuntimeBlob(
342     const char* name,
< prev index next >