212 BufferBlob::BufferBlob(const char* name, int size, CodeBuffer* cb) 213 : CodeBlob(name, cb, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, 0, NULL) 214 {} 215 216 BufferBlob* BufferBlob::create(const char* name, CodeBuffer* cb) { 217 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 218 219 BufferBlob* blob = NULL; 220 unsigned int size = allocation_size(cb, sizeof(BufferBlob)); 221 assert(name != NULL, "must provide a name"); 222 { 223 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 224 blob = new (size) BufferBlob(name, size, cb); 225 } 226 // Track memory usage statistic after releasing CodeCache_lock 227 MemoryService::track_code_cache_memory_usage(); 228 229 return blob; 230 } 231 232 233 void* BufferBlob::operator new(size_t s, unsigned size, bool is_critical) throw() { 234 void* p = CodeCache::allocate(size, is_critical); 235 return p; 236 } 237 238 239 void BufferBlob::free( BufferBlob *blob ) { 240 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 241 blob->flush(); 242 { 243 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 244 CodeCache::free((CodeBlob*)blob); 245 } 246 // Track memory usage statistic after releasing CodeCache_lock 247 MemoryService::track_code_cache_memory_usage(); 248 } 249 250 251 //---------------------------------------------------------------------------------------------------- 252 // Implementation of AdapterBlob 253 254 AdapterBlob::AdapterBlob(int size, CodeBuffer* cb) : 255 BufferBlob("I2C/C2I adapters", size, cb) { 256 CodeCache::commit(this); 257 } 258 259 AdapterBlob* AdapterBlob::create(CodeBuffer* cb) { 282 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 283 284 MethodHandlesAdapterBlob* blob = NULL; 285 unsigned int size = sizeof(MethodHandlesAdapterBlob); 286 // align the size to CodeEntryAlignment 287 size = align_code_offset(size); 288 size += round_to(buffer_size, oopSize); 289 { 290 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 291 // The parameter 'true' indicates a critical memory allocation. 292 // This means that CodeCacheMinimumFreeSpace is used, if necessary 293 const bool is_critical = true; 294 blob = new (size, is_critical) MethodHandlesAdapterBlob(size); 295 } 296 // Track memory usage statistic after releasing CodeCache_lock 297 MemoryService::track_code_cache_memory_usage(); 298 299 return blob; 300 } 301 302 303 //---------------------------------------------------------------------------------------------------- 304 // Implementation of RuntimeStub 305 306 RuntimeStub::RuntimeStub( 307 const char* name, 308 CodeBuffer* cb, 309 int size, 310 int frame_complete, 311 int frame_size, 312 OopMapSet* oop_maps, 313 bool caller_must_gc_arguments 314 ) 315 : CodeBlob(name, cb, sizeof(RuntimeStub), size, frame_complete, frame_size, oop_maps) 316 { 317 _caller_must_gc_arguments = caller_must_gc_arguments; 318 } 319 320 321 RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name, 322 CodeBuffer* cb, 323 int frame_complete, 324 int frame_size, 325 OopMapSet* oop_maps, 326 bool caller_must_gc_arguments) 327 { 328 RuntimeStub* stub = NULL; 329 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 330 { 331 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 332 unsigned int size = allocation_size(cb, sizeof(RuntimeStub)); 333 stub = new (size) RuntimeStub(stub_name, cb, size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments); 334 } 335 336 trace_new_stub(stub, "RuntimeStub - ", stub_name); 337 338 return stub; 339 } 340 341 342 void* RuntimeStub::operator new(size_t s, unsigned size) throw() { 343 void* p = CodeCache::allocate(size, true); 344 if (!p) fatal("Initial size of CodeCache is too small"); 345 return p; 346 } 347 348 // operator new shared by all singletons: 349 void* SingletonBlob::operator new(size_t s, unsigned size) throw() { 350 void* p = CodeCache::allocate(size, true); 351 if (!p) fatal("Initial size of CodeCache is too small"); 352 return p; 353 } 354 355 356 //---------------------------------------------------------------------------------------------------- 357 // Implementation of DeoptimizationBlob 358 359 DeoptimizationBlob::DeoptimizationBlob( 360 CodeBuffer* cb, 361 int size, 362 OopMapSet* oop_maps, 363 int unpack_offset, 364 int unpack_with_exception_offset, 365 int unpack_with_reexecution_offset, 366 int frame_size 367 ) 368 : SingletonBlob("DeoptimizationBlob", cb, sizeof(DeoptimizationBlob), size, frame_size, oop_maps) 369 { 370 _unpack_offset = unpack_offset; | 212 BufferBlob::BufferBlob(const char* name, int size, CodeBuffer* cb) 213 : CodeBlob(name, cb, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, 0, NULL) 214 {} 215 216 BufferBlob* BufferBlob::create(const char* name, CodeBuffer* cb) { 217 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 218 219 BufferBlob* blob = NULL; 220 unsigned int size = allocation_size(cb, sizeof(BufferBlob)); 221 assert(name != NULL, "must provide a name"); 222 { 223 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 224 blob = new (size) BufferBlob(name, size, cb); 225 } 226 // Track memory usage statistic after releasing CodeCache_lock 227 MemoryService::track_code_cache_memory_usage(); 228 229 return blob; 230 } 231 232 void* BufferBlob::operator new(size_t s, unsigned size, bool is_critical) throw() { 233 return CodeCache::allocate(size, CodeBlobType::NonMethod, is_critical); 234 } 235 236 void BufferBlob::free(BufferBlob *blob) { 237 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 238 blob->flush(); 239 { 240 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 241 CodeCache::free((CodeBlob*)blob); 242 } 243 // Track memory usage statistic after releasing CodeCache_lock 244 MemoryService::track_code_cache_memory_usage(); 245 } 246 247 248 //---------------------------------------------------------------------------------------------------- 249 // Implementation of AdapterBlob 250 251 AdapterBlob::AdapterBlob(int size, CodeBuffer* cb) : 252 BufferBlob("I2C/C2I adapters", size, cb) { 253 CodeCache::commit(this); 254 } 255 256 AdapterBlob* AdapterBlob::create(CodeBuffer* cb) { 279 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 280 281 MethodHandlesAdapterBlob* blob = NULL; 282 unsigned int size = sizeof(MethodHandlesAdapterBlob); 283 // align the size to CodeEntryAlignment 284 size = align_code_offset(size); 285 size += round_to(buffer_size, oopSize); 286 { 287 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 288 // The parameter 'true' indicates a critical memory allocation. 289 // This means that CodeCacheMinimumFreeSpace is used, if necessary 290 const bool is_critical = true; 291 blob = new (size, is_critical) MethodHandlesAdapterBlob(size); 292 } 293 // Track memory usage statistic after releasing CodeCache_lock 294 MemoryService::track_code_cache_memory_usage(); 295 296 return blob; 297 } 298 299 //---------------------------------------------------------------------------------------------------- 300 // Implementation of RuntimeStub 301 302 RuntimeStub::RuntimeStub( 303 const char* name, 304 CodeBuffer* cb, 305 int size, 306 int frame_complete, 307 int frame_size, 308 OopMapSet* oop_maps, 309 bool caller_must_gc_arguments 310 ) 311 : CodeBlob(name, cb, sizeof(RuntimeStub), size, frame_complete, frame_size, oop_maps) 312 { 313 _caller_must_gc_arguments = caller_must_gc_arguments; 314 } 315 316 317 RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name, 318 CodeBuffer* cb, 319 int frame_complete, 320 int frame_size, 321 OopMapSet* oop_maps, 322 bool caller_must_gc_arguments) 323 { 324 RuntimeStub* stub = NULL; 325 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 326 { 327 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 328 unsigned int size = allocation_size(cb, sizeof(RuntimeStub)); 329 stub = new (size) RuntimeStub(stub_name, cb, size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments); 330 } 331 332 trace_new_stub(stub, "RuntimeStub - ", stub_name); 333 334 return stub; 335 } 336 337 338 void* RuntimeStub::operator new(size_t s, unsigned size) throw() { 339 void* p = CodeCache::allocate(size, CodeBlobType::NonMethod, true); 340 if (!p) fatal("Initial size of CodeCache is too small"); 341 return p; 342 } 343 344 // operator new shared by all singletons: 345 void* SingletonBlob::operator new(size_t s, unsigned size) throw() { 346 void* p = CodeCache::allocate(size, CodeBlobType::NonMethod, true); 347 if (!p) fatal("Initial size of CodeCache is too small"); 348 return p; 349 } 350 351 352 //---------------------------------------------------------------------------------------------------- 353 // Implementation of DeoptimizationBlob 354 355 DeoptimizationBlob::DeoptimizationBlob( 356 CodeBuffer* cb, 357 int size, 358 OopMapSet* oop_maps, 359 int unpack_offset, 360 int unpack_with_exception_offset, 361 int unpack_with_reexecution_offset, 362 int frame_size 363 ) 364 : SingletonBlob("DeoptimizationBlob", cb, sizeof(DeoptimizationBlob), size, frame_size, oop_maps) 365 { 366 _unpack_offset = unpack_offset; |