src/hotspot/share/gc/shared/collectedHeap.inline.hpp
author redestad
Tue, 08 Jan 2019 10:54:00 +0100
changeset 53191 a257992e1e4d
parent 50882 80abf702eed8
child 53244 9807daeb47c4
permissions -rw-r--r--
8216285: Enable inlining of CollectedHeap::obj-/array-/class_allocate Reviewed-by: ehelin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53191
a257992e1e4d 8216285: Enable inlining of CollectedHeap::obj-/array-/class_allocate
redestad
parents: 50882
diff changeset
     2
 * Copyright (c) 2001, 2019, 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"
53191
a257992e1e4d 8216285: Enable inlining of CollectedHeap::obj-/array-/class_allocate
redestad
parents: 50882
diff changeset
    29
#include "gc/shared/memAllocator.hpp"
35862
411842d0c882 8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents: 33105
diff changeset
    30
#include "oops/oop.inline.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46619
diff changeset
    31
#include "utilities/align.hpp"
10566
630c177ec580 7081933: Use zeroing elimination optimization for large array
kvn
parents: 10565
diff changeset
    32
25905
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    33
inline HeapWord* CollectedHeap::align_allocation_or_fail(HeapWord* addr,
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    34
                                                         HeapWord* end,
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    35
                                                         unsigned short alignment_in_bytes) {
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    36
  if (alignment_in_bytes <= ObjectAlignmentInBytes) {
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    37
    return addr;
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    38
  }
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    39
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 46618
diff changeset
    40
  assert(is_aligned(addr, HeapWordSize),
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30764
diff changeset
    41
         "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
    42
  assert(is_aligned(alignment_in_bytes, HeapWordSize),
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30764
diff changeset
    43
         "Alignment size %u is incorrect.", alignment_in_bytes);
25905
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    44
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 46618
diff changeset
    45
  HeapWord* new_addr = align_up(addr, alignment_in_bytes);
25905
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    46
  size_t padding = pointer_delta(new_addr, addr);
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    47
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    48
  if (padding == 0) {
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    49
    return addr;
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
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    52
  if (padding < CollectedHeap::min_fill_size()) {
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    53
    padding += alignment_in_bytes / HeapWordSize;
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    54
    assert(padding >= CollectedHeap::min_fill_size(),
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30764
diff changeset
    55
           "alignment_in_bytes %u is expect to be larger "
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30764
diff changeset
    56
           "than the minimum object size", alignment_in_bytes);
25905
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    57
    new_addr = addr + padding;
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    58
  }
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    59
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30764
diff changeset
    60
  assert(new_addr > addr, "Unexpected arithmetic overflow "
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30764
diff changeset
    61
         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
    62
  if(new_addr < end) {
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    63
    CollectedHeap::fill_with_object(addr, padding);
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    64
    return new_addr;
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    65
  } else {
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    66
    return NULL;
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
}
04a3d83cc752 8031323: Optionally align objects copied to survivor spaces
jmasa
parents: 23995
diff changeset
    69
53191
a257992e1e4d 8216285: Enable inlining of CollectedHeap::obj-/array-/class_allocate
redestad
parents: 50882
diff changeset
    70
inline oop CollectedHeap::obj_allocate(Klass* klass, int size, TRAPS) {
a257992e1e4d 8216285: Enable inlining of CollectedHeap::obj-/array-/class_allocate
redestad
parents: 50882
diff changeset
    71
  ObjAllocator allocator(klass, size, THREAD);
a257992e1e4d 8216285: Enable inlining of CollectedHeap::obj-/array-/class_allocate
redestad
parents: 50882
diff changeset
    72
  return allocator.allocate();
a257992e1e4d 8216285: Enable inlining of CollectedHeap::obj-/array-/class_allocate
redestad
parents: 50882
diff changeset
    73
}
a257992e1e4d 8216285: Enable inlining of CollectedHeap::obj-/array-/class_allocate
redestad
parents: 50882
diff changeset
    74
a257992e1e4d 8216285: Enable inlining of CollectedHeap::obj-/array-/class_allocate
redestad
parents: 50882
diff changeset
    75
inline oop CollectedHeap::array_allocate(Klass* klass, int size, int length, bool do_zero, TRAPS) {
a257992e1e4d 8216285: Enable inlining of CollectedHeap::obj-/array-/class_allocate
redestad
parents: 50882
diff changeset
    76
  ObjArrayAllocator allocator(klass, size, length, do_zero, THREAD);
a257992e1e4d 8216285: Enable inlining of CollectedHeap::obj-/array-/class_allocate
redestad
parents: 50882
diff changeset
    77
  return allocator.allocate();
a257992e1e4d 8216285: Enable inlining of CollectedHeap::obj-/array-/class_allocate
redestad
parents: 50882
diff changeset
    78
}
a257992e1e4d 8216285: Enable inlining of CollectedHeap::obj-/array-/class_allocate
redestad
parents: 50882
diff changeset
    79
a257992e1e4d 8216285: Enable inlining of CollectedHeap::obj-/array-/class_allocate
redestad
parents: 50882
diff changeset
    80
inline oop CollectedHeap::class_allocate(Klass* klass, int size, TRAPS) {
a257992e1e4d 8216285: Enable inlining of CollectedHeap::obj-/array-/class_allocate
redestad
parents: 50882
diff changeset
    81
  ClassAllocator allocator(klass, size, THREAD);
a257992e1e4d 8216285: Enable inlining of CollectedHeap::obj-/array-/class_allocate
redestad
parents: 50882
diff changeset
    82
  return allocator.allocate();
a257992e1e4d 8216285: Enable inlining of CollectedHeap::obj-/array-/class_allocate
redestad
parents: 50882
diff changeset
    83
}
a257992e1e4d 8216285: Enable inlining of CollectedHeap::obj-/array-/class_allocate
redestad
parents: 50882
diff changeset
    84
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30152
diff changeset
    85
#endif // SHARE_VM_GC_SHARED_COLLECTEDHEAP_INLINE_HPP