227 BufferBlob::BufferBlob(const char* name, int size, CodeBuffer* cb) 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 { 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 ) 329 : CodeBlob(name, cb, sizeof(RuntimeStub), size, frame_complete, frame_size, oop_maps) 330 { 331 _caller_must_gc_arguments = caller_must_gc_arguments; 332 } 333 334 335 RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name, 336 CodeBuffer* cb, 337 int frame_complete, 338 int frame_size, 339 OopMapSet* oop_maps, 340 bool caller_must_gc_arguments) 341 { 342 RuntimeStub* stub = NULL; 343 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 344 { 345 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 346 unsigned int size = allocation_size(cb, sizeof(RuntimeStub)); 347 stub = new (size) RuntimeStub(stub_name, cb, size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments); 348 } 349 350 trace_new_stub(stub, "RuntimeStub - ", stub_name); 351 352 return stub; 353 } 354 355 356 void* RuntimeStub::operator new(size_t s, unsigned size) throw() { 357 void* p = CodeCache::allocate(size, true); 358 if (!p) fatal("Initial size of CodeCache is too small"); 359 return p; 360 } 361 362 // operator new shared by all singletons: 363 void* SingletonBlob::operator new(size_t s, unsigned size) throw() { 364 void* p = CodeCache::allocate(size, true); 365 if (!p) fatal("Initial size of CodeCache is too small"); 366 return p; 367 } 368 369 370 //---------------------------------------------------------------------------------------------------- 371 // Implementation of DeoptimizationBlob 372 373 DeoptimizationBlob::DeoptimizationBlob( 374 CodeBuffer* cb, 375 int size, 376 OopMapSet* oop_maps, 377 int unpack_offset, 378 int unpack_with_exception_offset, 379 int unpack_with_reexecution_offset, 380 int frame_size 381 ) 382 : SingletonBlob("DeoptimizationBlob", cb, sizeof(DeoptimizationBlob), size, frame_size, oop_maps) 383 { 384 _unpack_offset = unpack_offset; | 227 BufferBlob::BufferBlob(const char* name, int size, CodeBuffer* cb) 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 void* BufferBlob::operator new(size_t s, unsigned size, bool is_critical) throw() { 248 return CodeCache::allocate(size, CodeBlobType::NonMethod, is_critical); 249 } 250 251 void BufferBlob::free(BufferBlob *blob) { 252 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 253 { 254 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 255 CodeCache::free((CodeBlob*)blob, CodeBlobType::NonMethod); 256 } 257 // Track memory usage statistic after releasing CodeCache_lock 258 MemoryService::track_code_cache_memory_usage(); 259 } 260 261 262 //---------------------------------------------------------------------------------------------------- 263 // Implementation of AdapterBlob 264 265 AdapterBlob::AdapterBlob(int size, CodeBuffer* cb) : 266 BufferBlob("I2C/C2I adapters", size, cb) { 267 CodeCache::commit(this); 268 } 269 270 AdapterBlob* AdapterBlob::create(CodeBuffer* cb) { 271 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 272 273 AdapterBlob* blob = NULL; 274 unsigned int size = allocation_size(cb, sizeof(AdapterBlob)); 275 { 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 // The parameter 'true' indicates a critical memory allocation. 303 // This means that CodeCacheMinimumFreeSpace is used, if necessary 304 const bool is_critical = true; 305 blob = new (size, is_critical) MethodHandlesAdapterBlob(size); 306 } 307 // Track memory usage statistic after releasing CodeCache_lock 308 MemoryService::track_code_cache_memory_usage(); 309 310 return blob; 311 } 312 313 //---------------------------------------------------------------------------------------------------- 314 // Implementation of RuntimeStub 315 316 RuntimeStub::RuntimeStub( 317 const char* name, 318 CodeBuffer* cb, 319 int size, 320 int frame_complete, 321 int frame_size, 322 OopMapSet* oop_maps, 323 bool caller_must_gc_arguments 324 ) 325 : CodeBlob(name, cb, sizeof(RuntimeStub), size, frame_complete, frame_size, oop_maps) 326 { 327 _caller_must_gc_arguments = caller_must_gc_arguments; 328 } 329 330 331 RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name, 332 CodeBuffer* cb, 333 int frame_complete, 334 int frame_size, 335 OopMapSet* oop_maps, 336 bool caller_must_gc_arguments) 337 { 338 RuntimeStub* stub = NULL; 339 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 340 { 341 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 342 unsigned int size = allocation_size(cb, sizeof(RuntimeStub)); 343 stub = new (size) RuntimeStub(stub_name, cb, size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments); 344 } 345 346 trace_new_stub(stub, "RuntimeStub - ", stub_name); 347 348 return stub; 349 } 350 351 352 void* RuntimeStub::operator new(size_t s, unsigned size) throw() { 353 void* p = CodeCache::allocate(size, CodeBlobType::NonMethod, true); 354 if (!p) fatal("Initial size of CodeCache is too small"); 355 return p; 356 } 357 358 // operator new shared by all singletons: 359 void* SingletonBlob::operator new(size_t s, unsigned size) throw() { 360 void* p = CodeCache::allocate(size, CodeBlobType::NonMethod, true); 361 if (!p) fatal("Initial size of CodeCache is too small"); 362 return p; 363 } 364 365 366 //---------------------------------------------------------------------------------------------------- 367 // Implementation of DeoptimizationBlob 368 369 DeoptimizationBlob::DeoptimizationBlob( 370 CodeBuffer* cb, 371 int size, 372 OopMapSet* oop_maps, 373 int unpack_offset, 374 int unpack_with_exception_offset, 375 int unpack_with_reexecution_offset, 376 int frame_size 377 ) 378 : SingletonBlob("DeoptimizationBlob", cb, sizeof(DeoptimizationBlob), size, frame_size, oop_maps) 379 { 380 _unpack_offset = unpack_offset; |