< prev index next >

src/hotspot/share/code/codeBlob.cpp

Print this page

 61 
 62 unsigned int CodeBlob::align_code_offset(int offset) {
 63   // align the size to CodeEntryAlignment
 64   int header_size = (int)CodeHeap::header_size();
 65   return align_up(offset + header_size, CodeEntryAlignment) - header_size;
 66 }
 67 
 68 
 69 // This must be consistent with the CodeBlob constructor's layout actions.
 70 unsigned int CodeBlob::allocation_size(CodeBuffer* cb, int header_size) {
 71   unsigned int size = header_size;
 72   size += align_up(cb->total_relocation_size(), oopSize);
 73   // align the size to CodeEntryAlignment
 74   size = align_code_offset(size);
 75   size += align_up(cb->total_content_size(), oopSize);
 76   size += align_up(cb->total_oop_size(), oopSize);
 77   size += align_up(cb->total_metadata_size(), oopSize);
 78   return size;
 79 }
 80 
 81 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) :
 82   _type(type),
 83   _size(layout.size()),
 84   _header_size(layout.header_size()),
 85   _frame_complete_offset(frame_complete_offset),
 86   _data_offset(layout.data_offset()),
 87   _frame_size(frame_size),
 88   _code_begin(layout.code_begin()),
 89   _code_end(layout.code_end()),
 90   _content_begin(layout.content_begin()),
 91   _data_end(layout.data_end()),
 92   _relocation_begin(layout.relocation_begin()),
 93   _relocation_end(layout.relocation_end()),

 94   _oop_maps(oop_maps),
 95   _caller_must_gc_arguments(caller_must_gc_arguments),
 96   _name(name)
 97 {
 98   assert(is_aligned(layout.size(),            oopSize), "unaligned size");
 99   assert(is_aligned(layout.header_size(),     oopSize), "unaligned size");
100   assert(is_aligned(layout.relocation_size(), oopSize), "unaligned size");
101   assert(layout.code_end() == layout.content_end(), "must be the same - see code_end()");
102 #ifdef COMPILER1
103   // probably wrong for tiered
104   assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs");
105 #endif // COMPILER1
106   S390_ONLY(_ctable_offset = 0;) // avoid uninitialized fields
107 }
108 
109 CodeBlob::CodeBlob(const char* name, CompilerType type, const CodeBlobLayout& layout, CodeBuffer* cb /*UNUSED*/, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments) :
110   _type(type),
111   _size(layout.size()),
112   _header_size(layout.header_size()),
113   _frame_complete_offset(frame_complete_offset),
114   _data_offset(layout.data_offset()),
115   _frame_size(frame_size),
116   _code_begin(layout.code_begin()),
117   _code_end(layout.code_end()),
118   _content_begin(layout.content_begin()),
119   _data_end(layout.data_end()),
120   _relocation_begin(layout.relocation_begin()),
121   _relocation_end(layout.relocation_end()),

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

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

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

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