Tue, 19 May 2015 15:49:27 +0200
8061715: gc/g1/TestShrinkAuxiliaryData15.java fails with java.lang.RuntimeException: heap decommit failed - after > before
Summary: added WhiteBox methods to count regions and exact aux data sizes
Reviewed-by: jwilhelm, brutisso
ysr@777 | 1 | /* |
kbarrett@7831 | 2 | * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. |
ysr@777 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ysr@777 | 4 | * |
ysr@777 | 5 | * This code is free software; you can redistribute it and/or modify it |
ysr@777 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ysr@777 | 7 | * published by the Free Software Foundation. |
ysr@777 | 8 | * |
ysr@777 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
ysr@777 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ysr@777 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ysr@777 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
ysr@777 | 13 | * accompanied this code). |
ysr@777 | 14 | * |
ysr@777 | 15 | * You should have received a copy of the GNU General Public License version |
ysr@777 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
ysr@777 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ysr@777 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
ysr@777 | 22 | * |
ysr@777 | 23 | */ |
ysr@777 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_SATBQUEUE_HPP |
stefank@2314 | 26 | #define SHARE_VM_GC_IMPLEMENTATION_G1_SATBQUEUE_HPP |
stefank@2314 | 27 | |
kbarrett@7834 | 28 | #include "memory/allocation.hpp" |
stefank@2314 | 29 | #include "gc_implementation/g1/ptrQueue.hpp" |
stefank@2314 | 30 | |
ysr@777 | 31 | class JavaThread; |
tonyp@3416 | 32 | class SATBMarkQueueSet; |
ysr@777 | 33 | |
kbarrett@7834 | 34 | // Base class for processing the contents of a SATB buffer. |
kbarrett@7834 | 35 | class SATBBufferClosure : public StackObj { |
kbarrett@7834 | 36 | protected: |
kbarrett@7834 | 37 | ~SATBBufferClosure() { } |
kbarrett@7834 | 38 | |
kbarrett@7834 | 39 | public: |
kbarrett@7834 | 40 | // Process the SATB entries in the designated buffer range. |
kbarrett@7834 | 41 | virtual void do_buffer(void** buffer, size_t size) = 0; |
kbarrett@7834 | 42 | }; |
kbarrett@7834 | 43 | |
ysr@777 | 44 | // A ptrQueue whose elements are "oops", pointers to object heads. |
ysr@777 | 45 | class ObjPtrQueue: public PtrQueue { |
tonyp@3416 | 46 | friend class SATBMarkQueueSet; |
tonyp@3416 | 47 | |
tonyp@3416 | 48 | private: |
tonyp@3416 | 49 | // Filter out unwanted entries from the buffer. |
tonyp@3416 | 50 | void filter(); |
tonyp@3416 | 51 | |
ysr@777 | 52 | public: |
tonyp@2469 | 53 | ObjPtrQueue(PtrQueueSet* qset, bool perm = false) : |
tonyp@2197 | 54 | // SATB queues are only active during marking cycles. We create |
tonyp@2197 | 55 | // them with their active field set to false. If a thread is |
tonyp@2197 | 56 | // created during a cycle and its SATB queue needs to be activated |
tonyp@2197 | 57 | // before the thread starts running, we'll need to set its active |
tonyp@2197 | 58 | // field to true. This is done in JavaThread::initialize_queues(). |
tonyp@2469 | 59 | PtrQueue(qset, perm, false /* active */) { } |
tonyp@2469 | 60 | |
tschatzl@7445 | 61 | // Process queue entries and free resources. |
tschatzl@7445 | 62 | void flush(); |
tonyp@3416 | 63 | |
kbarrett@7834 | 64 | // Apply cl to the active part of the buffer. |
kbarrett@7834 | 65 | // Prerequisite: Must be at a safepoint. |
kbarrett@7834 | 66 | void apply_closure_and_empty(SATBBufferClosure* cl); |
kbarrett@7834 | 67 | |
tonyp@2469 | 68 | // Overrides PtrQueue::should_enqueue_buffer(). See the method's |
tonyp@2469 | 69 | // definition for more information. |
tonyp@2469 | 70 | virtual bool should_enqueue_buffer(); |
tonyp@2469 | 71 | |
tonyp@3416 | 72 | #ifndef PRODUCT |
tonyp@3416 | 73 | // Helpful for debugging |
tonyp@3416 | 74 | void print(const char* name); |
tonyp@3416 | 75 | static void print(const char* name, void** buf, size_t index, size_t sz); |
tonyp@3416 | 76 | #endif // PRODUCT |
ysr@777 | 77 | }; |
ysr@777 | 78 | |
ysr@777 | 79 | class SATBMarkQueueSet: public PtrQueueSet { |
ysr@777 | 80 | ObjPtrQueue _shared_satb_queue; |
ysr@777 | 81 | |
tonyp@1752 | 82 | #ifdef ASSERT |
pliden@6396 | 83 | void dump_active_states(bool expected_active); |
pliden@6396 | 84 | void verify_active_states(bool expected_active); |
tonyp@1752 | 85 | #endif // ASSERT |
ysr@777 | 86 | |
ysr@777 | 87 | public: |
ysr@777 | 88 | SATBMarkQueueSet(); |
ysr@777 | 89 | |
ysr@777 | 90 | void initialize(Monitor* cbl_mon, Mutex* fl_lock, |
iveresov@1546 | 91 | int process_completed_threshold, |
iveresov@1546 | 92 | Mutex* lock); |
ysr@777 | 93 | |
ysr@777 | 94 | static void handle_zero_index_for_thread(JavaThread* t); |
ysr@777 | 95 | |
pliden@6396 | 96 | // Apply "set_active(active)" to all SATB queues in the set. It should be |
tonyp@1752 | 97 | // called only with the world stopped. The method will assert that the |
tonyp@1752 | 98 | // SATB queues of all threads it visits, as well as the SATB queue |
tonyp@1752 | 99 | // set itself, has an active value same as expected_active. |
pliden@6396 | 100 | void set_active_all_threads(bool active, bool expected_active); |
ysr@777 | 101 | |
tonyp@3416 | 102 | // Filter all the currently-active SATB buffers. |
tonyp@3416 | 103 | void filter_thread_buffers(); |
tonyp@3416 | 104 | |
kbarrett@7834 | 105 | // If there exists some completed buffer, pop and process it, and |
kbarrett@7834 | 106 | // return true. Otherwise return false. Processing a buffer |
kbarrett@7834 | 107 | // consists of applying the closure to the buffer range starting |
kbarrett@7834 | 108 | // with the first non-NULL entry to the end of the buffer; the |
kbarrett@7834 | 109 | // leading entries may be NULL due to filtering. |
kbarrett@7834 | 110 | bool apply_closure_to_completed_buffer(SATBBufferClosure* cl); |
ysr@777 | 111 | |
tonyp@3416 | 112 | #ifndef PRODUCT |
tonyp@3416 | 113 | // Helpful for debugging |
tonyp@3416 | 114 | void print_all(const char* msg); |
tonyp@3416 | 115 | #endif // PRODUCT |
tonyp@3416 | 116 | |
ysr@777 | 117 | ObjPtrQueue* shared_satb_queue() { return &_shared_satb_queue; } |
ysr@777 | 118 | |
ysr@777 | 119 | // If a marking is being abandoned, reset any unprocessed log buffers. |
ysr@777 | 120 | void abandon_partial_marking(); |
ysr@777 | 121 | }; |
stefank@2314 | 122 | |
stefank@2314 | 123 | #endif // SHARE_VM_GC_IMPLEMENTATION_G1_SATBQUEUE_HPP |