< prev index next >

src/hotspot/share/code/codeBlob.cpp

Print this page

170   _code_offset(_content_offset),
171   _data_offset(size),
172   _frame_size(0),
173   S390_ONLY(_ctable_offset(0) COMMA)
174   _header_size(header_size),
175   _frame_complete_offset(CodeOffsets::frame_never_safe),
176   _kind(kind),
177   _caller_must_gc_arguments(false)
178 {
179   assert(is_aligned(size,            oopSize), "unaligned size");
180   assert(is_aligned(header_size,     oopSize), "unaligned size");
181   assert(_mutable_data = blob_end(), "sanity");
182 }
183 
184 void CodeBlob::purge() {
185   assert(_mutable_data != nullptr, "should never be null");
186   if (_mutable_data != blob_end()) {
187     os::free(_mutable_data);
188     _mutable_data = blob_end(); // Valid not null address
189   }
190   if (_oop_maps != nullptr) {
191     delete _oop_maps;
192     _oop_maps = nullptr;
193   }
194   NOT_PRODUCT(_asm_remarks.clear());
195   NOT_PRODUCT(_dbg_strings.clear());
196 }
197 
198 void CodeBlob::set_oop_maps(OopMapSet* p) {
199   // Danger Will Robinson! This method allocates a big
200   // chunk of memory, its your job to free it.
201   if (p != nullptr) {
202     _oop_maps = ImmutableOopMapSet::build_from(p);
203   } else {
204     _oop_maps = nullptr;
205   }
206 }
207 
208 const ImmutableOopMap* CodeBlob::oop_map_for_return_address(address return_address) const {
209   assert(_oop_maps != nullptr, "nope");
210   return _oop_maps->find_map_at_offset((intptr_t) return_address - (intptr_t) code_begin());
211 }
212 
213 void CodeBlob::print_code_on(outputStream* st) {
214   ResourceMark m;
215   Disassembler::decode(this, st);
216 }
217 










218 //-----------------------------------------------------------------------------------------
219 // Creates a RuntimeBlob from a CodeBuffer and copy code and relocation info.
220 
221 RuntimeBlob::RuntimeBlob(
222   const char* name,
223   CodeBlobKind kind,
224   CodeBuffer* cb,
225   int         size,
226   uint16_t    header_size,
227   int16_t     frame_complete,
228   int         frame_size,
229   OopMapSet*  oop_maps,
230   bool        caller_must_gc_arguments)
231   : CodeBlob(name, kind, cb, size, header_size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments,
232              align_up(cb->total_relocation_size(), oopSize))
233 {
234   cb->copy_code_and_locs_to(this);
235 }
236 
237 void RuntimeBlob::free(RuntimeBlob* blob) {

170   _code_offset(_content_offset),
171   _data_offset(size),
172   _frame_size(0),
173   S390_ONLY(_ctable_offset(0) COMMA)
174   _header_size(header_size),
175   _frame_complete_offset(CodeOffsets::frame_never_safe),
176   _kind(kind),
177   _caller_must_gc_arguments(false)
178 {
179   assert(is_aligned(size,            oopSize), "unaligned size");
180   assert(is_aligned(header_size,     oopSize), "unaligned size");
181   assert(_mutable_data = blob_end(), "sanity");
182 }
183 
184 void CodeBlob::purge() {
185   assert(_mutable_data != nullptr, "should never be null");
186   if (_mutable_data != blob_end()) {
187     os::free(_mutable_data);
188     _mutable_data = blob_end(); // Valid not null address
189   }
190   if (_oop_maps != nullptr && !AOTCodeCache::is_address_in_aot_cache((address)_oop_maps)) {
191     delete _oop_maps;
192     _oop_maps = nullptr;
193   }
194   NOT_PRODUCT(_asm_remarks.clear());
195   NOT_PRODUCT(_dbg_strings.clear());
196 }
197 
198 void CodeBlob::set_oop_maps(OopMapSet* p) {
199   // Danger Will Robinson! This method allocates a big
200   // chunk of memory, its your job to free it.
201   if (p != nullptr) {
202     _oop_maps = ImmutableOopMapSet::build_from(p);
203   } else {
204     _oop_maps = nullptr;
205   }
206 }
207 
208 const ImmutableOopMap* CodeBlob::oop_map_for_return_address(address return_address) const {
209   assert(_oop_maps != nullptr, "nope");
210   return _oop_maps->find_map_at_offset((intptr_t) return_address - (intptr_t) code_begin());
211 }
212 
213 void CodeBlob::print_code_on(outputStream* st) {
214   ResourceMark m;
215   Disassembler::decode(this, st);
216 }
217 
218 void CodeBlob::prepare_for_archiving() {
219   set_name(nullptr);
220   _oop_maps = nullptr;
221   _mutable_data = nullptr;
222 #ifndef PRODUCT
223   asm_remarks().clear();
224   dbg_strings().clear();
225 #endif /* PRODUCT */
226 }
227 
228 //-----------------------------------------------------------------------------------------
229 // Creates a RuntimeBlob from a CodeBuffer and copy code and relocation info.
230 
231 RuntimeBlob::RuntimeBlob(
232   const char* name,
233   CodeBlobKind kind,
234   CodeBuffer* cb,
235   int         size,
236   uint16_t    header_size,
237   int16_t     frame_complete,
238   int         frame_size,
239   OopMapSet*  oop_maps,
240   bool        caller_must_gc_arguments)
241   : CodeBlob(name, kind, cb, size, header_size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments,
242              align_up(cb->total_relocation_size(), oopSize))
243 {
244   cb->copy_code_and_locs_to(this);
245 }
246 
247 void RuntimeBlob::free(RuntimeBlob* blob) {
< prev index next >