src/share/vm/memory/allocation.inline.hpp

changeset 7074
833b0f92429a
parent 5614
9758d9f36299
child 7535
7ae4e26cb1e0
child 7806
ed0067c67bd7
     1.1 --- a/src/share/vm/memory/allocation.inline.hpp	Wed Aug 27 09:36:55 2014 +0200
     1.2 +++ b/src/share/vm/memory/allocation.inline.hpp	Wed Aug 27 08:19:12 2014 -0400
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -27,6 +27,7 @@
    1.11  
    1.12  #include "runtime/atomic.inline.hpp"
    1.13  #include "runtime/os.hpp"
    1.14 +#include "services/memTracker.hpp"
    1.15  
    1.16  // Explicit C-heap memory management
    1.17  
    1.18 @@ -49,12 +50,10 @@
    1.19  #endif
    1.20  
    1.21  // allocate using malloc; will fail if no memory available
    1.22 -inline char* AllocateHeap(size_t size, MEMFLAGS flags, address pc = 0,
    1.23 +inline char* AllocateHeap(size_t size, MEMFLAGS flags,
    1.24 +    const NativeCallStack& stack,
    1.25      AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
    1.26 -  if (pc == 0) {
    1.27 -    pc = CURRENT_PC;
    1.28 -  }
    1.29 -  char* p = (char*) os::malloc(size, flags, pc);
    1.30 +  char* p = (char*) os::malloc(size, flags, stack);
    1.31    #ifdef ASSERT
    1.32    if (PrintMallocFree) trace_heap_malloc(size, "AllocateHeap", p);
    1.33    #endif
    1.34 @@ -63,10 +62,14 @@
    1.35    }
    1.36    return p;
    1.37  }
    1.38 +inline char* AllocateHeap(size_t size, MEMFLAGS flags,
    1.39 +    AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
    1.40 +  return AllocateHeap(size, flags, CURRENT_PC, alloc_failmode);
    1.41 +}
    1.42  
    1.43 -inline char* ReallocateHeap(char *old, size_t size, MEMFLAGS flags,
    1.44 +inline char* ReallocateHeap(char *old, size_t size, MEMFLAGS flag,
    1.45      AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
    1.46 -  char* p = (char*) os::realloc(old, size, flags, CURRENT_PC);
    1.47 +  char* p = (char*) os::realloc(old, size, flag, CURRENT_PC);
    1.48    #ifdef ASSERT
    1.49    if (PrintMallocFree) trace_heap_malloc(size, "ReallocateHeap", p);
    1.50    #endif
    1.51 @@ -85,8 +88,22 @@
    1.52  
    1.53  
    1.54  template <MEMFLAGS F> void* CHeapObj<F>::operator new(size_t size,
    1.55 -      address caller_pc) throw() {
    1.56 -    void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC));
    1.57 +      const NativeCallStack& stack) throw() {
    1.58 +  void* p = (void*)AllocateHeap(size, F, stack);
    1.59 +#ifdef ASSERT
    1.60 +  if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p);
    1.61 +#endif
    1.62 +  return p;
    1.63 +}
    1.64 +
    1.65 +template <MEMFLAGS F> void* CHeapObj<F>::operator new(size_t size) throw() {
    1.66 +  return CHeapObj<F>::operator new(size, CALLER_PC);
    1.67 +}
    1.68 +
    1.69 +template <MEMFLAGS F> void* CHeapObj<F>::operator new (size_t size,
    1.70 +  const std::nothrow_t&  nothrow_constant, const NativeCallStack& stack) throw() {
    1.71 +  void* p = (void*)AllocateHeap(size, F, stack,
    1.72 +      AllocFailStrategy::RETURN_NULL);
    1.73  #ifdef ASSERT
    1.74      if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p);
    1.75  #endif
    1.76 @@ -94,23 +111,28 @@
    1.77    }
    1.78  
    1.79  template <MEMFLAGS F> void* CHeapObj<F>::operator new (size_t size,
    1.80 -  const std::nothrow_t&  nothrow_constant, address caller_pc) throw() {
    1.81 -  void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC),
    1.82 -      AllocFailStrategy::RETURN_NULL);
    1.83 -#ifdef ASSERT
    1.84 -    if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p);
    1.85 -#endif
    1.86 -    return p;
    1.87 +  const std::nothrow_t& nothrow_constant) throw() {
    1.88 +  return CHeapObj<F>::operator new(size, nothrow_constant, CALLER_PC);
    1.89  }
    1.90  
    1.91  template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size,
    1.92 -      address caller_pc) throw() {
    1.93 -    return CHeapObj<F>::operator new(size, caller_pc);
    1.94 +      const NativeCallStack& stack) throw() {
    1.95 +  return CHeapObj<F>::operator new(size, stack);
    1.96 +}
    1.97 +
    1.98 +template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size)
    1.99 +  throw() {
   1.100 +  return CHeapObj<F>::operator new(size, CALLER_PC);
   1.101  }
   1.102  
   1.103  template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size,
   1.104 -  const std::nothrow_t&  nothrow_constant, address caller_pc) throw() {
   1.105 -    return CHeapObj<F>::operator new(size, nothrow_constant, caller_pc);
   1.106 +  const std::nothrow_t&  nothrow_constant, const NativeCallStack& stack) throw() {
   1.107 +  return CHeapObj<F>::operator new(size, nothrow_constant, stack);
   1.108 +}
   1.109 +
   1.110 +template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size,
   1.111 +  const std::nothrow_t& nothrow_constant) throw() {
   1.112 +  return CHeapObj<F>::operator new(size, nothrow_constant, CALLER_PC);
   1.113  }
   1.114  
   1.115  template <MEMFLAGS F> void CHeapObj<F>::operator delete(void* p){

mercurial