253 MemoryService::track_code_cache_memory_usage(); 254 255 return blob; 256 } 257 258 void* BufferBlob::operator new(size_t s, unsigned size) throw() { 259 return CodeCache::allocate(size, CodeBlobType::NonNMethod); 260 } 261 262 void BufferBlob::free(BufferBlob *blob) { 263 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 264 blob->flush(); 265 { 266 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 267 CodeCache::free((RuntimeBlob*)blob); 268 } 269 // Track memory usage statistic after releasing CodeCache_lock 270 MemoryService::track_code_cache_memory_usage(); 271 } 272 273 BufferBlob::BufferBlob(const char* name, int size, CodeBuffer* cb, int frame_complete, int frame_size, OopMapSet* oop_maps) 274 : RuntimeBlob(name, cb, sizeof(BufferBlob), size, frame_complete, frame_size, oop_maps) 275 {} 276 277 278 //---------------------------------------------------------------------------------------------------- 279 // Implementation of AdapterBlob 280 281 AdapterBlob::AdapterBlob(int size, CodeBuffer* cb, int frame_complete, int frame_size, OopMapSet* oop_maps) : 282 BufferBlob("I2C/C2I adapters", size, cb, frame_complete, frame_size, oop_maps) { 283 CodeCache::commit(this); 284 } 285 286 AdapterBlob* AdapterBlob::create(CodeBuffer* cb, int frame_complete, int frame_size, OopMapSet* oop_maps) { 287 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 288 289 AdapterBlob* blob = NULL; 290 unsigned int size = CodeBlob::allocation_size(cb, sizeof(AdapterBlob)); 291 { 292 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 293 blob = new (size) AdapterBlob(size, cb, frame_complete, frame_size, oop_maps); 294 } 295 // Track memory usage statistic after releasing CodeCache_lock 296 MemoryService::track_code_cache_memory_usage(); 297 298 return blob; 299 } 300 301 VtableBlob::VtableBlob(const char* name, int size) : 302 BufferBlob(name, size) { 303 } 304 305 VtableBlob* VtableBlob::create(const char* name, int buffer_size) { 306 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 307 308 VtableBlob* blob = NULL; 309 unsigned int size = sizeof(VtableBlob); 310 // align the size to CodeEntryAlignment 311 size = align_code_offset(size); 312 size += align_up(buffer_size, oopSize); 313 assert(name != NULL, "must provide a name"); | 253 MemoryService::track_code_cache_memory_usage(); 254 255 return blob; 256 } 257 258 void* BufferBlob::operator new(size_t s, unsigned size) throw() { 259 return CodeCache::allocate(size, CodeBlobType::NonNMethod); 260 } 261 262 void BufferBlob::free(BufferBlob *blob) { 263 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 264 blob->flush(); 265 { 266 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 267 CodeCache::free((RuntimeBlob*)blob); 268 } 269 // Track memory usage statistic after releasing CodeCache_lock 270 MemoryService::track_code_cache_memory_usage(); 271 } 272 273 BufferBlob::BufferBlob(const char* name, int size, CodeBuffer* cb, int frame_complete, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments) 274 : RuntimeBlob(name, cb, sizeof(BufferBlob), size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments) 275 {} 276 277 278 //---------------------------------------------------------------------------------------------------- 279 // Implementation of AdapterBlob 280 281 AdapterBlob::AdapterBlob(int size, CodeBuffer* cb, int frame_complete, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments) : 282 BufferBlob("I2C/C2I adapters", size, cb, frame_complete, frame_size, oop_maps, caller_must_gc_arguments) { 283 CodeCache::commit(this); 284 } 285 286 AdapterBlob* AdapterBlob::create(CodeBuffer* cb, int frame_complete, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments) { 287 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 288 289 AdapterBlob* blob = NULL; 290 unsigned int size = CodeBlob::allocation_size(cb, sizeof(AdapterBlob)); 291 { 292 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 293 blob = new (size) AdapterBlob(size, cb, frame_complete, frame_size, oop_maps, caller_must_gc_arguments); 294 } 295 // Track memory usage statistic after releasing CodeCache_lock 296 MemoryService::track_code_cache_memory_usage(); 297 298 return blob; 299 } 300 301 VtableBlob::VtableBlob(const char* name, int size) : 302 BufferBlob(name, size) { 303 } 304 305 VtableBlob* VtableBlob::create(const char* name, int buffer_size) { 306 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 307 308 VtableBlob* blob = NULL; 309 unsigned int size = sizeof(VtableBlob); 310 // align the size to CodeEntryAlignment 311 size = align_code_offset(size); 312 size += align_up(buffer_size, oopSize); 313 assert(name != NULL, "must provide a name"); |