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