src/share/vm/code/codeBlob.cpp

Print this page
rev 4202 : 8008555: Debugging code in compiled method sometimes leaks memory
Summary: support for strings that have same life-time as code that uses them.
Reviewed-by:


 169     }
 170     Forte::register_stub(stub_id, stub->code_begin(), stub->code_end());
 171 
 172     if (JvmtiExport::should_post_dynamic_code_generated()) {
 173       const char* stub_name = name2;
 174       if (name2[0] == '\0')  stub_name = name1;
 175       JvmtiExport::post_dynamic_code_generated(stub_name, stub->code_begin(), stub->code_end());
 176     }
 177   }
 178 
 179   // Track memory usage statistic after releasing CodeCache_lock
 180   MemoryService::track_code_cache_memory_usage();
 181 }
 182 
 183 
 184 void CodeBlob::flush() {
 185   if (_oop_maps) {
 186     FREE_C_HEAP_ARRAY(unsigned char, _oop_maps, mtCode);
 187     _oop_maps = NULL;
 188   }
 189   _comments.free();
 190 }
 191 
 192 
 193 OopMap* CodeBlob::oop_map_for_return_address(address return_address) {
 194   assert(oop_maps() != NULL, "nope");
 195   return oop_maps()->find_map_at_offset((intptr_t) return_address - (intptr_t) code_begin());
 196 }
 197 
 198 
 199 //----------------------------------------------------------------------------------------------------
 200 // Implementation of BufferBlob
 201 
 202 
 203 BufferBlob::BufferBlob(const char* name, int size)
 204 : CodeBlob(name, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, /*locs_size:*/ 0)
 205 {}
 206 
 207 BufferBlob* BufferBlob::create(const char* name, int buffer_size) {
 208   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
 209 




 169     }
 170     Forte::register_stub(stub_id, stub->code_begin(), stub->code_end());
 171 
 172     if (JvmtiExport::should_post_dynamic_code_generated()) {
 173       const char* stub_name = name2;
 174       if (name2[0] == '\0')  stub_name = name1;
 175       JvmtiExport::post_dynamic_code_generated(stub_name, stub->code_begin(), stub->code_end());
 176     }
 177   }
 178 
 179   // Track memory usage statistic after releasing CodeCache_lock
 180   MemoryService::track_code_cache_memory_usage();
 181 }
 182 
 183 
 184 void CodeBlob::flush() {
 185   if (_oop_maps) {
 186     FREE_C_HEAP_ARRAY(unsigned char, _oop_maps, mtCode);
 187     _oop_maps = NULL;
 188   }
 189   _strings.free();
 190 }
 191 
 192 
 193 OopMap* CodeBlob::oop_map_for_return_address(address return_address) {
 194   assert(oop_maps() != NULL, "nope");
 195   return oop_maps()->find_map_at_offset((intptr_t) return_address - (intptr_t) code_begin());
 196 }
 197 
 198 
 199 //----------------------------------------------------------------------------------------------------
 200 // Implementation of BufferBlob
 201 
 202 
 203 BufferBlob::BufferBlob(const char* name, int size)
 204 : CodeBlob(name, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, /*locs_size:*/ 0)
 205 {}
 206 
 207 BufferBlob* BufferBlob::create(const char* name, int buffer_size) {
 208   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
 209