src/hotspot/share/gc/shenandoah/shenandoahForwarding.hpp
author stefank
Tue, 26 Nov 2019 10:47:46 +0100
changeset 59290 97d13893ec3c
parent 55076 785a12e0f89b
permissions -rw-r--r--
8234748: Clean up atomic and orderAccess includes Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
     1
/*
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
     2
 * Copyright (c) 2013, 2018, Red Hat, Inc. All rights reserved.
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
     3
 *
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
     6
 * published by the Free Software Foundation.
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
     7
 *
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
     8
 * This code is distributed in the hope that it will be useful, but WITHOUT
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
     9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    10
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    11
 * version 2 for more details (a copy is included in the LICENSE file that
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    12
 * accompanied this code).
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    13
 *
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License version
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    15
 * 2 along with this work; if not, write to the Free Software Foundation,
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    16
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    17
 *
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    18
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    19
 * or visit www.oracle.com if you need additional information or have any
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    20
 * questions.
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    21
 *
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    22
 */
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    23
54766
1321f8cf9de5 8223567: Rename ShenandoahBrooksPointer to ShenandoahForwarding
rkennke
parents: 53244
diff changeset
    24
#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHFORWARDING_HPP
1321f8cf9de5 8223567: Rename ShenandoahBrooksPointer to ShenandoahForwarding
rkennke
parents: 53244
diff changeset
    25
#define SHARE_GC_SHENANDOAH_SHENANDOAHFORWARDING_HPP
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    26
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    27
#include "oops/oop.hpp"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    28
#include "utilities/globalDefinitions.hpp"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    29
54766
1321f8cf9de5 8223567: Rename ShenandoahBrooksPointer to ShenandoahForwarding
rkennke
parents: 53244
diff changeset
    30
class ShenandoahForwarding {
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    31
public:
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    32
  /* Gets forwardee from the given object.
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    33
   */
54766
1321f8cf9de5 8223567: Rename ShenandoahBrooksPointer to ShenandoahForwarding
rkennke
parents: 53244
diff changeset
    34
  static inline oop get_forwardee(oop obj);
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    35
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    36
  /* Returns the raw value from forwardee slot.
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    37
   */
54766
1321f8cf9de5 8223567: Rename ShenandoahBrooksPointer to ShenandoahForwarding
rkennke
parents: 53244
diff changeset
    38
  static inline HeapWord* get_forwardee_raw(oop obj);
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    39
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    40
  /* Returns the raw value from forwardee slot without any checks.
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    41
   * Used for quick verification.
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    42
   */
54766
1321f8cf9de5 8223567: Rename ShenandoahBrooksPointer to ShenandoahForwarding
rkennke
parents: 53244
diff changeset
    43
  static inline HeapWord* get_forwardee_raw_unchecked(oop obj);
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    44
55076
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    45
  /**
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    46
   * Returns true if the object is forwarded, false otherwise.
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    47
   */
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    48
  static inline bool is_forwarded(oop obj);
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    49
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    50
  /* Tries to atomically update forwardee in $holder object to $update.
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    51
   * Assumes $holder points at itself.
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    52
   * Asserts $holder is in from-space.
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    53
   * Asserts $update is in to-space.
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    54
   *
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    55
   * Returns the new object 'update' upon success, or
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    56
   * the new forwardee that a competing thread installed.
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    57
   */
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    58
  static inline oop try_update_forwardee(oop obj, oop update);
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    59
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    60
};
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    61
54766
1321f8cf9de5 8223567: Rename ShenandoahBrooksPointer to ShenandoahForwarding
rkennke
parents: 53244
diff changeset
    62
#endif // SHARE_GC_SHENANDOAH_SHENANDOAHFORWARDING_HPP