src/hotspot/share/gc/g1/satbMarkQueue.hpp
author tschatzl
Fri, 09 Feb 2018 11:51:40 +0100
changeset 48889 216c2aabbf1f
parent 47216 71c04702a3d5
child 51278 d56dd9798d54
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:
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     1
/*
37065
c00d1c2ffb7c 8150676: Use BufferNode index
kbarrett
parents: 34148
diff changeset
     2
 * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     4
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     8
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    13
 * accompanied this code).
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    14
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5082
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5082
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: 5082
diff changeset
    21
 * questions.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    22
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    23
 */
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    24
33792
2bae5bf9e431 8077571: ObjPtrQueue is poorly named
kbarrett
parents: 33761
diff changeset
    25
#ifndef SHARE_VM_GC_G1_SATBMARKQUEUE_HPP
2bae5bf9e431 8077571: ObjPtrQueue is poorly named
kbarrett
parents: 33761
diff changeset
    26
#define SHARE_VM_GC_G1_SATBMARKQUEUE_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6768
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30577
diff changeset
    28
#include "gc/g1/ptrQueue.hpp"
30577
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30279
diff changeset
    29
#include "memory/allocation.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6768
diff changeset
    30
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    31
class JavaThread;
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 7920
diff changeset
    32
class SATBMarkQueueSet;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    33
30577
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30279
diff changeset
    34
// Base class for processing the contents of a SATB buffer.
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30279
diff changeset
    35
class SATBBufferClosure : public StackObj {
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30279
diff changeset
    36
protected:
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30279
diff changeset
    37
  ~SATBBufferClosure() { }
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30279
diff changeset
    38
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30279
diff changeset
    39
public:
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30279
diff changeset
    40
  // Process the SATB entries in the designated buffer range.
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30279
diff changeset
    41
  virtual void do_buffer(void** buffer, size_t size) = 0;
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30279
diff changeset
    42
};
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30279
diff changeset
    43
33792
2bae5bf9e431 8077571: ObjPtrQueue is poorly named
kbarrett
parents: 33761
diff changeset
    44
// A PtrQueue whose elements are (possibly stale) pointers to object heads.
2bae5bf9e431 8077571: ObjPtrQueue is poorly named
kbarrett
parents: 33761
diff changeset
    45
class SATBMarkQueue: public PtrQueue {
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 7920
diff changeset
    46
  friend class SATBMarkQueueSet;
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 7920
diff changeset
    47
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 7920
diff changeset
    48
private:
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 7920
diff changeset
    49
  // Filter out unwanted entries from the buffer.
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 7920
diff changeset
    50
  void filter();
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 7920
diff changeset
    51
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    52
public:
33792
2bae5bf9e431 8077571: ObjPtrQueue is poorly named
kbarrett
parents: 33761
diff changeset
    53
  SATBMarkQueue(SATBMarkQueueSet* qset, bool permanent = false);
7920
298df61588a2 7011379: G1: overly long concurrent marking cycles
tonyp
parents: 7397
diff changeset
    54
28507
354ef83ee258 8048949: Requeue queue implementation
tschatzl
parents: 27251
diff changeset
    55
  // Process queue entries and free resources.
354ef83ee258 8048949: Requeue queue implementation
tschatzl
parents: 27251
diff changeset
    56
  void flush();
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 7920
diff changeset
    57
30577
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30279
diff changeset
    58
  // Apply cl to the active part of the buffer.
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30279
diff changeset
    59
  // Prerequisite: Must be at a safepoint.
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30279
diff changeset
    60
  void apply_closure_and_empty(SATBBufferClosure* cl);
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30279
diff changeset
    61
7920
298df61588a2 7011379: G1: overly long concurrent marking cycles
tonyp
parents: 7397
diff changeset
    62
  // Overrides PtrQueue::should_enqueue_buffer(). See the method's
298df61588a2 7011379: G1: overly long concurrent marking cycles
tonyp
parents: 7397
diff changeset
    63
  // definition for more information.
298df61588a2 7011379: G1: overly long concurrent marking cycles
tonyp
parents: 7397
diff changeset
    64
  virtual bool should_enqueue_buffer();
298df61588a2 7011379: G1: overly long concurrent marking cycles
tonyp
parents: 7397
diff changeset
    65
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 7920
diff changeset
    66
#ifndef PRODUCT
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 7920
diff changeset
    67
  // Helpful for debugging
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 7920
diff changeset
    68
  void print(const char* name);
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 7920
diff changeset
    69
#endif // PRODUCT
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33792
diff changeset
    70
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33792
diff changeset
    71
  // Compiler support.
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33792
diff changeset
    72
  static ByteSize byte_offset_of_index() {
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33792
diff changeset
    73
    return PtrQueue::byte_offset_of_index<SATBMarkQueue>();
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33792
diff changeset
    74
  }
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33792
diff changeset
    75
  using PtrQueue::byte_width_of_index;
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33792
diff changeset
    76
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33792
diff changeset
    77
  static ByteSize byte_offset_of_buf() {
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33792
diff changeset
    78
    return PtrQueue::byte_offset_of_buf<SATBMarkQueue>();
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33792
diff changeset
    79
  }
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33792
diff changeset
    80
  using PtrQueue::byte_width_of_buf;
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33792
diff changeset
    81
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33792
diff changeset
    82
  static ByteSize byte_offset_of_active() {
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33792
diff changeset
    83
    return PtrQueue::byte_offset_of_active<SATBMarkQueue>();
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33792
diff changeset
    84
  }
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33792
diff changeset
    85
  using PtrQueue::byte_width_of_active;
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33792
diff changeset
    86
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    87
};
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    88
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    89
class SATBMarkQueueSet: public PtrQueueSet {
33792
2bae5bf9e431 8077571: ObjPtrQueue is poorly named
kbarrett
parents: 33761
diff changeset
    90
  SATBMarkQueue _shared_satb_queue;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    91
5082
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
    92
#ifdef ASSERT
22497
b2e1896e9616 8029162: G1: Shared SATB queue never enabled
pliden
parents: 11455
diff changeset
    93
  void dump_active_states(bool expected_active);
b2e1896e9616 8029162: G1: Shared SATB queue never enabled
pliden
parents: 11455
diff changeset
    94
  void verify_active_states(bool expected_active);
5082
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
    95
#endif // ASSERT
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    96
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    97
public:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    98
  SATBMarkQueueSet();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    99
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   100
  void initialize(Monitor* cbl_mon, Mutex* fl_lock,
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 3262
diff changeset
   101
                  int process_completed_threshold,
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 3262
diff changeset
   102
                  Mutex* lock);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   103
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   104
  static void handle_zero_index_for_thread(JavaThread* t);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   105
22497
b2e1896e9616 8029162: G1: Shared SATB queue never enabled
pliden
parents: 11455
diff changeset
   106
  // Apply "set_active(active)" to all SATB queues in the set. It should be
5082
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   107
  // called only with the world stopped. The method will assert that the
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   108
  // SATB queues of all threads it visits, as well as the SATB queue
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   109
  // set itself, has an active value same as expected_active.
22497
b2e1896e9616 8029162: G1: Shared SATB queue never enabled
pliden
parents: 11455
diff changeset
   110
  void set_active_all_threads(bool active, bool expected_active);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   111
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 7920
diff changeset
   112
  // Filter all the currently-active SATB buffers.
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 7920
diff changeset
   113
  void filter_thread_buffers();
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 7920
diff changeset
   114
30577
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30279
diff changeset
   115
  // If there exists some completed buffer, pop and process it, and
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30279
diff changeset
   116
  // return true.  Otherwise return false.  Processing a buffer
37065
c00d1c2ffb7c 8150676: Use BufferNode index
kbarrett
parents: 34148
diff changeset
   117
  // consists of applying the closure to the active range of the
c00d1c2ffb7c 8150676: Use BufferNode index
kbarrett
parents: 34148
diff changeset
   118
  // buffer; the leading entries may be excluded due to filtering.
30577
de9fa7ccc1bc 8075215: SATB buffer processing found reclaimed humongous object
kbarrett
parents: 30279
diff changeset
   119
  bool apply_closure_to_completed_buffer(SATBBufferClosure* cl);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   120
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 7920
diff changeset
   121
#ifndef PRODUCT
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 7920
diff changeset
   122
  // Helpful for debugging
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 7920
diff changeset
   123
  void print_all(const char* msg);
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 7920
diff changeset
   124
#endif // PRODUCT
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 7920
diff changeset
   125
33792
2bae5bf9e431 8077571: ObjPtrQueue is poorly named
kbarrett
parents: 33761
diff changeset
   126
  SATBMarkQueue* shared_satb_queue() { return &_shared_satb_queue; }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   127
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   128
  // If a marking is being abandoned, reset any unprocessed log buffers.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   129
  void abandon_partial_marking();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   130
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6768
diff changeset
   131
33792
2bae5bf9e431 8077571: ObjPtrQueue is poorly named
kbarrett
parents: 33761
diff changeset
   132
#endif // SHARE_VM_GC_G1_SATBMARKQUEUE_HPP