228 : CodeBlob(name, cb, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, 0, NULL) 229 {} 230 231 BufferBlob* BufferBlob::create(const char* name, CodeBuffer* cb) { 232 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 233 234 BufferBlob* blob = NULL; 235 unsigned int size = allocation_size(cb, sizeof(BufferBlob)); 236 assert(name != NULL, "must provide a name"); 237 { 238 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 239 blob = new (size) BufferBlob(name, size, cb); 240 } 241 // Track memory usage statistic after releasing CodeCache_lock 242 MemoryService::track_code_cache_memory_usage(); 243 244 return blob; 245 } 246 247 248 void* BufferBlob::operator new(size_t s, unsigned size) throw() { 249 void* p = CodeCache::allocate(size); 250 return p; 251 } 252 253 254 void BufferBlob::free( BufferBlob *blob ) { 255 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 256 { 257 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 258 CodeCache::free((CodeBlob*)blob); 259 } 260 // Track memory usage statistic after releasing CodeCache_lock 261 MemoryService::track_code_cache_memory_usage(); 262 } 263 264 265 //---------------------------------------------------------------------------------------------------- 266 // Implementation of AdapterBlob 267 268 AdapterBlob::AdapterBlob(int size, CodeBuffer* cb) : 269 BufferBlob("I2C/C2I adapters", size, cb) { 270 CodeCache::commit(this); 271 } 272 273 AdapterBlob* AdapterBlob::create(CodeBuffer* cb) { 274 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 275 276 AdapterBlob* blob = NULL; 277 unsigned int size = allocation_size(cb, sizeof(AdapterBlob)); 278 { 279 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 280 blob = new (size) AdapterBlob(size, cb); 281 } 282 // Track memory usage statistic after releasing CodeCache_lock 283 MemoryService::track_code_cache_memory_usage(); 284 285 return blob; 286 } 287 288 289 //---------------------------------------------------------------------------------------------------- 290 // Implementation of MethodHandlesAdapterBlob 291 292 MethodHandlesAdapterBlob* MethodHandlesAdapterBlob::create(int buffer_size) { 293 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 294 295 MethodHandlesAdapterBlob* blob = NULL; 296 unsigned int size = sizeof(MethodHandlesAdapterBlob); 297 // align the size to CodeEntryAlignment 298 size = align_code_offset(size); 299 size += round_to(buffer_size, oopSize); 300 { 301 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 302 blob = new (size) MethodHandlesAdapterBlob(size); 303 } 304 // Track memory usage statistic after releasing CodeCache_lock 305 MemoryService::track_code_cache_memory_usage(); 306 307 return blob; 308 } 309 310 311 //---------------------------------------------------------------------------------------------------- 312 // Implementation of RuntimeStub 313 314 RuntimeStub::RuntimeStub( 315 const char* name, 316 CodeBuffer* cb, 317 int size, 318 int frame_complete, 319 int frame_size, 320 OopMapSet* oop_maps, 321 bool caller_must_gc_arguments 322 ) | 228 : CodeBlob(name, cb, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, 0, NULL) 229 {} 230 231 BufferBlob* BufferBlob::create(const char* name, CodeBuffer* cb) { 232 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 233 234 BufferBlob* blob = NULL; 235 unsigned int size = allocation_size(cb, sizeof(BufferBlob)); 236 assert(name != NULL, "must provide a name"); 237 { 238 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 239 blob = new (size) BufferBlob(name, size, cb); 240 } 241 // Track memory usage statistic after releasing CodeCache_lock 242 MemoryService::track_code_cache_memory_usage(); 243 244 return blob; 245 } 246 247 248 void* BufferBlob::operator new(size_t s, unsigned size, bool is_critical) throw() { 249 void* p = CodeCache::allocate(size, is_critical); 250 return p; 251 } 252 253 254 void BufferBlob::free( BufferBlob *blob ) { 255 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 256 { 257 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 258 CodeCache::free((CodeBlob*)blob); 259 } 260 // Track memory usage statistic after releasing CodeCache_lock 261 MemoryService::track_code_cache_memory_usage(); 262 } 263 264 265 //---------------------------------------------------------------------------------------------------- 266 // Implementation of AdapterBlob 267 268 AdapterBlob::AdapterBlob(int size, CodeBuffer* cb) : 269 BufferBlob("I2C/C2I adapters", size, cb) { 270 CodeCache::commit(this); 271 } 272 273 AdapterBlob* AdapterBlob::create(CodeBuffer* cb) { 274 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 275 276 AdapterBlob* blob = NULL; 277 unsigned int size = allocation_size(cb, sizeof(AdapterBlob)); 278 { 279 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 280 // The parameter 'true' indicates a critical memory allocation. 281 // This means that CodeCacheMinimumFreeSpace is used, if necessary 282 const bool is_critical = true; 283 blob = new (size, is_critical) AdapterBlob(size, cb); 284 } 285 // Track memory usage statistic after releasing CodeCache_lock 286 MemoryService::track_code_cache_memory_usage(); 287 288 return blob; 289 } 290 291 292 //---------------------------------------------------------------------------------------------------- 293 // Implementation of MethodHandlesAdapterBlob 294 295 MethodHandlesAdapterBlob* MethodHandlesAdapterBlob::create(int buffer_size) { 296 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 297 298 MethodHandlesAdapterBlob* blob = NULL; 299 unsigned int size = sizeof(MethodHandlesAdapterBlob); 300 // align the size to CodeEntryAlignment 301 size = align_code_offset(size); 302 size += round_to(buffer_size, oopSize); 303 { 304 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 305 // The parameter 'true' indicates a critical memory allocation. 306 // This means that CodeCacheMinimumFreeSpace is used, if necessary 307 const bool is_critical = true; 308 blob = new (size, is_critical) MethodHandlesAdapterBlob(size); 309 } 310 // Track memory usage statistic after releasing CodeCache_lock 311 MemoryService::track_code_cache_memory_usage(); 312 313 return blob; 314 } 315 316 317 //---------------------------------------------------------------------------------------------------- 318 // Implementation of RuntimeStub 319 320 RuntimeStub::RuntimeStub( 321 const char* name, 322 CodeBuffer* cb, 323 int size, 324 int frame_complete, 325 int frame_size, 326 OopMapSet* oop_maps, 327 bool caller_must_gc_arguments 328 ) |