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