hotspot/src/share/vm/gc/parallel/psPromotionLAB.inline.hpp
author tschatzl
Thu, 28 Jan 2016 13:30:12 +0100
changeset 35877 a2a62511d0f8
parent 30764 fec48bf5a827
child 46565 8dcbf532ea00
permissions -rw-r--r--
8146987: Improve Parallel GC Full GC by caching results of live_words_in_range() Summary: A large part of time in the parallel scavenge collector is spent finding out the amount of live words within memory ranges to find out where to move an object to. Try to incrementally calculate this value. Reviewed-by: tschatzl, mgerdin, jmasa Contributed-by: ray alex <sky1young@gmail.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25905
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
     1
/*
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 25905
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
25905
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
     4
 *
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
     7
 * published by the Free Software Foundation.
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
     8
 *
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    13
 * accompanied this code).
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    14
 *
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    18
 *
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    21
 * questions.
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    22
 *
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    23
 */
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    24
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 25905
diff changeset
    25
#ifndef SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_INLINE_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 25905
diff changeset
    26
#define SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_INLINE_HPP
25905
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 25905
diff changeset
    28
#include "gc/parallel/psPromotionLAB.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 25905
diff changeset
    29
#include "gc/shared/collectedHeap.inline.hpp"
25905
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    30
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    31
HeapWord* PSYoungPromotionLAB::allocate(size_t size) {
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    32
  // Can't assert this, when young fills, we keep the LAB around, but flushed.
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    33
  // assert(_state != flushed, "Sanity");
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    34
  HeapWord* obj = CollectedHeap::align_allocation_or_fail(top(), end(), SurvivorAlignmentInBytes);
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    35
  if (obj == NULL) {
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    36
    return NULL;
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    37
  }
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    38
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    39
  HeapWord* new_top = obj + size;
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    40
  // The 'new_top>obj' check is needed to detect overflow of obj+size.
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    41
  if (new_top > obj && new_top <= end()) {
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    42
    set_top(new_top);
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    43
    assert(is_ptr_aligned(obj, SurvivorAlignmentInBytes) && is_object_aligned((intptr_t)new_top),
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    44
           "checking alignment");
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    45
    return obj;
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    46
  } else {
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    47
    set_top(obj);
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    48
    return NULL;
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    49
  }
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    50
}
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
diff changeset
    51
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 25905
diff changeset
    52
#endif // SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_INLINE_HPP