src/hotspot/share/code/codeBlob.cpp

Print this page


   1 /*
   2  * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 277 AdapterBlob::AdapterBlob(int size, CodeBuffer* cb) :
 278   BufferBlob("I2C/C2I adapters", size, cb) {
 279   CodeCache::commit(this);
 280 }
 281 
 282 AdapterBlob* AdapterBlob::create(CodeBuffer* cb) {
 283   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
 284 
 285   AdapterBlob* blob = NULL;
 286   unsigned int size = CodeBlob::allocation_size(cb, sizeof(AdapterBlob));
 287   {
 288     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 289     blob = new (size) AdapterBlob(size, cb);
 290   }
 291   // Track memory usage statistic after releasing CodeCache_lock
 292   MemoryService::track_code_cache_memory_usage();
 293 
 294   return blob;
 295 }
 296 



 297 



















 298 //----------------------------------------------------------------------------------------------------
 299 // Implementation of MethodHandlesAdapterBlob
 300 
 301 MethodHandlesAdapterBlob* MethodHandlesAdapterBlob::create(int buffer_size) {
 302   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
 303 
 304   MethodHandlesAdapterBlob* blob = NULL;
 305   unsigned int size = sizeof(MethodHandlesAdapterBlob);
 306   // align the size to CodeEntryAlignment
 307   size = CodeBlob::align_code_offset(size);
 308   size += align_up(buffer_size, oopSize);
 309   {
 310     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 311     blob = new (size) MethodHandlesAdapterBlob(size);
 312     if (blob == NULL) {
 313       vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "CodeCache: no room for method handle adapter blob");
 314     }
 315   }
 316   // Track memory usage statistic after releasing CodeCache_lock
 317   MemoryService::track_code_cache_memory_usage();


   1 /*
   2  * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 277 AdapterBlob::AdapterBlob(int size, CodeBuffer* cb) :
 278   BufferBlob("I2C/C2I adapters", size, cb) {
 279   CodeCache::commit(this);
 280 }
 281 
 282 AdapterBlob* AdapterBlob::create(CodeBuffer* cb) {
 283   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
 284 
 285   AdapterBlob* blob = NULL;
 286   unsigned int size = CodeBlob::allocation_size(cb, sizeof(AdapterBlob));
 287   {
 288     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 289     blob = new (size) AdapterBlob(size, cb);
 290   }
 291   // Track memory usage statistic after releasing CodeCache_lock
 292   MemoryService::track_code_cache_memory_usage();
 293 
 294   return blob;
 295 }
 296 
 297 VtableBlob::VtableBlob(const char* name, int size) :
 298   BufferBlob(name, size) {
 299 }
 300 
 301 VtableBlob* VtableBlob::create(const char* name, int buffer_size) {
 302   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
 303 
 304   VtableBlob* blob = NULL;
 305   unsigned int size = sizeof(VtableBlob);
 306   // align the size to CodeEntryAlignment
 307   size = align_code_offset(size);
 308   size += align_up(buffer_size, oopSize);
 309   assert(name != NULL, "must provide a name");
 310   {
 311     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 312     blob = new (size) VtableBlob(name, size);
 313   }
 314   // Track memory usage statistic after releasing CodeCache_lock
 315   MemoryService::track_code_cache_memory_usage();
 316 
 317   return blob;
 318 }
 319 
 320 //----------------------------------------------------------------------------------------------------
 321 // Implementation of MethodHandlesAdapterBlob
 322 
 323 MethodHandlesAdapterBlob* MethodHandlesAdapterBlob::create(int buffer_size) {
 324   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
 325 
 326   MethodHandlesAdapterBlob* blob = NULL;
 327   unsigned int size = sizeof(MethodHandlesAdapterBlob);
 328   // align the size to CodeEntryAlignment
 329   size = CodeBlob::align_code_offset(size);
 330   size += align_up(buffer_size, oopSize);
 331   {
 332     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 333     blob = new (size) MethodHandlesAdapterBlob(size);
 334     if (blob == NULL) {
 335       vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "CodeCache: no room for method handle adapter blob");
 336     }
 337   }
 338   // Track memory usage statistic after releasing CodeCache_lock
 339   MemoryService::track_code_cache_memory_usage();