src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp
author stefank
Tue, 26 Nov 2019 10:47:46 +0100
changeset 59290 97d13893ec3c
parent 59270 d5a1c6545a2b
child 59296 9186be5c78ba
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
/*
54006
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53850
diff changeset
     2
 * Copyright (c) 2013, 2019, Red Hat, Inc. All rights reserved.
52925
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"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    25
#include "gc/shenandoah/shenandoahAsserts.hpp"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    26
#include "gc/shenandoah/shenandoahBarrierSet.hpp"
58334
f642ad5c655f 8231447: Shenandoah: Compilation-time regression after JDK-8231086
rkennke
parents: 58266
diff changeset
    27
#include "gc/shenandoah/shenandoahBarrierSetClone.inline.hpp"
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    28
#include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    29
#include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
58985
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    30
#include "gc/shenandoah/shenandoahConcurrentRoots.hpp"
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    31
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    32
#include "gc/shenandoah/shenandoahHeuristics.hpp"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    33
#include "gc/shenandoah/shenandoahTraversalGC.hpp"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    34
#include "memory/iterator.inline.hpp"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    35
#include "runtime/interfaceSupport.inline.hpp"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    36
#ifdef COMPILER1
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    37
#include "gc/shenandoah/c1/shenandoahBarrierSetC1.hpp"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    38
#endif
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    39
#ifdef COMPILER2
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    40
#include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    41
#endif
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    42
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    43
class ShenandoahBarrierSetC1;
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    44
class ShenandoahBarrierSetC2;
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    45
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    46
ShenandoahBarrierSet::ShenandoahBarrierSet(ShenandoahHeap* heap) :
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    47
  BarrierSet(make_barrier_set_assembler<ShenandoahBarrierSetAssembler>(),
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    48
             make_barrier_set_c1<ShenandoahBarrierSetC1>(),
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    49
             make_barrier_set_c2<ShenandoahBarrierSetC2>(),
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    50
             NULL /* barrier_set_nmethod */,
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    51
             BarrierSet::FakeRtti(BarrierSet::ShenandoahBarrierSet)),
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    52
  _heap(heap),
58059
baa4dd528de0 8221361: Eliminate two-phase initialization for PtrQueueSet classes
kbarrett
parents: 55681
diff changeset
    53
  _satb_mark_queue_buffer_allocator("SATB Buffer Allocator", ShenandoahSATBBufferSize),
baa4dd528de0 8221361: Eliminate two-phase initialization for PtrQueueSet classes
kbarrett
parents: 55681
diff changeset
    54
  _satb_mark_queue_set(&_satb_mark_queue_buffer_allocator)
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    55
{
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    56
}
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    57
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    58
ShenandoahBarrierSetAssembler* ShenandoahBarrierSet::assembler() {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    59
  BarrierSetAssembler* const bsa = BarrierSet::barrier_set()->barrier_set_assembler();
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    60
  return reinterpret_cast<ShenandoahBarrierSetAssembler*>(bsa);
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    61
}
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    62
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    63
void ShenandoahBarrierSet::print_on(outputStream* st) const {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    64
  st->print("ShenandoahBarrierSet");
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    65
}
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    66
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    67
bool ShenandoahBarrierSet::is_a(BarrierSet::Name bsn) {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    68
  return bsn == BarrierSet::ShenandoahBarrierSet;
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    69
}
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    70
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    71
bool ShenandoahBarrierSet::is_aligned(HeapWord* hw) {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    72
  return true;
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    73
}
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
    74
58985
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    75
bool ShenandoahBarrierSet::need_load_reference_barrier(DecoratorSet decorators, BasicType type) {
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    76
  if (!ShenandoahLoadRefBarrier) return false;
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    77
  // Only needed for references
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    78
  return is_reference_type(type);
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    79
}
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    80
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    81
bool ShenandoahBarrierSet::use_load_reference_barrier_native(DecoratorSet decorators, BasicType type) {
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    82
  assert(need_load_reference_barrier(decorators, type), "Should be subset of LRB");
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    83
  assert(is_reference_type(type), "Why we here?");
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    84
  // Native load reference barrier is only needed for concurrent root processing
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    85
  if (!ShenandoahConcurrentRoots::can_do_concurrent_roots()) {
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    86
    return false;
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    87
  }
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    88
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    89
  return (decorators & IN_NATIVE) != 0;
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    90
}
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    91
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    92
bool ShenandoahBarrierSet::need_keep_alive_barrier(DecoratorSet decorators,BasicType type) {
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    93
  if (!ShenandoahKeepAliveBarrier) return false;
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    94
  // Only needed for references
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    95
  if (!is_reference_type(type)) return false;
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    96
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    97
  bool keep_alive = (decorators & AS_NO_KEEPALIVE) == 0;
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    98
  bool unknown = (decorators & ON_UNKNOWN_OOP_REF) != 0;
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
    99
  bool is_traversal_mode = ShenandoahHeap::heap()->is_traversal_mode();
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
   100
  bool on_weak_ref = (decorators & (ON_WEAK_OOP_REF | ON_PHANTOM_OOP_REF)) != 0;
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
   101
  return (on_weak_ref || unknown) && (keep_alive || is_traversal_mode);
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
   102
}
5606867a5e6e 8233339: Shenandoah: Centralize load barrier decisions into ShenandoahBarrierSet
zgu
parents: 58710
diff changeset
   103
54423
6c0ab8bd8da5 8221766: Load-reference barriers for Shenandoah
rkennke
parents: 54383
diff changeset
   104
oop ShenandoahBarrierSet::load_reference_barrier_not_null(oop obj) {
6c0ab8bd8da5 8221766: Load-reference barriers for Shenandoah
rkennke
parents: 54383
diff changeset
   105
  if (ShenandoahLoadRefBarrier && _heap->has_forwarded_objects()) {
6c0ab8bd8da5 8221766: Load-reference barriers for Shenandoah
rkennke
parents: 54383
diff changeset
   106
    return load_reference_barrier_impl(obj);
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   107
  } else {
54423
6c0ab8bd8da5 8221766: Load-reference barriers for Shenandoah
rkennke
parents: 54383
diff changeset
   108
    return obj;
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   109
  }
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   110
}
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   111
54423
6c0ab8bd8da5 8221766: Load-reference barriers for Shenandoah
rkennke
parents: 54383
diff changeset
   112
oop ShenandoahBarrierSet::load_reference_barrier(oop obj) {
6c0ab8bd8da5 8221766: Load-reference barriers for Shenandoah
rkennke
parents: 54383
diff changeset
   113
  if (obj != NULL) {
6c0ab8bd8da5 8221766: Load-reference barriers for Shenandoah
rkennke
parents: 54383
diff changeset
   114
    return load_reference_barrier_not_null(obj);
6c0ab8bd8da5 8221766: Load-reference barriers for Shenandoah
rkennke
parents: 54383
diff changeset
   115
  } else {
6c0ab8bd8da5 8221766: Load-reference barriers for Shenandoah
rkennke
parents: 54383
diff changeset
   116
    return obj;
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   117
  }
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   118
}
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   119
58219
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
   120
oop ShenandoahBarrierSet::load_reference_barrier_mutator(oop obj, oop* load_addr) {
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
   121
  return load_reference_barrier_mutator_work(obj, load_addr);
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
   122
}
54423
6c0ab8bd8da5 8221766: Load-reference barriers for Shenandoah
rkennke
parents: 54383
diff changeset
   123
58219
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
   124
oop ShenandoahBarrierSet::load_reference_barrier_mutator(oop obj, narrowOop* load_addr) {
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
   125
  return load_reference_barrier_mutator_work(obj, load_addr);
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
   126
}
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
   127
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
   128
template <class T>
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
   129
oop ShenandoahBarrierSet::load_reference_barrier_mutator_work(oop obj, T* load_addr) {
54423
6c0ab8bd8da5 8221766: Load-reference barriers for Shenandoah
rkennke
parents: 54383
diff changeset
   130
  assert(ShenandoahLoadRefBarrier, "should be enabled");
58219
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
   131
  shenandoah_assert_in_cset(load_addr, obj);
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   132
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   133
  oop fwd = resolve_forwarded_not_null(obj);
58177
4932dce35882 8230841: Remove oopDesc::equals()
pliden
parents: 58059
diff changeset
   134
  if (obj == fwd) {
58219
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
   135
    assert(_heap->is_gc_in_progress_mask(ShenandoahHeap::EVACUATION | ShenandoahHeap::TRAVERSAL),
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
   136
           "evac should be in progress");
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
   137
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   138
    ShenandoahEvacOOMScope oom_evac_scope;
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   139
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   140
    Thread* thread = Thread::current();
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   141
    oop res_oop = _heap->evacuate_object(obj, thread);
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   142
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   143
    // Since we are already here and paid the price of getting through runtime call adapters
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   144
    // and acquiring oom-scope, it makes sense to try and evacuate more adjacent objects,
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   145
    // thus amortizing the overhead. For sparsely live heaps, scan costs easily dominate
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   146
    // total assist costs, and can introduce a lot of evacuation latency. This is why we
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   147
    // only scan for _nearest_ N objects, regardless if they are eligible for evac or not.
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   148
    // The scan itself should also avoid touching the non-marked objects below TAMS, because
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   149
    // their metadata (notably, klasses) may be incorrect already.
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   150
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   151
    size_t max = ShenandoahEvacAssist;
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   152
    if (max > 0) {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   153
      // Traversal is special: it uses incomplete marking context, because it coalesces evac with mark.
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   154
      // Other code uses complete marking context, because evac happens after the mark.
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   155
      ShenandoahMarkingContext* ctx = _heap->is_concurrent_traversal_in_progress() ?
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   156
                                      _heap->marking_context() : _heap->complete_marking_context();
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   157
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   158
      ShenandoahHeapRegion* r = _heap->heap_region_containing(obj);
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   159
      assert(r->is_cset(), "sanity");
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   160
55076
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 55015
diff changeset
   161
      HeapWord* cur = (HeapWord*)obj + obj->size();
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   162
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   163
      size_t count = 0;
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   164
      while ((cur < r->top()) && ctx->is_marked(oop(cur)) && (count++ < max)) {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   165
        oop cur_oop = oop(cur);
58177
4932dce35882 8230841: Remove oopDesc::equals()
pliden
parents: 58059
diff changeset
   166
        if (cur_oop == resolve_forwarded_not_null(cur_oop)) {
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   167
          _heap->evacuate_object(cur_oop, thread);
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   168
        }
55076
785a12e0f89b 8224584: Shenandoah: Eliminate forwarding pointer word
rkennke
parents: 55015
diff changeset
   169
        cur = cur + cur_oop->size();
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   170
      }
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   171
    }
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   172
58219
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
   173
    fwd = res_oop;
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   174
  }
58219
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
   175
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
   176
  if (load_addr != NULL && fwd != obj) {
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
   177
    // Since we are here and we know the load address, update the reference.
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
   178
    ShenandoahHeap::cas_oop(fwd, load_addr, obj);
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
   179
  }
bc0648405d67 8231087: Shenandoah: Self-fixing load reference barriers for C1/C2
rkennke
parents: 58218
diff changeset
   180
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   181
  return fwd;
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   182
}
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   183
54423
6c0ab8bd8da5 8221766: Load-reference barriers for Shenandoah
rkennke
parents: 54383
diff changeset
   184
oop ShenandoahBarrierSet::load_reference_barrier_impl(oop obj) {
6c0ab8bd8da5 8221766: Load-reference barriers for Shenandoah
rkennke
parents: 54383
diff changeset
   185
  assert(ShenandoahLoadRefBarrier, "should be enabled");
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   186
  if (!CompressedOops::is_null(obj)) {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   187
    bool evac_in_progress = _heap->is_gc_in_progress_mask(ShenandoahHeap::EVACUATION | ShenandoahHeap::TRAVERSAL);
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   188
    oop fwd = resolve_forwarded_not_null(obj);
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   189
    if (evac_in_progress &&
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   190
        _heap->in_collection_set(obj) &&
58177
4932dce35882 8230841: Remove oopDesc::equals()
pliden
parents: 58059
diff changeset
   191
        obj == fwd) {
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   192
      Thread *t = Thread::current();
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   193
      if (t->is_GC_task_thread()) {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   194
        return _heap->evacuate_object(obj, t);
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   195
      } else {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   196
        ShenandoahEvacOOMScope oom_evac_scope;
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   197
        return _heap->evacuate_object(obj, t);
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   198
      }
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   199
    } else {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   200
      return fwd;
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   201
    }
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   202
  } else {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   203
    return obj;
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   204
  }
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   205
}
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   206
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   207
void ShenandoahBarrierSet::on_thread_create(Thread* thread) {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   208
  // Create thread local data
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   209
  ShenandoahThreadLocalData::create(thread);
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   210
}
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   211
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   212
void ShenandoahBarrierSet::on_thread_destroy(Thread* thread) {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   213
  // Destroy thread local data
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   214
  ShenandoahThreadLocalData::destroy(thread);
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   215
}
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   216
54006
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53850
diff changeset
   217
void ShenandoahBarrierSet::on_thread_attach(Thread *thread) {
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53850
diff changeset
   218
  assert(!thread->is_Java_thread() || !SafepointSynchronize::is_at_safepoint(),
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53850
diff changeset
   219
         "We should not be at a safepoint");
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53850
diff changeset
   220
  SATBMarkQueue& queue = ShenandoahThreadLocalData::satb_mark_queue(thread);
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53850
diff changeset
   221
  assert(!queue.is_active(), "SATB queue should not be active");
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53850
diff changeset
   222
  assert( queue.is_empty(),  "SATB queue should be empty");
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53850
diff changeset
   223
  queue.set_active(_satb_mark_queue_set.is_active());
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53850
diff changeset
   224
  if (thread->is_Java_thread()) {
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53850
diff changeset
   225
    ShenandoahThreadLocalData::set_gc_state(thread, _heap->gc_state());
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53850
diff changeset
   226
    ShenandoahThreadLocalData::initialize_gclab(thread);
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   227
  }
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   228
}
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   229
54006
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53850
diff changeset
   230
void ShenandoahBarrierSet::on_thread_detach(Thread *thread) {
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53850
diff changeset
   231
  SATBMarkQueue& queue = ShenandoahThreadLocalData::satb_mark_queue(thread);
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53850
diff changeset
   232
  queue.flush();
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53850
diff changeset
   233
  if (thread->is_Java_thread()) {
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53850
diff changeset
   234
    PLAB* gclab = ShenandoahThreadLocalData::gclab(thread);
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53850
diff changeset
   235
    if (gclab != NULL) {
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53850
diff changeset
   236
      gclab->retire();
a421bdf22394 8219613: Use NonJavaThread PtrQueues
kbarrett
parents: 53850
diff changeset
   237
    }
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   238
  }
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents:
diff changeset
   239
}
55654
92ab031d6540 8226695: Shenandoah: Wire C1 and C2 IN_NATIVE barrier
rkennke
parents: 55076
diff changeset
   240
58710
ff3eab78554f 8232674: Fix build and rename ShenandoahBarrierSet::oop_load_from_native_barrier
shade
parents: 58693
diff changeset
   241
oop ShenandoahBarrierSet::load_reference_barrier_native(oop obj, oop* load_addr) {
ff3eab78554f 8232674: Fix build and rename ShenandoahBarrierSet::oop_load_from_native_barrier
shade
parents: 58693
diff changeset
   242
  return load_reference_barrier_native_impl(obj, load_addr);
ff3eab78554f 8232674: Fix build and rename ShenandoahBarrierSet::oop_load_from_native_barrier
shade
parents: 58693
diff changeset
   243
}
ff3eab78554f 8232674: Fix build and rename ShenandoahBarrierSet::oop_load_from_native_barrier
shade
parents: 58693
diff changeset
   244
ff3eab78554f 8232674: Fix build and rename ShenandoahBarrierSet::oop_load_from_native_barrier
shade
parents: 58693
diff changeset
   245
oop ShenandoahBarrierSet::load_reference_barrier_native(oop obj, narrowOop* load_addr) {
ff3eab78554f 8232674: Fix build and rename ShenandoahBarrierSet::oop_load_from_native_barrier
shade
parents: 58693
diff changeset
   246
  // Assumption: narrow oop version should not be used anywhere.
ff3eab78554f 8232674: Fix build and rename ShenandoahBarrierSet::oop_load_from_native_barrier
shade
parents: 58693
diff changeset
   247
  ShouldNotReachHere();
ff3eab78554f 8232674: Fix build and rename ShenandoahBarrierSet::oop_load_from_native_barrier
shade
parents: 58693
diff changeset
   248
  return NULL;
ff3eab78554f 8232674: Fix build and rename ShenandoahBarrierSet::oop_load_from_native_barrier
shade
parents: 58693
diff changeset
   249
}
ff3eab78554f 8232674: Fix build and rename ShenandoahBarrierSet::oop_load_from_native_barrier
shade
parents: 58693
diff changeset
   250
ff3eab78554f 8232674: Fix build and rename ShenandoahBarrierSet::oop_load_from_native_barrier
shade
parents: 58693
diff changeset
   251
template <class T>
ff3eab78554f 8232674: Fix build and rename ShenandoahBarrierSet::oop_load_from_native_barrier
shade
parents: 58693
diff changeset
   252
oop ShenandoahBarrierSet::load_reference_barrier_native_impl(oop obj, T* load_addr) {
55681
7b671e6b0d5b 8225483: Shenandoah: Enhance native access barrier
zgu
parents: 55654
diff changeset
   253
  if (CompressedOops::is_null(obj)) {
7b671e6b0d5b 8225483: Shenandoah: Enhance native access barrier
zgu
parents: 55654
diff changeset
   254
    return NULL;
7b671e6b0d5b 8225483: Shenandoah: Enhance native access barrier
zgu
parents: 55654
diff changeset
   255
  }
7b671e6b0d5b 8225483: Shenandoah: Enhance native access barrier
zgu
parents: 55654
diff changeset
   256
58266
501df37ce76b 8231293: Shenandoah: Traversal should not revive dead weak roots
zgu
parents: 58219
diff changeset
   257
  ShenandoahMarkingContext* const marking_context = _heap->marking_context();
58674
42a3a8941418 8231999: Shenandoah: Traversal failed compiler/jsr292/CallSiteDepContextTest.java
zgu
parents: 58405
diff changeset
   258
  if (_heap->is_evacuation_in_progress() && !marking_context->is_marked(obj)) {
42a3a8941418 8231999: Shenandoah: Traversal failed compiler/jsr292/CallSiteDepContextTest.java
zgu
parents: 58405
diff changeset
   259
    Thread* thr = Thread::current();
42a3a8941418 8231999: Shenandoah: Traversal failed compiler/jsr292/CallSiteDepContextTest.java
zgu
parents: 58405
diff changeset
   260
    if (thr->is_Java_thread()) {
58266
501df37ce76b 8231293: Shenandoah: Traversal should not revive dead weak roots
zgu
parents: 58219
diff changeset
   261
      return NULL;
58674
42a3a8941418 8231999: Shenandoah: Traversal failed compiler/jsr292/CallSiteDepContextTest.java
zgu
parents: 58405
diff changeset
   262
    } else {
42a3a8941418 8231999: Shenandoah: Traversal failed compiler/jsr292/CallSiteDepContextTest.java
zgu
parents: 58405
diff changeset
   263
      return obj;
58266
501df37ce76b 8231293: Shenandoah: Traversal should not revive dead weak roots
zgu
parents: 58219
diff changeset
   264
    }
55681
7b671e6b0d5b 8225483: Shenandoah: Enhance native access barrier
zgu
parents: 55654
diff changeset
   265
  }
7b671e6b0d5b 8225483: Shenandoah: Enhance native access barrier
zgu
parents: 55654
diff changeset
   266
58693
3f35a9efd7de 8232010: Shenandoah: implement self-fixing native barrier
zgu
parents: 58674
diff changeset
   267
  oop fwd = load_reference_barrier_not_null(obj);
3f35a9efd7de 8232010: Shenandoah: implement self-fixing native barrier
zgu
parents: 58674
diff changeset
   268
  if (load_addr != NULL && fwd != obj) {
3f35a9efd7de 8232010: Shenandoah: implement self-fixing native barrier
zgu
parents: 58674
diff changeset
   269
    // Since we are here and we know the load address, update the reference.
3f35a9efd7de 8232010: Shenandoah: implement self-fixing native barrier
zgu
parents: 58674
diff changeset
   270
    ShenandoahHeap::cas_oop(fwd, load_addr, obj);
3f35a9efd7de 8232010: Shenandoah: implement self-fixing native barrier
zgu
parents: 58674
diff changeset
   271
  }
3f35a9efd7de 8232010: Shenandoah: implement self-fixing native barrier
zgu
parents: 58674
diff changeset
   272
3f35a9efd7de 8232010: Shenandoah: implement self-fixing native barrier
zgu
parents: 58674
diff changeset
   273
  return fwd;
55654
92ab031d6540 8226695: Shenandoah: Wire C1 and C2 IN_NATIVE barrier
rkennke
parents: 55076
diff changeset
   274
}
58334
f642ad5c655f 8231447: Shenandoah: Compilation-time regression after JDK-8231086
rkennke
parents: 58266
diff changeset
   275
f642ad5c655f 8231447: Shenandoah: Compilation-time regression after JDK-8231086
rkennke
parents: 58266
diff changeset
   276
void ShenandoahBarrierSet::clone_barrier_runtime(oop src) {
58405
752bf4d5fbb7 8231499: Shenandoah: compiler/arraycopy/TestDefaultMethodArrayCloneDeoptC2 fails
rkennke
parents: 58334
diff changeset
   277
  if (_heap->has_forwarded_objects()) {
752bf4d5fbb7 8231499: Shenandoah: compiler/arraycopy/TestDefaultMethodArrayCloneDeoptC2 fails
rkennke
parents: 58334
diff changeset
   278
    clone_barrier(src);
752bf4d5fbb7 8231499: Shenandoah: compiler/arraycopy/TestDefaultMethodArrayCloneDeoptC2 fails
rkennke
parents: 58334
diff changeset
   279
  }
58334
f642ad5c655f 8231447: Shenandoah: Compilation-time regression after JDK-8231086
rkennke
parents: 58266
diff changeset
   280
}
f642ad5c655f 8231447: Shenandoah: Compilation-time regression after JDK-8231086
rkennke
parents: 58266
diff changeset
   281