src/hotspot/share/gc/shenandoah/shenandoahForwarding.inline.hpp
author stefank
Tue, 26 Nov 2019 10:47:46 +0100
changeset 59290 97d13893ec3c
parent 57811 947252a54b98
child 58679 9c3209ff7550
child 59292 95b1385dd476
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) 2015, 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_INLINE_HPP
1321f8cf9de5 8223567: Rename ShenandoahBrooksPointer to ShenandoahForwarding
rkennke
parents: 53244
diff changeset
    25
#define SHARE_GC_SHENANDOAH_SHENANDOAHFORWARDING_INLINE_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 "gc/shenandoah/shenandoahAsserts.hpp"
54766
1321f8cf9de5 8223567: Rename ShenandoahBrooksPointer to ShenandoahForwarding
rkennke
parents: 53244
diff changeset
    28
#include "gc/shenandoah/shenandoahForwarding.hpp"
57811
947252a54b98 8229838: Rename markOop files to markWord
stefank
parents: 57777
diff changeset
    29
#include "oops/markWord.inline.hpp"
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    30
#include "runtime/atomic.hpp"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    31
54766
1321f8cf9de5 8223567: Rename ShenandoahBrooksPointer to ShenandoahForwarding
rkennke
parents: 53244
diff changeset
    32
inline HeapWord* ShenandoahForwarding::get_forwardee_raw(oop obj) {
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    33
  shenandoah_assert_in_heap(NULL, obj);
55076
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    34
  return get_forwardee_raw_unchecked(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
54766
1321f8cf9de5 8223567: Rename ShenandoahBrooksPointer to ShenandoahForwarding
rkennke
parents: 53244
diff changeset
    37
inline HeapWord* ShenandoahForwarding::get_forwardee_raw_unchecked(oop obj) {
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 55076
diff changeset
    38
  markWord mark = obj->mark_raw();
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 55076
diff changeset
    39
  if (mark.is_marked()) {
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 55076
diff changeset
    40
    return (HeapWord*) mark.clear_lock_bits().to_pointer();
55076
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    41
  } else {
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    42
    return (HeapWord*) obj;
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    43
  }
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    44
}
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    45
54766
1321f8cf9de5 8223567: Rename ShenandoahBrooksPointer to ShenandoahForwarding
rkennke
parents: 53244
diff changeset
    46
inline oop ShenandoahForwarding::get_forwardee(oop obj) {
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    47
  shenandoah_assert_correct(NULL, obj);
55076
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    48
  return oop(get_forwardee_raw_unchecked(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
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    51
inline bool ShenandoahForwarding::is_forwarded(oop obj) {
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 55076
diff changeset
    52
  return obj->mark_raw().is_marked();
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    53
}
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    54
54766
1321f8cf9de5 8223567: Rename ShenandoahBrooksPointer to ShenandoahForwarding
rkennke
parents: 53244
diff changeset
    55
inline oop ShenandoahForwarding::try_update_forwardee(oop obj, oop update) {
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 55076
diff changeset
    56
  markWord old_mark = obj->mark_raw();
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 55076
diff changeset
    57
  if (old_mark.is_marked()) {
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 55076
diff changeset
    58
    return oop(old_mark.clear_lock_bits().to_pointer());
55076
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    59
  }
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    60
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 55076
diff changeset
    61
  markWord new_mark = markWord::encode_pointer_as_mark(update);
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 55076
diff changeset
    62
  markWord prev_mark = obj->cas_set_mark_raw(new_mark, old_mark);
55076
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    63
  if (prev_mark == old_mark) {
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    64
    return update;
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    65
  } else {
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 55076
diff changeset
    66
    return oop(prev_mark.clear_lock_bits().to_pointer());
55076
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 54766
diff changeset
    67
  }
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    68
}
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    69
54766
1321f8cf9de5 8223567: Rename ShenandoahBrooksPointer to ShenandoahForwarding
rkennke
parents: 53244
diff changeset
    70
#endif // SHARE_GC_SHENANDOAH_SHENANDOAHFORWARDING_INLINE_HPP