comparison src/share/vm/memory/allocation.hpp @ 12355:cefad50507d8

Merge with hs25-b53
author Gilles Duboscq <duboscq@ssw.jku.at>
date Fri, 11 Oct 2013 10:38:03 +0200
parents 6b0fd0964b87 9758d9f36299
children d8041d695d19
comparison
equal deleted inserted replaced
12058:ccb4f2af2319 12355:cefad50507d8
202 202
203 203
204 204
205 template <MEMFLAGS F> class CHeapObj ALLOCATION_SUPER_CLASS_SPEC { 205 template <MEMFLAGS F> class CHeapObj ALLOCATION_SUPER_CLASS_SPEC {
206 public: 206 public:
207 _NOINLINE_ void* operator new(size_t size, address caller_pc = 0); 207 _NOINLINE_ void* operator new(size_t size, address caller_pc = 0) throw();
208 _NOINLINE_ void* operator new (size_t size, const std::nothrow_t& nothrow_constant, 208 _NOINLINE_ void* operator new (size_t size, const std::nothrow_t& nothrow_constant,
209 address caller_pc = 0); 209 address caller_pc = 0) throw();
210 _NOINLINE_ void* operator new [](size_t size, address caller_pc = 0); 210 _NOINLINE_ void* operator new [](size_t size, address caller_pc = 0) throw();
211 _NOINLINE_ void* operator new [](size_t size, const std::nothrow_t& nothrow_constant, 211 _NOINLINE_ void* operator new [](size_t size, const std::nothrow_t& nothrow_constant,
212 address caller_pc = 0); 212 address caller_pc = 0) throw();
213 void operator delete(void* p); 213 void operator delete(void* p);
214 void operator delete [] (void* p); 214 void operator delete [] (void* p);
215 }; 215 };
216 216
217 // Base class for objects allocated on the stack only. 217 // Base class for objects allocated on the stack only.
218 // Calling new or delete will result in fatal error. 218 // Calling new or delete will result in fatal error.
219 219
220 class StackObj ALLOCATION_SUPER_CLASS_SPEC { 220 class StackObj ALLOCATION_SUPER_CLASS_SPEC {
221 private: 221 private:
222 void* operator new(size_t size); 222 void* operator new(size_t size) throw();
223 void operator delete(void* p); 223 void operator delete(void* p);
224 void* operator new [](size_t size); 224 void* operator new [](size_t size) throw();
225 void operator delete [](void* p); 225 void operator delete [](void* p);
226 }; 226 };
227 227
228 // Base class for objects used as value objects. 228 // Base class for objects used as value objects.
229 // Calling new or delete will result in fatal error. 229 // Calling new or delete will result in fatal error.
243 // With gcc and possible other compilers the VALUE_OBJ_CLASS_SPEC can 243 // With gcc and possible other compilers the VALUE_OBJ_CLASS_SPEC can
244 // be defined as a an empty string "". 244 // be defined as a an empty string "".
245 // 245 //
246 class _ValueObj { 246 class _ValueObj {
247 private: 247 private:
248 void* operator new(size_t size); 248 void* operator new(size_t size) throw();
249 void operator delete(void* p); 249 void operator delete(void* p);
250 void* operator new [](size_t size); 250 void* operator new [](size_t size) throw();
251 void operator delete [](void* p); 251 void operator delete [](void* p);
252 }; 252 };
253 253
254 254
255 // Base class for objects stored in Metaspace. 255 // Base class for objects stored in Metaspace.
314 } 314 }
315 } 315 }
316 316
317 void* operator new(size_t size, ClassLoaderData* loader_data, 317 void* operator new(size_t size, ClassLoaderData* loader_data,
318 size_t word_size, bool read_only, 318 size_t word_size, bool read_only,
319 Type type, Thread* thread); 319 Type type, Thread* thread) throw();
320 // can't use TRAPS from this header file. 320 // can't use TRAPS from this header file.
321 void operator delete(void* p) { ShouldNotCallThis(); } 321 void operator delete(void* p) { ShouldNotCallThis(); }
322 }; 322 };
323 323
324 // Base class for classes that constitute name spaces. 324 // Base class for classes that constitute name spaces.
337 337
338 protected: 338 protected:
339 Chunk* _next; // Next Chunk in list 339 Chunk* _next; // Next Chunk in list
340 const size_t _len; // Size of this Chunk 340 const size_t _len; // Size of this Chunk
341 public: 341 public:
342 void* operator new(size_t size, AllocFailType alloc_failmode, size_t length); 342 void* operator new(size_t size, AllocFailType alloc_failmode, size_t length) throw();
343 void operator delete(void* p); 343 void operator delete(void* p);
344 Chunk(size_t length); 344 Chunk(size_t length);
345 345
346 enum { 346 enum {
347 // default sizes; make them slightly smaller than 2**k to guard against 347 // default sizes; make them slightly smaller than 2**k to guard against
420 ~Arena(); 420 ~Arena();
421 void destruct_contents(); 421 void destruct_contents();
422 char* hwm() const { return _hwm; } 422 char* hwm() const { return _hwm; }
423 423
424 // new operators 424 // new operators
425 void* operator new (size_t size); 425 void* operator new (size_t size) throw();
426 void* operator new (size_t size, const std::nothrow_t& nothrow_constant); 426 void* operator new (size_t size, const std::nothrow_t& nothrow_constant) throw();
427 427
428 // dynamic memory type tagging 428 // dynamic memory type tagging
429 void* operator new(size_t size, MEMFLAGS flags); 429 void* operator new(size_t size, MEMFLAGS flags) throw();
430 void* operator new(size_t size, const std::nothrow_t& nothrow_constant, MEMFLAGS flags); 430 void* operator new(size_t size, const std::nothrow_t& nothrow_constant, MEMFLAGS flags) throw();
431 void operator delete(void* p); 431 void operator delete(void* p);
432 432
433 // Fast allocate in the arena. Common case is: pointer test + increment. 433 // Fast allocate in the arena. Common case is: pointer test + increment.
434 void* Amalloc(size_t x, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) { 434 void* Amalloc(size_t x, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
435 assert(is_power_of_2(ARENA_AMALLOC_ALIGNMENT) , "should be a power of 2"); 435 assert(is_power_of_2(ARENA_AMALLOC_ALIGNMENT) , "should be a power of 2");
581 ResourceObj& operator=(const ResourceObj& r); // default copy assignment 581 ResourceObj& operator=(const ResourceObj& r); // default copy assignment
582 ~ResourceObj(); 582 ~ResourceObj();
583 #endif // ASSERT 583 #endif // ASSERT
584 584
585 public: 585 public:
586 void* operator new(size_t size, allocation_type type, MEMFLAGS flags); 586 void* operator new(size_t size, allocation_type type, MEMFLAGS flags) throw();
587 void* operator new [](size_t size, allocation_type type, MEMFLAGS flags); 587 void* operator new [](size_t size, allocation_type type, MEMFLAGS flags) throw();
588 void* operator new(size_t size, const std::nothrow_t& nothrow_constant, 588 void* operator new(size_t size, const std::nothrow_t& nothrow_constant,
589 allocation_type type, MEMFLAGS flags); 589 allocation_type type, MEMFLAGS flags) throw();
590 void* operator new [](size_t size, const std::nothrow_t& nothrow_constant, 590 void* operator new [](size_t size, const std::nothrow_t& nothrow_constant,
591 allocation_type type, MEMFLAGS flags); 591 allocation_type type, MEMFLAGS flags) throw();
592 592
593 void* operator new(size_t size, Arena *arena) { 593 void* operator new(size_t size, Arena *arena) throw() {
594 address res = (address)arena->Amalloc(size); 594 address res = (address)arena->Amalloc(size);
595 DEBUG_ONLY(set_allocation_type(res, ARENA);) 595 DEBUG_ONLY(set_allocation_type(res, ARENA);)
596 return res; 596 return res;
597 } 597 }
598 598
599 void* operator new [](size_t size, Arena *arena) { 599 void* operator new [](size_t size, Arena *arena) throw() {
600 address res = (address)arena->Amalloc(size); 600 address res = (address)arena->Amalloc(size);
601 DEBUG_ONLY(set_allocation_type(res, ARENA);) 601 DEBUG_ONLY(set_allocation_type(res, ARENA);)
602 return res; 602 return res;
603 } 603 }
604 604
605 void* operator new(size_t size) { 605 void* operator new(size_t size) throw() {
606 address res = (address)resource_allocate_bytes(size); 606 address res = (address)resource_allocate_bytes(size);
607 DEBUG_ONLY(set_allocation_type(res, RESOURCE_AREA);) 607 DEBUG_ONLY(set_allocation_type(res, RESOURCE_AREA);)
608 return res; 608 return res;
609 } 609 }
610 610
611 void* operator new(size_t size, const std::nothrow_t& nothrow_constant) { 611 void* operator new(size_t size, const std::nothrow_t& nothrow_constant) throw() {
612 address res = (address)resource_allocate_bytes(size, AllocFailStrategy::RETURN_NULL); 612 address res = (address)resource_allocate_bytes(size, AllocFailStrategy::RETURN_NULL);
613 DEBUG_ONLY(if (res != NULL) set_allocation_type(res, RESOURCE_AREA);) 613 DEBUG_ONLY(if (res != NULL) set_allocation_type(res, RESOURCE_AREA);)
614 return res; 614 return res;
615 } 615 }
616 616
617 void* operator new [](size_t size) { 617 void* operator new [](size_t size) throw() {
618 address res = (address)resource_allocate_bytes(size); 618 address res = (address)resource_allocate_bytes(size);
619 DEBUG_ONLY(set_allocation_type(res, RESOURCE_AREA);) 619 DEBUG_ONLY(set_allocation_type(res, RESOURCE_AREA);)
620 return res; 620 return res;
621 } 621 }
622 622
623 void* operator new [](size_t size, const std::nothrow_t& nothrow_constant) { 623 void* operator new [](size_t size, const std::nothrow_t& nothrow_constant) throw() {
624 address res = (address)resource_allocate_bytes(size, AllocFailStrategy::RETURN_NULL); 624 address res = (address)resource_allocate_bytes(size, AllocFailStrategy::RETURN_NULL);
625 DEBUG_ONLY(if (res != NULL) set_allocation_type(res, RESOURCE_AREA);) 625 DEBUG_ONLY(if (res != NULL) set_allocation_type(res, RESOURCE_AREA);)
626 return res; 626 return res;
627 } 627 }
628 628
664 664
665 #define NEW_RESOURCE_OBJ_RETURN_NULL(type)\ 665 #define NEW_RESOURCE_OBJ_RETURN_NULL(type)\
666 NEW_RESOURCE_ARRAY_RETURN_NULL(type, 1) 666 NEW_RESOURCE_ARRAY_RETURN_NULL(type, 1)
667 667
668 #define NEW_C_HEAP_ARRAY3(type, size, memflags, pc, allocfail)\ 668 #define NEW_C_HEAP_ARRAY3(type, size, memflags, pc, allocfail)\
669 (type*) AllocateHeap(size * sizeof(type), memflags, pc, allocfail) 669 (type*) AllocateHeap((size) * sizeof(type), memflags, pc, allocfail)
670 670
671 #define NEW_C_HEAP_ARRAY2(type, size, memflags, pc)\ 671 #define NEW_C_HEAP_ARRAY2(type, size, memflags, pc)\
672 (type*) (AllocateHeap((size) * sizeof(type), memflags, pc)) 672 (type*) (AllocateHeap((size) * sizeof(type), memflags, pc))
673 673
674 #define NEW_C_HEAP_ARRAY(type, size, memflags)\ 674 #define NEW_C_HEAP_ARRAY(type, size, memflags)\
675 (type*) (AllocateHeap((size) * sizeof(type), memflags)) 675 (type*) (AllocateHeap((size) * sizeof(type), memflags))
676 676
677 #define NEW_C_HEAP_ARRAY2_RETURN_NULL(type, size, memflags, pc)\ 677 #define NEW_C_HEAP_ARRAY2_RETURN_NULL(type, size, memflags, pc)\
678 NEW_C_HEAP_ARRAY3(type, size, memflags, pc, AllocFailStrategy::RETURN_NULL) 678 NEW_C_HEAP_ARRAY3(type, (size), memflags, pc, AllocFailStrategy::RETURN_NULL)
679 679
680 #define NEW_C_HEAP_ARRAY_RETURN_NULL(type, size, memflags)\ 680 #define NEW_C_HEAP_ARRAY_RETURN_NULL(type, size, memflags)\
681 NEW_C_HEAP_ARRAY3(type, size, memflags, (address)0, AllocFailStrategy::RETURN_NULL) 681 NEW_C_HEAP_ARRAY3(type, (size), memflags, (address)0, AllocFailStrategy::RETURN_NULL)
682 682
683 #define REALLOC_C_HEAP_ARRAY(type, old, size, memflags)\ 683 #define REALLOC_C_HEAP_ARRAY(type, old, size, memflags)\
684 (type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags)) 684 (type*) (ReallocateHeap((char*)(old), (size) * sizeof(type), memflags))
685 685
686 #define REALLOC_C_HEAP_ARRAY_RETURN_NULL(type, old, size, memflags)\ 686 #define REALLOC_C_HEAP_ARRAY_RETURN_NULL(type, old, size, memflags)\
687 (type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags, AllocFailStrategy::RETURN_NULL)) 687 (type*) (ReallocateHeap((char*)(old), (size) * sizeof(type), memflags, AllocFailStrategy::RETURN_NULL))
688 688
689 #define FREE_C_HEAP_ARRAY(type, old, memflags) \ 689 #define FREE_C_HEAP_ARRAY(type, old, memflags) \
690 FreeHeap((char*)(old), memflags) 690 FreeHeap((char*)(old), memflags)
691 691
692 // allocate type in heap without calling ctor 692 // allocate type in heap without calling ctor