src/hotspot/share/gc/z/zForwardingTable.cpp
author pliden
Thu, 28 Mar 2019 19:43:59 +0100
changeset 54330 69e80a82db9a
parent 54163 790679f86a51
child 58809 44dc3d796110
permissions -rw-r--r--
8221540: ZGC: Reduce width of zForwardingEntry::from_index field Reviewed-by: stefank, eosterlund
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
/*
54162
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 52799
diff changeset
     2
 * Copyright (c) 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: 54162
diff changeset
    25
#include "gc/z/zAddress.inline.hpp"
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    26
#include "gc/z/zForwarding.inline.hpp"
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    27
#include "gc/z/zForwardingTable.inline.hpp"
54162
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 52799
diff changeset
    28
#include "gc/z/zGranuleMap.inline.hpp"
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    29
#include "utilities/debug.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    30
54162
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 52799
diff changeset
    31
ZForwardingTable::ZForwardingTable() :
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 52799
diff changeset
    32
    _map() {}
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    33
54163
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    34
void ZForwardingTable::insert(ZForwarding* forwarding) {
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    35
  const uintptr_t addr = ZAddress::good(forwarding->start());
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    36
  const size_t size = forwarding->size();
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    37
54162
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 52799
diff changeset
    38
  assert(get(addr) == NULL, "Invalid entry");
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 52799
diff changeset
    39
  _map.put(addr, size, forwarding);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    40
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    41
54163
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    42
void ZForwardingTable::remove(ZForwarding* forwarding) {
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    43
  const uintptr_t addr = ZAddress::good(forwarding->start());
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    44
  const size_t size = forwarding->size();
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    45
54163
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    46
  assert(get(addr) == forwarding, "Invalid entry");
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    47
  _map.put(addr, size, NULL);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    48
}