1 /*
  2  * Copyright (c) 1998, 2024, 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_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)
 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
106   ImmutableOopMapSet* _oop_maps;                 // OopMap for this CodeBlob
107   const char*         _name;
108 
109   int        _size;                              // total size of CodeBlob in bytes
110   int        _header_size;                       // size of header (depends on subclass)
111   int        _relocation_size;                   // size of relocation
112   int        _content_offset;                    // offset to where content region begins (this includes consts, insts, stubs)
113   int        _code_offset;                       // offset to where instructions region begins (this includes insts, stubs)
114   int        _frame_complete_offset;             // instruction offsets in [0.._frame_complete_offset) have
115                                                  // not finished setting up their frame. Beware of pc's in
116                                                  // that range. There is a similar range(s) on returns
117                                                  // which we don't detect.
118   int        _data_offset;                       // offset to where data region begins
119   int        _frame_size;                        // size of stack frame in words (NOT slots. On x64 these are 64bit words)
120 
121   S390_ONLY(int       _ctable_offset;)
122 
123   CodeBlobKind        _kind;                     // Kind of this code blob
124 
125   bool                _caller_must_gc_arguments;
126 
127 #ifndef PRODUCT
128   AsmRemarks _asm_remarks;
129   DbgStrings _dbg_strings;
130 #endif // not PRODUCT
131 
132   DEBUG_ONLY( void verify_parameters() );
133 
134   CodeBlob(const char* name, CodeBlobKind kind, int size, int header_size, int relocation_size,
135            int content_offset, int code_offset, int data_offset, int frame_complete_offset,
136            int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments);
137 
138   CodeBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size, int header_size,
139            int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments);
140 
141   // Simple CodeBlob used for simple BufferBlob.
142   CodeBlob(const char* name, CodeBlobKind kind, int size, int header_size);
143 
144   void operator delete(void* p) { }
145 
146 public:
147 
148   virtual ~CodeBlob() {
149     assert(_oop_maps == nullptr, "Not flushed");
150   }
151 
152   // Returns the space needed for CodeBlob
153   static unsigned int allocation_size(CodeBuffer* cb, int header_size);
154   static unsigned int align_code_offset(int offset);
155 
156   // Deletion
157   virtual void purge(bool free_code_cache_data, bool unregister_nmethod);
158 
159   // Typing
160   bool is_nmethod() const                     { return _kind == CodeBlobKind::Nmethod; }
161   bool is_buffer_blob() const                 { return _kind == CodeBlobKind::Buffer; }
162   bool is_runtime_stub() const                { return _kind == CodeBlobKind::Runtime_Stub; }
163   bool is_deoptimization_stub() const         { return _kind == CodeBlobKind::Deoptimization; }
164   bool is_uncommon_trap_stub() const          { return _kind == CodeBlobKind::Uncommon_Trap; }
165   bool is_exception_stub() const              { return _kind == CodeBlobKind::Exception; }
166   bool is_safepoint_stub() const              { return _kind == CodeBlobKind::Safepoint; }
167   bool is_adapter_blob() const                { return _kind == CodeBlobKind::Adapter; }
168   bool is_vtable_blob() const                 { return _kind == CodeBlobKind::Vtable; }
169   bool is_method_handles_adapter_blob() const { return _kind == CodeBlobKind::MH_Adapter; }
170   bool is_buffered_inline_type_blob() const   { return _kind == CodeBlobKind::BufferedInlineType; }
171   bool is_upcall_stub() const                 { return _kind == CodeBlobKind::Upcall; }
172 
173   // Casting
174   nmethod* as_nmethod_or_null()               { return is_nmethod() ? (nmethod*) this : nullptr; }
175   nmethod* as_nmethod()                       { assert(is_nmethod(), "must be nmethod"); return (nmethod*) this; }
176   CodeBlob* as_codeblob_or_null() const       { return (CodeBlob*) this; }
177   UpcallStub* as_upcall_stub() const          { assert(is_upcall_stub(), "must be upcall stub"); return (UpcallStub*) this; }
178   RuntimeStub* as_runtime_stub() const        { assert(is_runtime_stub(), "must be runtime blob"); return (RuntimeStub*) this; }
179 
180   // Boundaries
181   address    header_begin() const             { return (address)    this; }
182   address    header_end() const               { return ((address)   this) + _header_size; }
183   relocInfo* relocation_begin() const         { return (relocInfo*) header_end(); }
184   relocInfo* relocation_end() const           { return (relocInfo*)(header_end()   + _relocation_size); }
185   address    content_begin() const            { return (address)    header_begin() + _content_offset; }
186   address    content_end() const              { return (address)    header_begin() + _data_offset; }
187   address    code_begin() const               { return (address)    header_begin() + _code_offset; }
188   // code_end == content_end is true for all types of blobs for now, it is also checked in the constructor
189   address    code_end() const                 { return (address)    header_begin() + _data_offset; }
190   address    data_begin() const               { return (address)    header_begin() + _data_offset; }
191   address    data_end() const                 { return (address)    header_begin() + _size; }
192 
193   // Offsets
194   int content_offset() const                  { return _content_offset; }
195   int code_offset() const                     { return _code_offset; }
196   int data_offset() const                     { return _data_offset; }
197 
198   // This field holds the beginning of the const section in the old code buffer.
199   // It is needed to fix relocations of pc-relative loads when resizing the
200   // the constant pool or moving it.
201   S390_ONLY(address ctable_begin() const { return header_begin() + _ctable_offset; })
202   void set_ctable_begin(address ctable) { S390_ONLY(_ctable_offset = ctable - header_begin();) }
203 
204   // Sizes
205   int size() const               { return _size; }
206   int header_size() const        { return _header_size; }
207   int relocation_size() const    { return pointer_delta_as_int((address) relocation_end(), (address) relocation_begin()); }
208   int content_size() const       { return pointer_delta_as_int(content_end(), content_begin()); }
209   int code_size() const          { return pointer_delta_as_int(code_end(), code_begin()); }
210 
211   // Only used from CodeCache::free_unused_tail() after the Interpreter blob was trimmed
212   void adjust_size(size_t used) {
213     _size = (int)used;
214     _data_offset = (int)used;
215   }
216 
217   // Containment
218   bool blob_contains(address addr) const         { return header_begin()       <= addr && addr < data_end();       }
219   bool code_contains(address addr) const         { return code_begin()         <= addr && addr < code_end();       }
220   bool contains(address addr) const              { return content_begin()      <= addr && addr < content_end();    }
221   bool is_frame_complete_at(address addr) const  { return _frame_complete_offset != CodeOffsets::frame_never_safe &&
222                                                           code_contains(addr) && addr >= code_begin() + _frame_complete_offset; }
223   int frame_complete_offset() const              { return _frame_complete_offset; }
224 
225   // OopMap for frame
226   ImmutableOopMapSet* oop_maps() const           { return _oop_maps; }
227   void set_oop_maps(OopMapSet* p);
228 
229   const ImmutableOopMap* oop_map_for_slot(int slot, address return_address) const;
230   const ImmutableOopMap* oop_map_for_return_address(address return_address) const;
231   virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) = 0;
232 
233   // Frame support. Sizes are in word units.
234   int  frame_size() const                        { return _frame_size; }
235   void set_frame_size(int size)                  { _frame_size = size; }
236 
237   // Returns true, if the next frame is responsible for GC'ing oops passed as arguments
238   bool caller_must_gc_arguments(JavaThread* thread) const { return _caller_must_gc_arguments; }
239 
240   // Naming
241   const char* name() const                       { return _name; }
242   void set_name(const char* name)                { _name = name; }
243 
244   // Debugging
245   virtual void verify() = 0;
246   virtual void print() const;
247   virtual void print_on(outputStream* st) const;
248   virtual void print_value_on(outputStream* st) const;
249   void dump_for_addr(address addr, outputStream* st, bool verbose) const;
250   void print_code_on(outputStream* st);
251 
252   // Print to stream, any comments associated with offset.
253   virtual void print_block_comment(outputStream* stream, address block_begin) const {
254 #ifndef PRODUCT
255     ptrdiff_t offset = block_begin - code_begin();
256     assert(offset >= 0, "Expecting non-negative offset!");
257     _asm_remarks.print(uint(offset), stream);
258 #endif
259   }
260 
261 #ifndef PRODUCT
262   AsmRemarks &asm_remarks() { return _asm_remarks; }
263   DbgStrings &dbg_strings() { return _dbg_strings; }
264 
265   void use_remarks(AsmRemarks &remarks) { _asm_remarks.share(remarks); }
266   void use_strings(DbgStrings &strings) { _dbg_strings.share(strings); }
267 #endif
268 };
269 
270 //----------------------------------------------------------------------------------------------------
271 // RuntimeBlob: used for non-compiled method code (adapters, stubs, blobs)
272 
273 class RuntimeBlob : public CodeBlob {
274   friend class VMStructs;
275  public:
276 
277   // Creation
278   // a) simple CodeBlob
279   RuntimeBlob(const char* name, CodeBlobKind kind, int size, int header_size)
280     : CodeBlob(name, kind, size, header_size)
281   {}
282 
283   // b) full CodeBlob
284   // frame_complete is the offset from the beginning of the instructions
285   // to where the frame setup (from stackwalk viewpoint) is complete.
286   RuntimeBlob(
287     const char* name,
288     CodeBlobKind kind,
289     CodeBuffer* cb,
290     int         size,
291     int         header_size,
292     int         frame_complete,
293     int         frame_size,
294     OopMapSet*  oop_maps,
295     bool        caller_must_gc_arguments = false
296   );
297 
298   static void free(RuntimeBlob* blob);
299 
300   // Deal with Disassembler, VTune, Forte, JvmtiExport, MemoryService.
301   static void trace_new_stub(RuntimeBlob* blob, const char* name1, const char* name2 = "");
302 };
303 
304 class WhiteBox;
305 //----------------------------------------------------------------------------------------------------
306 // BufferBlob: used to hold non-relocatable machine code such as the interpreter, stubroutines, etc.
307 
308 class BufferBlob: public RuntimeBlob {
309   friend class VMStructs;
310   friend class AdapterBlob;
311   friend class VtableBlob;
312   friend class MethodHandlesAdapterBlob;
313   friend class BufferedInlineTypeBlob;
314   friend class UpcallStub;
315   friend class WhiteBox;
316 
317  private:
318   // Creation support
319   BufferBlob(const char* name, CodeBlobKind kind, int size);
320   BufferBlob(const char* name, CodeBlobKind kind, CodeBuffer* cb, int size, int header_size);
321   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);
322 
323   void* operator new(size_t s, unsigned size) throw();
324 
325  public:
326   // Creation
327   static BufferBlob* create(const char* name, uint buffer_size);
328   static BufferBlob* create(const char* name, CodeBuffer* cb);
329 
330   static void free(BufferBlob* buf);
331 
332   // GC/Verification support
333   void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) override { /* nothing to do */ }
334 
335   void verify() override;
336   void print_on(outputStream* st) const override;
337   void print_value_on(outputStream* st) const override;
338 };
339 
340 
341 //----------------------------------------------------------------------------------------------------
342 // AdapterBlob: used to hold C2I/I2C adapters
343 
344 class AdapterBlob: public BufferBlob {
345 private:
346   AdapterBlob(int size, CodeBuffer* cb, int frame_complete, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments = false);
347 
348 public:
349   // Creation
350   static AdapterBlob* create(CodeBuffer* cb,
351                              int frame_complete,
352                              int frame_size,
353                              OopMapSet* oop_maps,
354                              bool caller_must_gc_arguments = false);
355 
356   bool caller_must_gc_arguments(JavaThread* thread) const { return true; }
357 };
358 
359 //---------------------------------------------------------------------------------------------------
360 class VtableBlob: public BufferBlob {
361 private:
362   VtableBlob(const char*, int);
363 
364   void* operator new(size_t s, unsigned size) throw();
365 
366 public:
367   // Creation
368   static VtableBlob* create(const char* name, int buffer_size);
369 };
370 
371 //----------------------------------------------------------------------------------------------------
372 // MethodHandlesAdapterBlob: used to hold MethodHandles adapters
373 
374 class MethodHandlesAdapterBlob: public BufferBlob {
375 private:
376   MethodHandlesAdapterBlob(int size): BufferBlob("MethodHandles adapters", CodeBlobKind::MH_Adapter, size) {}
377 
378 public:
379   // Creation
380   static MethodHandlesAdapterBlob* create(int buffer_size);
381 };
382 
383 //----------------------------------------------------------------------------------------------------
384 // BufferedInlineTypeBlob : used for pack/unpack handlers
385 
386 class BufferedInlineTypeBlob: public BufferBlob {
387 private:
388   const int _pack_fields_off;
389   const int _pack_fields_jobject_off;
390   const int _unpack_fields_off;
391 
392   BufferedInlineTypeBlob(int size, CodeBuffer* cb, int pack_fields_off, int pack_fields_jobject_off, int unpack_fields_off);
393 
394 public:
395   // Creation
396   static BufferedInlineTypeBlob* create(CodeBuffer* cb, int pack_fields_off, int pack_fields_jobject_off, int unpack_fields_off);
397 
398   address pack_fields() const { return code_begin() + _pack_fields_off; }
399   address pack_fields_jobject() const { return code_begin() + _pack_fields_jobject_off; }
400   address unpack_fields() const { return code_begin() + _unpack_fields_off; }
401 };
402 
403 //----------------------------------------------------------------------------------------------------
404 // RuntimeStub: describes stubs used by compiled code to call a (static) C++ runtime routine
405 
406 class RuntimeStub: public RuntimeBlob {
407   friend class VMStructs;
408  private:
409   // Creation support
410   RuntimeStub(
411     const char* name,
412     CodeBuffer* cb,
413     int         size,
414     int         frame_complete,
415     int         frame_size,
416     OopMapSet*  oop_maps,
417     bool        caller_must_gc_arguments
418   );
419 
420   void* operator new(size_t s, unsigned size) throw();
421 
422  public:
423   // Creation
424   static RuntimeStub* new_runtime_stub(
425     const char* stub_name,
426     CodeBuffer* cb,
427     int         frame_complete,
428     int         frame_size,
429     OopMapSet*  oop_maps,
430     bool        caller_must_gc_arguments,
431     bool        alloc_fail_is_fatal=true
432   );
433 
434   static void free(RuntimeStub* stub) { RuntimeBlob::free(stub); }
435 
436   address entry_point() const                    { return code_begin(); }
437 
438   // GC/Verification support
439   void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) override { /* nothing to do */ }
440 
441   void verify() override;
442   void print_on(outputStream* st) const override;
443   void print_value_on(outputStream* st) const override;
444 };
445 
446 
447 //----------------------------------------------------------------------------------------------------
448 // Super-class for all blobs that exist in only one instance. Implements default behaviour.
449 
450 class SingletonBlob: public RuntimeBlob {
451   friend class VMStructs;
452 
453  protected:
454   void* operator new(size_t s, unsigned size) throw();
455 
456  public:
457    SingletonBlob(
458      const char*  name,
459      CodeBlobKind kind,
460      CodeBuffer*  cb,
461      int          size,
462      int          header_size,
463      int          frame_size,
464      OopMapSet*   oop_maps
465    )
466    : RuntimeBlob(name, kind, cb, size, header_size, CodeOffsets::frame_never_safe, frame_size, oop_maps)
467   {};
468 
469   address entry_point()                          { return code_begin(); }
470 
471   // GC/Verification support
472   void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) override { /* nothing to do */ }
473   void verify() override; // does nothing
474   void print_on(outputStream* st) const override;
475   void print_value_on(outputStream* st) const override;
476 };
477 
478 
479 //----------------------------------------------------------------------------------------------------
480 // DeoptimizationBlob
481 
482 class DeoptimizationBlob: public SingletonBlob {
483   friend class VMStructs;
484   friend class JVMCIVMStructs;
485  private:
486   int _unpack_offset;
487   int _unpack_with_exception;
488   int _unpack_with_reexecution;
489 
490   int _unpack_with_exception_in_tls;
491 
492 #if INCLUDE_JVMCI
493   // Offsets when JVMCI calls uncommon_trap.
494   int _uncommon_trap_offset;
495   int _implicit_exception_uncommon_trap_offset;
496 #endif
497 
498   // Creation support
499   DeoptimizationBlob(
500     CodeBuffer* cb,
501     int         size,
502     OopMapSet*  oop_maps,
503     int         unpack_offset,
504     int         unpack_with_exception_offset,
505     int         unpack_with_reexecution_offset,
506     int         frame_size
507   );
508 
509  public:
510   // Creation
511   static DeoptimizationBlob* create(
512     CodeBuffer* cb,
513     OopMapSet*  oop_maps,
514     int         unpack_offset,
515     int         unpack_with_exception_offset,
516     int         unpack_with_reexecution_offset,
517     int         frame_size
518   );
519 
520   // Printing
521   void print_value_on(outputStream* st) const override;
522 
523   address unpack() const                         { return code_begin() + _unpack_offset;           }
524   address unpack_with_exception() const          { return code_begin() + _unpack_with_exception;   }
525   address unpack_with_reexecution() const        { return code_begin() + _unpack_with_reexecution; }
526 
527   // Alternate entry point for C1 where the exception and issuing pc
528   // are in JavaThread::_exception_oop and JavaThread::_exception_pc
529   // instead of being in registers.  This is needed because C1 doesn't
530   // model exception paths in a way that keeps these registers free so
531   // there may be live values in those registers during deopt.
532   void set_unpack_with_exception_in_tls_offset(int offset) {
533     _unpack_with_exception_in_tls = offset;
534     assert(code_contains(code_begin() + _unpack_with_exception_in_tls), "must be PC inside codeblob");
535   }
536   address unpack_with_exception_in_tls() const   { return code_begin() + _unpack_with_exception_in_tls; }
537 
538 #if INCLUDE_JVMCI
539   // Offsets when JVMCI calls uncommon_trap.
540   void set_uncommon_trap_offset(int offset) {
541     _uncommon_trap_offset = offset;
542     assert(contains(code_begin() + _uncommon_trap_offset), "must be PC inside codeblob");
543   }
544   address uncommon_trap() const                  { return code_begin() + _uncommon_trap_offset; }
545 
546   void set_implicit_exception_uncommon_trap_offset(int offset) {
547     _implicit_exception_uncommon_trap_offset = offset;
548     assert(contains(code_begin() + _implicit_exception_uncommon_trap_offset), "must be PC inside codeblob");
549   }
550   address implicit_exception_uncommon_trap() const { return code_begin() + _implicit_exception_uncommon_trap_offset; }
551 #endif // INCLUDE_JVMCI
552 };
553 
554 
555 //----------------------------------------------------------------------------------------------------
556 // UncommonTrapBlob (currently only used by Compiler 2)
557 
558 #ifdef COMPILER2
559 
560 class UncommonTrapBlob: public SingletonBlob {
561   friend class VMStructs;
562  private:
563   // Creation support
564   UncommonTrapBlob(
565     CodeBuffer* cb,
566     int         size,
567     OopMapSet*  oop_maps,
568     int         frame_size
569   );
570 
571  public:
572   // Creation
573   static UncommonTrapBlob* create(
574     CodeBuffer* cb,
575     OopMapSet*  oop_maps,
576     int         frame_size
577   );
578 };
579 
580 
581 //----------------------------------------------------------------------------------------------------
582 // ExceptionBlob: used for exception unwinding in compiled code (currently only used by Compiler 2)
583 
584 class ExceptionBlob: public SingletonBlob {
585   friend class VMStructs;
586  private:
587   // Creation support
588   ExceptionBlob(
589     CodeBuffer* cb,
590     int         size,
591     OopMapSet*  oop_maps,
592     int         frame_size
593   );
594 
595  public:
596   // Creation
597   static ExceptionBlob* create(
598     CodeBuffer* cb,
599     OopMapSet*  oop_maps,
600     int         frame_size
601   );
602 };
603 #endif // COMPILER2
604 
605 
606 //----------------------------------------------------------------------------------------------------
607 // SafepointBlob: handles illegal_instruction exceptions during a safepoint
608 
609 class SafepointBlob: public SingletonBlob {
610   friend class VMStructs;
611  private:
612   // Creation support
613   SafepointBlob(
614     CodeBuffer* cb,
615     int         size,
616     OopMapSet*  oop_maps,
617     int         frame_size
618   );
619 
620  public:
621   // Creation
622   static SafepointBlob* create(
623     CodeBuffer* cb,
624     OopMapSet*  oop_maps,
625     int         frame_size
626   );
627 };
628 
629 //----------------------------------------------------------------------------------------------------
630 
631 class UpcallLinker;
632 
633 // A (Panama) upcall stub. Not used by JNI.
634 class UpcallStub: public RuntimeBlob {
635   friend class UpcallLinker;
636  private:
637   jobject _receiver;
638   ByteSize _frame_data_offset;
639 
640   UpcallStub(const char* name, CodeBuffer* cb, int size, jobject receiver, ByteSize frame_data_offset);
641 
642   void* operator new(size_t s, unsigned size) throw();
643 
644   struct FrameData {
645     JavaFrameAnchor jfa;
646     JavaThread* thread;
647     JNIHandleBlock* old_handles;
648     JNIHandleBlock* new_handles;
649   };
650 
651   // defined in frame_ARCH.cpp
652   FrameData* frame_data_for_frame(const frame& frame) const;
653  public:
654   // Creation
655   static UpcallStub* create(const char* name, CodeBuffer* cb, jobject receiver, ByteSize frame_data_offset);
656 
657   static void free(UpcallStub* blob);
658 
659   jobject receiver() { return _receiver; }
660 
661   JavaFrameAnchor* jfa_for_frame(const frame& frame) const;
662 
663   // GC/Verification support
664   void oops_do(OopClosure* f, const frame& frame);
665   void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) override;
666   void verify() override;
667 
668   // Misc.
669   void print_on(outputStream* st) const override;
670   void print_value_on(outputStream* st) const override;
671 };
672 
673 #endif // SHARE_CODE_CODEBLOB_HPP