< prev index next >

src/hotspot/share/gc/z/zVirtualMemory.cpp

Print this page


   1 /*
   2  * Copyright (c) 2015, 2019, 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  */


 134 
 135   log_info(gc, init)("Address Space Type: %s/%s/%s",
 136                      (contiguous ? "Contiguous" : "Discontiguous"),
 137                      (limit == ZAddressOffsetMax ? "Unrestricted" : "Restricted"),
 138                      (reserved == size ? "Complete" : "Degraded"));
 139   log_info(gc, init)("Address Space Size: " SIZE_FORMAT "M x " SIZE_FORMAT " = " SIZE_FORMAT "M",
 140                      reserved / M, ZHeapViews, (reserved * ZHeapViews) / M);
 141 
 142   return reserved >= max_capacity;
 143 }
 144 
 145 void ZVirtualMemoryManager::nmt_reserve(uintptr_t start, size_t size) {
 146   MemTracker::record_virtual_memory_reserve((void*)start, size, CALLER_PC);
 147   MemTracker::record_virtual_memory_type((void*)start, mtJavaHeap);
 148 }
 149 
 150 bool ZVirtualMemoryManager::is_initialized() const {
 151   return _initialized;
 152 }
 153 
 154 ZVirtualMemory ZVirtualMemoryManager::alloc(size_t size, bool alloc_from_front) {
 155   uintptr_t start;
 156 
 157   if (alloc_from_front || size <= ZPageSizeSmall) {
 158     // Small page

 159     start = _manager.alloc_from_front(size);
 160   } else {
 161     // Medium/Large page
 162     start = _manager.alloc_from_back(size);
 163   }
 164 
 165   return ZVirtualMemory(start, size);
 166 }
 167 
 168 void ZVirtualMemoryManager::free(const ZVirtualMemory& vmem) {
 169   _manager.free(vmem.start(), vmem.size());
 170 }
   1 /*
   2  * Copyright (c) 2015, 2020, 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  */


 134 
 135   log_info(gc, init)("Address Space Type: %s/%s/%s",
 136                      (contiguous ? "Contiguous" : "Discontiguous"),
 137                      (limit == ZAddressOffsetMax ? "Unrestricted" : "Restricted"),
 138                      (reserved == size ? "Complete" : "Degraded"));
 139   log_info(gc, init)("Address Space Size: " SIZE_FORMAT "M x " SIZE_FORMAT " = " SIZE_FORMAT "M",
 140                      reserved / M, ZHeapViews, (reserved * ZHeapViews) / M);
 141 
 142   return reserved >= max_capacity;
 143 }
 144 
 145 void ZVirtualMemoryManager::nmt_reserve(uintptr_t start, size_t size) {
 146   MemTracker::record_virtual_memory_reserve((void*)start, size, CALLER_PC);
 147   MemTracker::record_virtual_memory_type((void*)start, mtJavaHeap);
 148 }
 149 
 150 bool ZVirtualMemoryManager::is_initialized() const {
 151   return _initialized;
 152 }
 153 
 154 ZVirtualMemory ZVirtualMemoryManager::alloc(size_t size, bool force_low_address) {
 155   uintptr_t start;
 156 
 157   // Small pages are allocated at low addresses, while medium/large pages
 158   // are allocated at high addresses (unless forced to be at a low address).
 159   if (force_low_address || size <= ZPageSizeSmall) {
 160     start = _manager.alloc_from_front(size);
 161   } else {

 162     start = _manager.alloc_from_back(size);
 163   }
 164 
 165   return ZVirtualMemory(start, size);
 166 }
 167 
 168 void ZVirtualMemoryManager::free(const ZVirtualMemory& vmem) {
 169   _manager.free(vmem.start(), vmem.size());
 170 }
< prev index next >