1 /*
   2  * Copyright (c) 1998, 2016, 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_CODE_CODEBLOB_HPP
  26 #define SHARE_VM_CODE_CODEBLOB_HPP
  27 
  28 #include "asm/codeBuffer.hpp"
  29 #include "compiler/compilerDefinitions.hpp"
  30 #include "compiler/oopMap.hpp"
  31 #include "runtime/frame.hpp"
  32 #include "runtime/handles.hpp"
  33 #include "utilities/align.hpp"
  34 #include "utilities/macros.hpp"
  35 
  36 // CodeBlob Types
  37 // Used in the CodeCache to assign CodeBlobs to different CodeHeaps
  38 struct CodeBlobType {
  39   enum {
  40     MethodNonProfiled   = 0,    // Execution level 1 and 4 (non-profiled) nmethods (including native nmethods)
  41     MethodProfiled      = 1,    // Execution level 2 and 3 (profiled) nmethods
  42     NonNMethod          = 2,    // Non-nmethods like Buffers, Adapters and Runtime Stubs
  43     All                 = 3,    // All types (No code cache segmentation)
  44     AOT                 = 4,    // AOT methods
  45     NumTypes            = 5     // Number of CodeBlobTypes
  46   };
  47 };
  48 
  49 // CodeBlob - superclass for all entries in the CodeCache.
  50 //
  51 // Subtypes are:
  52 //   CompiledMethod       : Compiled Java methods (include method that calls to native code)
  53 //     nmethod            : JIT Compiled Java methods
  54 //   RuntimeBlob          : Non-compiled method code; generated glue code
  55 //     RuntimeStub        : Call to VM runtime methods
  56 //     DeoptimizationBlob : Used for deoptimization
  57 //     ExceptionBlob      : Used for stack unrolling
  58 //     SafepointBlob      : Used to handle illegal instruction exceptions
  59 //
  60 //
  61 // Layout:
  62 //   - header
  63 //   - relocation
  64 //   - content space
  65 //     - instruction space
  66 //   - data space
  67 
  68 
  69 class CodeBlobLayout;
  70 
  71 class CodeBlob VALUE_OBJ_CLASS_SPEC {
  72   friend class VMStructs;
  73   friend class JVMCIVMStructs;
  74   friend class CodeCacheDumper;
  75 
  76 protected:
  77 
  78   const CompilerType _type;                      // CompilerType
  79   int        _size;                              // total size of CodeBlob in bytes
  80   int        _header_size;                       // size of header (depends on subclass)
  81   int        _frame_complete_offset;             // instruction offsets in [0.._frame_complete_offset) have
  82                                                  // not finished setting up their frame. Beware of pc's in
  83                                                  // that range. There is a similar range(s) on returns
  84                                                  // which we don't detect.
  85   int        _data_offset;                       // offset to where data region begins
  86   int        _frame_size;                        // size of stack frame
  87 
  88   address    _code_begin;
  89   address    _code_end;
  90   address    _content_begin;                     // address to where content region begins (this includes consts, insts, stubs)
  91                                                  // address    _content_end - not required, for all CodeBlobs _code_end == _content_end for now
  92   address    _data_end;
  93   address    _relocation_begin;
  94   address    _relocation_end;
  95 
  96   ImmutableOopMapSet* _oop_maps;                 // OopMap for this CodeBlob
  97   bool                _caller_must_gc_arguments;
  98   CodeStrings         _strings;
  99   const char*         _name;
 100   S390_ONLY(int       _ctable_offset;)
 101 
 102   CodeBlob(const char* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments);
 103   CodeBlob(const char* name, CompilerType type, const CodeBlobLayout& layout, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments);
 104 public:
 105   // Returns the space needed for CodeBlob
 106   static unsigned int allocation_size(CodeBuffer* cb, int header_size);
 107   static unsigned int align_code_offset(int offset);
 108 
 109   // Deletion
 110   virtual void flush();
 111 
 112   // Typing
 113   virtual bool is_buffer_blob() const                 { return false; }
 114   virtual bool is_nmethod() const                     { return false; }
 115   virtual bool is_runtime_stub() const                { return false; }
 116   virtual bool is_deoptimization_stub() const         { return false; }
 117   virtual bool is_uncommon_trap_stub() const          { return false; }
 118   virtual bool is_exception_stub() const              { return false; }
 119   virtual bool is_safepoint_stub() const              { return false; }
 120   virtual bool is_adapter_blob() const                { return false; }
 121   virtual bool is_method_handles_adapter_blob() const { return false; }
 122   virtual bool is_aot() const                         { return false; }
 123   virtual bool is_compiled() const                    { return false; }
 124 
 125   inline bool is_compiled_by_c1() const    { return _type == compiler_c1; };
 126   inline bool is_compiled_by_c2() const    { return _type == compiler_c2; };
 127   inline bool is_compiled_by_jvmci() const { return _type == compiler_jvmci; };
 128   inline bool is_compiled_by_shark() const { return _type == compiler_shark; };
 129   const char* compiler_name() const;
 130 
 131   // Casting
 132   nmethod* as_nmethod_or_null()                { return is_nmethod() ? (nmethod*) this : NULL; }
 133   nmethod* as_nmethod()                        { assert(is_nmethod(), "must be nmethod"); return (nmethod*) this; }
 134   CompiledMethod* as_compiled_method_or_null() { return is_compiled() ? (CompiledMethod*) this : NULL; }
 135   CompiledMethod* as_compiled_method()         { assert(is_compiled(), "must be compiled"); return (CompiledMethod*) this; }
 136   CodeBlob* as_codeblob_or_null() const        { return (CodeBlob*) this; }
 137 
 138   // Boundaries
 139   address header_begin() const        { return (address) this; }
 140   relocInfo* relocation_begin() const { return (relocInfo*) _relocation_begin; };
 141   relocInfo* relocation_end() const   { return (relocInfo*) _relocation_end; }
 142   address content_begin() const       { return _content_begin; }
 143   address content_end() const         { return _code_end; } // _code_end == _content_end is true for all types of blobs for now, it is also checked in the constructor
 144   address code_begin() const          { return _code_begin;    }
 145   address code_end() const            { return _code_end; }
 146   address data_end() const            { return _data_end;      }
 147 
 148   // This field holds the beginning of the const section in the old code buffer.
 149   // It is needed to fix relocations of pc-relative loads when resizing the
 150   // the constant pool or moving it.
 151   S390_ONLY(address ctable_begin() const { return header_begin() + _ctable_offset; })
 152   void set_ctable_begin(address ctable) { S390_ONLY(_ctable_offset = ctable - header_begin();) }
 153 
 154   // Sizes
 155   int size() const                               { return _size; }
 156   int header_size() const                        { return _header_size; }
 157   int relocation_size() const                    { return (address) relocation_end() - (address) relocation_begin(); }
 158   int content_size() const                       { return           content_end()    -           content_begin();    }
 159   int code_size() const                          { return           code_end()       -           code_begin();       }
 160   // Only used from CodeCache::free_unused_tail() after the Interpreter blob was trimmed
 161   void adjust_size(size_t used) {
 162     _size = (int)used;
 163     _data_offset = (int)used;
 164     _code_end = (address)this + used;
 165     _data_end = (address)this + used;
 166   }
 167 
 168   // Containment
 169   bool blob_contains(address addr) const         { return header_begin()       <= addr && addr < data_end();       }
 170   bool code_contains(address addr) const         { return code_begin()         <= addr && addr < code_end();       }
 171   bool contains(address addr) const              { return content_begin()      <= addr && addr < content_end();    }
 172   bool is_frame_complete_at(address addr) const  { return _frame_complete_offset != CodeOffsets::frame_never_safe &&
 173                                                           code_contains(addr) && addr >= code_begin() + _frame_complete_offset; }
 174 
 175   // CodeCache support: really only used by the nmethods, but in order to get
 176   // asserts and certain bookkeeping to work in the CodeCache they are defined
 177   // virtual here.
 178   virtual bool is_zombie() const                 { return false; }
 179   virtual bool is_locked_by_vm() const           { return false; }
 180 
 181   virtual bool is_unloaded() const               { return false; }
 182   virtual bool is_not_entrant() const            { return false; }
 183 
 184   // GC support
 185   virtual bool is_alive() const                  = 0;
 186 
 187   // OopMap for frame
 188   ImmutableOopMapSet* oop_maps() const           { return _oop_maps; }
 189   void set_oop_maps(OopMapSet* p);
 190   const ImmutableOopMap* oop_map_for_return_address(address return_address);
 191   virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) = 0;
 192 
 193   // Frame support
 194   int  frame_size() const                        { return _frame_size; }
 195   void set_frame_size(int size)                  { _frame_size = size; }
 196 
 197   // Returns true, if the next frame is responsible for GC'ing oops passed as arguments
 198   bool caller_must_gc_arguments(JavaThread* thread) const { return _caller_must_gc_arguments; }
 199 
 200   // Naming
 201   const char* name() const                       { return _name; }
 202   void set_name(const char* name)                { _name = name; }
 203 
 204   // Debugging
 205   virtual void verify() = 0;
 206   virtual void print() const                     { print_on(tty); };
 207   virtual void print_on(outputStream* st) const;
 208   virtual void print_value_on(outputStream* st) const;
 209   void print_code();
 210 
 211   // Print the comment associated with offset on stream, if there is one
 212   virtual void print_block_comment(outputStream* stream, address block_begin) const {
 213     intptr_t offset = (intptr_t)(block_begin - code_begin());
 214     _strings.print_block_comment(stream, offset);
 215   }
 216 
 217   // Transfer ownership of comments to this CodeBlob
 218   void set_strings(CodeStrings& strings) {
 219     assert(!is_aot(), "invalid on aot");
 220     _strings.assign(strings);
 221   }
 222 
 223   static ByteSize name_field_offset() {
 224     return byte_offset_of(CodeBlob, _name);
 225   }
 226 
 227   static ByteSize oop_maps_field_offset() {
 228     return byte_offset_of(CodeBlob, _oop_maps);
 229   }
 230 };
 231 
 232 class CodeBlobLayout : public StackObj {
 233 private:
 234   int _size;
 235   int _header_size;
 236   int _relocation_size;
 237   int _content_offset;
 238   int _code_offset;
 239   int _data_offset;
 240   address _code_begin;
 241   address _code_end;
 242   address _content_begin;
 243   address _content_end;
 244   address _data_end;
 245   address _relocation_begin;
 246   address _relocation_end;
 247 
 248 public:
 249   CodeBlobLayout(address code_begin, address code_end, address content_begin, address content_end, address data_end, address relocation_begin, address relocation_end) :
 250     _size(0),
 251     _header_size(0),
 252     _relocation_size(0),
 253     _content_offset(0),
 254     _code_offset(0),
 255     _data_offset(0),
 256     _content_begin(content_begin),
 257     _content_end(content_end),
 258     _code_begin(code_begin),
 259     _code_end(code_end),
 260     _data_end(data_end),
 261     _relocation_begin(relocation_begin),
 262     _relocation_end(relocation_end)
 263   {
 264   }
 265 
 266   CodeBlobLayout(const address start, int size, int header_size, int relocation_size, int data_offset) :
 267     _size(size),
 268     _header_size(header_size),
 269     _relocation_size(relocation_size),
 270     _content_offset(CodeBlob::align_code_offset(_header_size + _relocation_size)),
 271     _code_offset(_content_offset),
 272     _data_offset(data_offset)
 273   {
 274     assert(is_aligned(_relocation_size, oopSize), "unaligned size");
 275 
 276     _code_begin = (address) start + _code_offset;
 277     _code_end = (address) start + _data_offset;
 278 
 279     _content_begin = (address) start + _content_offset;
 280     _content_end = (address) start + _data_offset;
 281 
 282     _data_end = (address) start + _size;
 283     _relocation_begin = (address) start + _header_size;
 284     _relocation_end = _relocation_begin + _relocation_size;
 285   }
 286 
 287   CodeBlobLayout(const address start, int size, int header_size, const CodeBuffer* cb) :
 288     _size(size),
 289     _header_size(header_size),
 290     _relocation_size(align_up(cb->total_relocation_size(), oopSize)),
 291     _content_offset(CodeBlob::align_code_offset(_header_size + _relocation_size)),
 292     _code_offset(_content_offset + cb->total_offset_of(cb->insts())),
 293     _data_offset(_content_offset + align_up(cb->total_content_size(), oopSize))
 294   {
 295     assert(is_aligned(_relocation_size, oopSize), "unaligned size");
 296 
 297     _code_begin = (address) start + _code_offset;
 298     _code_end = (address) start + _data_offset;
 299 
 300     _content_begin = (address) start + _content_offset;
 301     _content_end = (address) start + _data_offset;
 302 
 303     _data_end = (address) start + _size;
 304     _relocation_begin = (address) start + _header_size;
 305     _relocation_end = _relocation_begin + _relocation_size;
 306   }
 307 
 308   int size() const { return _size; }
 309   int header_size() const { return _header_size; }
 310   int relocation_size() const { return _relocation_size; }
 311   int content_offset() const { return _content_offset; }
 312   int code_offset() const { return _code_offset; }
 313   int data_offset() const { return _data_offset; }
 314   address code_begin() const { return _code_begin; }
 315   address code_end() const { return _code_end; }
 316   address data_end() const { return _data_end; }
 317   address relocation_begin() const { return _relocation_begin; }
 318   address relocation_end() const { return _relocation_end; }
 319   address content_begin() const { return _content_begin; }
 320   address content_end() const { return _content_end; }
 321 };
 322 
 323 
 324 class RuntimeBlob : public CodeBlob {
 325   friend class VMStructs;
 326  public:
 327 
 328   // Creation
 329   // a) simple CodeBlob
 330   // frame_complete is the offset from the beginning of the instructions
 331   // to where the frame setup (from stackwalk viewpoint) is complete.
 332   RuntimeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size);
 333 
 334   // b) full CodeBlob
 335   RuntimeBlob(
 336     const char* name,
 337     CodeBuffer* cb,
 338     int         header_size,
 339     int         size,
 340     int         frame_complete,
 341     int         frame_size,
 342     OopMapSet*  oop_maps,
 343     bool        caller_must_gc_arguments = false
 344   );
 345 
 346   // GC support
 347   virtual bool is_alive() const                  = 0;
 348 
 349   void verify();
 350 
 351   // OopMap for frame
 352   virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f)  { ShouldNotReachHere(); }
 353 
 354   // Debugging
 355   void print() const                             { print_on(tty); }
 356   virtual void print_on(outputStream* st) const { CodeBlob::print_on(st); }
 357   virtual void print_value_on(outputStream* st) const { CodeBlob::print_value_on(st); }
 358 
 359   // Deal with Disassembler, VTune, Forte, JvmtiExport, MemoryService.
 360   static void trace_new_stub(RuntimeBlob* blob, const char* name1, const char* name2 = "");
 361 };
 362 
 363 class WhiteBox;
 364 //----------------------------------------------------------------------------------------------------
 365 // BufferBlob: used to hold non-relocatable machine code such as the interpreter, stubroutines, etc.
 366 
 367 class BufferBlob: public RuntimeBlob {
 368   friend class VMStructs;
 369   friend class AdapterBlob;
 370   friend class MethodHandlesAdapterBlob;
 371   friend class WhiteBox;
 372 
 373  private:
 374   // Creation support
 375   BufferBlob(const char* name, int size);
 376   BufferBlob(const char* name, int size, CodeBuffer* cb);
 377 
 378   void* operator new(size_t s, unsigned size) throw();
 379 
 380  public:
 381   // Creation
 382   static BufferBlob* create(const char* name, int buffer_size);
 383   static BufferBlob* create(const char* name, CodeBuffer* cb);
 384 
 385   static void free(BufferBlob* buf);
 386 
 387   // Typing
 388   virtual bool is_buffer_blob() const            { return true; }
 389 
 390   // GC/Verification support
 391   void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f)  { /* nothing to do */ }
 392   bool is_alive() const                          { return true; }
 393 
 394   void verify();
 395   void print_on(outputStream* st) const;
 396   void print_value_on(outputStream* st) const;
 397 };
 398 
 399 
 400 //----------------------------------------------------------------------------------------------------
 401 // AdapterBlob: used to hold C2I/I2C adapters
 402 
 403 class AdapterBlob: public BufferBlob {
 404 private:
 405   AdapterBlob(int size, CodeBuffer* cb);
 406 
 407 public:
 408   // Creation
 409   static AdapterBlob* create(CodeBuffer* cb);
 410 
 411   // Typing
 412   virtual bool is_adapter_blob() const { return true; }
 413 };
 414 
 415 
 416 //----------------------------------------------------------------------------------------------------
 417 // MethodHandlesAdapterBlob: used to hold MethodHandles adapters
 418 
 419 class MethodHandlesAdapterBlob: public BufferBlob {
 420 private:
 421   MethodHandlesAdapterBlob(int size)                 : BufferBlob("MethodHandles adapters", size) {}
 422 
 423 public:
 424   // Creation
 425   static MethodHandlesAdapterBlob* create(int buffer_size);
 426 
 427   // Typing
 428   virtual bool is_method_handles_adapter_blob() const { return true; }
 429 };
 430 
 431 
 432 //----------------------------------------------------------------------------------------------------
 433 // RuntimeStub: describes stubs used by compiled code to call a (static) C++ runtime routine
 434 
 435 class RuntimeStub: public RuntimeBlob {
 436   friend class VMStructs;
 437  private:
 438   // Creation support
 439   RuntimeStub(
 440     const char* name,
 441     CodeBuffer* cb,
 442     int         size,
 443     int         frame_complete,
 444     int         frame_size,
 445     OopMapSet*  oop_maps,
 446     bool        caller_must_gc_arguments
 447   );
 448 
 449   void* operator new(size_t s, unsigned size) throw();
 450 
 451  public:
 452   // Creation
 453   static RuntimeStub* new_runtime_stub(
 454     const char* stub_name,
 455     CodeBuffer* cb,
 456     int         frame_complete,
 457     int         frame_size,
 458     OopMapSet*  oop_maps,
 459     bool        caller_must_gc_arguments
 460   );
 461 
 462   // Typing
 463   bool is_runtime_stub() const                   { return true; }
 464 
 465   address entry_point() const                    { return code_begin(); }
 466 
 467   // GC/Verification support
 468   void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f)  { /* nothing to do */ }
 469   bool is_alive() const                          { return true; }
 470 
 471   void verify();
 472   void print_on(outputStream* st) const;
 473   void print_value_on(outputStream* st) const;
 474 };
 475 
 476 
 477 //----------------------------------------------------------------------------------------------------
 478 // Super-class for all blobs that exist in only one instance. Implements default behaviour.
 479 
 480 class SingletonBlob: public RuntimeBlob {
 481   friend class VMStructs;
 482 
 483  protected:
 484   void* operator new(size_t s, unsigned size) throw();
 485 
 486  public:
 487    SingletonBlob(
 488      const char* name,
 489      CodeBuffer* cb,
 490      int         header_size,
 491      int         size,
 492      int         frame_size,
 493      OopMapSet*  oop_maps
 494    )
 495    : RuntimeBlob(name, cb, header_size, size, CodeOffsets::frame_never_safe, frame_size, oop_maps)
 496   {};
 497 
 498   address entry_point()                          { return code_begin(); }
 499 
 500   bool is_alive() const                          { return true; }
 501 
 502   // GC/Verification support
 503   void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f)  { /* nothing to do */ }
 504   void verify(); // does nothing
 505   void print_on(outputStream* st) const;
 506   void print_value_on(outputStream* st) const;
 507 };
 508 
 509 
 510 //----------------------------------------------------------------------------------------------------
 511 // DeoptimizationBlob
 512 
 513 class DeoptimizationBlob: public SingletonBlob {
 514   friend class VMStructs;
 515   friend class JVMCIVMStructs;
 516  private:
 517   int _unpack_offset;
 518   int _unpack_with_exception;
 519   int _unpack_with_reexecution;
 520 
 521   int _unpack_with_exception_in_tls;
 522 
 523 #if INCLUDE_JVMCI
 524   // Offsets when JVMCI calls uncommon_trap.
 525   int _uncommon_trap_offset;
 526   int _implicit_exception_uncommon_trap_offset;
 527 #endif
 528 
 529   // Creation support
 530   DeoptimizationBlob(
 531     CodeBuffer* cb,
 532     int         size,
 533     OopMapSet*  oop_maps,
 534     int         unpack_offset,
 535     int         unpack_with_exception_offset,
 536     int         unpack_with_reexecution_offset,
 537     int         frame_size
 538   );
 539 
 540  public:
 541   // Creation
 542   static DeoptimizationBlob* create(
 543     CodeBuffer* cb,
 544     OopMapSet*  oop_maps,
 545     int         unpack_offset,
 546     int         unpack_with_exception_offset,
 547     int         unpack_with_reexecution_offset,
 548     int         frame_size
 549   );
 550 
 551   // Typing
 552   bool is_deoptimization_stub() const { return true; }
 553   bool exception_address_is_unpack_entry(address pc) const {
 554     address unpack_pc = unpack();
 555     return (pc == unpack_pc || (pc + frame::pc_return_offset) == unpack_pc);
 556   }
 557 
 558   // GC for args
 559   void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { /* Nothing to do */ }
 560 
 561   // Printing
 562   void print_value_on(outputStream* st) const;
 563 
 564   address unpack() const                         { return code_begin() + _unpack_offset;           }
 565   address unpack_with_exception() const          { return code_begin() + _unpack_with_exception;   }
 566   address unpack_with_reexecution() const        { return code_begin() + _unpack_with_reexecution; }
 567 
 568   // Alternate entry point for C1 where the exception and issuing pc
 569   // are in JavaThread::_exception_oop and JavaThread::_exception_pc
 570   // instead of being in registers.  This is needed because C1 doesn't
 571   // model exception paths in a way that keeps these registers free so
 572   // there may be live values in those registers during deopt.
 573   void set_unpack_with_exception_in_tls_offset(int offset) {
 574     _unpack_with_exception_in_tls = offset;
 575     assert(code_contains(code_begin() + _unpack_with_exception_in_tls), "must be PC inside codeblob");
 576   }
 577   address unpack_with_exception_in_tls() const   { return code_begin() + _unpack_with_exception_in_tls; }
 578 
 579 #if INCLUDE_JVMCI
 580   // Offsets when JVMCI calls uncommon_trap.
 581   void set_uncommon_trap_offset(int offset) {
 582     _uncommon_trap_offset = offset;
 583     assert(contains(code_begin() + _uncommon_trap_offset), "must be PC inside codeblob");
 584   }
 585   address uncommon_trap() const                  { return code_begin() + _uncommon_trap_offset; }
 586 
 587   void set_implicit_exception_uncommon_trap_offset(int offset) {
 588     _implicit_exception_uncommon_trap_offset = offset;
 589     assert(contains(code_begin() + _implicit_exception_uncommon_trap_offset), "must be PC inside codeblob");
 590   }
 591   address implicit_exception_uncommon_trap() const { return code_begin() + _implicit_exception_uncommon_trap_offset; }
 592 #endif // INCLUDE_JVMCI
 593 };
 594 
 595 
 596 //----------------------------------------------------------------------------------------------------
 597 // UncommonTrapBlob (currently only used by Compiler 2)
 598 
 599 #ifdef COMPILER2
 600 
 601 class UncommonTrapBlob: public SingletonBlob {
 602   friend class VMStructs;
 603  private:
 604   // Creation support
 605   UncommonTrapBlob(
 606     CodeBuffer* cb,
 607     int         size,
 608     OopMapSet*  oop_maps,
 609     int         frame_size
 610   );
 611 
 612  public:
 613   // Creation
 614   static UncommonTrapBlob* create(
 615     CodeBuffer* cb,
 616     OopMapSet*  oop_maps,
 617     int         frame_size
 618   );
 619 
 620   // GC for args
 621   void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f)  { /* nothing to do */ }
 622 
 623   // Typing
 624   bool is_uncommon_trap_stub() const             { return true; }
 625 };
 626 
 627 
 628 //----------------------------------------------------------------------------------------------------
 629 // ExceptionBlob: used for exception unwinding in compiled code (currently only used by Compiler 2)
 630 
 631 class ExceptionBlob: public SingletonBlob {
 632   friend class VMStructs;
 633  private:
 634   // Creation support
 635   ExceptionBlob(
 636     CodeBuffer* cb,
 637     int         size,
 638     OopMapSet*  oop_maps,
 639     int         frame_size
 640   );
 641 
 642  public:
 643   // Creation
 644   static ExceptionBlob* create(
 645     CodeBuffer* cb,
 646     OopMapSet*  oop_maps,
 647     int         frame_size
 648   );
 649 
 650   // GC for args
 651   void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f)  { /* nothing to do */ }
 652 
 653   // Typing
 654   bool is_exception_stub() const                 { return true; }
 655 };
 656 #endif // COMPILER2
 657 
 658 
 659 //----------------------------------------------------------------------------------------------------
 660 // SafepointBlob: handles illegal_instruction exceptions during a safepoint
 661 
 662 class SafepointBlob: public SingletonBlob {
 663   friend class VMStructs;
 664  private:
 665   // Creation support
 666   SafepointBlob(
 667     CodeBuffer* cb,
 668     int         size,
 669     OopMapSet*  oop_maps,
 670     int         frame_size
 671   );
 672 
 673  public:
 674   // Creation
 675   static SafepointBlob* create(
 676     CodeBuffer* cb,
 677     OopMapSet*  oop_maps,
 678     int         frame_size
 679   );
 680 
 681   // GC for args
 682   void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f)  { /* nothing to do */ }
 683 
 684   // Typing
 685   bool is_safepoint_stub() const                 { return true; }
 686 };
 687 
 688 #endif // SHARE_VM_CODE_CODEBLOB_HPP