src/hotspot/share/gc/shared/cardTableBarrierSet.cpp
author jwilhelm
Sat, 24 Mar 2018 01:08:35 +0100
changeset 49488 1f9dd2360b17
parent 49390 src/hotspot/share/gc/shared/cardTableModRefBS.cpp@95f0b54a3024
parent 49484 src/hotspot/share/gc/shared/cardTableModRefBS.cpp@ee8fa73b90f9
child 49734 f946776e9354
permissions -rw-r--r--
Merge
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: 4461
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4461
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: 4461
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
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5892
diff changeset
    25
#include "precompiled.hpp"
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    26
#include "gc/shared/cardTableBarrierSetAssembler.hpp"
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49390
diff changeset
    27
#include "gc/shared/cardTableBarrierSet.inline.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30291
diff changeset
    28
#include "gc/shared/collectedHeap.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30291
diff changeset
    29
#include "gc/shared/genCollectedHeap.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30291
diff changeset
    30
#include "gc/shared/space.inline.hpp"
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    31
#include "logging/log.hpp"
30291
54cdc5c1a9cb 8068352: Move virtualspace.* out of src/share/vm/runtime to memory directory
coleenp
parents: 30154
diff changeset
    32
#include "memory/virtualspace.hpp"
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    33
#include "oops/oop.inline.hpp"
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    34
#include "runtime/thread.hpp"
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12268
diff changeset
    35
#include "services/memTracker.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46619
diff changeset
    36
#include "utilities/align.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13963
diff changeset
    37
#include "utilities/macros.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5892
diff changeset
    38
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// This kind of "BarrierSet" allows a "CollectedHeap" to detect and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// enumerate ref fields that have been modified (since the last
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
// enumeration.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    43
CardTableBarrierSet::CardTableBarrierSet(BarrierSetAssembler* barrier_set_assembler,
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    44
                                         CardTable* card_table,
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    45
                                         const BarrierSet::FakeRtti& fake_rtti) :
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    46
  ModRefBarrierSet(barrier_set_assembler,
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    47
                   fake_rtti.add_tag(BarrierSet::CardTableBarrierSet)),
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    48
  _defer_initial_card_mark(false),
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    49
  _card_table(card_table)
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    50
{}
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    51
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49390
diff changeset
    52
CardTableBarrierSet::CardTableBarrierSet(CardTable* card_table) :
49484
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    53
  ModRefBarrierSet(make_barrier_set_assembler<CardTableBarrierSetAssembler>(),
ee8fa73b90f9 8198949: Modularize arraycopy stub routine GC barriers
eosterlund
parents: 49455
diff changeset
    54
                   BarrierSet::FakeRtti(BarrierSet::CardTableBarrierSet)),
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    55
  _defer_initial_card_mark(false),
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    56
  _card_table(card_table)
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    57
{}
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    58
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49390
diff changeset
    59
void CardTableBarrierSet::initialize() {
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    60
  initialize_deferred_card_mark_barriers();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49390
diff changeset
    63
CardTableBarrierSet::~CardTableBarrierSet() {
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    64
  delete _card_table;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49390
diff changeset
    67
void CardTableBarrierSet::write_ref_array_work(MemRegion mr) {
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    68
  _card_table->dirty_MemRegion(mr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49390
diff changeset
    71
void CardTableBarrierSet::invalidate(MemRegion mr) {
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    72
  _card_table->invalidate(mr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49390
diff changeset
    75
void CardTableBarrierSet::print_on(outputStream* st) const {
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    76
  _card_table->print_on(st);
12268
f7897aacb9ce 7157141: crash in 64 bit with corrupted oops
never
parents: 11177
diff changeset
    77
}
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    78
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    79
// Helper for ReduceInitialCardMarks. For performance,
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    80
// compiled code may elide card-marks for initializing stores
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    81
// to a newly allocated object along the fast-path. We
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    82
// compensate for such elided card-marks as follows:
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    83
// (a) Generational, non-concurrent collectors, such as
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    84
//     GenCollectedHeap(ParNew,DefNew,Tenured) and
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    85
//     ParallelScavengeHeap(ParallelGC, ParallelOldGC)
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    86
//     need the card-mark if and only if the region is
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    87
//     in the old gen, and do not care if the card-mark
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    88
//     succeeds or precedes the initializing stores themselves,
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    89
//     so long as the card-mark is completed before the next
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    90
//     scavenge. For all these cases, we can do a card mark
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    91
//     at the point at which we do a slow path allocation
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    92
//     in the old gen, i.e. in this call.
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    93
// (b) GenCollectedHeap(ConcurrentMarkSweepGeneration) requires
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    94
//     in addition that the card-mark for an old gen allocated
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    95
//     object strictly follow any associated initializing stores.
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    96
//     In these cases, the memRegion remembered below is
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    97
//     used to card-mark the entire region either just before the next
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    98
//     slow-path allocation by this thread or just before the next scavenge or
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
    99
//     CMS-associated safepoint, whichever of these events happens first.
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   100
//     (The implicit assumption is that the object has been fully
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   101
//     initialized by this point, a fact that we assert when doing the
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   102
//     card-mark.)
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   103
// (c) G1CollectedHeap(G1) uses two kinds of write barriers. When a
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   104
//     G1 concurrent marking is in progress an SATB (pre-write-)barrier
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   105
//     is used to remember the pre-value of any store. Initializing
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   106
//     stores will not need this barrier, so we need not worry about
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   107
//     compensating for the missing pre-barrier here. Turning now
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   108
//     to the post-barrier, we note that G1 needs a RS update barrier
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   109
//     which simply enqueues a (sequence of) dirty cards which may
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   110
//     optionally be refined by the concurrent update threads. Note
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   111
//     that this barrier need only be applied to a non-young write,
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   112
//     but, like in CMS, because of the presence of concurrent refinement
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   113
//     (much like CMS' precleaning), must strictly follow the oop-store.
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   114
//     Thus, using the same protocol for maintaining the intended
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   115
//     invariants turns out, serendepitously, to be the same for both
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   116
//     G1 and CMS.
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   117
//
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   118
// For any future collector, this code should be reexamined with
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   119
// that specific collector in mind, and the documentation above suitably
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   120
// extended and updated.
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49390
diff changeset
   121
void CardTableBarrierSet::on_slowpath_allocation_exit(JavaThread* thread, oop new_obj) {
49390
95f0b54a3024 8199220: Zero build broken after 8195103, 8191102 and 8189871
enevill
parents: 49164
diff changeset
   122
#if defined(COMPILER2) || INCLUDE_JVMCI
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   123
  if (!ReduceInitialCardMarks) {
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   124
    return;
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   125
  }
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   126
  // If a previous card-mark was deferred, flush it now.
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   127
  flush_deferred_card_mark_barrier(thread);
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   128
  if (new_obj->is_typeArray() || _card_table->is_in_young(new_obj)) {
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   129
    // Arrays of non-references don't need a post-barrier.
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   130
    // The deferred_card_mark region should be empty
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   131
    // following the flush above.
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   132
    assert(thread->deferred_card_mark().is_empty(), "Error");
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   133
  } else {
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   134
    MemRegion mr((HeapWord*)new_obj, new_obj->size());
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   135
    assert(!mr.is_empty(), "Error");
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   136
    if (_defer_initial_card_mark) {
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   137
      // Defer the card mark
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   138
      thread->set_deferred_card_mark(mr);
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   139
    } else {
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   140
      // Do the card mark
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   141
      invalidate(mr);
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   142
    }
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   143
  }
49390
95f0b54a3024 8199220: Zero build broken after 8195103, 8191102 and 8189871
enevill
parents: 49164
diff changeset
   144
#endif // COMPILER2 || JVMCI
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   145
}
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   146
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49390
diff changeset
   147
void CardTableBarrierSet::initialize_deferred_card_mark_barriers() {
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   148
  // Used for ReduceInitialCardMarks (when COMPILER2 or JVMCI is used);
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   149
  // otherwise remains unused.
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   150
#if defined(COMPILER2) || INCLUDE_JVMCI
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   151
  _defer_initial_card_mark = is_server_compilation_mode_vm() && ReduceInitialCardMarks && can_elide_tlab_store_barriers()
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   152
                             && (DeferInitialCardMark || card_mark_must_follow_store());
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   153
#else
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   154
  assert(_defer_initial_card_mark == false, "Who would set it?");
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   155
#endif
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   156
}
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   157
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49390
diff changeset
   158
void CardTableBarrierSet::flush_deferred_card_mark_barrier(JavaThread* thread) {
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   159
#if defined(COMPILER2) || INCLUDE_JVMCI
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   160
  MemRegion deferred = thread->deferred_card_mark();
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   161
  if (!deferred.is_empty()) {
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   162
    assert(_defer_initial_card_mark, "Otherwise should be empty");
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   163
    {
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   164
      // Verify that the storage points to a parsable object in heap
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   165
      DEBUG_ONLY(oop old_obj = oop(deferred.start());)
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   166
      assert(!_card_table->is_in_young(old_obj),
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   167
             "Else should have been filtered in on_slowpath_allocation_exit()");
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   168
      assert(oopDesc::is_oop(old_obj, true), "Not an oop");
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   169
      assert(deferred.word_size() == (size_t)(old_obj->size()),
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   170
             "Mismatch: multiple objects?");
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   171
    }
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   172
    write_region(deferred);
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   173
    // "Clear" the deferred_card_mark field
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   174
    thread->set_deferred_card_mark(MemRegion());
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   175
  }
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   176
  assert(thread->deferred_card_mark().is_empty(), "invariant");
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   177
#else
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   178
  assert(!_defer_initial_card_mark, "Should be false");
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   179
  assert(thread->deferred_card_mark().is_empty(), "Should be empty");
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   180
#endif
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   181
}
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   182
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49390
diff changeset
   183
void CardTableBarrierSet::on_thread_detach(JavaThread* thread) {
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   184
  // The deferred store barriers must all have been flushed to the
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   185
  // card-table (or other remembered set structure) before GC starts
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   186
  // processing the card-table (or other remembered set).
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   187
  flush_deferred_card_mark_barrier(thread);
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
   188
}
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   189
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49390
diff changeset
   190
bool CardTableBarrierSet::card_mark_must_follow_store() const {
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   191
 return _card_table->scanned_concurrently();
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   192
}