comparison src/share/vm/memory/allocation.cpp @ 12146:9758d9f36299

8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced Summary: declare all user-defined operator new()s within Hotspot code with the empty throw() exception specification Reviewed-by: coleenp, twisti, dholmes, hseigel, dcubed, kvn, ccheung Contributed-by: lois.foltan@oracle.com
author coleenp
date Thu, 29 Aug 2013 18:56:29 -0400
parents cf9d71d3e474
children ce86c36b8921 183bd5c00828 2b8e28fdf503
comparison
equal deleted inserted replaced
12145:cef1e56a4d88 12146:9758d9f36299
47 #endif 47 #endif
48 #ifdef TARGET_OS_FAMILY_bsd 48 #ifdef TARGET_OS_FAMILY_bsd
49 # include "os_bsd.inline.hpp" 49 # include "os_bsd.inline.hpp"
50 #endif 50 #endif
51 51
52 void* StackObj::operator new(size_t size) { ShouldNotCallThis(); return 0; } 52 void* StackObj::operator new(size_t size) throw() { ShouldNotCallThis(); return 0; }
53 void StackObj::operator delete(void* p) { ShouldNotCallThis(); } 53 void StackObj::operator delete(void* p) { ShouldNotCallThis(); }
54 void* StackObj::operator new [](size_t size) { ShouldNotCallThis(); return 0; } 54 void* StackObj::operator new [](size_t size) throw() { ShouldNotCallThis(); return 0; }
55 void StackObj::operator delete [](void* p) { ShouldNotCallThis(); } 55 void StackObj::operator delete [](void* p) { ShouldNotCallThis(); }
56 56
57 void* _ValueObj::operator new(size_t size) { ShouldNotCallThis(); return 0; } 57 void* _ValueObj::operator new(size_t size) throw() { ShouldNotCallThis(); return 0; }
58 void _ValueObj::operator delete(void* p) { ShouldNotCallThis(); } 58 void _ValueObj::operator delete(void* p) { ShouldNotCallThis(); }
59 void* _ValueObj::operator new [](size_t size) { ShouldNotCallThis(); return 0; } 59 void* _ValueObj::operator new [](size_t size) throw() { ShouldNotCallThis(); return 0; }
60 void _ValueObj::operator delete [](void* p) { ShouldNotCallThis(); } 60 void _ValueObj::operator delete [](void* p) { ShouldNotCallThis(); }
61 61
62 void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data, 62 void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data,
63 size_t word_size, bool read_only, 63 size_t word_size, bool read_only,
64 MetaspaceObj::Type type, TRAPS) { 64 MetaspaceObj::Type type, TRAPS) throw() {
65 // Klass has it's own operator new 65 // Klass has it's own operator new
66 return Metaspace::allocate(loader_data, word_size, read_only, 66 return Metaspace::allocate(loader_data, word_size, read_only,
67 type, CHECK_NULL); 67 type, CHECK_NULL);
68 } 68 }
69 69
78 78
79 void MetaspaceObj::print_address_on(outputStream* st) const { 79 void MetaspaceObj::print_address_on(outputStream* st) const {
80 st->print(" {"INTPTR_FORMAT"}", this); 80 st->print(" {"INTPTR_FORMAT"}", this);
81 } 81 }
82 82
83 void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flags) { 83 void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flags) throw() {
84 address res; 84 address res;
85 switch (type) { 85 switch (type) {
86 case C_HEAP: 86 case C_HEAP:
87 res = (address)AllocateHeap(size, flags, CALLER_PC); 87 res = (address)AllocateHeap(size, flags, CALLER_PC);
88 DEBUG_ONLY(set_allocation_type(res, C_HEAP);) 88 DEBUG_ONLY(set_allocation_type(res, C_HEAP);)
95 ShouldNotReachHere(); 95 ShouldNotReachHere();
96 } 96 }
97 return res; 97 return res;
98 } 98 }
99 99
100 void* ResourceObj::operator new [](size_t size, allocation_type type, MEMFLAGS flags) { 100 void* ResourceObj::operator new [](size_t size, allocation_type type, MEMFLAGS flags) throw() {
101 return (address) operator new(size, type, flags); 101 return (address) operator new(size, type, flags);
102 } 102 }
103 103
104 void* ResourceObj::operator new(size_t size, const std::nothrow_t& nothrow_constant, 104 void* ResourceObj::operator new(size_t size, const std::nothrow_t& nothrow_constant,
105 allocation_type type, MEMFLAGS flags) { 105 allocation_type type, MEMFLAGS flags) throw() {
106 //should only call this with std::nothrow, use other operator new() otherwise 106 //should only call this with std::nothrow, use other operator new() otherwise
107 address res; 107 address res;
108 switch (type) { 108 switch (type) {
109 case C_HEAP: 109 case C_HEAP:
110 res = (address)AllocateHeap(size, flags, CALLER_PC, AllocFailStrategy::RETURN_NULL); 110 res = (address)AllocateHeap(size, flags, CALLER_PC, AllocFailStrategy::RETURN_NULL);
119 } 119 }
120 return res; 120 return res;
121 } 121 }
122 122
123 void* ResourceObj::operator new [](size_t size, const std::nothrow_t& nothrow_constant, 123 void* ResourceObj::operator new [](size_t size, const std::nothrow_t& nothrow_constant,
124 allocation_type type, MEMFLAGS flags) { 124 allocation_type type, MEMFLAGS flags) throw() {
125 return (address)operator new(size, nothrow_constant, type, flags); 125 return (address)operator new(size, nothrow_constant, type, flags);
126 } 126 }
127 127
128 void ResourceObj::operator delete(void* p) { 128 void ResourceObj::operator delete(void* p) {
129 assert(((ResourceObj *)p)->allocated_on_C_heap(), 129 assert(((ResourceObj *)p)->allocated_on_C_heap(),
368 }; 368 };
369 369
370 //-------------------------------------------------------------------------------------- 370 //--------------------------------------------------------------------------------------
371 // Chunk implementation 371 // Chunk implementation
372 372
373 void* Chunk::operator new (size_t requested_size, AllocFailType alloc_failmode, size_t length) { 373 void* Chunk::operator new (size_t requested_size, AllocFailType alloc_failmode, size_t length) throw() {
374 // requested_size is equal to sizeof(Chunk) but in order for the arena 374 // requested_size is equal to sizeof(Chunk) but in order for the arena
375 // allocations to come out aligned as expected the size must be aligned 375 // allocations to come out aligned as expected the size must be aligned
376 // to expected arena alignment. 376 // to expected arena alignment.
377 // expect requested_size but if sizeof(Chunk) doesn't match isn't proper size we must align it. 377 // expect requested_size but if sizeof(Chunk) doesn't match isn't proper size we must align it.
378 assert(ARENA_ALIGN(requested_size) == aligned_overhead_size(), "Bad alignment"); 378 assert(ARENA_ALIGN(requested_size) == aligned_overhead_size(), "Bad alignment");
476 Arena::~Arena() { 476 Arena::~Arena() {
477 destruct_contents(); 477 destruct_contents();
478 NOT_PRODUCT(Atomic::dec(&_instance_count);) 478 NOT_PRODUCT(Atomic::dec(&_instance_count);)
479 } 479 }
480 480
481 void* Arena::operator new(size_t size) { 481 void* Arena::operator new(size_t size) throw() {
482 assert(false, "Use dynamic memory type binding"); 482 assert(false, "Use dynamic memory type binding");
483 return NULL; 483 return NULL;
484 } 484 }
485 485
486 void* Arena::operator new (size_t size, const std::nothrow_t& nothrow_constant) { 486 void* Arena::operator new (size_t size, const std::nothrow_t& nothrow_constant) throw() {
487 assert(false, "Use dynamic memory type binding"); 487 assert(false, "Use dynamic memory type binding");
488 return NULL; 488 return NULL;
489 } 489 }
490 490
491 // dynamic memory type binding 491 // dynamic memory type binding
492 void* Arena::operator new(size_t size, MEMFLAGS flags) { 492 void* Arena::operator new(size_t size, MEMFLAGS flags) throw() {
493 #ifdef ASSERT 493 #ifdef ASSERT
494 void* p = (void*)AllocateHeap(size, flags|otArena, CALLER_PC); 494 void* p = (void*)AllocateHeap(size, flags|otArena, CALLER_PC);
495 if (PrintMallocFree) trace_heap_malloc(size, "Arena-new", p); 495 if (PrintMallocFree) trace_heap_malloc(size, "Arena-new", p);
496 return p; 496 return p;
497 #else 497 #else
498 return (void *) AllocateHeap(size, flags|otArena, CALLER_PC); 498 return (void *) AllocateHeap(size, flags|otArena, CALLER_PC);
499 #endif 499 #endif
500 } 500 }
501 501
502 void* Arena::operator new(size_t size, const std::nothrow_t& nothrow_constant, MEMFLAGS flags) { 502 void* Arena::operator new(size_t size, const std::nothrow_t& nothrow_constant, MEMFLAGS flags) throw() {
503 #ifdef ASSERT 503 #ifdef ASSERT
504 void* p = os::malloc(size, flags|otArena, CALLER_PC); 504 void* p = os::malloc(size, flags|otArena, CALLER_PC);
505 if (PrintMallocFree) trace_heap_malloc(size, "Arena-new", p); 505 if (PrintMallocFree) trace_heap_malloc(size, "Arena-new", p);
506 return p; 506 return p;
507 #else 507 #else
686 // from jdk source and causing data corruption. Such as 686 // from jdk source and causing data corruption. Such as
687 // Java_sun_security_ec_ECKeyPairGenerator_generateECKeyPair 687 // Java_sun_security_ec_ECKeyPairGenerator_generateECKeyPair
688 // define ALLOW_OPERATOR_NEW_USAGE for platform on which global operator new allowed. 688 // define ALLOW_OPERATOR_NEW_USAGE for platform on which global operator new allowed.
689 // 689 //
690 #ifndef ALLOW_OPERATOR_NEW_USAGE 690 #ifndef ALLOW_OPERATOR_NEW_USAGE
691 void* operator new(size_t size){ 691 void* operator new(size_t size) throw() {
692 assert(false, "Should not call global operator new"); 692 assert(false, "Should not call global operator new");
693 return 0; 693 return 0;
694 } 694 }
695 695
696 void* operator new [](size_t size){ 696 void* operator new [](size_t size) throw() {
697 assert(false, "Should not call global operator new[]"); 697 assert(false, "Should not call global operator new[]");
698 return 0; 698 return 0;
699 } 699 }
700 700
701 void* operator new(size_t size, const std::nothrow_t& nothrow_constant){ 701 void* operator new(size_t size, const std::nothrow_t& nothrow_constant) throw() {
702 assert(false, "Should not call global operator new"); 702 assert(false, "Should not call global operator new");
703 return 0; 703 return 0;
704 } 704 }
705 705
706 void* operator new [](size_t size, std::nothrow_t& nothrow_constant){ 706 void* operator new [](size_t size, std::nothrow_t& nothrow_constant) throw() {
707 assert(false, "Should not call global operator new[]"); 707 assert(false, "Should not call global operator new[]");
708 return 0; 708 return 0;
709 } 709 }
710 710
711 void operator delete(void* p) { 711 void operator delete(void* p) {