src/hotspot/share/gc/parallel/psCardTable.cpp
author eosterlund
Mon, 26 Feb 2018 09:34:12 +0100
changeset 49164 7e958a8ebcd3
parent 48961 src/hotspot/share/gc/parallel/cardTableExtension.cpp@120b61d50f85
child 49194 ece10494786c
child 49455 848864ed9b17
permissions -rw-r--r--
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy Reviewed-by: stefank, coleenp, kvn, ehelin
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: 47216
diff changeset
     2
 * Copyright (c) 2001, 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: 2131
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2131
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: 2131
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: 6248
diff changeset
    25
#include "precompiled.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    26
#include "gc/parallel/gcTaskManager.hpp"
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents: 35061
diff changeset
    27
#include "gc/parallel/objectStartArray.inline.hpp"
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47216
diff changeset
    28
#include "gc/parallel/parallelScavengeHeap.inline.hpp"
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
    29
#include "gc/parallel/psCardTable.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    30
#include "gc/parallel/psPromotionManager.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    31
#include "gc/parallel/psScavenge.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    32
#include "gc/parallel/psTasks.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30173
diff changeset
    33
#include "gc/parallel/psYoungGen.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6248
diff changeset
    34
#include "oops/oop.inline.hpp"
24487
71ff0bd674eb 8042737: Introduce umbrella header prefetch.inline.hpp
goetz
parents: 24424
diff changeset
    35
#include "runtime/prefetch.inline.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46619
diff changeset
    36
#include "utilities/align.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// Checks an individual oop for missing precise marks. Mark
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// may be either dirty or newgen.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
class CheckForUnmarkedOops : public OopClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    41
 private:
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
    42
  PSYoungGen*  _young_gen;
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
    43
  PSCardTable* _card_table;
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
    44
  HeapWord*    _unmarked_addr;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    46
 protected:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    47
  template <class T> void do_oop_work(T* p) {
12380
48f69987dbca 7160613: VerifyRememberedSets doesn't work with CompressedOops
stefank
parents: 11174
diff changeset
    48
    oop obj = oopDesc::load_decode_heap_oop(p);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    49
    if (_young_gen->is_in_reserved(obj) &&
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
        !_card_table->addr_is_marked_imprecise(p)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
      // Don't overwrite the first missing card mark
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
      if (_unmarked_addr == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
        _unmarked_addr = (HeapWord*)p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    58
 public:
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
    59
  CheckForUnmarkedOops(PSYoungGen* young_gen, PSCardTable* card_table) :
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    60
    _young_gen(young_gen), _card_table(card_table), _unmarked_addr(NULL) { }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    61
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    62
  virtual void do_oop(oop* p)       { CheckForUnmarkedOops::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    63
  virtual void do_oop(narrowOop* p) { CheckForUnmarkedOops::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  bool has_unmarked_oop() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    return _unmarked_addr != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18069
diff changeset
    70
// Checks all objects for the existence of some type of mark,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
// precise or imprecise, dirty or newgen.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
class CheckForUnmarkedObjects : public ObjectClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    73
 private:
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
    74
  PSYoungGen*  _young_gen;
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
    75
  PSCardTable* _card_table;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  CheckForUnmarkedObjects() {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29792
diff changeset
    79
    ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    _young_gen = heap->young_gen();
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
    81
    _card_table = heap->card_table();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  // Card marks are not precise. The current system can leave us with
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18069
diff changeset
    85
  // a mismatch of precise marks and beginning of object marks. This means
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  // we test for missing precise marks first. If any are found, we don't
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  // fail unless the object head is also unmarked.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  virtual void do_object(oop obj) {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    89
    CheckForUnmarkedOops object_check(_young_gen, _card_table);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12380
diff changeset
    90
    obj->oop_iterate_no_header(&object_check);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    if (object_check.has_unmarked_oop()) {
32618
bbbe25551000 8130823: VerifyRememberedSets is an expensive nop in product builds
jwilhelm
parents: 31964
diff changeset
    92
      guarantee(_card_table->addr_is_marked_imprecise(obj), "Found unmarked young_gen object");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
// Checks for precise marking of oops as newgen.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
class CheckForPreciseMarks : public OopClosure {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    99
 private:
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   100
  PSYoungGen*  _young_gen;
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   101
  PSCardTable* _card_table;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   103
 protected:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   104
  template <class T> void do_oop_work(T* p) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   105
    oop obj = oopDesc::load_decode_heap_oop_not_null(p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   106
    if (_young_gen->is_in_reserved(obj)) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   107
      assert(_card_table->addr_is_marked_precise(p), "Found unmarked precise oop");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   108
      _card_table->set_card_newgen(p);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   109
    }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   110
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   111
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
 public:
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   113
  CheckForPreciseMarks(PSYoungGen* young_gen, PSCardTable* card_table) :
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    _young_gen(young_gen), _card_table(card_table) { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   116
  virtual void do_oop(oop* p)       { CheckForPreciseMarks::do_oop_work(p); }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   117
  virtual void do_oop(narrowOop* p) { CheckForPreciseMarks::do_oop_work(p); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
// We get passed the space_top value to prevent us from traversing into
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
// the old_gen promotion labs, which cannot be safely parsed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
13924
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   123
// Do not call this method if the space is empty.
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   124
// It is a waste to start tasks and get here only to
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   125
// do no work.  If this method needs to be called
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   126
// when the space is empty, fix the calculation of
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   127
// end_card to allow sp_top == sp->bottom().
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   129
void PSCardTable::scavenge_contents_parallel(ObjectStartArray* start_array,
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   130
                                             MutableSpace* sp,
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   131
                                             HeapWord* space_top,
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   132
                                             PSPromotionManager* pm,
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   133
                                             uint stripe_number,
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   134
                                             uint stripe_total) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  int ssize = 128; // Naked constant!  Work unit = 64k.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  int dirty_card_count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
13924
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   138
  // It is a waste to get here if empty.
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   139
  assert(sp->bottom() < sp->top(), "Should not be called if empty");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  oop* sp_top = (oop*)space_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  jbyte* start_card = byte_for(sp->bottom());
13924
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   142
  jbyte* end_card   = byte_for(sp_top - 1) + 1;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  oop* last_scanned = NULL; // Prevent scanning objects more than once
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   144
  // The width of the stripe ssize*stripe_total must be
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   145
  // consistent with the number of stripes so that the complete slice
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   146
  // is covered.
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   147
  size_t slice_width = ssize * stripe_total;
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 7397
diff changeset
   148
  for (jbyte* slice = start_card; slice < end_card; slice += slice_width) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    jbyte* worker_start_card = slice + stripe_number * ssize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    if (worker_start_card >= end_card)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
      return; // We're done.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    jbyte* worker_end_card = worker_start_card + ssize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    if (worker_end_card > end_card)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
      worker_end_card = end_card;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    // We do not want to scan objects more than once. In order to accomplish
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    // this, we assert that any object with an object head inside our 'slice'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    // belongs to us. We may need to extend the range of scanned cards if the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
    // last object continues into the next 'slice'.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
    // Note! ending cards are exclusive!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    HeapWord* slice_start = addr_for(worker_start_card);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    HeapWord* slice_end = MIN2((HeapWord*) sp_top, addr_for(worker_end_card));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
13924
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   166
#ifdef ASSERT
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   167
    if (GCWorkerDelayMillis > 0) {
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   168
      // Delay 1 worker so that it proceeds after all the work
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   169
      // has been completed.
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   170
      if (stripe_number < 2) {
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   171
        os::sleep(Thread::current(), GCWorkerDelayMillis, false);
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   172
      }
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   173
    }
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   174
#endif
159131321ed4 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 13728
diff changeset
   175
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    // If there are not objects starting within the chunk, skip it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    if (!start_array->object_starts_in_range(slice_start, slice_end)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
      continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
    }
2131
98f9cef66a34 6810672: Comment typos
twisti
parents: 977
diff changeset
   180
    // Update our beginning addr
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    HeapWord* first_object = start_array->object_start(slice_start);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    debug_only(oop* first_object_within_slice = (oop*) first_object;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    if (first_object < slice_start) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
      last_scanned = (oop*)(first_object + oop(first_object)->size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
      debug_only(first_object_within_slice = last_scanned;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
      worker_start_card = byte_for(last_scanned);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
    // Update the ending addr
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    if (slice_end < (HeapWord*)sp_top) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
      // The subtraction is important! An object may start precisely at slice_end.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
      HeapWord* last_object = start_array->object_start(slice_end - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
      slice_end = last_object + oop(last_object)->size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
      // worker_end_card is exclusive, so bump it one past the end of last_object's
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
      // covered span.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
      worker_end_card = byte_for(slice_end) + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
      if (worker_end_card > end_card)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
        worker_end_card = end_card;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
    assert(slice_end <= (HeapWord*)sp_top, "Last object in slice crosses space boundary");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
    assert(is_valid_card_address(worker_start_card), "Invalid worker start card");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    assert(is_valid_card_address(worker_end_card), "Invalid worker end card");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
    // Note that worker_start_card >= worker_end_card is legal, and happens when
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    // an object spans an entire slice.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    assert(worker_start_card <= end_card, "worker start card beyond end card");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
    assert(worker_end_card <= end_card, "worker end card beyond end card");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
    jbyte* current_card = worker_start_card;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    while (current_card < worker_end_card) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
      // Find an unclean card.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
      while (current_card < worker_end_card && card_is_clean(*current_card)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
        current_card++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
      jbyte* first_unclean_card = current_card;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
      // Find the end of a run of contiguous unclean cards
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
      while (current_card < worker_end_card && !card_is_clean(*current_card)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
        while (current_card < worker_end_card && !card_is_clean(*current_card)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
          current_card++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
        if (current_card < worker_end_card) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
          // Some objects may be large enough to span several cards. If such
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
          // an object has more than one dirty card, separated by a clean card,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
          // we will attempt to scan it twice. The test against "last_scanned"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
          // prevents the redundant object scan, but it does not prevent newly
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
          // marked cards from being cleaned.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
          HeapWord* last_object_in_dirty_region = start_array->object_start(addr_for(current_card)-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
          size_t size_of_last_object = oop(last_object_in_dirty_region)->size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
          HeapWord* end_of_last_object = last_object_in_dirty_region + size_of_last_object;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
          jbyte* ending_card_of_last_object = byte_for(end_of_last_object);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
          assert(ending_card_of_last_object <= worker_end_card, "ending_card_of_last_object is greater than worker_end_card");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
          if (ending_card_of_last_object > current_card) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
            // This means the object spans the next complete card.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
            // We need to bump the current_card to ending_card_of_last_object
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
            current_card = ending_card_of_last_object;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
      jbyte* following_clean_card = current_card;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
      if (first_unclean_card < worker_end_card) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
        oop* p = (oop*) start_array->object_start(addr_for(first_unclean_card));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
        assert((HeapWord*)p <= addr_for(first_unclean_card), "checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
        // "p" should always be >= "last_scanned" because newly GC dirtied
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
        // cards are no longer scanned again (see comment at end
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
        // of loop on the increment of "current_card").  Test that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
        // hypothesis before removing this code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
        // If this code is removed, deal with the first time through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
        // the loop when the last_scanned is the object starting in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
        // the previous slice.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
        assert((p >= last_scanned) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
               (last_scanned == first_object_within_slice),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
               "Should no longer be possible");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
        if (p < last_scanned) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
          // Avoid scanning more than once; this can happen because
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
          // newgen cards set by GC may a different set than the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
          // originally dirty set
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
          p = last_scanned;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
        oop* to = (oop*)addr_for(following_clean_card);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
        // Test slice_end first!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
        if ((HeapWord*)to > slice_end) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
          to = (oop*)slice_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
        } else if (to > sp_top) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
          to = sp_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
        // we know which cards to scan, now clear them
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
        if (first_unclean_card <= worker_start_card+1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
          first_unclean_card = worker_start_card+1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
        if (following_clean_card >= worker_end_card-1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
          following_clean_card = worker_end_card-1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
        while (first_unclean_card < following_clean_card) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
          *first_unclean_card++ = clean_card;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
        const int interval = PrefetchScanIntervalInBytes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
        // scan all objects in the range
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
        if (interval != 0) {
6248
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 5892
diff changeset
   285
          while (p < to) {
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 5892
diff changeset
   286
            Prefetch::write(p, interval);
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 5892
diff changeset
   287
            oop m = oop(p);
46968
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46625
diff changeset
   288
            assert(oopDesc::is_oop_or_null(m), "Expected an oop or NULL for header field at " PTR_FORMAT, p2i(m));
29792
8c6fa07f0869 8075957: Reduce calls to the GC specific object visitors in oopDesc
stefank
parents: 29325
diff changeset
   289
            pm->push_contents(m);
6248
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 5892
diff changeset
   290
            p += m->size();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
          }
6248
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 5892
diff changeset
   292
          pm->drain_stacks_cond_depth();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
        } else {
6248
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 5892
diff changeset
   294
          while (p < to) {
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 5892
diff changeset
   295
            oop m = oop(p);
46968
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46625
diff changeset
   296
            assert(oopDesc::is_oop_or_null(m), "Expected an oop or NULL for header field at " PTR_FORMAT, p2i(m));
29792
8c6fa07f0869 8075957: Reduce calls to the GC specific object visitors in oopDesc
stefank
parents: 29325
diff changeset
   297
            pm->push_contents(m);
6248
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 5892
diff changeset
   298
            p += m->size();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
          }
6248
2e661807cef0 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 5892
diff changeset
   300
          pm->drain_stacks_cond_depth();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
        last_scanned = p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
      // "current_card" is still the "following_clean_card" or
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
      // the current_card is >= the worker_end_card so the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
      // loop will not execute again.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
      assert((current_card == following_clean_card) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
             (current_card >= worker_end_card),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
        "current_card should only be incremented if it still equals "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
        "following_clean_card");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
      // Increment current_card so that it is not processed again.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
      // It may now be dirty because a old-to-young pointer was
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
      // found on it an updated.  If it is now dirty, it cannot be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
      // be safely cleaned in the next iteration.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
      current_card++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
// This should be called before a scavenge.
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   321
void PSCardTable::verify_all_young_refs_imprecise() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  CheckForUnmarkedObjects check;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29792
diff changeset
   324
  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  PSOldGen* old_gen = heap->old_gen();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  old_gen->object_iterate(&check);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
// This should be called immediately after a scavenge, before mutators resume.
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   331
void PSCardTable::verify_all_young_refs_precise() {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29792
diff changeset
   332
  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  PSOldGen* old_gen = heap->old_gen();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   335
  CheckForPreciseMarks check(heap->young_gen(), this);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12380
diff changeset
   337
  old_gen->oop_iterate_no_header(&check);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  verify_all_young_refs_precise_helper(old_gen->object_space()->used_region());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   342
void PSCardTable::verify_all_young_refs_precise_helper(MemRegion mr) {
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   343
  jbyte* bot = byte_for(mr.start());
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   344
  jbyte* top = byte_for(mr.end());
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   345
  while (bot <= top) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
    assert(*bot == clean_card || *bot == verify_card, "Found unwanted or unknown card mark");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
    if (*bot == verify_card)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
      *bot = youngergen_card;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
    bot++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   353
bool PSCardTable::addr_is_marked_imprecise(void *addr) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  jbyte* p = byte_for(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  jbyte val = *p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  if (card_is_dirty(val))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  if (card_is_newgen(val))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  if (card_is_clean(val))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  assert(false, "Found unhandled card mark type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
// Also includes verify_card
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   372
bool PSCardTable::addr_is_marked_precise(void *addr) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  jbyte* p = byte_for(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  jbyte val = *p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  if (card_is_newgen(val))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  if (card_is_verify(val))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  if (card_is_clean(val))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  if (card_is_dirty(val))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  assert(false, "Found unhandled card mark type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
// Assumes that only the base or the end changes.  This allows indentification
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
// of the region that is being resized.  The
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
// CardTableModRefBS::resize_covered_region() is used for the normal case
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
// where the covered regions are growing or shrinking at the high end.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
// The method resize_covered_region_by_end() is analogous to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
// CardTableModRefBS::resize_covered_region() but
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
// for regions that grow or shrink at the low end.
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   400
void PSCardTable::resize_covered_region(MemRegion new_region) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  for (int i = 0; i < _cur_covered_regions; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
    if (_covered[i].start() == new_region.start()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
      // Found a covered region with the same start as the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
      // new region.  The region is growing or shrinking
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
      // from the start of the region.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
      resize_covered_region_by_start(new_region);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
    if (_covered[i].start() > new_region.start()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  int changed_region = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  for (int j = 0; j < _cur_covered_regions; j++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
    if (_covered[j].end() == new_region.end()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
      changed_region = j;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
      // This is a case where the covered region is growing or shrinking
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
      // at the start of the region.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
      assert(changed_region != -1, "Don't expect to add a covered region");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
      assert(_covered[changed_region].byte_size() != new_region.byte_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
        "The sizes should be different here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
      resize_covered_region_by_end(changed_region, new_region);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  // This should only be a new covered region (where no existing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  // covered region matches at the start or the end).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  assert(_cur_covered_regions < _max_covered_regions,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
    "An existing region should have been found");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  resize_covered_region_by_start(new_region);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   434
void PSCardTable::resize_covered_region_by_start(MemRegion new_region) {
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   435
  CardTable::resize_covered_region(new_region);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  debug_only(verify_guard();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   439
void PSCardTable::resize_covered_region_by_end(int changed_region,
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   440
                                               MemRegion new_region) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  assert(SafepointSynchronize::is_at_safepoint(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
    "Only expect an expansion at the low end at a GC");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  debug_only(verify_guard();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  for (int k = 0; k < _cur_covered_regions; k++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
    if (_covered[k].end() == new_region.end()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
      assert(changed_region == k, "Changed region is incorrect");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  // Commit new or uncommit old pages, if necessary.
5892
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   454
  if (resize_commit_uncommit(changed_region, new_region)) {
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   455
    // Set the new start of the committed region
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   456
    resize_update_committed_table(changed_region, new_region);
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   457
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  // Update card table entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  resize_update_card_table_entries(changed_region, new_region);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  // Update the covered region
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  resize_update_covered_table(changed_region, new_region);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33105
diff changeset
   465
  int ind = changed_region;
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33105
diff changeset
   466
  log_trace(gc, barrier)("CardTableModRefBS::resize_covered_region: ");
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33105
diff changeset
   467
  log_trace(gc, barrier)("    _covered[%d].start(): " INTPTR_FORMAT "  _covered[%d].last(): " INTPTR_FORMAT,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33105
diff changeset
   468
                ind, p2i(_covered[ind].start()), ind, p2i(_covered[ind].last()));
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33105
diff changeset
   469
  log_trace(gc, barrier)("    _committed[%d].start(): " INTPTR_FORMAT "  _committed[%d].last(): " INTPTR_FORMAT,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33105
diff changeset
   470
                ind, p2i(_committed[ind].start()), ind, p2i(_committed[ind].last()));
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33105
diff changeset
   471
  log_trace(gc, barrier)("    byte_for(start): " INTPTR_FORMAT "  byte_for(last): " INTPTR_FORMAT,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33105
diff changeset
   472
                p2i(byte_for(_covered[ind].start())),  p2i(byte_for(_covered[ind].last())));
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33105
diff changeset
   473
  log_trace(gc, barrier)("    addr_for(start): " INTPTR_FORMAT "  addr_for(last): " INTPTR_FORMAT,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33105
diff changeset
   474
                p2i(addr_for((jbyte*) _committed[ind].start())), p2i(addr_for((jbyte*) _committed[ind].last())));
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33105
diff changeset
   475
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  debug_only(verify_guard();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   479
bool PSCardTable::resize_commit_uncommit(int changed_region,
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   480
                                         MemRegion new_region) {
5892
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   481
  bool result = false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  // Commit new or uncommit old pages, if necessary.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  MemRegion cur_committed = _committed[changed_region];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  assert(_covered[changed_region].end() == new_region.end(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
    "The ends of the regions are expected to match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
  // Extend the start of this _committed region to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  // to cover the start of any previous _committed region.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  // This forms overlapping regions, but never interior regions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  HeapWord* min_prev_start = lowest_prev_committed_start(changed_region);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  if (min_prev_start < cur_committed.start()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
    // Only really need to set start of "cur_committed" to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
    // the new start (min_prev_start) but assertion checking code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
    // below use cur_committed.end() so make it correct.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
    MemRegion new_committed =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
        MemRegion(min_prev_start, cur_committed.end());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
    cur_committed = new_committed;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
#ifdef ASSERT
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 29792
diff changeset
   499
  ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 46618
diff changeset
   500
  assert(cur_committed.start() == align_up(cur_committed.start(), os::vm_page_size()),
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   501
         "Starts should have proper alignment");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
  jbyte* new_start = byte_for(new_region.start());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
  // Round down because this is for the start address
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   506
  HeapWord* new_start_aligned = align_down((HeapWord*)new_start, os::vm_page_size());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
  // The guard page is always committed and should not be committed over.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  // This method is used in cases where the generation is growing toward
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  // lower addresses but the guard region is still at the end of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
  // card table.  That still makes sense when looking for writes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
  // off the end of the card table.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
  if (new_start_aligned < cur_committed.start()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
    // Expand the committed region
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
    // Case A
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
    //                                          |+ guard +|
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
    //                          |+ cur committed +++++++++|
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
    //                  |+ new committed +++++++++++++++++|
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
    // Case B
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
    //                                          |+ guard +|
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
    //                        |+ cur committed +|
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
    //                  |+ new committed +++++++|
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
    // These are not expected because the calculation of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
    // cur committed region and the new committed region
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
    // share the same end for the covered region.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
    // Case C
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
    //                                          |+ guard +|
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
    //                        |+ cur committed +|
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
    //                  |+ new committed +++++++++++++++++|
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
    // Case D
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
    //                                          |+ guard +|
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
    //                        |+ cur committed +++++++++++|
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
    //                  |+ new committed +++++++|
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
    HeapWord* new_end_for_commit =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
      MIN2(cur_committed.end(), _guard_region.start());
971
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 360
diff changeset
   539
    if(new_start_aligned < new_end_for_commit) {
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 360
diff changeset
   540
      MemRegion new_committed =
f0b20be4165d 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 360
diff changeset
   541
        MemRegion(new_start_aligned, new_end_for_commit);
18069
e6d4971c8650 8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents: 17087
diff changeset
   542
      os::commit_memory_or_exit((char*)new_committed.start(),
e6d4971c8650 8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents: 17087
diff changeset
   543
                                new_committed.byte_size(), !ExecMem,
e6d4971c8650 8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents: 17087
diff changeset
   544
                                "card table expansion");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
    }
5892
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   546
    result = true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
  } else if (new_start_aligned > cur_committed.start()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
    // Shrink the committed region
5892
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   549
#if 0 // uncommitting space is currently unsafe because of the interactions
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   550
      // of growing and shrinking regions.  One region A can uncommit space
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   551
      // that it owns but which is being used by another region B (maybe).
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   552
      // Region B has not committed the space because it was already
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   553
      // committed by region A.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
    MemRegion uncommit_region = committed_unique_to_self(changed_region,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
      MemRegion(cur_committed.start(), new_start_aligned));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
    if (!uncommit_region.is_empty()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
      if (!os::uncommit_memory((char*)uncommit_region.start(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
                               uncommit_region.byte_size())) {
5892
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   559
        // If the uncommit fails, ignore it.  Let the
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   560
        // committed table resizing go even though the committed
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   561
        // table will over state the committed space.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
    }
5892
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   564
#else
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   565
    assert(!result, "Should be false with current workaround");
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   566
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
  assert(_committed[changed_region].end() == cur_committed.end(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
    "end should not change");
5892
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   570
  return result;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   573
void PSCardTable::resize_update_committed_table(int changed_region,
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   574
                                                MemRegion new_region) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
  jbyte* new_start = byte_for(new_region.start());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
  // Set the new start of the committed region
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   578
  HeapWord* new_start_aligned = align_down((HeapWord*)new_start, os::vm_page_size());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
  MemRegion new_committed = MemRegion(new_start_aligned,
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   580
                                      _committed[changed_region].end());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
  _committed[changed_region] = new_committed;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
  _committed[changed_region].set_start(new_start_aligned);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   585
void PSCardTable::resize_update_card_table_entries(int changed_region,
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   586
                                                   MemRegion new_region) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
  debug_only(verify_guard();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
  MemRegion original_covered = _covered[changed_region];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
  // Initialize the card entries.  Only consider the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
  // region covered by the card table (_whole_heap)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  jbyte* entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
  if (new_region.start() < _whole_heap.start()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
    entry = byte_for(_whole_heap.start());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
    entry = byte_for(new_region.start());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
  jbyte* end = byte_for(original_covered.start());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
  // If _whole_heap starts at the original covered regions start,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
  // this loop will not execute.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
  while (entry < end) { *entry++ = clean_card; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   603
void PSCardTable::resize_update_covered_table(int changed_region,
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   604
                                              MemRegion new_region) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
  // Update the covered region
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
  _covered[changed_region].set_start(new_region.start());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
  _covered[changed_region].set_word_size(new_region.word_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
  // reorder regions.  There should only be at most 1 out
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
  // of order.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
  for (int i = _cur_covered_regions-1 ; i > 0; i--) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
    if (_covered[i].start() < _covered[i-1].start()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
        MemRegion covered_mr = _covered[i-1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
        _covered[i-1] = _covered[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
        _covered[i] = covered_mr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
        MemRegion committed_mr = _committed[i-1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
      _committed[i-1] = _committed[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
      _committed[i] = committed_mr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
  for (int m = 0; m < _cur_covered_regions-1; m++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
    assert(_covered[m].start() <= _covered[m+1].start(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
      "Covered regions out of order");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
    assert(_committed[m].start() <= _committed[m+1].start(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
      "Committed regions out of order");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
// Returns the start of any committed region that is lower than
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
// the target committed region (index ind) and that intersects the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
// target region.  If none, return start of target region.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
//      -------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
//      |           |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
//      -------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
//              ------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
//              | target   |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
//              ------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
//                               -------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
//                               |           |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
//                               -------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
//      ^ returns this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
//      -------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
//      |           |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
//      -------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
//                      ------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
//                      | target   |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
//                      ------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
//                               -------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
//                               |           |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
//                               -------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
//                      ^ returns this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   658
HeapWord* PSCardTable::lowest_prev_committed_start(int ind) const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
  assert(_cur_covered_regions >= 0, "Expecting at least on region");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
  HeapWord* min_start = _committed[ind].start();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
  for (int j = 0; j < ind; j++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
    HeapWord* this_start = _committed[j].start();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
    if ((this_start < min_start) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
        !(_committed[j].intersection(_committed[ind])).is_empty()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
       min_start = this_start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
  return min_start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
}
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47216
diff changeset
   670
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48961
diff changeset
   671
bool PSCardTable::is_in_young(oop obj) const {
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47216
diff changeset
   672
  return ParallelScavengeHeap::heap()->is_in_young(obj);
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47216
diff changeset
   673
}