< prev index next >

src/hotspot/share/gc/z/zPage.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  */


  41   assert_initialized();
  42 }
  43 
  44 ZPage::ZPage(uint8_t type, const ZVirtualMemory& vmem, const ZPhysicalMemory& pmem) :
  45     _type(type),
  46     _numa_id((uint8_t)-1),
  47     _seqnum(0),
  48     _virtual(vmem),
  49     _top(start()),
  50     _livemap(object_max_count()),
  51     _last_used(0),
  52     _physical(pmem) {
  53   assert_initialized();
  54 }
  55 
  56 ZPage::~ZPage() {}
  57 
  58 void ZPage::assert_initialized() const {
  59   assert(!_virtual.is_null(), "Should not be null");
  60   assert(!_physical.is_null(), "Should not be null");

  61   assert((_type == ZPageTypeSmall && size() == ZPageSizeSmall) ||
  62          (_type == ZPageTypeMedium && size() == ZPageSizeMedium) ||
  63          (_type == ZPageTypeLarge && is_aligned(size(), ZGranuleSize)),
  64          "Page type/size mismatch");
  65 }
  66 
  67 void ZPage::reset() {
  68   _seqnum = ZGlobalSeqNum;
  69   _top = start();
  70   _livemap.reset();
  71   _last_used = 0;
  72 }
  73 
  74 ZPage* ZPage::retype(uint8_t type) {
  75   assert(_type != type, "Invalid retype");
  76   _type = type;
  77   _livemap.resize(object_max_count());
  78   return this;
  79 }
  80 
  81 ZPage* ZPage::split(size_t size) {
  82   return split(type_from_size(size), size);
  83 }
  84 
  85 ZPage* ZPage::split(uint8_t type, size_t size) {
  86   assert(_virtual.size() > size, "Invalid split");
  87 
  88   // Resize this page, keep _numa_id, _seqnum, and _last_used
  89   const ZVirtualMemory vmem = _virtual.split(size);
  90   const ZPhysicalMemory pmem = _physical.split(size);
  91   _type = type_from_size(_virtual.size());
  92   _top = start();
  93   _livemap.resize(object_max_count());
  94 
  95   // Create new page, inherit _seqnum and _last_used
  96   ZPage* const page = new ZPage(type, vmem, pmem);
  97   page->_seqnum = _seqnum;
  98   page->_last_used = _last_used;
  99   return page;



















 100 }
 101 
 102 void ZPage::print_on(outputStream* out) const {
 103   out->print_cr(" %-6s  " PTR_FORMAT " " PTR_FORMAT " " PTR_FORMAT " %s%s",
 104                 type_to_string(), start(), top(), end(),
 105                 is_allocating()  ? " Allocating"  : "",
 106                 is_relocatable() ? " Relocatable" : "");
 107 }
 108 
 109 void ZPage::print() const {
 110   print_on(tty);
 111 }
   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  */


  41   assert_initialized();
  42 }
  43 
  44 ZPage::ZPage(uint8_t type, const ZVirtualMemory& vmem, const ZPhysicalMemory& pmem) :
  45     _type(type),
  46     _numa_id((uint8_t)-1),
  47     _seqnum(0),
  48     _virtual(vmem),
  49     _top(start()),
  50     _livemap(object_max_count()),
  51     _last_used(0),
  52     _physical(pmem) {
  53   assert_initialized();
  54 }
  55 
  56 ZPage::~ZPage() {}
  57 
  58 void ZPage::assert_initialized() const {
  59   assert(!_virtual.is_null(), "Should not be null");
  60   assert(!_physical.is_null(), "Should not be null");
  61   assert(_virtual.size() == _physical.size(), "Virtual/Physical size mismatch");
  62   assert((_type == ZPageTypeSmall && size() == ZPageSizeSmall) ||
  63          (_type == ZPageTypeMedium && size() == ZPageSizeMedium) ||
  64          (_type == ZPageTypeLarge && is_aligned(size(), ZGranuleSize)),
  65          "Page type/size mismatch");
  66 }
  67 
  68 void ZPage::reset() {
  69   _seqnum = ZGlobalSeqNum;
  70   _top = start();
  71   _livemap.reset();
  72   _last_used = 0;
  73 }
  74 
  75 ZPage* ZPage::retype(uint8_t type) {
  76   assert(_type != type, "Invalid retype");
  77   _type = type;
  78   _livemap.resize(object_max_count());
  79   return this;
  80 }
  81 
  82 ZPage* ZPage::split(size_t size) {
  83   return split(type_from_size(size), size);
  84 }
  85 
  86 ZPage* ZPage::split(uint8_t type, size_t size) {
  87   assert(_virtual.size() > size, "Invalid split");
  88 
  89   // Resize this page, keep _numa_id, _seqnum, and _last_used
  90   const ZVirtualMemory vmem = _virtual.split(size);
  91   const ZPhysicalMemory pmem = _physical.split(size);
  92   _type = type_from_size(_virtual.size());
  93   _top = start();
  94   _livemap.resize(object_max_count());
  95 
  96   // Create new page, inherit _seqnum and _last_used
  97   ZPage* const page = new ZPage(type, vmem, pmem);
  98   page->_seqnum = _seqnum;
  99   page->_last_used = _last_used;
 100   return page;
 101 }
 102 
 103 ZPage* ZPage::split_committed() {
 104   const ZPhysicalMemory pmem = _physical.split_committed();
 105   if (pmem.is_null()) {
 106     // Nothing committed
 107     return NULL;
 108   }
 109 
 110   assert(!_physical.is_null(), "Should not be null");
 111 
 112   // Resize this page
 113   const ZVirtualMemory vmem = _virtual.split(pmem.size());
 114   _type = type_from_size(_virtual.size());
 115   _top = start();
 116   _livemap.resize(object_max_count());
 117 
 118   // Create new page
 119   return new ZPage(vmem, pmem);
 120 }
 121 
 122 void ZPage::print_on(outputStream* out) const {
 123   out->print_cr(" %-6s  " PTR_FORMAT " " PTR_FORMAT " " PTR_FORMAT " %s%s",
 124                 type_to_string(), start(), top(), end(),
 125                 is_allocating()  ? " Allocating"  : "",
 126                 is_relocatable() ? " Relocatable" : "");
 127 }
 128 
 129 void ZPage::print() const {
 130   print_on(tty);
 131 }
< prev index next >