src/hotspot/share/gc/shared/collectedHeap.inline.hpp
author eosterlund
Tue, 16 Oct 2018 13:18:22 +0200
changeset 52142 ca0c25e01c5b
parent 50882 80abf702eed8
child 53191 a257992e1e4d
permissions -rw-r--r--
8210498: nmethod entry barriers Reviewed-by: kvn, pliden
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
49593
4dd58ecc9912 8200105: Remove cyclic dependency between oop.inline.hpp and collectedHeap.inline.hpp
stefank
parents: 47779
diff changeset
     2
 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2105
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2105
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2105
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30152
diff changeset
    25
#ifndef SHARE_VM_GC_SHARED_COLLECTEDHEAP_INLINE_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30152
diff changeset
    26
#define SHARE_VM_GC_SHARED_COLLECTEDHEAP_INLINE_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30152
diff changeset
    28
#include "gc/shared/collectedHeap.hpp"
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents: 33105
diff changeset
    29
#include "oops/oop.inline.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46619
diff changeset
    30
#include "utilities/align.hpp"
10566
630c177ec580 7081933: Use zeroing elimination optimization for large array
kvn
parents: 10565
diff changeset
    31
25905
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    32
inline HeapWord* CollectedHeap::align_allocation_or_fail(HeapWord* addr,
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    33
                                                         HeapWord* end,
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    34
                                                         unsigned short alignment_in_bytes) {
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    35
  if (alignment_in_bytes <= ObjectAlignmentInBytes) {
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    36
    return addr;
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    37
  }
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    38
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 46618
diff changeset
    39
  assert(is_aligned(addr, HeapWordSize),
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30764
diff changeset
    40
         "Address " PTR_FORMAT " is not properly aligned.", p2i(addr));
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 46618
diff changeset
    41
  assert(is_aligned(alignment_in_bytes, HeapWordSize),
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30764
diff changeset
    42
         "Alignment size %u is incorrect.", alignment_in_bytes);
25905
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    43
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 46618
diff changeset
    44
  HeapWord* new_addr = align_up(addr, alignment_in_bytes);
25905
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    45
  size_t padding = pointer_delta(new_addr, addr);
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    46
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    47
  if (padding == 0) {
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    48
    return addr;
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    49
  }
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    50
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    51
  if (padding < CollectedHeap::min_fill_size()) {
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    52
    padding += alignment_in_bytes / HeapWordSize;
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    53
    assert(padding >= CollectedHeap::min_fill_size(),
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30764
diff changeset
    54
           "alignment_in_bytes %u is expect to be larger "
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30764
diff changeset
    55
           "than the minimum object size", alignment_in_bytes);
25905
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    56
    new_addr = addr + padding;
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    57
  }
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    58
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30764
diff changeset
    59
  assert(new_addr > addr, "Unexpected arithmetic overflow "
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30764
diff changeset
    60
         PTR_FORMAT " not greater than " PTR_FORMAT, p2i(new_addr), p2i(addr));
25905
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    61
  if(new_addr < end) {
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    62
    CollectedHeap::fill_with_object(addr, padding);
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    63
    return new_addr;
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    64
  } else {
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    65
    return NULL;
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    66
  }
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    67
}
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    68
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30152
diff changeset
    69
#endif // SHARE_VM_GC_SHARED_COLLECTEDHEAP_INLINE_HPP