< prev index next >

src/hotspot/share/memory/vtBuffer.cpp

Print this page




  25 #include "precompiled.hpp"
  26 #include "gc/shared/gcLocker.hpp"
  27 #include "memory/vtBuffer.hpp"
  28 #include "oops/oop.inline.hpp"
  29 #include "oops/valueKlass.hpp"
  30 #include "runtime/frame.hpp"
  31 #include "runtime/globals_extension.hpp"
  32 #include "runtime/os.hpp"
  33 #include "runtime/thread.hpp"
  34 #include "utilities/globalDefinitions.hpp"
  35 #include "utilities/ticks.hpp"
  36 #include "utilities/ticks.inline.hpp"
  37 
  38 VTBufferChunk* VTBuffer::_free_list = NULL;
  39 Mutex* VTBuffer::_pool_lock = new Mutex(Mutex::leaf, "VTBuffer::_pool_lock", true, Monitor::_safepoint_check_never);
  40 int VTBuffer::_pool_counter = 0;
  41 int VTBuffer::_max_pool_counter = 0;
  42 int VTBuffer::_total_allocated = 0;
  43 int VTBuffer::_total_failed = 0;
  44 address VTBuffer::_base = NULL;

  45 address VTBuffer::_commit_ptr;
  46 size_t VTBuffer::_size;
  47 
  48 void VTBuffer::init() {
  49   if ((!(EnableValhalla || EnableMVT)) || ValueTypesBufferMaxMemory == 0) {
  50     _base = NULL;

  51     _commit_ptr = NULL;
  52     _size = 0;
  53     return;
  54   }
  55   size_t size = ValueTypesBufferMaxMemory * os::vm_page_size();
  56   _base = (address)os::reserve_memory(size, NULL, (size_t)os::vm_page_size());
  57   if (_base == NULL) {
  58     if (!FLAG_IS_DEFAULT(ValueTypesBufferMaxMemory)) {
  59       vm_exit_during_initialization("Cannot reserved memory requested for Thread-Local Value Buffer");
  60     }
  61     // memory allocation failed, disabling buffering
  62     ValueTypesBufferMaxMemory = 0;
  63     _size = 0;
  64     _commit_ptr = NULL;

  65   } else {
  66     _commit_ptr = _base;
  67     _size = size;

  68   }
  69 }
  70 
  71 VTBufferChunk* VTBuffer::get_new_chunk(JavaThread* thread) {
  72   if (_commit_ptr  >= _base + _size) {
  73     return NULL;
  74   }
  75   if (os::commit_memory((char*)_commit_ptr, (size_t)os::vm_page_size(), false)) {
  76     VTBufferChunk* chunk = (VTBufferChunk*)_commit_ptr;
  77     _commit_ptr += os::vm_page_size();
  78     VTBufferChunk::init(chunk, thread);
  79     return chunk;
  80   } else {
  81    return NULL;
  82   }
  83 }
  84 
  85 void VTBufferChunk::zap(void* start) {
  86   assert(this == (VTBufferChunk*)((intptr_t)start & chunk_mask()), "start must be in current chunk");
  87   if (ZapVTBufferChunks) {




  25 #include "precompiled.hpp"
  26 #include "gc/shared/gcLocker.hpp"
  27 #include "memory/vtBuffer.hpp"
  28 #include "oops/oop.inline.hpp"
  29 #include "oops/valueKlass.hpp"
  30 #include "runtime/frame.hpp"
  31 #include "runtime/globals_extension.hpp"
  32 #include "runtime/os.hpp"
  33 #include "runtime/thread.hpp"
  34 #include "utilities/globalDefinitions.hpp"
  35 #include "utilities/ticks.hpp"
  36 #include "utilities/ticks.inline.hpp"
  37 
  38 VTBufferChunk* VTBuffer::_free_list = NULL;
  39 Mutex* VTBuffer::_pool_lock = new Mutex(Mutex::leaf, "VTBuffer::_pool_lock", true, Monitor::_safepoint_check_never);
  40 int VTBuffer::_pool_counter = 0;
  41 int VTBuffer::_max_pool_counter = 0;
  42 int VTBuffer::_total_allocated = 0;
  43 int VTBuffer::_total_failed = 0;
  44 address VTBuffer::_base = NULL;
  45 address VTBuffer::_end = NULL;
  46 address VTBuffer::_commit_ptr;
  47 size_t VTBuffer::_size;
  48 
  49 void VTBuffer::init() {
  50   if ((!(EnableValhalla || EnableMVT)) || ValueTypesBufferMaxMemory == 0) {
  51     _base = NULL;
  52     _end = NULL;
  53     _commit_ptr = NULL;
  54     _size = 0;
  55     return;
  56   }
  57   size_t size = ValueTypesBufferMaxMemory * os::vm_page_size();
  58   _base = (address)os::reserve_memory(size, NULL, (size_t)os::vm_page_size());
  59   if (_base == NULL) {
  60     if (!FLAG_IS_DEFAULT(ValueTypesBufferMaxMemory)) {
  61       vm_exit_during_initialization("Cannot reserved memory requested for Thread-Local Value Buffer");
  62     }
  63     // memory allocation failed, disabling buffering
  64     ValueTypesBufferMaxMemory = 0;
  65     _size = 0;
  66     _commit_ptr = NULL;
  67     _end = NULL;
  68   } else {
  69     _commit_ptr = _base;
  70     _size = size;
  71     _end = _base + _size;
  72   }
  73 }
  74 
  75 VTBufferChunk* VTBuffer::get_new_chunk(JavaThread* thread) {
  76   if (_commit_ptr  >= _base + _size) {
  77     return NULL;
  78   }
  79   if (os::commit_memory((char*)_commit_ptr, (size_t)os::vm_page_size(), false)) {
  80     VTBufferChunk* chunk = (VTBufferChunk*)_commit_ptr;
  81     _commit_ptr += os::vm_page_size();
  82     VTBufferChunk::init(chunk, thread);
  83     return chunk;
  84   } else {
  85    return NULL;
  86   }
  87 }
  88 
  89 void VTBufferChunk::zap(void* start) {
  90   assert(this == (VTBufferChunk*)((intptr_t)start & chunk_mask()), "start must be in current chunk");
  91   if (ZapVTBufferChunks) {


< prev index next >