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