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