Mercurial > hg > truffle
diff src/share/vm/memory/allocation.cpp @ 11017:ce9ecec70f99
Merge
author | chegar |
---|---|
date | Thu, 23 May 2013 12:44:18 +0100 |
parents | 7ee0d5c53c78 f9be75d21404 |
children | eaf3742822ec |
line wrap: on
line diff
--- a/src/share/vm/memory/allocation.cpp Thu May 16 11:44:33 2013 +0100 +++ b/src/share/vm/memory/allocation.cpp Thu May 23 12:44:18 2013 +0100 @@ -49,10 +49,15 @@ # include "os_bsd.inline.hpp" #endif -void* StackObj::operator new(size_t size) { ShouldNotCallThis(); return 0; }; -void StackObj::operator delete(void* p) { ShouldNotCallThis(); }; -void* _ValueObj::operator new(size_t size) { ShouldNotCallThis(); return 0; }; -void _ValueObj::operator delete(void* p) { ShouldNotCallThis(); }; +void* StackObj::operator new(size_t size) { ShouldNotCallThis(); return 0; } +void StackObj::operator delete(void* p) { ShouldNotCallThis(); } +void* StackObj::operator new [](size_t size) { ShouldNotCallThis(); return 0; } +void StackObj::operator delete [](void* p) { ShouldNotCallThis(); } + +void* _ValueObj::operator new(size_t size) { ShouldNotCallThis(); return 0; } +void _ValueObj::operator delete(void* p) { ShouldNotCallThis(); } +void* _ValueObj::operator new [](size_t size) { ShouldNotCallThis(); return 0; } +void _ValueObj::operator delete [](void* p) { ShouldNotCallThis(); } void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, bool read_only, TRAPS) { @@ -81,7 +86,6 @@ st->print(" {"INTPTR_FORMAT"}", this); } - void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flags) { address res; switch (type) { @@ -99,6 +103,10 @@ return res; } +void* ResourceObj::operator new [](size_t size, allocation_type type, MEMFLAGS flags) { + return (address) operator new(size, type, flags); +} + void* ResourceObj::operator new(size_t size, const std::nothrow_t& nothrow_constant, allocation_type type, MEMFLAGS flags) { //should only call this with std::nothrow, use other operator new() otherwise @@ -118,6 +126,10 @@ return res; } +void* ResourceObj::operator new [](size_t size, const std::nothrow_t& nothrow_constant, + allocation_type type, MEMFLAGS flags) { + return (address)operator new(size, nothrow_constant, type, flags); +} void ResourceObj::operator delete(void* p) { assert(((ResourceObj *)p)->allocated_on_C_heap(), @@ -126,6 +138,10 @@ FreeHeap(p); } +void ResourceObj::operator delete [](void* p) { + operator delete(p); +} + #ifdef ASSERT void ResourceObj::set_allocation_type(address res, allocation_type type) { // Set allocation type in the resource object @@ -215,8 +231,6 @@ tty->print_cr("Heap free " INTPTR_FORMAT, p); } -bool warn_new_operator = false; // see vm_main - //-------------------------------------------------------------------------------------- // ChunkPool implementation @@ -360,7 +374,7 @@ void* Chunk::operator new (size_t requested_size, AllocFailType alloc_failmode, size_t length) { // requested_size is equal to sizeof(Chunk) but in order for the arena // allocations to come out aligned as expected the size must be aligned - // to expected arean alignment. + // to expected arena alignment. // expect requested_size but if sizeof(Chunk) doesn't match isn't proper size we must align it. assert(ARENA_ALIGN(requested_size) == aligned_overhead_size(), "Bad alignment"); size_t bytes = ARENA_ALIGN(requested_size) + length; @@ -667,19 +681,40 @@ // a memory leak. Use CHeapObj as the base class of such objects to make it explicit // that they're allocated on the C heap. // Commented out in product version to avoid conflicts with third-party C++ native code. -// %% note this is causing a problem on solaris debug build. the global -// new is being called from jdk source and causing data corruption. -// src/share/native/sun/awt/font/fontmanager/textcache/hsMemory.cpp::hsSoftNew -// define CATCH_OPERATOR_NEW_USAGE if you want to use this. -#ifdef CATCH_OPERATOR_NEW_USAGE +// On certain platforms, such as Mac OS X (Darwin), in debug version, new is being called +// from jdk source and causing data corruption. Such as +// Java_sun_security_ec_ECKeyPairGenerator_generateECKeyPair +// define ALLOW_OPERATOR_NEW_USAGE for platform on which global operator new allowed. +// +#ifndef ALLOW_OPERATOR_NEW_USAGE void* operator new(size_t size){ - static bool warned = false; - if (!warned && warn_new_operator) - warning("should not call global (default) operator new"); - warned = true; - return (void *) AllocateHeap(size, "global operator new"); + assert(false, "Should not call global operator new"); + return 0; +} + +void* operator new [](size_t size){ + assert(false, "Should not call global operator new[]"); + return 0; +} + +void* operator new(size_t size, const std::nothrow_t& nothrow_constant){ + assert(false, "Should not call global operator new"); + return 0; } -#endif + +void* operator new [](size_t size, std::nothrow_t& nothrow_constant){ + assert(false, "Should not call global operator new[]"); + return 0; +} + +void operator delete(void* p) { + assert(false, "Should not call global delete"); +} + +void operator delete [](void* p) { + assert(false, "Should not call global delete []"); +} +#endif // ALLOW_OPERATOR_NEW_USAGE void AllocatedObj::print() const { print_on(tty); } void AllocatedObj::print_value() const { print_value_on(tty); }