comparison src/share/vm/memory/allocation.hpp @ 10983:abbd5c660b48

8016105: Add complementary RETURN_NULL allocation macros in allocation.hpp Reviewed-by: sla, rbackman
author mgronlun
date Sat, 15 Jun 2013 13:17:36 +0200
parents f2110083203d
children 9f9c0a163cc5
comparison
equal deleted inserted replaced
10982:7fa28f3d3f62 10983:abbd5c660b48
633 (type*) resource_allocate_bytes((size) * sizeof(type), AllocFailStrategy::RETURN_NULL) 633 (type*) resource_allocate_bytes((size) * sizeof(type), AllocFailStrategy::RETURN_NULL)
634 634
635 #define NEW_RESOURCE_ARRAY_IN_THREAD(thread, type, size)\ 635 #define NEW_RESOURCE_ARRAY_IN_THREAD(thread, type, size)\
636 (type*) resource_allocate_bytes(thread, (size) * sizeof(type)) 636 (type*) resource_allocate_bytes(thread, (size) * sizeof(type))
637 637
638 #define NEW_RESOURCE_ARRAY_IN_THREAD_RETURN_NULL(thread, type, size)\
639 (type*) resource_allocate_bytes(thread, (size) * sizeof(type), AllocFailStrategy::RETURN_NULL)
640
638 #define REALLOC_RESOURCE_ARRAY(type, old, old_size, new_size)\ 641 #define REALLOC_RESOURCE_ARRAY(type, old, old_size, new_size)\
639 (type*) resource_reallocate_bytes((char*)(old), (old_size) * sizeof(type), (new_size) * sizeof(type) ) 642 (type*) resource_reallocate_bytes((char*)(old), (old_size) * sizeof(type), (new_size) * sizeof(type))
643
644 #define REALLOC_RESOURCE_ARRAY_RETURN_NULL(type, old, old_size, new_size)\
645 (type*) resource_reallocate_bytes((char*)(old), (old_size) * sizeof(type),\
646 (new_size) * sizeof(type), AllocFailStrategy::RETURN_NULL)
640 647
641 #define FREE_RESOURCE_ARRAY(type, old, size)\ 648 #define FREE_RESOURCE_ARRAY(type, old, size)\
642 resource_free_bytes((char*)(old), (size) * sizeof(type)) 649 resource_free_bytes((char*)(old), (size) * sizeof(type))
643 650
644 #define FREE_FAST(old)\ 651 #define FREE_FAST(old)\
645 /* nop */ 652 /* nop */
646 653
647 #define NEW_RESOURCE_OBJ(type)\ 654 #define NEW_RESOURCE_OBJ(type)\
648 NEW_RESOURCE_ARRAY(type, 1) 655 NEW_RESOURCE_ARRAY(type, 1)
649 656
657 #define NEW_RESOURCE_OBJ_RETURN_NULL(type)\
658 NEW_RESOURCE_ARRAY_RETURN_NULL(type, 1)
659
660 #define NEW_C_HEAP_ARRAY3(type, size, memflags, pc, allocfail)\
661 (type*) AllocateHeap(size * sizeof(type), memflags, pc, allocfail)
662
663 #define NEW_C_HEAP_ARRAY2(type, size, memflags, pc)\
664 (type*) (AllocateHeap((size) * sizeof(type), memflags, pc))
665
650 #define NEW_C_HEAP_ARRAY(type, size, memflags)\ 666 #define NEW_C_HEAP_ARRAY(type, size, memflags)\
651 (type*) (AllocateHeap((size) * sizeof(type), memflags)) 667 (type*) (AllocateHeap((size) * sizeof(type), memflags))
652 668
669 #define NEW_C_HEAP_ARRAY2_RETURN_NULL(type, size, memflags, pc)\
670 NEW_C_HEAP_ARRAY3(type, size, memflags, pc, AllocFailStrategy::RETURN_NULL)
671
672 #define NEW_C_HEAP_ARRAY_RETURN_NULL(type, size, memflags)\
673 NEW_C_HEAP_ARRAY3(type, size, memflags, (address)0, AllocFailStrategy::RETURN_NULL)
674
653 #define REALLOC_C_HEAP_ARRAY(type, old, size, memflags)\ 675 #define REALLOC_C_HEAP_ARRAY(type, old, size, memflags)\
654 (type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags)) 676 (type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags))
655 677
678 #define REALLOC_C_HEAP_ARRAY_RETURN_NULL(type, old, size, memflags)\
679 (type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags, AllocFailStrategy::RETURN_NULL))
680
656 #define FREE_C_HEAP_ARRAY(type, old, memflags) \ 681 #define FREE_C_HEAP_ARRAY(type, old, memflags) \
657 FreeHeap((char*)(old), memflags) 682 FreeHeap((char*)(old), memflags)
658
659 #define NEW_C_HEAP_ARRAY2(type, size, memflags, pc)\
660 (type*) (AllocateHeap((size) * sizeof(type), memflags, pc))
661
662 #define REALLOC_C_HEAP_ARRAY2(type, old, size, memflags, pc)\
663 (type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags, pc))
664
665 #define NEW_C_HEAP_ARRAY3(type, size, memflags, pc, allocfail) \
666 (type*) AllocateHeap(size * sizeof(type), memflags, pc, allocfail)
667 683
668 // allocate type in heap without calling ctor 684 // allocate type in heap without calling ctor
669 #define NEW_C_HEAP_OBJ(type, memflags)\ 685 #define NEW_C_HEAP_OBJ(type, memflags)\
670 NEW_C_HEAP_ARRAY(type, 1, memflags) 686 NEW_C_HEAP_ARRAY(type, 1, memflags)
687
688 #define NEW_C_HEAP_OBJ_RETURN_NULL(type, memflags)\
689 NEW_C_HEAP_ARRAY_RETURN_NULL(type, 1, memflags)
671 690
672 // deallocate obj of type in heap without calling dtor 691 // deallocate obj of type in heap without calling dtor
673 #define FREE_C_HEAP_OBJ(objname, memflags)\ 692 #define FREE_C_HEAP_OBJ(objname, memflags)\
674 FreeHeap((char*)objname, memflags); 693 FreeHeap((char*)objname, memflags);
675 694