hotspot/src/share/vm/gc/parallel/psPromotionLAB.inline.hpp
author stefank
Tue, 04 Jul 2017 15:58:10 +0200
changeset 46619 a3919f5e8d2b
parent 46565 8dcbf532ea00
child 46625 edefffab74e2
permissions -rw-r--r--
8178499: Remove _ptr_ and _size_ infixes from align functions Reviewed-by: rehn, tschatzl
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);
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 46565
diff changeset
    43
    assert(is_aligned(obj, SurvivorAlignmentInBytes) && is_object_aligned(new_top),
25905
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