src/hotspot/share/gc/z/zRelocationSet.cpp
author eosterlund
Wed, 28 Aug 2019 11:19:09 +0200
changeset 57903 5e2576c303a2
parent 54163 790679f86a51
permissions -rw-r--r--
8229278: Improve hs_err location printing to assume less about GC internals Reviewed-by: stefank, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     1
/*
54163
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
     2
 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     4
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     7
 * published by the Free Software Foundation.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     8
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    13
 * accompanied this code).
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    14
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    18
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    21
 * questions.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    22
 */
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    23
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    24
#include "precompiled.hpp"
54163
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    25
#include "gc/z/zForwarding.hpp"
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    26
#include "gc/z/zRelocationSet.hpp"
54163
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    27
#include "memory/allocation.hpp"
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    28
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    29
ZRelocationSet::ZRelocationSet() :
54163
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    30
    _forwardings(NULL),
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    31
    _nforwardings(0) {}
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    32
54163
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    33
void ZRelocationSet::populate(ZPage* const* group0, size_t ngroup0,
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    34
                              ZPage* const* group1, size_t ngroup1) {
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    35
  _nforwardings = ngroup0 + ngroup1;
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    36
  _forwardings = REALLOC_C_HEAP_ARRAY(ZForwarding*, _forwardings, _nforwardings, mtGC);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    37
54163
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    38
  size_t j = 0;
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    39
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    40
  // Populate group 0
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    41
  for (size_t i = 0; i < ngroup0; i++) {
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    42
    _forwardings[j++] = ZForwarding::create(group0[i]);
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    43
  }
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    44
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    45
  // Populate group 1
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    46
  for (size_t i = 0; i < ngroup1; i++) {
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    47
    _forwardings[j++] = ZForwarding::create(group1[i]);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    48
  }
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    49
}
54163
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    50
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    51
void ZRelocationSet::reset() {
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    52
  for (size_t i = 0; i < _nforwardings; i++) {
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    53
    ZForwarding::destroy(_forwardings[i]);
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    54
    _forwardings[i] = NULL;
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    55
  }
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 50525
diff changeset
    56
}