src/hotspot/share/gc/g1/g1ConcurrentMark.inline.hpp
author tschatzl
Fri, 09 Feb 2018 11:51:40 +0100
changeset 48889 216c2aabbf1f
parent 47678 c84eeb55c55e
child 49333 489f1dd40582
permissions -rw-r--r--
8196602: Change HeapRegionClosure to comply to naming conventions Reviewed-by: kbarrett, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9994
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
     1
/*
46328
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
     2
 * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
9994
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
     4
 *
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
     8
 *
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    13
 * accompanied this code).
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    14
 *
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    18
 *
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    21
 * questions.
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    22
 *
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    23
 */
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    24
35943
e726308008c0 8148973: Rename g1/concurrentMark.{hpp,cpp,inline.hpp} to g1/g1ConcurrentMark.{hpp,cpp,inline.hpp}
ehelin
parents: 35862
diff changeset
    25
#ifndef SHARE_VM_GC_G1_G1CONCURRENTMARK_INLINE_HPP
e726308008c0 8148973: Rename g1/concurrentMark.{hpp,cpp,inline.hpp} to g1/g1ConcurrentMark.{hpp,cpp,inline.hpp}
ehelin
parents: 35862
diff changeset
    26
#define SHARE_VM_GC_G1_G1CONCURRENTMARK_INLINE_HPP
9994
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30577
diff changeset
    28
#include "gc/g1/g1CollectedHeap.inline.hpp"
35943
e726308008c0 8148973: Rename g1/concurrentMark.{hpp,cpp,inline.hpp} to g1/g1ConcurrentMark.{hpp,cpp,inline.hpp}
ehelin
parents: 35862
diff changeset
    29
#include "gc/g1/g1ConcurrentMark.hpp"
46751
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents: 46750
diff changeset
    30
#include "gc/g1/g1ConcurrentMarkBitMap.inline.hpp"
42597
a9611bab7578 8057003: Large reference arrays cause extremely long synchronization times
tschatzl
parents: 41176
diff changeset
    31
#include "gc/g1/g1ConcurrentMarkObjArrayProcessor.inline.hpp"
47647
64dba69fc528 8189276: Make SuspendibleThreadSet and related code available to other GCs
rkennke
parents: 47216
diff changeset
    32
#include "gc/shared/suspendibleThreadSet.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30577
diff changeset
    33
#include "gc/shared/taskqueue.inline.hpp"
46502
116a09d8f142 8180755: Remove use of bitMap.inline.hpp include from instanceKlass.hpp and c1_ValueSet.hpp
tschatzl
parents: 46328
diff changeset
    34
#include "utilities/bitMap.inline.hpp"
9994
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    35
46752
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
    36
inline bool G1ConcurrentMark::mark_in_next_bitmap(oop const obj) {
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
    37
  HeapRegion* const hr = _g1h->heap_region_containing(obj);
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
    38
  return mark_in_next_bitmap(hr, obj);
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
    39
}
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
    40
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
    41
inline bool G1ConcurrentMark::mark_in_next_bitmap(HeapRegion* const hr, oop const obj) {
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
    42
  assert(hr != NULL, "just checking");
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
    43
  assert(hr->is_in_reserved(obj), "Attempting to mark object at " PTR_FORMAT " that is not contained in the given region %u", p2i(obj), hr->hrm_index());
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
    44
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
    45
  if (hr->obj_allocated_since_next_marking(obj)) {
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
    46
    return false;
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
    47
  }
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
    48
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
    49
  // Some callers may have stale objects to mark above nTAMS after humongous reclaim.
46800
498d81a49f6b 8186035: Klass::decode_klass_not_null() asserted on bad oop
stefank
parents: 46752
diff changeset
    50
  // Can't assert that this is a valid object at this point, since it might be in the process of being copied by another thread.
46752
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
    51
  assert(!hr->is_continues_humongous(), "Should not try to mark object " PTR_FORMAT " in Humongous continues region %u above nTAMS " PTR_FORMAT, p2i(obj), hr->hrm_index(), p2i(hr->next_top_at_mark_start()));
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
    52
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
    53
  HeapWord* const obj_addr = (HeapWord*)obj;
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
    54
47678
c84eeb55c55e 8184667: Clean up G1ConcurrentMark files
tschatzl
parents: 47647
diff changeset
    55
  return _next_mark_bitmap->par_mark(obj_addr);
11584
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11583
diff changeset
    56
}
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11583
diff changeset
    57
41176
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 39966
diff changeset
    58
#ifndef PRODUCT
31994
3721b7aa3a0d 8079082: VerifyNoCSetOopsClosure is derived twice from Closure
kbarrett
parents: 31592
diff changeset
    59
template<typename Fn>
41176
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 39966
diff changeset
    60
inline void G1CMMarkStack::iterate(Fn fn) const {
39966
43c7f35b800e 8160897: Concurrent mark mark stack memory allocation leaks memory
tschatzl
parents: 37414
diff changeset
    61
  assert_at_safepoint(true);
41176
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 39966
diff changeset
    62
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 39966
diff changeset
    63
  size_t num_chunks = 0;
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 39966
diff changeset
    64
46328
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
    65
  TaskQueueEntryChunk* cur = _chunk_list;
41176
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 39966
diff changeset
    66
  while (cur != NULL) {
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 39966
diff changeset
    67
    guarantee(num_chunks <= _chunks_in_chunk_list, "Found " SIZE_FORMAT " oop chunks which is more than there should be", num_chunks);
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 39966
diff changeset
    68
46328
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
    69
    for (size_t i = 0; i < EntriesPerChunk; ++i) {
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
    70
      if (cur->data[i].is_null()) {
41176
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 39966
diff changeset
    71
        break;
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 39966
diff changeset
    72
      }
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 39966
diff changeset
    73
      fn(cur->data[i]);
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 39966
diff changeset
    74
    }
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 39966
diff changeset
    75
    cur = cur->next;
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 39966
diff changeset
    76
    num_chunks++;
31994
3721b7aa3a0d 8079082: VerifyNoCSetOopsClosure is derived twice from Closure
kbarrett
parents: 31592
diff changeset
    77
  }
3721b7aa3a0d 8079082: VerifyNoCSetOopsClosure is derived twice from Closure
kbarrett
parents: 31592
diff changeset
    78
}
41176
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 39966
diff changeset
    79
#endif
31994
3721b7aa3a0d 8079082: VerifyNoCSetOopsClosure is derived twice from Closure
kbarrett
parents: 31592
diff changeset
    80
32350
fec57eb3f599 8133121: Move implementation of process_grey_object to concurrentMark.inline.hpp
asiebenborn
parents: 31994
diff changeset
    81
// It scans an object and visits its children.
46328
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
    82
inline void G1CMTask::scan_task_entry(G1TaskQueueEntry task_entry) { process_grey_task_entry<true>(task_entry); }
32350
fec57eb3f599 8133121: Move implementation of process_grey_object to concurrentMark.inline.hpp
asiebenborn
parents: 31994
diff changeset
    83
46328
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
    84
inline void G1CMTask::push(G1TaskQueueEntry task_entry) {
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
    85
  assert(task_entry.is_array_slice() || _g1h->is_in_g1_reserved(task_entry.obj()), "invariant");
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
    86
  assert(task_entry.is_array_slice() || !_g1h->is_on_master_free_list(
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
    87
              _g1h->heap_region_containing(task_entry.obj())), "invariant");
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
    88
  assert(task_entry.is_array_slice() || !_g1h->is_obj_ill(task_entry.obj()), "invariant");  // FIXME!!!
47678
c84eeb55c55e 8184667: Clean up G1ConcurrentMark files
tschatzl
parents: 47647
diff changeset
    89
  assert(task_entry.is_array_slice() || _next_mark_bitmap->is_marked((HeapWord*)task_entry.obj()), "invariant");
9994
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    90
46328
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
    91
  if (!_task_queue->push(task_entry)) {
9994
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    92
    // The local task queue looks full. We need to push some entries
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    93
    // to the global stack.
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    94
    move_entries_to_global_stack();
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    95
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    96
    // this should succeed since, even if we overflow the global
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    97
    // stack, we should have definitely removed some entries from the
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
    98
    // local queue. So, there must be space on it.
46328
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
    99
    bool success = _task_queue->push(task_entry);
9994
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
   100
    assert(success, "invariant");
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
   101
  }
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
   102
}
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
   103
35943
e726308008c0 8148973: Rename g1/concurrentMark.{hpp,cpp,inline.hpp} to g1/g1ConcurrentMark.{hpp,cpp,inline.hpp}
ehelin
parents: 35862
diff changeset
   104
inline bool G1CMTask::is_below_finger(oop obj, HeapWord* global_finger) const {
30577
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30566
diff changeset
   105
  // If obj is above the global finger, then the mark bitmap scan
30162
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   106
  // will find it later, and no push is needed.  Similarly, if we have
30577
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30566
diff changeset
   107
  // a current region and obj is between the local finger and the
30162
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   108
  // end of the current region, then no push is needed.  The tradeoff
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   109
  // of checking both vs only checking the global finger is that the
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   110
  // local check will be more accurate and so result in fewer pushes,
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   111
  // but may also be a little slower.
30577
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30566
diff changeset
   112
  HeapWord* objAddr = (HeapWord*)obj;
30162
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   113
  if (_finger != NULL) {
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   114
    // We have a current region.
9994
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
   115
30162
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   116
    // Finger and region values are all NULL or all non-NULL.  We
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   117
    // use _finger to check since we immediately use its value.
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   118
    assert(_curr_region != NULL, "invariant");
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   119
    assert(_region_limit != NULL, "invariant");
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   120
    assert(_region_limit <= global_finger, "invariant");
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   121
30577
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30566
diff changeset
   122
    // True if obj is less than the local finger, or is between
30162
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   123
    // the region limit and the global finger.
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   124
    if (objAddr < _finger) {
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   125
      return true;
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   126
    } else if (objAddr < _region_limit) {
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   127
      return false;
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   128
    } // Else check global finger.
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   129
  }
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   130
  // Check global finger.
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   131
  return objAddr < global_finger;
ba9738750a74 8076265: Simplify deal_with_reference
kbarrett
parents: 29472
diff changeset
   132
}
9994
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
   133
32350
fec57eb3f599 8133121: Move implementation of process_grey_object to concurrentMark.inline.hpp
asiebenborn
parents: 31994
diff changeset
   134
template<bool scan>
46328
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
   135
inline void G1CMTask::process_grey_task_entry(G1TaskQueueEntry task_entry) {
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
   136
  assert(scan || (task_entry.is_oop() && task_entry.obj()->is_typeArray()), "Skipping scan of grey non-typeArray");
47678
c84eeb55c55e 8184667: Clean up G1ConcurrentMark files
tschatzl
parents: 47647
diff changeset
   137
  assert(task_entry.is_array_slice() || _next_mark_bitmap->is_marked((HeapWord*)task_entry.obj()),
42597
a9611bab7578 8057003: Large reference arrays cause extremely long synchronization times
tschatzl
parents: 41176
diff changeset
   138
         "Any stolen object should be a slice or marked");
32350
fec57eb3f599 8133121: Move implementation of process_grey_object to concurrentMark.inline.hpp
asiebenborn
parents: 31994
diff changeset
   139
fec57eb3f599 8133121: Move implementation of process_grey_object to concurrentMark.inline.hpp
asiebenborn
parents: 31994
diff changeset
   140
  if (scan) {
46328
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
   141
    if (task_entry.is_array_slice()) {
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
   142
      _words_scanned += _objArray_processor.process_slice(task_entry.slice());
42597
a9611bab7578 8057003: Large reference arrays cause extremely long synchronization times
tschatzl
parents: 41176
diff changeset
   143
    } else {
46328
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
   144
      oop obj = task_entry.obj();
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
   145
      if (G1CMObjArrayProcessor::should_be_sliced(obj)) {
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
   146
        _words_scanned += _objArray_processor.process_obj(obj);
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
   147
      } else {
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
   148
        _words_scanned += obj->oop_iterate_size(_cm_oop_closure);;
6061df52d610 8168467: Use TaskEntry as task mark queue elements
tschatzl
parents: 42597
diff changeset
   149
      }
42597
a9611bab7578 8057003: Large reference arrays cause extremely long synchronization times
tschatzl
parents: 41176
diff changeset
   150
    }
32350
fec57eb3f599 8133121: Move implementation of process_grey_object to concurrentMark.inline.hpp
asiebenborn
parents: 31994
diff changeset
   151
  }
fec57eb3f599 8133121: Move implementation of process_grey_object to concurrentMark.inline.hpp
asiebenborn
parents: 31994
diff changeset
   152
  check_limits();
fec57eb3f599 8133121: Move implementation of process_grey_object to concurrentMark.inline.hpp
asiebenborn
parents: 31994
diff changeset
   153
}
fec57eb3f599 8133121: Move implementation of process_grey_object to concurrentMark.inline.hpp
asiebenborn
parents: 31994
diff changeset
   154
42597
a9611bab7578 8057003: Large reference arrays cause extremely long synchronization times
tschatzl
parents: 41176
diff changeset
   155
inline size_t G1CMTask::scan_objArray(objArrayOop obj, MemRegion mr) {
a9611bab7578 8057003: Large reference arrays cause extremely long synchronization times
tschatzl
parents: 41176
diff changeset
   156
  obj->oop_iterate(_cm_oop_closure, mr);
a9611bab7578 8057003: Large reference arrays cause extremely long synchronization times
tschatzl
parents: 41176
diff changeset
   157
  return mr.word_size();
a9611bab7578 8057003: Large reference arrays cause extremely long synchronization times
tschatzl
parents: 41176
diff changeset
   158
}
a9611bab7578 8057003: Large reference arrays cause extremely long synchronization times
tschatzl
parents: 41176
diff changeset
   159
37413
2f71679d06dd 8077144: Concurrent mark initialization takes too long
tschatzl
parents: 35943
diff changeset
   160
inline void G1CMTask::make_reference_grey(oop obj) {
46752
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   161
  if (!_cm->mark_in_next_bitmap(obj)) {
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   162
    return;
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   163
  }
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   164
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   165
  // No OrderAccess:store_load() is needed. It is implicit in the
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   166
  // CAS done in G1CMBitMap::parMark() call in the routine above.
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   167
  HeapWord* global_finger = _cm->finger();
30577
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30566
diff changeset
   168
46752
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   169
  // We only need to push a newly grey object on the mark
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   170
  // stack if it is in a section of memory the mark bitmap
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   171
  // scan has already examined.  Mark bitmap scanning
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   172
  // maintains progress "fingers" for determining that.
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   173
  //
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   174
  // Notice that the global finger might be moving forward
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   175
  // concurrently. This is not a problem. In the worst case, we
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   176
  // mark the object while it is above the global finger and, by
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   177
  // the time we read the global finger, it has moved forward
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   178
  // past this object. In this case, the object will probably
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   179
  // be visited when a task is scanning the region and will also
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   180
  // be pushed on the stack. So, some duplicate work, but no
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   181
  // correctness problems.
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   182
  if (is_below_finger(obj, global_finger)) {
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   183
    G1TaskQueueEntry entry = G1TaskQueueEntry::from_oop(obj);
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   184
    if (obj->is_typeArray()) {
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   185
      // Immediately process arrays of primitive types, rather
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   186
      // than pushing on the mark stack.  This keeps us from
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   187
      // adding humongous objects to the mark stack that might
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   188
      // be reclaimed before the entry is processed - see
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   189
      // selection of candidates for eager reclaim of humongous
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   190
      // objects.  The cost of the additional type test is
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   191
      // mitigated by avoiding a trip through the mark stack,
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   192
      // by only doing a bookkeeping update and avoiding the
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   193
      // actual scan of the object - a typeArray contains no
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   194
      // references, and the metadata is built-in.
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   195
      process_grey_task_entry<false>(entry);
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   196
    } else {
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   197
      push(entry);
30577
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30566
diff changeset
   198
    }
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30566
diff changeset
   199
  }
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30566
diff changeset
   200
}
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30566
diff changeset
   201
35943
e726308008c0 8148973: Rename g1/concurrentMark.{hpp,cpp,inline.hpp} to g1/g1ConcurrentMark.{hpp,cpp,inline.hpp}
ehelin
parents: 35862
diff changeset
   202
inline void G1CMTask::deal_with_reference(oop obj) {
30577
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30566
diff changeset
   203
  increment_refs_reached();
46752
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   204
  if (obj == NULL) {
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   205
    return;
9994
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
   206
  }
46752
a2b799e3f0be 8184348: Merge G1ConcurrentMark::par_mark() and G1ConcurrentMark::grayRoot()
tschatzl
parents: 46751
diff changeset
   207
  make_reference_grey(obj);
9994
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
   208
}
efb74fdbd46e 7046558: G1: concurrent marking optimizations
tonyp
parents:
diff changeset
   209
47678
c84eeb55c55e 8184667: Clean up G1ConcurrentMark files
tschatzl
parents: 47647
diff changeset
   210
inline void G1ConcurrentMark::mark_in_prev_bitmap(oop p) {
c84eeb55c55e 8184667: Clean up G1ConcurrentMark files
tschatzl
parents: 47647
diff changeset
   211
  assert(!_prev_mark_bitmap->is_marked((HeapWord*) p), "sanity");
c84eeb55c55e 8184667: Clean up G1ConcurrentMark files
tschatzl
parents: 47647
diff changeset
   212
 _prev_mark_bitmap->mark((HeapWord*) p);
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 9999
diff changeset
   213
}
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 9999
diff changeset
   214
47678
c84eeb55c55e 8184667: Clean up G1ConcurrentMark files
tschatzl
parents: 47647
diff changeset
   215
bool G1ConcurrentMark::is_marked_in_prev_bitmap(oop p) const {
46968
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46800
diff changeset
   216
  assert(p != NULL && oopDesc::is_oop(p), "expected an oop");
47678
c84eeb55c55e 8184667: Clean up G1ConcurrentMark files
tschatzl
parents: 47647
diff changeset
   217
  return _prev_mark_bitmap->is_marked((HeapWord*)p);
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents: 34282
diff changeset
   218
}
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents: 34282
diff changeset
   219
37414
2672ba9af0dc 8151386: Extract card live data out of G1ConcurrentMark
tschatzl
parents: 37413
diff changeset
   220
inline bool G1ConcurrentMark::do_yield_check() {
2672ba9af0dc 8151386: Extract card live data out of G1ConcurrentMark
tschatzl
parents: 37413
diff changeset
   221
  if (SuspendibleThreadSet::should_yield()) {
2672ba9af0dc 8151386: Extract card live data out of G1ConcurrentMark
tschatzl
parents: 37413
diff changeset
   222
    SuspendibleThreadSet::yield();
2672ba9af0dc 8151386: Extract card live data out of G1ConcurrentMark
tschatzl
parents: 37413
diff changeset
   223
    return true;
2672ba9af0dc 8151386: Extract card live data out of G1ConcurrentMark
tschatzl
parents: 37413
diff changeset
   224
  } else {
2672ba9af0dc 8151386: Extract card live data out of G1ConcurrentMark
tschatzl
parents: 37413
diff changeset
   225
    return false;
2672ba9af0dc 8151386: Extract card live data out of G1ConcurrentMark
tschatzl
parents: 37413
diff changeset
   226
  }
2672ba9af0dc 8151386: Extract card live data out of G1ConcurrentMark
tschatzl
parents: 37413
diff changeset
   227
}
2672ba9af0dc 8151386: Extract card live data out of G1ConcurrentMark
tschatzl
parents: 37413
diff changeset
   228
35943
e726308008c0 8148973: Rename g1/concurrentMark.{hpp,cpp,inline.hpp} to g1/g1ConcurrentMark.{hpp,cpp,inline.hpp}
ehelin
parents: 35862
diff changeset
   229
#endif // SHARE_VM_GC_G1_G1CONCURRENTMARK_INLINE_HPP