src/hotspot/share/gc/z/zForwarding.hpp
author pliden
Mon, 18 Mar 2019 11:50:40 +0100
changeset 54167 d0d26fc836dd
parent 54163 790679f86a51
child 54172 f92f1f1045ad
permissions -rw-r--r--
8220592: ZGC: Move destruction of detached ZPages into ZPageAllocator 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
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50525
diff changeset
     2
 * Copyright (c) 2015, 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
54162
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    24
#ifndef SHARE_GC_Z_ZFORWARDING_HPP
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    25
#define SHARE_GC_Z_ZFORWARDING_HPP
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    26
54162
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    27
#include "gc/z/zForwardingEntry.hpp"
54163
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    28
#include "gc/z/zVirtualMemory.hpp"
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    29
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    30
class ZPage;
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    31
54162
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    32
typedef uint32_t ZForwardingCursor;
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    33
54162
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    34
class ZForwarding {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    35
  friend class VMStructs;
54162
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    36
  friend class ZForwardingTest;
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    37
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    38
private:
54163
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    39
  const ZVirtualMemory _virtual;
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    40
  const size_t         _object_alignment_shift;
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    41
  const uint32_t       _nentries;
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    42
  ZPage*               _page;
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    43
  volatile uint32_t    _refcount;
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    44
  volatile bool        _pinned;
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    45
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    46
  bool inc_refcount();
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    47
  bool dec_refcount();
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    48
54162
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    49
  ZForwardingEntry* entries() const;
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    50
  ZForwardingEntry at(ZForwardingCursor* cursor) const;
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    51
  ZForwardingEntry first(uintptr_t from_index, ZForwardingCursor* cursor) const;
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    52
  ZForwardingEntry next(ZForwardingCursor* cursor) const;
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    53
54163
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    54
  ZForwarding(ZPage* page, uint32_t nentries);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    55
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    56
public:
54163
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    57
  static ZForwarding* create(ZPage* page);
54162
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    58
  static void destroy(ZForwarding* forwarding);
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    59
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    60
  uintptr_t start() const;
54163
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    61
  size_t size() const;
54162
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    62
  size_t object_alignment_shift() const;
54163
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    63
  ZPage* page() const;
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    64
54162
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    65
  bool is_pinned() const;
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    66
  void set_pinned();
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    67
54163
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    68
  bool retain_page();
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    69
  void release_page();
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    70
54162
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    71
  ZForwardingEntry find(uintptr_t from_index) const;
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    72
  ZForwardingEntry find(uintptr_t from_index, ZForwardingCursor* cursor) const;
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    73
  uintptr_t insert(uintptr_t from_index, uintptr_t to_offset, ZForwardingCursor* cursor);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    74
54163
790679f86a51 8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents: 54162
diff changeset
    75
  void verify() const;
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    76
};
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    77
54162
f344a0c6e19e 8220587: ZGC: Break out forwarding information from ZPage
pliden
parents: 53244
diff changeset
    78
#endif // SHARE_GC_Z_ZFORWARDING_HPP