src/share/vm/code/codeBlob.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/code

src/share/vm/code/codeBlob.cpp

Print this page




 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::NonNMethod, 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) {
 257   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
 258 
 259   AdapterBlob* blob = NULL;
 260   unsigned int size = allocation_size(cb, sizeof(AdapterBlob));
 261   {
 262     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 263     // The parameter 'true' indicates a critical memory allocation.
 264     // This means that CodeCacheMinimumFreeSpace is used, if necessary
 265     const bool is_critical = true;
 266     blob = new (size, is_critical) AdapterBlob(size, cb);
 267   }
 268   // Track memory usage statistic after releasing CodeCache_lock
 269   MemoryService::track_code_cache_memory_usage();
 270 
 271   return blob;
 272 }
 273 
 274 
 275 //----------------------------------------------------------------------------------------------------
 276 // Implementation of MethodHandlesAdapterBlob
 277 
 278 MethodHandlesAdapterBlob* MethodHandlesAdapterBlob::create(int buffer_size) {
 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)


 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::NonNMethod, 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::NonNMethod, 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;




 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) throw() {
 233   return CodeCache::allocate(size, CodeBlobType::NonNMethod);
 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) {
 257   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
 258 
 259   AdapterBlob* blob = NULL;
 260   unsigned int size = allocation_size(cb, sizeof(AdapterBlob));
 261   {
 262     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 263     blob = new (size) AdapterBlob(size, cb);



 264   }
 265   // Track memory usage statistic after releasing CodeCache_lock
 266   MemoryService::track_code_cache_memory_usage();
 267 
 268   return blob;
 269 }
 270 
 271 
 272 //----------------------------------------------------------------------------------------------------
 273 // Implementation of MethodHandlesAdapterBlob
 274 
 275 MethodHandlesAdapterBlob* MethodHandlesAdapterBlob::create(int buffer_size) {
 276   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
 277 
 278   MethodHandlesAdapterBlob* blob = NULL;
 279   unsigned int size = sizeof(MethodHandlesAdapterBlob);
 280   // align the size to CodeEntryAlignment
 281   size = align_code_offset(size);
 282   size += round_to(buffer_size, oopSize);
 283   {
 284     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 285     blob = new (size) MethodHandlesAdapterBlob(size);



 286   }
 287   // Track memory usage statistic after releasing CodeCache_lock
 288   MemoryService::track_code_cache_memory_usage();
 289 
 290   return blob;
 291 }
 292 
 293 //----------------------------------------------------------------------------------------------------
 294 // Implementation of RuntimeStub
 295 
 296 RuntimeStub::RuntimeStub(
 297   const char* name,
 298   CodeBuffer* cb,
 299   int         size,
 300   int         frame_complete,
 301   int         frame_size,
 302   OopMapSet*  oop_maps,
 303   bool        caller_must_gc_arguments
 304 )
 305 : CodeBlob(name, cb, sizeof(RuntimeStub), size, frame_complete, frame_size, oop_maps)


 313                                            int frame_complete,
 314                                            int frame_size,
 315                                            OopMapSet* oop_maps,
 316                                            bool caller_must_gc_arguments)
 317 {
 318   RuntimeStub* stub = NULL;
 319   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
 320   {
 321     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 322     unsigned int size = allocation_size(cb, sizeof(RuntimeStub));
 323     stub = new (size) RuntimeStub(stub_name, cb, size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments);
 324   }
 325 
 326   trace_new_stub(stub, "RuntimeStub - ", stub_name);
 327 
 328   return stub;
 329 }
 330 
 331 
 332 void* RuntimeStub::operator new(size_t s, unsigned size) throw() {
 333   void* p = CodeCache::allocate(size, CodeBlobType::NonNMethod);
 334   if (!p) fatal("Initial size of CodeCache is too small");
 335   return p;
 336 }
 337 
 338 // operator new shared by all singletons:
 339 void* SingletonBlob::operator new(size_t s, unsigned size) throw() {
 340   void* p = CodeCache::allocate(size, CodeBlobType::NonNMethod);
 341   if (!p) fatal("Initial size of CodeCache is too small");
 342   return p;
 343 }
 344 
 345 
 346 //----------------------------------------------------------------------------------------------------
 347 // Implementation of DeoptimizationBlob
 348 
 349 DeoptimizationBlob::DeoptimizationBlob(
 350   CodeBuffer* cb,
 351   int         size,
 352   OopMapSet*  oop_maps,
 353   int         unpack_offset,
 354   int         unpack_with_exception_offset,
 355   int         unpack_with_reexecution_offset,
 356   int         frame_size
 357 )
 358 : SingletonBlob("DeoptimizationBlob", cb, sizeof(DeoptimizationBlob), size, frame_size, oop_maps)
 359 {
 360   _unpack_offset           = unpack_offset;


src/share/vm/code/codeBlob.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File