src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp
author stefank
Tue, 26 Nov 2019 10:47:46 +0100
changeset 59290 97d13893ec3c
parent 58819 ef8be51fff48
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) 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
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    24
#include "precompiled.hpp"
58218
0d7877278adf 8231086: Shenandoah: Stronger invariant for object-arraycopy
rkennke
parents: 55679
diff changeset
    25
#include "gc/shenandoah/shenandoahBarrierSet.inline.hpp"
58334
f642ad5c655f 8231447: Shenandoah: Compilation-time regression after JDK-8231086
rkennke
parents: 58219
diff changeset
    26
#include "gc/shenandoah/shenandoahBarrierSetClone.inline.hpp"
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    27
#include "gc/shenandoah/shenandoahRuntime.hpp"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    28
#include "gc/shenandoah/shenandoahThreadLocalData.hpp"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    29
#include "runtime/interfaceSupport.inline.hpp"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    30
#include "oops/oop.inline.hpp"
58339
c7d9df2e470c 8231410: Shenandoah: clone barrier should use base pointer
shade
parents: 58334
diff changeset
    31
#include "utilities/copy.hpp"
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    32
58218
0d7877278adf 8231086: Shenandoah: Stronger invariant for object-arraycopy
rkennke
parents: 55679
diff changeset
    33
void ShenandoahRuntime::write_ref_array_pre_oop_entry(oop* src, oop* dst, size_t length) {
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    34
  ShenandoahBarrierSet *bs = ShenandoahBarrierSet::barrier_set();
58218
0d7877278adf 8231086: Shenandoah: Stronger invariant for object-arraycopy
rkennke
parents: 55679
diff changeset
    35
  bs->arraycopy_pre(src, dst, length);
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    36
}
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    37
58218
0d7877278adf 8231086: Shenandoah: Stronger invariant for object-arraycopy
rkennke
parents: 55679
diff changeset
    38
void ShenandoahRuntime::write_ref_array_pre_narrow_oop_entry(narrowOop* src, narrowOop* dst, size_t length) {
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    39
  ShenandoahBarrierSet *bs = ShenandoahBarrierSet::barrier_set();
58218
0d7877278adf 8231086: Shenandoah: Stronger invariant for object-arraycopy
rkennke
parents: 55679
diff changeset
    40
  bs->arraycopy_pre(src, dst, length);
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    41
}
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    42
58218
0d7877278adf 8231086: Shenandoah: Stronger invariant for object-arraycopy
rkennke
parents: 55679
diff changeset
    43
void ShenandoahRuntime::write_ref_array_pre_duinit_oop_entry(oop* src, oop* dst, size_t length) {
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    44
  ShenandoahBarrierSet *bs = ShenandoahBarrierSet::barrier_set();
58218
0d7877278adf 8231086: Shenandoah: Stronger invariant for object-arraycopy
rkennke
parents: 55679
diff changeset
    45
  bs->arraycopy_update(src, length);
0d7877278adf 8231086: Shenandoah: Stronger invariant for object-arraycopy
rkennke
parents: 55679
diff changeset
    46
}
0d7877278adf 8231086: Shenandoah: Stronger invariant for object-arraycopy
rkennke
parents: 55679
diff changeset
    47
0d7877278adf 8231086: Shenandoah: Stronger invariant for object-arraycopy
rkennke
parents: 55679
diff changeset
    48
void ShenandoahRuntime::write_ref_array_pre_duinit_narrow_oop_entry(narrowOop* src, narrowOop* dst, size_t length) {
0d7877278adf 8231086: Shenandoah: Stronger invariant for object-arraycopy
rkennke
parents: 55679
diff changeset
    49
  ShenandoahBarrierSet *bs = ShenandoahBarrierSet::barrier_set();
0d7877278adf 8231086: Shenandoah: Stronger invariant for object-arraycopy
rkennke
parents: 55679
diff changeset
    50
  bs->arraycopy_update(src, length);
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    51
}
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    52
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    53
// Shenandoah pre write barrier slowpath
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    54
JRT_LEAF(void, ShenandoahRuntime::write_ref_field_pre_entry(oopDesc* orig, JavaThread *thread))
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    55
  if (orig == NULL) {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    56
    assert(false, "should be optimized out");
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    57
    return;
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    58
  }
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    59
  shenandoah_assert_correct(NULL, orig);
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    60
  // store the original value that was in the field reference
54383
cdc3bb0983a6 8221751: Shenandoah: Improve SATB enqueueing
rkennke
parents: 52925
diff changeset
    61
  assert(ShenandoahThreadLocalData::satb_mark_queue(thread).is_active(), "Shouldn't be here otherwise");
cdc3bb0983a6 8221751: Shenandoah: Improve SATB enqueueing
rkennke
parents: 52925
diff changeset
    62
  ShenandoahThreadLocalData::satb_mark_queue(thread).enqueue_known_active(orig);
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    63
JRT_END
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    64
58819
ef8be51fff48 8232992: Shenandoah: Implement self-fixing interpreter LRB
zgu
parents: 58710
diff changeset
    65
JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier(oopDesc* src, oop* load_addr))
58219
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
    66
  return ShenandoahBarrierSet::barrier_set()->load_reference_barrier_mutator(src, load_addr);
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
    67
JRT_END
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
    68
58819
ef8be51fff48 8232992: Shenandoah: Implement self-fixing interpreter LRB
zgu
parents: 58710
diff changeset
    69
JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_narrow(oopDesc* src, narrowOop* load_addr))
58219
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
    70
  return ShenandoahBarrierSet::barrier_set()->load_reference_barrier_mutator(src, load_addr);
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    71
JRT_END
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    72
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    73
// Shenandoah clone barrier: makes sure that references point to to-space
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    74
// in cloned objects.
58405
752bf4d5fbb7 8231499: Shenandoah: compiler/arraycopy/TestDefaultMethodArrayCloneDeoptC2 fails
rkennke
parents: 58339
diff changeset
    75
JRT_LEAF(void, ShenandoahRuntime::shenandoah_clone_barrier(oopDesc* src))
58339
c7d9df2e470c 8231410: Shenandoah: clone barrier should use base pointer
shade
parents: 58334
diff changeset
    76
  oop s = oop(src);
c7d9df2e470c 8231410: Shenandoah: clone barrier should use base pointer
shade
parents: 58334
diff changeset
    77
  shenandoah_assert_correct(NULL, s);
c7d9df2e470c 8231410: Shenandoah: clone barrier should use base pointer
shade
parents: 58334
diff changeset
    78
  ShenandoahBarrierSet::barrier_set()->clone_barrier(s);
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    79
JRT_END
55654
92ab031d6540 8226695: Shenandoah: Wire C1 and C2 IN_NATIVE barrier
rkennke
parents: 54423
diff changeset
    80
58693
3f35a9efd7de 8232010: Shenandoah: implement self-fixing native barrier
zgu
parents: 58405
diff changeset
    81
JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_native(oopDesc * src, oop* load_addr))
58710
ff3eab78554f 8232674: Fix build and rename ShenandoahBarrierSet::oop_load_from_native_barrier
shade
parents: 58693
diff changeset
    82
  return (oopDesc*) ShenandoahBarrierSet::barrier_set()->load_reference_barrier_native(oop(src), load_addr);
55654
92ab031d6540 8226695: Shenandoah: Wire C1 and C2 IN_NATIVE barrier
rkennke
parents: 54423
diff changeset
    83
JRT_END