src/share/vm/memory/threadLocalAllocBuffer.cpp

Print this page


   1 /*
   2  * Copyright (c) 1999, 2009, 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 
  25 // Thread-Local Edens support















  26 
  27 # include "incls/_precompiled.incl"
  28 # include "incls/_threadLocalAllocBuffer.cpp.incl"
  29 
  30 // static member initialization
  31 unsigned         ThreadLocalAllocBuffer::_target_refills = 0;
  32 GlobalTLABStats* ThreadLocalAllocBuffer::_global_stats   = NULL;
  33 
  34 void ThreadLocalAllocBuffer::clear_before_allocation() {
  35   _slow_refill_waste += (unsigned)remaining();
  36   make_parsable(true);   // also retire the TLAB
  37 }
  38 
  39 void ThreadLocalAllocBuffer::accumulate_statistics_before_gc() {
  40   global_stats()->initialize();
  41 
  42   for(JavaThread *thread = Threads::first(); thread; thread = thread->next()) {
  43     thread->tlab().accumulate_statistics();
  44     thread->tlab().initialize_statistics();
  45   }
  46 
  47   // Publish new stats if some allocation occurred.
  48   if (global_stats()->allocation() != 0) {


   1 /*
   2  * Copyright (c) 1999, 2010, 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 
  25 #include "precompiled.hpp"
  26 #include "memory/genCollectedHeap.hpp"
  27 #include "memory/resourceArea.hpp"
  28 #include "memory/threadLocalAllocBuffer.inline.hpp"
  29 #include "memory/universe.inline.hpp"
  30 #include "oops/oop.inline.hpp"
  31 #include "utilities/copy.hpp"
  32 #ifdef TARGET_OS_FAMILY_linux
  33 # include "thread_linux.inline.hpp"
  34 #endif
  35 #ifdef TARGET_OS_FAMILY_solaris
  36 # include "thread_solaris.inline.hpp"
  37 #endif
  38 #ifdef TARGET_OS_FAMILY_windows
  39 # include "thread_windows.inline.hpp"
  40 #endif
  41 
  42 // Thread-Local Edens support

  43 
  44 // static member initialization
  45 unsigned         ThreadLocalAllocBuffer::_target_refills = 0;
  46 GlobalTLABStats* ThreadLocalAllocBuffer::_global_stats   = NULL;
  47 
  48 void ThreadLocalAllocBuffer::clear_before_allocation() {
  49   _slow_refill_waste += (unsigned)remaining();
  50   make_parsable(true);   // also retire the TLAB
  51 }
  52 
  53 void ThreadLocalAllocBuffer::accumulate_statistics_before_gc() {
  54   global_stats()->initialize();
  55 
  56   for(JavaThread *thread = Threads::first(); thread; thread = thread->next()) {
  57     thread->tlab().accumulate_statistics();
  58     thread->tlab().initialize_statistics();
  59   }
  60 
  61   // Publish new stats if some allocation occurred.
  62   if (global_stats()->allocation() != 0) {