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) 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 { 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 ) 323 : CodeBlob(name, cb, sizeof(RuntimeStub), size, frame_complete, frame_size, oop_maps) 324 { 325 _caller_must_gc_arguments = caller_must_gc_arguments; 326 } 327 328 329 RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name, 330 CodeBuffer* cb, 331 int frame_complete, 332 int frame_size, 333 OopMapSet* oop_maps, 334 bool caller_must_gc_arguments) 335 { 336 RuntimeStub* stub = NULL; 337 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 338 { 339 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 340 unsigned int size = allocation_size(cb, sizeof(RuntimeStub)); 341 stub = new (size) RuntimeStub(stub_name, cb, size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments); 342 } 343 344 trace_new_stub(stub, "RuntimeStub - ", stub_name); 345 346 return stub; 347 } 348 349 350 void* RuntimeStub::operator new(size_t s, unsigned size) throw() { 351 void* p = CodeCache::allocate(size, true); 352 if (!p) fatal("Initial size of CodeCache is too small"); 353 return p; 354 } 355 356 // operator new shared by all singletons: 357 void* SingletonBlob::operator new(size_t s, unsigned size) throw() { 358 void* p = CodeCache::allocate(size, true); 359 if (!p) fatal("Initial size of CodeCache is too small"); 360 return p; 361 } 362 363 364 //---------------------------------------------------------------------------------------------------- 365 // Implementation of DeoptimizationBlob 366 367 DeoptimizationBlob::DeoptimizationBlob( 368 CodeBuffer* cb, 369 int size, 370 OopMapSet* oop_maps, 371 int unpack_offset, 372 int unpack_with_exception_offset, 373 int unpack_with_reexecution_offset, 374 int frame_size 375 ) 376 : SingletonBlob("DeoptimizationBlob", cb, sizeof(DeoptimizationBlob), size, frame_size, oop_maps) 377 { 378 _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) throw() { 248 return CodeCache::allocate(size, btNonMethod); 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, btNonMethod); 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 { 287 // Implementation of MethodHandlesAdapterBlob 288 289 MethodHandlesAdapterBlob* MethodHandlesAdapterBlob::create(int buffer_size) { 290 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 291 292 MethodHandlesAdapterBlob* blob = NULL; 293 unsigned int size = sizeof(MethodHandlesAdapterBlob); 294 // align the size to CodeEntryAlignment 295 size = align_code_offset(size); 296 size += round_to(buffer_size, oopSize); 297 { 298 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 299 blob = new (size) MethodHandlesAdapterBlob(size); 300 } 301 // Track memory usage statistic after releasing CodeCache_lock 302 MemoryService::track_code_cache_memory_usage(); 303 304 return blob; 305 } 306 307 //---------------------------------------------------------------------------------------------------- 308 // Implementation of RuntimeStub 309 310 RuntimeStub::RuntimeStub( 311 const char* name, 312 CodeBuffer* cb, 313 int size, 314 int frame_complete, 315 int frame_size, 316 OopMapSet* oop_maps, 317 bool caller_must_gc_arguments 318 ) 319 : CodeBlob(name, cb, sizeof(RuntimeStub), size, frame_complete, frame_size, oop_maps) 320 { 321 _caller_must_gc_arguments = caller_must_gc_arguments; 322 } 323 324 325 RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name, 326 CodeBuffer* cb, 327 int frame_complete, 328 int frame_size, 329 OopMapSet* oop_maps, 330 bool caller_must_gc_arguments) 331 { 332 RuntimeStub* stub = NULL; 333 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock 334 { 335 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 336 unsigned int size = allocation_size(cb, sizeof(RuntimeStub)); 337 stub = new (size) RuntimeStub(stub_name, cb, size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments); 338 } 339 340 trace_new_stub(stub, "RuntimeStub - ", stub_name); 341 342 return stub; 343 } 344 345 346 void* RuntimeStub::operator new(size_t s, unsigned size) throw() { 347 void* p = CodeCache::allocate(size, btNonMethod, true); 348 if (!p) fatal("Initial size of CodeCache is too small"); 349 return p; 350 } 351 352 // operator new shared by all singletons: 353 void* SingletonBlob::operator new(size_t s, unsigned size) throw() { 354 void* p = CodeCache::allocate(size, btNonMethod, true); 355 if (!p) fatal("Initial size of CodeCache is too small"); 356 return p; 357 } 358 359 360 //---------------------------------------------------------------------------------------------------- 361 // Implementation of DeoptimizationBlob 362 363 DeoptimizationBlob::DeoptimizationBlob( 364 CodeBuffer* cb, 365 int size, 366 OopMapSet* oop_maps, 367 int unpack_offset, 368 int unpack_with_exception_offset, 369 int unpack_with_reexecution_offset, 370 int frame_size 371 ) 372 : SingletonBlob("DeoptimizationBlob", cb, sizeof(DeoptimizationBlob), size, frame_size, oop_maps) 373 { 374 _unpack_offset = unpack_offset; |