| 1 | /* | 
|---|
| 2 | * Copyright (c) 2016, 2019, Red Hat, Inc. All rights reserved. | 
|---|
| 3 | * | 
|---|
| 4 | * This code is free software; you can redistribute it and/or modify it | 
|---|
| 5 | * under the terms of the GNU General Public License version 2 only, as | 
|---|
| 6 | * published by the Free Software Foundation. | 
|---|
| 7 | * | 
|---|
| 8 | * This code is distributed in the hope that it will be useful, but WITHOUT | 
|---|
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 
|---|
| 10 | * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License | 
|---|
| 11 | * version 2 for more details (a copy is included in the LICENSE file that | 
|---|
| 12 | * accompanied this code). | 
|---|
| 13 | * | 
|---|
| 14 | * You should have received a copy of the GNU General Public License version | 
|---|
| 15 | * 2 along with this work; if not, write to the Free Software Foundation, | 
|---|
| 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | 
|---|
| 17 | * | 
|---|
| 18 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | 
|---|
| 19 | * or visit www.oracle.com if you need additional information or have any | 
|---|
| 20 | * questions. | 
|---|
| 21 | * | 
|---|
| 22 | */ | 
|---|
| 23 |  | 
|---|
| 24 | #include "precompiled.hpp" | 
|---|
| 25 |  | 
|---|
| 26 | #include "gc/shenandoah/shenandoahHeap.inline.hpp" | 
|---|
| 27 | #include "gc/shenandoah/shenandoahTaskqueue.inline.hpp" | 
|---|
| 28 | #include "logging/log.hpp" | 
|---|
| 29 | #include "logging/logStream.hpp" | 
|---|
| 30 |  | 
|---|
| 31 | void ShenandoahObjToScanQueueSet::clear() { | 
|---|
| 32 | uint size = GenericTaskQueueSet<ShenandoahObjToScanQueue, mtGC>::size(); | 
|---|
| 33 | for (uint index = 0; index < size; index ++) { | 
|---|
| 34 | ShenandoahObjToScanQueue* q = queue(index); | 
|---|
| 35 | assert(q != NULL, "Sanity"); | 
|---|
| 36 | q->clear(); | 
|---|
| 37 | } | 
|---|
| 38 | } | 
|---|
| 39 |  | 
|---|
| 40 | bool ShenandoahObjToScanQueueSet::is_empty() { | 
|---|
| 41 | uint size = GenericTaskQueueSet<ShenandoahObjToScanQueue, mtGC>::size(); | 
|---|
| 42 | for (uint index = 0; index < size; index ++) { | 
|---|
| 43 | ShenandoahObjToScanQueue* q = queue(index); | 
|---|
| 44 | assert(q != NULL, "Sanity"); | 
|---|
| 45 | if (!q->is_empty()) { | 
|---|
| 46 | return false; | 
|---|
| 47 | } | 
|---|
| 48 | } | 
|---|
| 49 | return true; | 
|---|
| 50 | } | 
|---|
| 51 |  | 
|---|
| 52 | ShenandoahTaskTerminator::ShenandoahTaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set) : | 
|---|
| 53 | _terminator(new OWSTTaskTerminator(n_threads, queue_set)) { } | 
|---|
| 54 |  | 
|---|
| 55 | ShenandoahTaskTerminator::~ShenandoahTaskTerminator() { | 
|---|
| 56 | assert(_terminator != NULL, "Invariant"); | 
|---|
| 57 | delete _terminator; | 
|---|
| 58 | } | 
|---|
| 59 |  | 
|---|
| 60 | #if TASKQUEUE_STATS | 
|---|
| 61 | void ShenandoahObjToScanQueueSet::print_taskqueue_stats_hdr(outputStream* const st) { | 
|---|
| 62 | st->print_raw_cr( "GC Task Stats"); | 
|---|
| 63 | st->print_raw( "thr "); TaskQueueStats::print_header(1, st); st->cr(); | 
|---|
| 64 | st->print_raw( "--- "); TaskQueueStats::print_header(2, st); st->cr(); | 
|---|
| 65 | } | 
|---|
| 66 |  | 
|---|
| 67 | void ShenandoahObjToScanQueueSet::print_taskqueue_stats() const { | 
|---|
| 68 | if (!log_develop_is_enabled(Trace, gc, task, stats)) { | 
|---|
| 69 | return; | 
|---|
| 70 | } | 
|---|
| 71 | Log(gc, task, stats) log; | 
|---|
| 72 | ResourceMark rm; | 
|---|
| 73 | LogStream ls(log.trace()); | 
|---|
| 74 | outputStream* st = &ls; | 
|---|
| 75 | print_taskqueue_stats_hdr(st); | 
|---|
| 76 |  | 
|---|
| 77 | ShenandoahObjToScanQueueSet* queues = const_cast<ShenandoahObjToScanQueueSet*>(this); | 
|---|
| 78 | TaskQueueStats totals; | 
|---|
| 79 | const uint n = size(); | 
|---|
| 80 | for (uint i = 0; i < n; ++i) { | 
|---|
| 81 | st->print(UINT32_FORMAT_W(3), i); | 
|---|
| 82 | queues->queue(i)->stats.print(st); | 
|---|
| 83 | st->cr(); | 
|---|
| 84 | totals += queues->queue(i)->stats; | 
|---|
| 85 | } | 
|---|
| 86 | st->print( "tot "); totals.print(st); st->cr(); | 
|---|
| 87 | DEBUG_ONLY(totals.verify()); | 
|---|
| 88 |  | 
|---|
| 89 | } | 
|---|
| 90 |  | 
|---|
| 91 | void ShenandoahObjToScanQueueSet::reset_taskqueue_stats() { | 
|---|
| 92 | const uint n = size(); | 
|---|
| 93 | for (uint i = 0; i < n; ++i) { | 
|---|
| 94 | queue(i)->stats.reset(); | 
|---|
| 95 | } | 
|---|
| 96 | } | 
|---|
| 97 | #endif // TASKQUEUE_STATS | 
|---|
| 98 |  | 
|---|