< prev index next >

src/hotspot/share/gc/z/zThreadLocalAllocBuffer.cpp

Print this page


   1 /*
   2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 #include "gc/z/zStatTLAB.hpp"




  25 
  26 ZPerWorker<ThreadLocalAllocStats>* ZStatTLAB::_stats = NULL;
  27 
  28 void ZStatTLAB::initialize() {
  29   if (UseTLAB) {
  30     assert(_stats == NULL, "Already initialized");
  31     _stats = new ZPerWorker<ThreadLocalAllocStats>();
  32     reset();
  33   }
  34 }
  35 
  36 void ZStatTLAB::reset() {
  37   if (UseTLAB) {
  38     ZPerWorkerIterator<ThreadLocalAllocStats> iter(_stats);
  39     for (ThreadLocalAllocStats* stats; iter.next(&stats);) {
  40       stats->reset();
  41     }
  42   }
  43 }
  44 
  45 ThreadLocalAllocStats* ZStatTLAB::get() {
  46   if (UseTLAB) {
  47     return _stats->addr();
  48   }
  49 
  50   return NULL;
  51 }
  52 
  53 void ZStatTLAB::publish() {
  54   if (UseTLAB) {
  55     ThreadLocalAllocStats total;
  56 
  57     ZPerWorkerIterator<ThreadLocalAllocStats> iter(_stats);
  58     for (ThreadLocalAllocStats* stats; iter.next(&stats);) {
  59       total.update(*stats);
  60     }
  61 
  62     total.publish();



















  63   }
  64 }
   1 /*
   2  * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 #include "precompiled.hpp"
  25 #include "gc/z/zAddress.inline.hpp"
  26 #include "gc/z/zThreadLocalAllocBuffer.hpp"
  27 #include "runtime/globals.hpp"
  28 #include "runtime/thread.hpp"
  29 
  30 ZPerWorker<ThreadLocalAllocStats>* ZThreadLocalAllocBuffer::_stats = NULL;
  31 
  32 void ZThreadLocalAllocBuffer::initialize() {
  33   if (UseTLAB) {
  34     assert(_stats == NULL, "Already initialized");
  35     _stats = new ZPerWorker<ThreadLocalAllocStats>();
  36     reset_statistics();
  37   }
  38 }
  39 
  40 void ZThreadLocalAllocBuffer::reset_statistics() {
  41   if (UseTLAB) {
  42     ZPerWorkerIterator<ThreadLocalAllocStats> iter(_stats);
  43     for (ThreadLocalAllocStats* stats; iter.next(&stats);) {
  44       stats->reset();
  45     }
  46   }
  47 }
  48 
  49 void ZThreadLocalAllocBuffer::publish_statistics() {








  50   if (UseTLAB) {
  51     ThreadLocalAllocStats total;
  52 
  53     ZPerWorkerIterator<ThreadLocalAllocStats> iter(_stats);
  54     for (ThreadLocalAllocStats* stats; iter.next(&stats);) {
  55       total.update(*stats);
  56     }
  57 
  58     total.publish();
  59   }
  60 }
  61 
  62 static void fixup_address(HeapWord** p) {
  63   *p = (HeapWord*)ZAddress::good_or_null((uintptr_t)*p);
  64 }
  65 
  66 void ZThreadLocalAllocBuffer::retire(Thread* thread) {
  67   if (UseTLAB && thread->is_Java_thread()) {
  68     ThreadLocalAllocStats* const stats = _stats->addr();
  69     thread->tlab().addresses_do(fixup_address);
  70     thread->tlab().retire(stats);
  71     thread->tlab().resize();
  72   }
  73 }
  74 
  75 void ZThreadLocalAllocBuffer::remap(Thread* thread) {
  76   if (UseTLAB && thread->is_Java_thread()) {
  77     thread->tlab().addresses_do(fixup_address);
  78   }
  79 }
< prev index next >