src/hotspot/share/gc/shared/modRefBarrierSet.hpp
author stefank
Thu, 22 Feb 2018 18:36:32 +0100
changeset 49048 4e8c86b75428
parent 48961 120b61d50f85
child 49164 7e958a8ebcd3
permissions -rw-r--r--
8198525: Move _size_policy out of GenCollectorPolicy into GenCollectedHeap Reviewed-by: pliden, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
     2
 * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1388
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1388
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: 1388
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29325
diff changeset
    25
#ifndef SHARE_VM_GC_SHARED_MODREFBARRIERSET_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29325
diff changeset
    26
#define SHARE_VM_GC_SHARED_MODREFBARRIERSET_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29325
diff changeset
    28
#include "gc/shared/barrierSet.hpp"
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    29
#include "memory/memRegion.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    31
class Klass;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
class ModRefBarrierSet: public BarrierSet {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
protected:
29325
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 28830
diff changeset
    35
  ModRefBarrierSet(const BarrierSet::FakeRtti& fake_rtti)
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 28830
diff changeset
    36
    : BarrierSet(fake_rtti.add_tag(BarrierSet::ModRef)) { }
28830
a252e278c3d9 8064947: Clean up BarrierSet ctor/dtor
jprovino
parents: 27687
diff changeset
    37
  ~ModRefBarrierSet() { }
a252e278c3d9 8064947: Clean up BarrierSet ctor/dtor
jprovino
parents: 27687
diff changeset
    38
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
public:
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    40
  template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    41
  inline void write_ref_field_pre(T* addr) {}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    42
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    43
  template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    44
  inline void write_ref_field_post(T *addr, oop new_value) {}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    45
42598
45562c0473fb 8166898: G1SATBCardTableLoggingModRefBS::invalidate() incorrect with whole_heap == true
lmesnik
parents: 32612
diff changeset
    46
  // Causes all refs in "mr" to be assumed to be modified.
45562c0473fb 8166898: G1SATBCardTableLoggingModRefBS::invalidate() incorrect with whole_heap == true
lmesnik
parents: 32612
diff changeset
    47
  virtual void invalidate(MemRegion mr) = 0;
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    48
  virtual void write_region(MemRegion mr) = 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  // The caller guarantees that "mr" contains no references.  (Perhaps it's
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  // objects have been moved elsewhere.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  virtual void clear(MemRegion mr) = 0;
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    53
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    54
  // The ModRef abstraction introduces pre and post barriers
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    55
  template <DecoratorSet decorators, typename BarrierSetT>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    56
  class AccessBarrier: public BarrierSet::AccessBarrier<decorators, BarrierSetT> {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    57
    typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    58
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    59
  public:
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    60
    template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    61
    static void oop_store_in_heap(T* addr, oop value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    62
    template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    63
    static oop oop_atomic_cmpxchg_in_heap(oop new_value, T* addr, oop compare_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    64
    template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    65
    static oop oop_atomic_xchg_in_heap(oop new_value, T* addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    66
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    67
    template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    68
    static bool oop_arraycopy_in_heap(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    69
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    70
    static void clone_in_heap(oop src, oop dst, size_t size);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    71
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    72
    static void oop_store_in_heap_at(oop base, ptrdiff_t offset, oop value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    73
      oop_store_in_heap(AccessInternal::oop_field_addr<decorators>(base, offset), value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    74
    }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    75
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    76
    static oop oop_atomic_xchg_in_heap_at(oop new_value, oop base, ptrdiff_t offset) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    77
      return oop_atomic_xchg_in_heap(new_value, AccessInternal::oop_field_addr<decorators>(base, offset));
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    78
    }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    79
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    80
    static oop oop_atomic_cmpxchg_in_heap_at(oop new_value, oop base, ptrdiff_t offset, oop compare_value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    81
      return oop_atomic_cmpxchg_in_heap(new_value, AccessInternal::oop_field_addr<decorators>(base, offset), compare_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    82
    }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47658
diff changeset
    83
  };
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    85
29325
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 28830
diff changeset
    86
template<>
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 28830
diff changeset
    87
struct BarrierSet::GetName<ModRefBarrierSet> {
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 28830
diff changeset
    88
  static const BarrierSet::Name value = BarrierSet::ModRef;
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 28830
diff changeset
    89
};
0e86e64c66e5 8069016: Add BarrierSet downcast support
kbarrett
parents: 28830
diff changeset
    90
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29325
diff changeset
    91
#endif // SHARE_VM_GC_SHARED_MODREFBARRIERSET_HPP