< prev index next >

src/share/vm/memory/allocation.cpp

Print this page
rev 9067 : 8139040: Fix initializations before ShouldNotReachHere()


  49 void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data,
  50                                  size_t word_size, bool read_only,
  51                                  MetaspaceObj::Type type, TRAPS) throw() {
  52   // Klass has it's own operator new
  53   return Metaspace::allocate(loader_data, word_size, read_only, type, THREAD);
  54 }
  55 
  56 bool MetaspaceObj::is_shared() const {
  57   return MetaspaceShared::is_in_shared_space(this);
  58 }
  59 
  60 bool MetaspaceObj::is_metaspace_object() const {
  61   return Metaspace::contains((void*)this);
  62 }
  63 
  64 void MetaspaceObj::print_address_on(outputStream* st) const {
  65   st->print(" {" INTPTR_FORMAT "}", p2i(this));
  66 }
  67 
  68 void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flags) throw() {
  69   address res;
  70   switch (type) {
  71    case C_HEAP:
  72     res = (address)AllocateHeap(size, flags, CALLER_PC);
  73     DEBUG_ONLY(set_allocation_type(res, C_HEAP);)
  74     break;
  75    case RESOURCE_AREA:
  76     // new(size) sets allocation type RESOURCE_AREA.
  77     res = (address)operator new(size);
  78     break;
  79    default:
  80     ShouldNotReachHere();
  81   }
  82   return res;
  83 }
  84 
  85 void* ResourceObj::operator new [](size_t size, allocation_type type, MEMFLAGS flags) throw() {
  86   return (address) operator new(size, type, flags);
  87 }
  88 
  89 void* ResourceObj::operator new(size_t size, const std::nothrow_t&  nothrow_constant,
  90     allocation_type type, MEMFLAGS flags) throw() {
  91   //should only call this with std::nothrow, use other operator new() otherwise
  92   address res;
  93   switch (type) {
  94    case C_HEAP:
  95     res = (address)AllocateHeap(size, flags, CALLER_PC, AllocFailStrategy::RETURN_NULL);
  96     DEBUG_ONLY(if (res!= NULL) set_allocation_type(res, C_HEAP);)
  97     break;
  98    case RESOURCE_AREA:
  99     // new(size) sets allocation type RESOURCE_AREA.
 100     res = (address)operator new(size, std::nothrow);
 101     break;
 102    default:
 103     ShouldNotReachHere();
 104   }
 105   return res;
 106 }
 107 
 108 void* ResourceObj::operator new [](size_t size, const std::nothrow_t&  nothrow_constant,
 109     allocation_type type, MEMFLAGS flags) throw() {
 110   return (address)operator new(size, nothrow_constant, type, flags);
 111 }
 112 




  49 void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data,
  50                                  size_t word_size, bool read_only,
  51                                  MetaspaceObj::Type type, TRAPS) throw() {
  52   // Klass has it's own operator new
  53   return Metaspace::allocate(loader_data, word_size, read_only, type, THREAD);
  54 }
  55 
  56 bool MetaspaceObj::is_shared() const {
  57   return MetaspaceShared::is_in_shared_space(this);
  58 }
  59 
  60 bool MetaspaceObj::is_metaspace_object() const {
  61   return Metaspace::contains((void*)this);
  62 }
  63 
  64 void MetaspaceObj::print_address_on(outputStream* st) const {
  65   st->print(" {" INTPTR_FORMAT "}", p2i(this));
  66 }
  67 
  68 void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flags) throw() {
  69   address res = NULL;
  70   switch (type) {
  71    case C_HEAP:
  72     res = (address)AllocateHeap(size, flags, CALLER_PC);
  73     DEBUG_ONLY(set_allocation_type(res, C_HEAP);)
  74     break;
  75    case RESOURCE_AREA:
  76     // new(size) sets allocation type RESOURCE_AREA.
  77     res = (address)operator new(size);
  78     break;
  79    default:
  80     ShouldNotReachHere();
  81   }
  82   return res;
  83 }
  84 
  85 void* ResourceObj::operator new [](size_t size, allocation_type type, MEMFLAGS flags) throw() {
  86   return (address) operator new(size, type, flags);
  87 }
  88 
  89 void* ResourceObj::operator new(size_t size, const std::nothrow_t&  nothrow_constant,
  90     allocation_type type, MEMFLAGS flags) throw() {
  91   // should only call this with std::nothrow, use other operator new() otherwise
  92   address res = NULL;
  93   switch (type) {
  94    case C_HEAP:
  95     res = (address)AllocateHeap(size, flags, CALLER_PC, AllocFailStrategy::RETURN_NULL);
  96     DEBUG_ONLY(if (res!= NULL) set_allocation_type(res, C_HEAP);)
  97     break;
  98    case RESOURCE_AREA:
  99     // new(size) sets allocation type RESOURCE_AREA.
 100     res = (address)operator new(size, std::nothrow);
 101     break;
 102    default:
 103     ShouldNotReachHere();
 104   }
 105   return res;
 106 }
 107 
 108 void* ResourceObj::operator new [](size_t size, const std::nothrow_t&  nothrow_constant,
 109     allocation_type type, MEMFLAGS flags) throw() {
 110   return (address)operator new(size, nothrow_constant, type, flags);
 111 }
 112 


< prev index next >