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