src/hotspot/share/gc/g1/g1BarrierSet.hpp
author eosterlund
Wed, 21 Mar 2018 14:38:32 +0100
changeset 49484 ee8fa73b90f9
parent 49455 848864ed9b17
child 49488 1f9dd2360b17
permissions -rw-r--r--
8198949: Modularize arraycopy stub routine GC barriers Reviewed-by: rkennke, pliden
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     1
/*
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48784
diff changeset
     2
 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     4
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     8
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    13
 * accompanied this code).
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    14
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3262
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3262
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3262
diff changeset
    21
 * questions.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    22
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    23
 */
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    24
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    25
#ifndef SHARE_VM_GC_G1_G1BARRIERSET_HPP
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    26
#define SHARE_VM_GC_G1_G1BARRIERSET_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49347
diff changeset
    28
#include "gc/shared/cardTableBarrierSet.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    30
class DirtyCardQueueSet;
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    31
class CardTable;
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    32
class G1CardTable;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    33
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    34
// This barrier is specialized to use a logging barrier to support
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    35
// snapshot-at-the-beginning marking.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    36
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49347
diff changeset
    37
class G1BarrierSet: public CardTableBarrierSet {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 32612
diff changeset
    38
  friend class VMStructs;
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    39
 private:
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    40
  DirtyCardQueueSet& _dcqs;
28830
a252e278c3d9 8064947: Clean up BarrierSet ctor/dtor
jprovino
parents: 28217
diff changeset
    41
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    42
 public:
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    43
  G1BarrierSet(G1CardTable* table);
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    44
  ~G1BarrierSet() { }
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    45
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    46
  // Add "pre_val" to a set of objects that may have been disconnected from the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    47
  // pre-marking object graph.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    48
  static void enqueue(oop pre_val);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    49
48784
899b522ed65c 8194741: Refactor oops in constant pool from CDS to use the Access API
eosterlund
parents: 47998
diff changeset
    50
  static void enqueue_if_weak_or_archive(DecoratorSet decorators, oop value);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    51
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    52
  template <class T> void write_ref_array_pre_work(T* dst, size_t count);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    53
  virtual void write_ref_array_pre(oop* dst, size_t count, bool dest_uninitialized);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    54
  virtual void write_ref_array_pre(narrowOop* dst, size_t count, bool dest_uninitialized);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    55
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    56
  static void write_ref_array_pre_oop_entry(oop* dst, size_t length);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    57
  static void write_ref_array_pre_narrow_oop_entry(narrowOop* dst, size_t length);
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    58
  static void write_ref_array_post_entry(HeapWord* dst, size_t length);
20309
7445302daff6 8025305: Cleanup CardTableModRefBS usage in G1
mgerdin
parents: 15482
diff changeset
    59
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    60
  template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    61
  void write_ref_field_pre(T* field);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25480
diff changeset
    62
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    63
  // NB: if you do a whole-heap invalidation, the "usual invariant" defined
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    64
  // above no longer applies.
42598
45562c0473fb 8166898: G1SATBCardTableLoggingModRefBS::invalidate() incorrect with whole_heap == true
lmesnik
parents: 35862
diff changeset
    65
  void invalidate(MemRegion mr);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    66
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48784
diff changeset
    67
  void write_region(MemRegion mr)         { invalidate(mr); }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    68
  void write_ref_array_work(MemRegion mr) { invalidate(mr); }
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    69
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    70
  template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    71
  void write_ref_field_post(T* field, oop new_val);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    72
  void write_ref_field_post_slow(volatile jbyte* byte);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    73
49007
82d9d5744e5f 8197994: Move JavaThread::initialize_queues() logic to G1SATBCardTableLoggingModRefBS
pliden
parents: 48961
diff changeset
    74
  virtual void on_thread_attach(JavaThread* thread);
82d9d5744e5f 8197994: Move JavaThread::initialize_queues() logic to G1SATBCardTableLoggingModRefBS
pliden
parents: 48961
diff changeset
    75
  virtual void on_thread_detach(JavaThread* thread);
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48784
diff changeset
    76
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    77
  // Callbacks for runtime accesses.
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    78
  template <DecoratorSet decorators, typename BarrierSetT = G1BarrierSet>
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    79
  class AccessBarrier: public ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    80
    typedef ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> ModRef;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    81
    typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    82
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    83
  public:
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    84
    // Needed for loads on non-heap weak references
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    85
    template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    86
    static oop oop_load_not_in_heap(T* addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    87
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    88
    // Needed for non-heap stores
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    89
    template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    90
    static void oop_store_not_in_heap(T* addr, oop new_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    91
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    92
    // Needed for weak references
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    93
    static oop oop_load_in_heap_at(oop base, ptrdiff_t offset);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    94
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    95
    // Defensive: will catch weak oops at addresses in heap
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    96
    template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    97
    static oop oop_load_in_heap(T* addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
    98
  };
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    99
};
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   100
29325
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 29081
diff changeset
   101
template<>
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
   102
struct BarrierSet::GetName<G1BarrierSet> {
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
   103
  static const BarrierSet::Name value = BarrierSet::G1BarrierSet;
29325
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 29081
diff changeset
   104
};
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 29081
diff changeset
   105
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   106
template<>
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
   107
struct BarrierSet::GetType<BarrierSet::G1BarrierSet> {
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
   108
  typedef ::G1BarrierSet type;
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   109
};
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47794
diff changeset
   110
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
   111
#endif // SHARE_VM_GC_G1_G1BARRIERSET_HPP