src/hotspot/share/memory/allocation.inline.hpp
author jiangli
Thu, 16 Aug 2018 17:29:22 -0400
changeset 51425 4e9667589c43
parent 49590 66c32f2a7f10
child 53244 9807daeb47c4
permissions -rw-r--r--
8209389: SIGSEGV in WalkOopAndArchiveClosure::do_oop_work. Summary: Check the MetaspaceShared::archive_heap_object return value and handle failure accordingly. Reviewed-by: iklam, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
48532
a53f30471b2d 8195094: Fix type-O in "8159422: Very high Concurrent Mark mark stack contention"
goetz
parents: 47216
diff changeset
     2
 * Copyright (c) 1997, 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: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
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: 1
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
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_MEMORY_ALLOCATION_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_MEMORY_ALLOCATION_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
40655
9f644073d3a0 8157907: Incorrect inclusion of atomic.hpp instead of atomic.inline.hpp
dholmes
parents: 39405
diff changeset
    28
#include "runtime/atomic.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "runtime/os.hpp"
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 23545
diff changeset
    30
#include "services/memTracker.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46619
diff changeset
    31
#include "utilities/align.hpp"
39405
314741ca98d5 8153743: AllocateHeap() and ReallocateHeap() should use ALWAYSINLINE macro
ysuenaga
parents: 37096
diff changeset
    32
#include "utilities/globalDefinitions.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// Explicit C-heap memory management
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
8325
cc62dbe71e6a 7018849: 7017124 fix broke VM build on some platforms
kvn
parents: 8320
diff changeset
    36
#ifndef PRODUCT
8320
544210b4dd48 7017124: Fix some VM stats to avoid 32-bit overflow
kvn
parents: 7397
diff changeset
    37
// Increments unsigned long value for statistics (not atomic on MP).
544210b4dd48 7017124: Fix some VM stats to avoid 32-bit overflow
kvn
parents: 7397
diff changeset
    38
inline void inc_stat_counter(volatile julong* dest, julong add_value) {
8325
cc62dbe71e6a 7018849: 7017124 fix broke VM build on some platforms
kvn
parents: 8320
diff changeset
    39
#if defined(SPARC) || defined(X86)
cc62dbe71e6a 7018849: 7017124 fix broke VM build on some platforms
kvn
parents: 8320
diff changeset
    40
  // Sparc and X86 have atomic jlong (8 bytes) instructions
48955
e22914003cf0 8194691: Cleanup unnecessary casts in Atomic/OrderAccess uses
kbarrett
parents: 48859
diff changeset
    41
  julong value = Atomic::load(dest);
8320
544210b4dd48 7017124: Fix some VM stats to avoid 32-bit overflow
kvn
parents: 7397
diff changeset
    42
  value += add_value;
48955
e22914003cf0 8194691: Cleanup unnecessary casts in Atomic/OrderAccess uses
kbarrett
parents: 48859
diff changeset
    43
  Atomic::store(value, dest);
8325
cc62dbe71e6a 7018849: 7017124 fix broke VM build on some platforms
kvn
parents: 8320
diff changeset
    44
#else
cc62dbe71e6a 7018849: 7017124 fix broke VM build on some platforms
kvn
parents: 8320
diff changeset
    45
  // possible word-tearing during load/store
cc62dbe71e6a 7018849: 7017124 fix broke VM build on some platforms
kvn
parents: 8320
diff changeset
    46
  *dest += add_value;
cc62dbe71e6a 7018849: 7017124 fix broke VM build on some platforms
kvn
parents: 8320
diff changeset
    47
#endif
8320
544210b4dd48 7017124: Fix some VM stats to avoid 32-bit overflow
kvn
parents: 7397
diff changeset
    48
}
8325
cc62dbe71e6a 7018849: 7017124 fix broke VM build on some platforms
kvn
parents: 8320
diff changeset
    49
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
46704
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
    51
template <class E>
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
    52
size_t MmapArrayAllocator<E>::size_for(size_t length) {
37057
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
    53
  size_t size = length * sizeof(E);
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
    54
  int alignment = os::vm_allocation_granularity();
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 41176
diff changeset
    55
  return align_up(size, alignment);
37057
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
    56
}
23545
2c14fb03a06d 8037959: BitMap::resize frees old map before copying memory if !in_resource_area
mgerdin
parents: 19696
diff changeset
    57
46704
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
    58
template <class E>
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
    59
E* MmapArrayAllocator<E>::allocate_or_null(size_t length, MEMFLAGS flags) {
41176
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 40655
diff changeset
    60
  size_t size = size_for(length);
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 40655
diff changeset
    61
  int alignment = os::vm_allocation_granularity();
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 40655
diff changeset
    62
46704
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
    63
  char* addr = os::reserve_memory(size, NULL, alignment, flags);
41176
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 40655
diff changeset
    64
  if (addr == NULL) {
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 40655
diff changeset
    65
    return NULL;
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 40655
diff changeset
    66
  }
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 40655
diff changeset
    67
48532
a53f30471b2d 8195094: Fix type-O in "8159422: Very high Concurrent Mark mark stack contention"
goetz
parents: 47216
diff changeset
    68
  if (os::commit_memory(addr, size, !ExecMem)) {
41176
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 40655
diff changeset
    69
    return (E*)addr;
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 40655
diff changeset
    70
  } else {
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 40655
diff changeset
    71
    os::release_memory(addr, size);
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 40655
diff changeset
    72
    return NULL;
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 40655
diff changeset
    73
  }
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 40655
diff changeset
    74
}
ff9f64534cff 8159422: Very high Concurrent Mark mark stack contention
tschatzl
parents: 40655
diff changeset
    75
46704
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
    76
template <class E>
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
    77
E* MmapArrayAllocator<E>::allocate(size_t length, MEMFLAGS flags) {
37096
42437cf54027 8151534: Refactor ArrayAllocator for easier reuse
stefank
parents: 37057
diff changeset
    78
  size_t size = size_for(length);
23545
2c14fb03a06d 8037959: BitMap::resize frees old map before copying memory if !in_resource_area
mgerdin
parents: 19696
diff changeset
    79
  int alignment = os::vm_allocation_granularity();
2c14fb03a06d 8037959: BitMap::resize frees old map before copying memory if !in_resource_area
mgerdin
parents: 19696
diff changeset
    80
46704
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
    81
  char* addr = os::reserve_memory(size, NULL, alignment, flags);
23545
2c14fb03a06d 8037959: BitMap::resize frees old map before copying memory if !in_resource_area
mgerdin
parents: 19696
diff changeset
    82
  if (addr == NULL) {
2c14fb03a06d 8037959: BitMap::resize frees old map before copying memory if !in_resource_area
mgerdin
parents: 19696
diff changeset
    83
    vm_exit_out_of_memory(size, OOM_MMAP_ERROR, "Allocator (reserve)");
2c14fb03a06d 8037959: BitMap::resize frees old map before copying memory if !in_resource_area
mgerdin
parents: 19696
diff changeset
    84
  }
2c14fb03a06d 8037959: BitMap::resize frees old map before copying memory if !in_resource_area
mgerdin
parents: 19696
diff changeset
    85
2c14fb03a06d 8037959: BitMap::resize frees old map before copying memory if !in_resource_area
mgerdin
parents: 19696
diff changeset
    86
  os::commit_memory_or_exit(addr, size, !ExecMem, "Allocator (commit)");
37057
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
    87
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
    88
  return (E*)addr;
23545
2c14fb03a06d 8037959: BitMap::resize frees old map before copying memory if !in_resource_area
mgerdin
parents: 19696
diff changeset
    89
}
2c14fb03a06d 8037959: BitMap::resize frees old map before copying memory if !in_resource_area
mgerdin
parents: 19696
diff changeset
    90
46704
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
    91
template <class E>
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
    92
void MmapArrayAllocator<E>::free(E* addr, size_t length) {
37096
42437cf54027 8151534: Refactor ArrayAllocator for easier reuse
stefank
parents: 37057
diff changeset
    93
  bool result = os::release_memory((char*)addr, size_for(length));
42437cf54027 8151534: Refactor ArrayAllocator for easier reuse
stefank
parents: 37057
diff changeset
    94
  assert(result, "Failed to release memory");
42437cf54027 8151534: Refactor ArrayAllocator for easier reuse
stefank
parents: 37057
diff changeset
    95
}
42437cf54027 8151534: Refactor ArrayAllocator for easier reuse
stefank
parents: 37057
diff changeset
    96
46704
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
    97
template <class E>
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
    98
size_t MallocArrayAllocator<E>::size_for(size_t length) {
37096
42437cf54027 8151534: Refactor ArrayAllocator for easier reuse
stefank
parents: 37057
diff changeset
    99
  return length * sizeof(E);
42437cf54027 8151534: Refactor ArrayAllocator for easier reuse
stefank
parents: 37057
diff changeset
   100
}
42437cf54027 8151534: Refactor ArrayAllocator for easier reuse
stefank
parents: 37057
diff changeset
   101
46704
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   102
template <class E>
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   103
E* MallocArrayAllocator<E>::allocate(size_t length, MEMFLAGS flags) {
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   104
  return (E*)AllocateHeap(size_for(length), flags);
37096
42437cf54027 8151534: Refactor ArrayAllocator for easier reuse
stefank
parents: 37057
diff changeset
   105
}
42437cf54027 8151534: Refactor ArrayAllocator for easier reuse
stefank
parents: 37057
diff changeset
   106
46704
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   107
template<class E>
49590
66c32f2a7f10 8200111: MallocArrayAllocator::free should not take a length parameter
stefank
parents: 49465
diff changeset
   108
void MallocArrayAllocator<E>::free(E* addr) {
37096
42437cf54027 8151534: Refactor ArrayAllocator for easier reuse
stefank
parents: 37057
diff changeset
   109
  FreeHeap(addr);
42437cf54027 8151534: Refactor ArrayAllocator for easier reuse
stefank
parents: 37057
diff changeset
   110
}
42437cf54027 8151534: Refactor ArrayAllocator for easier reuse
stefank
parents: 37057
diff changeset
   111
46704
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   112
template <class E>
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   113
bool ArrayAllocator<E>::should_use_malloc(size_t length) {
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   114
  return MallocArrayAllocator<E>::size_for(length) < ArrayAllocatorMallocLimit;
37096
42437cf54027 8151534: Refactor ArrayAllocator for easier reuse
stefank
parents: 37057
diff changeset
   115
}
42437cf54027 8151534: Refactor ArrayAllocator for easier reuse
stefank
parents: 37057
diff changeset
   116
46704
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   117
template <class E>
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   118
E* ArrayAllocator<E>::allocate_malloc(size_t length, MEMFLAGS flags) {
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   119
  return MallocArrayAllocator<E>::allocate(length, flags);
37096
42437cf54027 8151534: Refactor ArrayAllocator for easier reuse
stefank
parents: 37057
diff changeset
   120
}
42437cf54027 8151534: Refactor ArrayAllocator for easier reuse
stefank
parents: 37057
diff changeset
   121
46704
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   122
template <class E>
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   123
E* ArrayAllocator<E>::allocate_mmap(size_t length, MEMFLAGS flags) {
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   124
  return MmapArrayAllocator<E>::allocate(length, flags);
37096
42437cf54027 8151534: Refactor ArrayAllocator for easier reuse
stefank
parents: 37057
diff changeset
   125
}
42437cf54027 8151534: Refactor ArrayAllocator for easier reuse
stefank
parents: 37057
diff changeset
   126
46704
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   127
template <class E>
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   128
E* ArrayAllocator<E>::allocate(size_t length, MEMFLAGS flags) {
37057
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
   129
  if (should_use_malloc(length)) {
46704
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   130
    return allocate_malloc(length, flags);
37057
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
   131
  }
16682
4e30a46f6b76 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 15855
diff changeset
   132
46704
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   133
  return allocate_mmap(length, flags);
16682
4e30a46f6b76 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 15855
diff changeset
   134
}
4e30a46f6b76 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 15855
diff changeset
   135
46704
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   136
template <class E>
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   137
E* ArrayAllocator<E>::reallocate(E* old_addr, size_t old_length, size_t new_length, MEMFLAGS flags) {
37057
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
   138
  E* new_addr = (new_length > 0)
46704
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   139
      ? allocate(new_length, flags)
37057
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
   140
      : NULL;
23545
2c14fb03a06d 8037959: BitMap::resize frees old map before copying memory if !in_resource_area
mgerdin
parents: 19696
diff changeset
   141
37057
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
   142
  if (new_addr != NULL && old_addr != NULL) {
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
   143
    memcpy(new_addr, old_addr, MIN2(old_length, new_length) * sizeof(E));
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
   144
  }
23545
2c14fb03a06d 8037959: BitMap::resize frees old map before copying memory if !in_resource_area
mgerdin
parents: 19696
diff changeset
   145
37057
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
   146
  if (old_addr != NULL) {
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
   147
    free(old_addr, old_length);
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
   148
  }
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
   149
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
   150
  return new_addr;
23545
2c14fb03a06d 8037959: BitMap::resize frees old map before copying memory if !in_resource_area
mgerdin
parents: 19696
diff changeset
   151
}
2c14fb03a06d 8037959: BitMap::resize frees old map before copying memory if !in_resource_area
mgerdin
parents: 19696
diff changeset
   152
46704
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   153
template<class E>
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   154
void ArrayAllocator<E>::free_malloc(E* addr, size_t length) {
49590
66c32f2a7f10 8200111: MallocArrayAllocator::free should not take a length parameter
stefank
parents: 49465
diff changeset
   155
  MallocArrayAllocator<E>::free(addr);
37057
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
   156
}
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
   157
46704
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   158
template<class E>
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   159
void ArrayAllocator<E>::free_mmap(E* addr, size_t length) {
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   160
  MmapArrayAllocator<E>::free(addr, length);
37057
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
   161
}
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
   162
46704
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   163
template<class E>
211b3f6b75ef 8182169: ArrayAllocator should take MEMFLAGS as regular parameter
kbarrett
parents: 46625
diff changeset
   164
void ArrayAllocator<E>::free(E* addr, size_t length) {
37057
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
   165
  if (addr != NULL) {
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
   166
    if (should_use_malloc(length)) {
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
   167
      free_malloc(addr, length);
16682
4e30a46f6b76 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 15855
diff changeset
   168
    } else {
37057
03b3e1870228 8151436: Leaner ArrayAllocator and BitMaps
stefank
parents: 30293
diff changeset
   169
      free_mmap(addr, length);
16682
4e30a46f6b76 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 15855
diff changeset
   170
    }
4e30a46f6b76 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 15855
diff changeset
   171
  }
4e30a46f6b76 7197666: java -d64 -version core dumps in a box with lots of memory
brutisso
parents: 15855
diff changeset
   172
}
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8325
diff changeset
   173
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   174
#endif // SHARE_VM_MEMORY_ALLOCATION_INLINE_HPP