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