140 static unsigned int allocation_size(CodeBuffer* cb, int header_size);
141 static unsigned int align_code_offset(int offset);
142
143 // Deletion
144 virtual void flush();
145
146 // Typing
147 virtual bool is_buffer_blob() const { return false; }
148 virtual bool is_nmethod() const { return false; }
149 virtual bool is_runtime_stub() const { return false; }
150 virtual bool is_deoptimization_stub() const { return false; }
151 virtual bool is_uncommon_trap_stub() const { return false; }
152 virtual bool is_exception_stub() const { return false; }
153 virtual bool is_safepoint_stub() const { return false; }
154 virtual bool is_adapter_blob() const { return false; }
155 virtual bool is_vtable_blob() const { return false; }
156 virtual bool is_method_handles_adapter_blob() const { return false; }
157 virtual bool is_upcall_stub() const { return false; }
158 bool is_compiled() const { return _is_compiled; }
159 const bool* is_compiled_addr() const { return &_is_compiled; }
160
161 inline bool is_compiled_by_c1() const { return _type == compiler_c1; };
162 inline bool is_compiled_by_c2() const { return _type == compiler_c2; };
163 inline bool is_compiled_by_jvmci() const { return _type == compiler_jvmci; };
164 const char* compiler_name() const;
165 CompilerType compiler_type() const { return _type; }
166
167 // Casting
168 nmethod* as_nmethod_or_null() { return is_nmethod() ? (nmethod*) this : nullptr; }
169 nmethod* as_nmethod() { assert(is_nmethod(), "must be nmethod"); return (nmethod*) this; }
170 CompiledMethod* as_compiled_method_or_null() { return is_compiled() ? (CompiledMethod*) this : nullptr; }
171 CompiledMethod* as_compiled_method() { assert(is_compiled(), "must be compiled"); return (CompiledMethod*) this; }
172 CodeBlob* as_codeblob_or_null() const { return (CodeBlob*) this; }
173 UpcallStub* as_upcall_stub() const { assert(is_upcall_stub(), "must be upcall stub"); return (UpcallStub*) this; }
174 RuntimeStub* as_runtime_stub() const { assert(is_runtime_stub(), "must be runtime blob"); return (RuntimeStub*) this; }
175
176 // Boundaries
177 address header_begin() const { return (address) this; }
178 relocInfo* relocation_begin() const { return (relocInfo*) _relocation_begin; };
179 relocInfo* relocation_end() const { return (relocInfo*) _relocation_end; }
379 // OopMap for frame
380 virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { ShouldNotReachHere(); }
381
382 // Debugging
383 virtual void print_on(outputStream* st) const { CodeBlob::print_on(st); }
384 virtual void print_value_on(outputStream* st) const { CodeBlob::print_value_on(st); }
385
386 // Deal with Disassembler, VTune, Forte, JvmtiExport, MemoryService.
387 static void trace_new_stub(RuntimeBlob* blob, const char* name1, const char* name2 = "");
388 };
389
390 class WhiteBox;
391 //----------------------------------------------------------------------------------------------------
392 // BufferBlob: used to hold non-relocatable machine code such as the interpreter, stubroutines, etc.
393
394 class BufferBlob: public RuntimeBlob {
395 friend class VMStructs;
396 friend class AdapterBlob;
397 friend class VtableBlob;
398 friend class MethodHandlesAdapterBlob;
399 friend class UpcallStub;
400 friend class WhiteBox;
401
402 private:
403 // Creation support
404 BufferBlob(const char* name, int size);
405 BufferBlob(const char* name, int size, CodeBuffer* cb);
406
407 // This ordinary operator delete is needed even though not used, so the
408 // below two-argument operator delete will be treated as a placement
409 // delete rather than an ordinary sized delete; see C++14 3.7.4.2/p2.
410 void operator delete(void* p);
411 void* operator new(size_t s, unsigned size) throw();
412
413 public:
414 // Creation
415 static BufferBlob* create(const char* name, int buffer_size);
416 static BufferBlob* create(const char* name, CodeBuffer* cb);
417
418 static void free(BufferBlob* buf);
419
420 // Typing
421 virtual bool is_buffer_blob() const { return true; }
422
423 // GC/Verification support
424 void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { /* nothing to do */ }
425
426 void verify();
427 void print_on(outputStream* st) const;
428 void print_value_on(outputStream* st) const;
429 };
430
431
432 //----------------------------------------------------------------------------------------------------
433 // AdapterBlob: used to hold C2I/I2C adapters
434
435 class AdapterBlob: public BufferBlob {
436 private:
437 AdapterBlob(int size, CodeBuffer* cb);
438
439 public:
440 // Creation
441 static AdapterBlob* create(CodeBuffer* cb);
442
443 // Typing
444 virtual bool is_adapter_blob() const { return true; }
445 };
446
447 //---------------------------------------------------------------------------------------------------
448 class VtableBlob: public BufferBlob {
449 private:
450 VtableBlob(const char*, int);
451
452 void* operator new(size_t s, unsigned size) throw();
453
454 public:
455 // Creation
456 static VtableBlob* create(const char* name, int buffer_size);
457
458 // Typing
459 virtual bool is_vtable_blob() const { return true; }
460 };
461
462 //----------------------------------------------------------------------------------------------------
463 // MethodHandlesAdapterBlob: used to hold MethodHandles adapters
464
465 class MethodHandlesAdapterBlob: public BufferBlob {
466 private:
467 MethodHandlesAdapterBlob(int size): BufferBlob("MethodHandles adapters", size) {}
468
469 public:
470 // Creation
471 static MethodHandlesAdapterBlob* create(int buffer_size);
472
473 // Typing
474 virtual bool is_method_handles_adapter_blob() const { return true; }
475 };
476
477
478 //----------------------------------------------------------------------------------------------------
479 // RuntimeStub: describes stubs used by compiled code to call a (static) C++ runtime routine
480
481 class RuntimeStub: public RuntimeBlob {
482 friend class VMStructs;
483 private:
484 // Creation support
485 RuntimeStub(
486 const char* name,
487 CodeBuffer* cb,
488 int size,
489 int frame_complete,
490 int frame_size,
491 OopMapSet* oop_maps,
492 bool caller_must_gc_arguments
493 );
494
495 // This ordinary operator delete is needed even though not used, so the
496 // below two-argument operator delete will be treated as a placement
|
140 static unsigned int allocation_size(CodeBuffer* cb, int header_size);
141 static unsigned int align_code_offset(int offset);
142
143 // Deletion
144 virtual void flush();
145
146 // Typing
147 virtual bool is_buffer_blob() const { return false; }
148 virtual bool is_nmethod() const { return false; }
149 virtual bool is_runtime_stub() const { return false; }
150 virtual bool is_deoptimization_stub() const { return false; }
151 virtual bool is_uncommon_trap_stub() const { return false; }
152 virtual bool is_exception_stub() const { return false; }
153 virtual bool is_safepoint_stub() const { return false; }
154 virtual bool is_adapter_blob() const { return false; }
155 virtual bool is_vtable_blob() const { return false; }
156 virtual bool is_method_handles_adapter_blob() const { return false; }
157 virtual bool is_upcall_stub() const { return false; }
158 bool is_compiled() const { return _is_compiled; }
159 const bool* is_compiled_addr() const { return &_is_compiled; }
160 virtual bool is_buffered_inline_type_blob() const { return false; }
161
162 inline bool is_compiled_by_c1() const { return _type == compiler_c1; };
163 inline bool is_compiled_by_c2() const { return _type == compiler_c2; };
164 inline bool is_compiled_by_jvmci() const { return _type == compiler_jvmci; };
165 const char* compiler_name() const;
166 CompilerType compiler_type() const { return _type; }
167
168 // Casting
169 nmethod* as_nmethod_or_null() { return is_nmethod() ? (nmethod*) this : nullptr; }
170 nmethod* as_nmethod() { assert(is_nmethod(), "must be nmethod"); return (nmethod*) this; }
171 CompiledMethod* as_compiled_method_or_null() { return is_compiled() ? (CompiledMethod*) this : nullptr; }
172 CompiledMethod* as_compiled_method() { assert(is_compiled(), "must be compiled"); return (CompiledMethod*) this; }
173 CodeBlob* as_codeblob_or_null() const { return (CodeBlob*) this; }
174 UpcallStub* as_upcall_stub() const { assert(is_upcall_stub(), "must be upcall stub"); return (UpcallStub*) this; }
175 RuntimeStub* as_runtime_stub() const { assert(is_runtime_stub(), "must be runtime blob"); return (RuntimeStub*) this; }
176
177 // Boundaries
178 address header_begin() const { return (address) this; }
179 relocInfo* relocation_begin() const { return (relocInfo*) _relocation_begin; };
180 relocInfo* relocation_end() const { return (relocInfo*) _relocation_end; }
380 // OopMap for frame
381 virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { ShouldNotReachHere(); }
382
383 // Debugging
384 virtual void print_on(outputStream* st) const { CodeBlob::print_on(st); }
385 virtual void print_value_on(outputStream* st) const { CodeBlob::print_value_on(st); }
386
387 // Deal with Disassembler, VTune, Forte, JvmtiExport, MemoryService.
388 static void trace_new_stub(RuntimeBlob* blob, const char* name1, const char* name2 = "");
389 };
390
391 class WhiteBox;
392 //----------------------------------------------------------------------------------------------------
393 // BufferBlob: used to hold non-relocatable machine code such as the interpreter, stubroutines, etc.
394
395 class BufferBlob: public RuntimeBlob {
396 friend class VMStructs;
397 friend class AdapterBlob;
398 friend class VtableBlob;
399 friend class MethodHandlesAdapterBlob;
400 friend class BufferedInlineTypeBlob;
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 header_size, int size, CodeBuffer* cb);
408 BufferBlob(const char* name, int size, CodeBuffer* cb, int frame_complete, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments = false);
409
410 // This ordinary operator delete is needed even though not used, so the
411 // below two-argument operator delete will be treated as a placement
412 // delete rather than an ordinary sized delete; see C++14 3.7.4.2/p2.
413 void operator delete(void* p);
414 void* operator new(size_t s, unsigned size) throw();
415
416 public:
417 // Creation
418 static BufferBlob* create(const char* name, int buffer_size);
419 static BufferBlob* create(const char* name, CodeBuffer* cb);
420
421 static void free(BufferBlob* buf);
422
423 // Typing
424 virtual bool is_buffer_blob() const { return true; }
425
426 // GC/Verification support
427 void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { /* nothing to do */ }
428
429 void verify();
430 void print_on(outputStream* st) const;
431 void print_value_on(outputStream* st) const;
432 };
433
434
435 //----------------------------------------------------------------------------------------------------
436 // AdapterBlob: used to hold C2I/I2C adapters
437
438 class AdapterBlob: public BufferBlob {
439 private:
440 AdapterBlob(int size, CodeBuffer* cb, int frame_complete, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments = false);
441
442 public:
443 // Creation
444 static AdapterBlob* create(CodeBuffer* cb,
445 int frame_complete,
446 int frame_size,
447 OopMapSet* oop_maps,
448 bool caller_must_gc_arguments = false);
449
450 // Typing
451 virtual bool is_adapter_blob() const { return true; }
452
453 bool caller_must_gc_arguments(JavaThread* thread) const { return true; }
454 };
455
456 //---------------------------------------------------------------------------------------------------
457 class VtableBlob: public BufferBlob {
458 private:
459 VtableBlob(const char*, int);
460
461 void* operator new(size_t s, unsigned size) throw();
462
463 public:
464 // Creation
465 static VtableBlob* create(const char* name, int buffer_size);
466
467 // Typing
468 virtual bool is_vtable_blob() const { return true; }
469 };
470
471 //----------------------------------------------------------------------------------------------------
472 // MethodHandlesAdapterBlob: used to hold MethodHandles adapters
473
474 class MethodHandlesAdapterBlob: public BufferBlob {
475 private:
476 MethodHandlesAdapterBlob(int size): BufferBlob("MethodHandles adapters", size) {}
477
478 public:
479 // Creation
480 static MethodHandlesAdapterBlob* create(int buffer_size);
481
482 // Typing
483 virtual bool is_method_handles_adapter_blob() const { return true; }
484 };
485
486 //----------------------------------------------------------------------------------------------------
487 // BufferedInlineTypeBlob : used for pack/unpack handlers
488
489 class BufferedInlineTypeBlob: public BufferBlob {
490 private:
491 const int _pack_fields_off;
492 const int _pack_fields_jobject_off;
493 const int _unpack_fields_off;
494
495 BufferedInlineTypeBlob(int size, CodeBuffer* cb, int pack_fields_off, int pack_fields_jobject_off, int unpack_fields_off);
496
497 public:
498 // Creation
499 static BufferedInlineTypeBlob* create(CodeBuffer* cb, int pack_fields_off, int pack_fields_jobject_off, int unpack_fields_off);
500
501 address pack_fields() const { return code_begin() + _pack_fields_off; }
502 address pack_fields_jobject() const { return code_begin() + _pack_fields_jobject_off; }
503 address unpack_fields() const { return code_begin() + _unpack_fields_off; }
504
505 // Typing
506 virtual bool is_buffered_inline_type_blob() const { return true; }
507 };
508
509 //----------------------------------------------------------------------------------------------------
510 // RuntimeStub: describes stubs used by compiled code to call a (static) C++ runtime routine
511
512 class RuntimeStub: public RuntimeBlob {
513 friend class VMStructs;
514 private:
515 // Creation support
516 RuntimeStub(
517 const char* name,
518 CodeBuffer* cb,
519 int size,
520 int frame_complete,
521 int frame_size,
522 OopMapSet* oop_maps,
523 bool caller_must_gc_arguments
524 );
525
526 // This ordinary operator delete is needed even though not used, so the
527 // below two-argument operator delete will be treated as a placement
|