< prev index next >

src/hotspot/share/code/codeBlob.cpp

Print this page




  56 unsigned int CodeBlob::align_code_offset(int offset) {
  57   // align the size to CodeEntryAlignment
  58   return
  59     ((offset + (int)CodeHeap::header_size() + (CodeEntryAlignment-1)) & ~(CodeEntryAlignment-1))
  60     - (int)CodeHeap::header_size();
  61 }
  62 
  63 
  64 // This must be consistent with the CodeBlob constructor's layout actions.
  65 unsigned int CodeBlob::allocation_size(CodeBuffer* cb, int header_size) {
  66   unsigned int size = header_size;
  67   size += align_up(cb->total_relocation_size(), oopSize);
  68   // align the size to CodeEntryAlignment
  69   size = align_code_offset(size);
  70   size += align_up(cb->total_content_size(), oopSize);
  71   size += align_up(cb->total_oop_size(), oopSize);
  72   size += align_up(cb->total_metadata_size(), oopSize);
  73   return size;
  74 }
  75 
  76 CodeBlob::CodeBlob(const char* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments) :
  77   _type(type),
  78   _size(layout.size()),
  79   _header_size(layout.header_size()),
  80   _frame_complete_offset(frame_complete_offset),
  81   _data_offset(layout.data_offset()),
  82   _frame_size(frame_size),
  83   _code_begin(layout.code_begin()),
  84   _code_end(layout.code_end()),
  85   _content_begin(layout.content_begin()),
  86   _data_end(layout.data_end()),
  87   _relocation_begin(layout.relocation_begin()),
  88   _relocation_end(layout.relocation_end()),

  89   _oop_maps(oop_maps),
  90   _caller_must_gc_arguments(caller_must_gc_arguments),
  91   _strings(CodeStrings()),
  92   _name(name)
  93 {
  94   assert(is_aligned(layout.size(),            oopSize), "unaligned size");
  95   assert(is_aligned(layout.header_size(),     oopSize), "unaligned size");
  96   assert(is_aligned(layout.relocation_size(), oopSize), "unaligned size");
  97   assert(layout.code_end() == layout.content_end(), "must be the same - see code_end()");
  98 #ifdef COMPILER1
  99   // probably wrong for tiered
 100   assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs");
 101 #endif // COMPILER1
 102 }
 103 
 104 CodeBlob::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) :
 105   _type(type),
 106   _size(layout.size()),
 107   _header_size(layout.header_size()),
 108   _frame_complete_offset(frame_complete_offset),
 109   _data_offset(layout.data_offset()),
 110   _frame_size(frame_size),
 111   _code_begin(layout.code_begin()),
 112   _code_end(layout.code_end()),
 113   _content_begin(layout.content_begin()),
 114   _data_end(layout.data_end()),
 115   _relocation_begin(layout.relocation_begin()),
 116   _relocation_end(layout.relocation_end()),

 117   _caller_must_gc_arguments(caller_must_gc_arguments),
 118   _strings(CodeStrings()),
 119   _name(name)
 120 {
 121   assert(is_aligned(_size,        oopSize), "unaligned size");
 122   assert(is_aligned(_header_size, oopSize), "unaligned size");
 123   assert(_data_offset <= _size, "codeBlob is too small");
 124   assert(layout.code_end() == layout.content_end(), "must be the same - see code_end()");
 125 
 126   set_oop_maps(oop_maps);
 127 #ifdef COMPILER1
 128   // probably wrong for tiered
 129   assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs");
 130 #endif // COMPILER1
 131 }
 132 
 133 
 134 // Creates a simple CodeBlob. Sets up the size of the different regions.
 135 RuntimeBlob::RuntimeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size)
 136   : CodeBlob(name, compiler_none, CodeBlobLayout((address) this, size, header_size, locs_size, size), frame_complete, 0, NULL, false /* caller_must_gc_arguments */)


 189       if ((stub->oop_maps() != NULL) && AbstractDisassembler::show_structs()) {
 190         tty->print_cr("- - - [OOP MAPS]- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
 191         stub->oop_maps()->print();
 192       }
 193       tty->print_cr("- - - [END] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
 194       tty->cr();
 195     }
 196     Forte::register_stub(stub_id, stub->code_begin(), stub->code_end());
 197 
 198     if (JvmtiExport::should_post_dynamic_code_generated()) {
 199       const char* stub_name = name2;
 200       if (name2[0] == '\0')  stub_name = name1;
 201       JvmtiExport::post_dynamic_code_generated(stub_name, stub->code_begin(), stub->code_end());
 202     }
 203   }
 204 
 205   // Track memory usage statistic after releasing CodeCache_lock
 206   MemoryService::track_code_cache_memory_usage();
 207 }
 208 
 209 const ImmutableOopMap* CodeBlob::oop_map_for_return_address(address return_address) {
 210   assert(_oop_maps != NULL, "nope");
 211   return _oop_maps->find_map_at_offset((intptr_t) return_address - (intptr_t) code_begin());
 212 }
 213 
 214 void CodeBlob::print_code() {
 215   ResourceMark m;
 216   Disassembler::decode(this, tty);
 217 }
 218 
 219 //----------------------------------------------------------------------------------------------------
 220 // Implementation of BufferBlob
 221 
 222 
 223 BufferBlob::BufferBlob(const char* name, int size)
 224 : RuntimeBlob(name, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, /*locs_size:*/ 0)
 225 {}
 226 
 227 BufferBlob* BufferBlob::create(const char* name, int buffer_size) {
 228   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
 229 




  56 unsigned int CodeBlob::align_code_offset(int offset) {
  57   // align the size to CodeEntryAlignment
  58   return
  59     ((offset + (int)CodeHeap::header_size() + (CodeEntryAlignment-1)) & ~(CodeEntryAlignment-1))
  60     - (int)CodeHeap::header_size();
  61 }
  62 
  63 
  64 // This must be consistent with the CodeBlob constructor's layout actions.
  65 unsigned int CodeBlob::allocation_size(CodeBuffer* cb, int header_size) {
  66   unsigned int size = header_size;
  67   size += align_up(cb->total_relocation_size(), oopSize);
  68   // align the size to CodeEntryAlignment
  69   size = align_code_offset(size);
  70   size += align_up(cb->total_content_size(), oopSize);
  71   size += align_up(cb->total_oop_size(), oopSize);
  72   size += align_up(cb->total_metadata_size(), oopSize);
  73   return size;
  74 }
  75 
  76 CodeBlob::CodeBlob(const char* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments, bool compiled) :
  77   _type(type),
  78   _size(layout.size()),
  79   _header_size(layout.header_size()),
  80   _frame_complete_offset(frame_complete_offset),
  81   _data_offset(layout.data_offset()),
  82   _frame_size(frame_size),
  83   _code_begin(layout.code_begin()),
  84   _code_end(layout.code_end()),
  85   _content_begin(layout.content_begin()),
  86   _data_end(layout.data_end()),
  87   _relocation_begin(layout.relocation_begin()),
  88   _relocation_end(layout.relocation_end()),
  89   _is_compiled(compiled),
  90   _oop_maps(oop_maps),
  91   _caller_must_gc_arguments(caller_must_gc_arguments),
  92   _strings(CodeStrings()),
  93   _name(name)
  94 {
  95   assert(is_aligned(layout.size(),            oopSize), "unaligned size");
  96   assert(is_aligned(layout.header_size(),     oopSize), "unaligned size");
  97   assert(is_aligned(layout.relocation_size(), oopSize), "unaligned size");
  98   assert(layout.code_end() == layout.content_end(), "must be the same - see code_end()");
  99 #ifdef COMPILER1
 100   // probably wrong for tiered
 101   assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs");
 102 #endif // COMPILER1
 103 }
 104 
 105 CodeBlob::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, bool compiled) :
 106   _type(type),
 107   _size(layout.size()),
 108   _header_size(layout.header_size()),
 109   _frame_complete_offset(frame_complete_offset),
 110   _data_offset(layout.data_offset()),
 111   _frame_size(frame_size),
 112   _code_begin(layout.code_begin()),
 113   _code_end(layout.code_end()),
 114   _content_begin(layout.content_begin()),
 115   _data_end(layout.data_end()),
 116   _relocation_begin(layout.relocation_begin()),
 117   _relocation_end(layout.relocation_end()),
 118   _is_compiled(compiled),
 119   _caller_must_gc_arguments(caller_must_gc_arguments),
 120   _strings(CodeStrings()),
 121   _name(name)
 122 {
 123   assert(is_aligned(_size,        oopSize), "unaligned size");
 124   assert(is_aligned(_header_size, oopSize), "unaligned size");
 125   assert(_data_offset <= _size, "codeBlob is too small");
 126   assert(layout.code_end() == layout.content_end(), "must be the same - see code_end()");
 127 
 128   set_oop_maps(oop_maps);
 129 #ifdef COMPILER1
 130   // probably wrong for tiered
 131   assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs");
 132 #endif // COMPILER1
 133 }
 134 
 135 
 136 // Creates a simple CodeBlob. Sets up the size of the different regions.
 137 RuntimeBlob::RuntimeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size)
 138   : CodeBlob(name, compiler_none, CodeBlobLayout((address) this, size, header_size, locs_size, size), frame_complete, 0, NULL, false /* caller_must_gc_arguments */)


 191       if ((stub->oop_maps() != NULL) && AbstractDisassembler::show_structs()) {
 192         tty->print_cr("- - - [OOP MAPS]- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
 193         stub->oop_maps()->print();
 194       }
 195       tty->print_cr("- - - [END] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
 196       tty->cr();
 197     }
 198     Forte::register_stub(stub_id, stub->code_begin(), stub->code_end());
 199 
 200     if (JvmtiExport::should_post_dynamic_code_generated()) {
 201       const char* stub_name = name2;
 202       if (name2[0] == '\0')  stub_name = name1;
 203       JvmtiExport::post_dynamic_code_generated(stub_name, stub->code_begin(), stub->code_end());
 204     }
 205   }
 206 
 207   // Track memory usage statistic after releasing CodeCache_lock
 208   MemoryService::track_code_cache_memory_usage();
 209 }
 210 
 211 const ImmutableOopMap* CodeBlob::oop_map_for_return_address(address return_address) const {
 212   assert(_oop_maps != NULL, "nope");
 213   return _oop_maps->find_map_at_offset((intptr_t) return_address - (intptr_t) code_begin());
 214 }
 215 
 216 void CodeBlob::print_code() {
 217   ResourceMark m;
 218   Disassembler::decode(this, tty);
 219 }
 220 
 221 //----------------------------------------------------------------------------------------------------
 222 // Implementation of BufferBlob
 223 
 224 
 225 BufferBlob::BufferBlob(const char* name, int size)
 226 : RuntimeBlob(name, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, /*locs_size:*/ 0)
 227 {}
 228 
 229 BufferBlob* BufferBlob::create(const char* name, int buffer_size) {
 230   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
 231 


< prev index next >