src/hotspot/share/gc/z/zForwardingTable.cpp
author stefank
Mon, 28 Oct 2019 11:23:28 +0100
changeset 58810 3aba4a42d8ad
parent 58809 44dc3d796110
permissions -rw-r--r--
8232602: ZGC: Make ZGranuleMap ZAddress agnostic Reviewed-by: pliden, 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/zForwarding.inline.hpp"
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    26
#include "gc/z/zForwardingTable.inline.hpp"
58809
44dc3d796110 8232601: ZGC: Parameterize the ZGranuleMap table size
stefank
parents: 54163
diff changeset
    27
#include "gc/z/zGlobals.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() :
58809
44dc3d796110 8232601: ZGC: Parameterize the ZGranuleMap table size
stefank
parents: 54163
diff changeset
    32
    _map(ZAddressOffsetMax) {}
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) {
58810
3aba4a42d8ad 8232602: ZGC: Make ZGranuleMap ZAddress agnostic
stefank
parents: 58809
diff changeset
    35
  const uintptr_t offset = forwarding->start();
54163
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
58810
3aba4a42d8ad 8232602: ZGC: Make ZGranuleMap ZAddress agnostic
stefank
parents: 58809
diff changeset
    38
  assert(_map.get(offset) == NULL, "Invalid entry");
3aba4a42d8ad 8232602: ZGC: Make ZGranuleMap ZAddress agnostic
stefank
parents: 58809
diff changeset
    39
  _map.put(offset, 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) {
58810
3aba4a42d8ad 8232602: ZGC: Make ZGranuleMap ZAddress agnostic
stefank
parents: 58809
diff changeset
    43
  const uintptr_t offset = forwarding->start();
54163
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
58810
3aba4a42d8ad 8232602: ZGC: Make ZGranuleMap ZAddress agnostic
stefank
parents: 58809
diff changeset
    46
  assert(_map.get(offset) == forwarding, "Invalid entry");
3aba4a42d8ad 8232602: ZGC: Make ZGranuleMap ZAddress agnostic
stefank
parents: 58809
diff changeset
    47
  _map.put(offset, size, NULL);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    48
}