src/share/vm/memory/threadLocalAllocBuffer.inline.hpp

Mon, 23 Jun 2008 16:49:37 -0700

author
ysr
date
Mon, 23 Jun 2008 16:49:37 -0700
changeset 782
60fb9c4db4e6
parent 435
a61af66fc99e
child 1600
2dd52dea6d28
permissions
-rw-r--r--

6718086: CMS assert: _concurrent_iteration_safe_limit update missed
Summary: Initialize the field correctly in ContiguousSpace's constructor and initialize() methods, using the latter for the survivor spaces upon initial construction or a subsequent resizing of the young generation. Add some missing Space sub-class constructors.
Reviewed-by: apetrusenko

     1 /*
     2  * Copyright 1999-2007 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 inline HeapWord* ThreadLocalAllocBuffer::allocate(size_t size) {
    26   invariants();
    27   HeapWord* obj = top();
    28   if (pointer_delta(end(), obj) >= size) {
    29     // successful thread-local allocation
    31     DEBUG_ONLY(Copy::fill_to_words(obj, size, badHeapWordVal));
    32     // This addition is safe because we know that top is
    33     // at least size below end, so the add can't wrap.
    34     set_top(obj + size);
    36     invariants();
    37     return obj;
    38   }
    39   return NULL;
    40 }
    42 inline size_t ThreadLocalAllocBuffer::compute_size(size_t obj_size) {
    43   const size_t aligned_obj_size = align_object_size(obj_size);
    45   // Compute the size for the new TLAB.
    46   // The "last" tlab may be smaller to reduce fragmentation.
    47   // unsafe_max_tlab_alloc is just a hint.
    48   const size_t available_size = Universe::heap()->unsafe_max_tlab_alloc(myThread()) /
    49                                                   HeapWordSize;
    50   size_t new_tlab_size = MIN2(available_size, desired_size() + aligned_obj_size);
    52   // Make sure there's enough room for object and filler int[].
    53   const size_t obj_plus_filler_size = aligned_obj_size + alignment_reserve();
    54   if (new_tlab_size < obj_plus_filler_size) {
    55     // If there isn't enough room for the allocation, return failure.
    56     if (PrintTLAB && Verbose) {
    57       gclog_or_tty->print_cr("ThreadLocalAllocBuffer::compute_size(" SIZE_FORMAT ")"
    58                     " returns failure",
    59                     obj_size);
    60     }
    61     return 0;
    62   }
    63   if (PrintTLAB && Verbose) {
    64     gclog_or_tty->print_cr("ThreadLocalAllocBuffer::compute_size(" SIZE_FORMAT ")"
    65                   " returns " SIZE_FORMAT,
    66                   obj_size, new_tlab_size);
    67   }
    68   return new_tlab_size;
    69 }
    72 void ThreadLocalAllocBuffer::record_slow_allocation(size_t obj_size) {
    73   // Raise size required to bypass TLAB next time. Why? Else there's
    74   // a risk that a thread that repeatedly allocates objects of one
    75   // size will get stuck on this slow path.
    77   set_refill_waste_limit(refill_waste_limit() + refill_waste_limit_increment());
    79   _slow_allocations++;
    81   if (PrintTLAB && Verbose) {
    82     Thread* thrd = myThread();
    83     gclog_or_tty->print("TLAB: %s thread: "INTPTR_FORMAT" [id: %2d]"
    84                         " obj: "SIZE_FORMAT
    85                         " free: "SIZE_FORMAT
    86                         " waste: "SIZE_FORMAT"\n",
    87                         "slow", thrd, thrd->osthread()->thread_id(),
    88                         obj_size, free(), refill_waste_limit());
    89   }
    90 }

mercurial