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