diff --git a/src/os/windows/vm/os_windows.cpp b/src/os/windows/vm/os_windows.cpp index 4434da815d0758d108147bafa53b5a1d5ee411d9..0a8034d32177353d77a0afb51117d3b723b7fe6d 100644 --- a/src/os/windows/vm/os_windows.cpp +++ b/src/os/windows/vm/os_windows.cpp @@ -3305,7 +3305,7 @@ void os::pd_start_thread(Thread* thread) { assert(ret != SYS_THREAD_ERROR, "StartThread failed"); // should propagate back } -class HighResolutionInterval : public CHeapObj { +class HighResolutionInterval { // The default timer resolution seems to be 10 milliseconds. // (Where is this written down?) // If someone wants to sleep for only a fraction of the default, diff --git a/src/share/vm/classfile/altHashing.cpp b/src/share/vm/classfile/altHashing.cpp index 8dfc3153ca43e2fe8b157d16efbcd7a1e888037f..df2c53e55015fb207ca8dc32aa7cdc4a66da0c8a 100644 --- a/src/share/vm/classfile/altHashing.cpp +++ b/src/share/vm/classfile/altHashing.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -242,8 +242,8 @@ static const juint MURMUR3_32_X86_CHECK_VALUE = 0xB0F57EE3; void AltHashing::testMurmur3_32_ByteArray() { // printf("testMurmur3_32_ByteArray\n"); - jbyte vector[256]; - jbyte hashes[4 * 256]; + jbyte* vector = new jbyte[256]; + jbyte* hashes = new jbyte[4 * 256]; for (int i = 0; i < 256; i++) { vector[i] = (jbyte) i; diff --git a/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp b/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp index c2aafb7bc203debf07202581817b6b90e892448c..e57d405e5d0beec3a49e7b21d6b97a95c8fadecf 100644 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,7 @@ ConcurrentMarkSweepPolicy::ConcurrentMarkSweepPolicy() { } void ConcurrentMarkSweepPolicy::initialize_generations() { - _generations = NEW_C_HEAP_ARRAY3(GenerationSpecPtr, number_of_generations(), mtGC, 0, AllocFailStrategy::RETURN_NULL); + _generations = new GenerationSpecPtr[number_of_generations()]; if (_generations == NULL) vm_exit_during_initialization("Unable to allocate gen spec"); diff --git a/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp b/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp index a1ea68998fe9555f416ae61626c43cfb06d5a8f7..56e94051c3abb3c2a27b2dda855e7bd88af3fbe7 100644 --- a/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp +++ b/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -282,8 +282,7 @@ OtherRegionsTable::OtherRegionsTable(HeapRegion* hr) : _fine_eviction_stride = _max_fine_entries / _fine_eviction_sample_size; } - _fine_grain_regions = NEW_C_HEAP_ARRAY3(PerRegionTablePtr, _max_fine_entries, - mtGC, 0, AllocFailStrategy::RETURN_NULL); + _fine_grain_regions = new PerRegionTablePtr[_max_fine_entries]; if (_fine_grain_regions == NULL) { vm_exit_out_of_memory(sizeof(void*)*_max_fine_entries, diff --git a/src/share/vm/memory/allocation.cpp b/src/share/vm/memory/allocation.cpp index 18f758ab9214a3c172a42b32fbb9eec113acd55c..f83eada8192eaeacec163f78079edf401e48c05e 100644 --- a/src/share/vm/memory/allocation.cpp +++ b/src/share/vm/memory/allocation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,12 +51,8 @@ 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) { @@ -85,6 +81,7 @@ void MetaspaceObj::print_address_on(outputStream* st) const { st->print(" {"INTPTR_FORMAT"}", this); } + void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flags) { address res; switch (type) { @@ -102,10 +99,6 @@ void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flag 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 @@ -125,10 +118,6 @@ void* ResourceObj::operator new(size_t size, const std::nothrow_t& nothrow_cons 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(), @@ -137,10 +126,6 @@ void ResourceObj::operator delete(void* p) { 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 @@ -375,7 +360,7 @@ class ChunkPoolCleaner : public PeriodicTask { void* Chunk::operator new(size_t requested_size, 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 arena alignment. + // to expected arean 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; @@ -684,21 +669,19 @@ void* Arena::internal_malloc_4(size_t x) { // 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 void* operator new(size_t size){ - ShouldNotReachHere(); return 0; -} - -void* operator new [](size_t size){ - ShouldNotReachHere(); return 0; -} - -void* operator new(size_t size, const std::nothrow_t& nothrow_constant){ - ShouldNotReachHere(); return 0; -} - -void* operator new [](size_t size, std::nothrow_t& nothrow_constant){ - ShouldNotReachHere(); return 0; + 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"); } +#endif void AllocatedObj::print() const { print_on(tty); } void AllocatedObj::print_value() const { print_value_on(tty); } diff --git a/src/share/vm/memory/allocation.hpp b/src/share/vm/memory/allocation.hpp index 7e5616e85603495b4739e622d6926d6a73a576a9..bc01b0135b0dbc6b693143f55ab87adc27f24a40 100644 --- a/src/share/vm/memory/allocation.hpp +++ b/src/share/vm/memory/allocation.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -86,24 +86,12 @@ typedef AllocFailStrategy::AllocFailEnum AllocFailType; // subclasses. // // The following macros and function should be used to allocate memory -// directly in the resource area or in the C-heap, The _OBJECT variants -// of the NEW_C_HEAP macros are used when a constructor and destructor -// must be invoked for the object(s) and the objects are not inherited -// from CHeapObj. The preferable way to allocate objects is using the -// new operator. -// -// WARNING: The array variant must only be used for a homogenous array -// where all objects are of the exact type specified. If subtypes are -// stored in the array then the incorrect destructor might be called. +// directly in the resource area or in the C-heap: // // NEW_RESOURCE_ARRAY(type,size) // NEW_RESOURCE_OBJ(type) // NEW_C_HEAP_ARRAY(type,size) // NEW_C_HEAP_OBJ(type) -// NEW_C_HEAP_OBJECT(type, memflags, pc, allocfail) -// NEW_C_HEAP_OBJECT_ARRAY(type, size, memflags, pc, allocfail) -// FREE_C_HEAP_OBJECT(type, objname, memflags) -// FREE_C_HEAP_OBJECT_ARRAY(type, size, arrayname, memflags) // char* AllocateHeap(size_t size, const char* name); // void FreeHeap(void* p); // @@ -207,11 +195,8 @@ template class CHeapObj ALLOCATION_SUPER_CLASS_SPEC { _NOINLINE_ void* operator new(size_t size, address caller_pc = 0); _NOINLINE_ void* operator new (size_t size, const std::nothrow_t& nothrow_constant, address caller_pc = 0); - _NOINLINE_ void* operator new [](size_t size, address caller_pc = 0); - _NOINLINE_ void* operator new [](size_t size, const std::nothrow_t& nothrow_constant, - address caller_pc = 0); + void operator delete(void* p); - void operator delete [] (void* p); }; // Base class for objects allocated on the stack only. @@ -221,8 +206,6 @@ class StackObj ALLOCATION_SUPER_CLASS_SPEC { private: void* operator new(size_t size); void operator delete(void* p); - void* operator new [](size_t size); - void operator delete [](void* p); }; // Base class for objects used as value objects. @@ -246,9 +229,7 @@ class StackObj ALLOCATION_SUPER_CLASS_SPEC { class _ValueObj { private: void* operator new(size_t size); - void operator delete(void* p); - void* operator new [](size_t size); - void operator delete [](void* p); + void operator delete(void* p); }; @@ -529,24 +510,13 @@ class ResourceObj ALLOCATION_SUPER_CLASS_SPEC { public: void* operator new(size_t size, allocation_type type, MEMFLAGS flags); - void* operator new [](size_t size, allocation_type type, MEMFLAGS flags); void* operator new(size_t size, const std::nothrow_t& nothrow_constant, allocation_type type, MEMFLAGS flags); - void* operator new [](size_t size, const std::nothrow_t& nothrow_constant, - allocation_type type, MEMFLAGS flags); - void* operator new(size_t size, Arena *arena) { address res = (address)arena->Amalloc(size); DEBUG_ONLY(set_allocation_type(res, ARENA);) return res; } - - void* operator new [](size_t size, Arena *arena) { - address res = (address)arena->Amalloc(size); - DEBUG_ONLY(set_allocation_type(res, ARENA);) - return res; - } - void* operator new(size_t size) { address res = (address)resource_allocate_bytes(size); DEBUG_ONLY(set_allocation_type(res, RESOURCE_AREA);) @@ -559,20 +529,7 @@ class ResourceObj ALLOCATION_SUPER_CLASS_SPEC { return res; } - void* operator new [](size_t size) { - address res = (address)resource_allocate_bytes(size); - DEBUG_ONLY(set_allocation_type(res, RESOURCE_AREA);) - return res; - } - - void* operator new [](size_t size, const std::nothrow_t& nothrow_constant) { - address res = (address)resource_allocate_bytes(size, AllocFailStrategy::RETURN_NULL); - DEBUG_ONLY(if (res != NULL) set_allocation_type(res, RESOURCE_AREA);) - return res; - } - void operator delete(void* p); - void operator delete [](void* p); }; // One of the following macros must be used when allocating an array @@ -603,60 +560,22 @@ class ResourceObj ALLOCATION_SUPER_CLASS_SPEC { #define REALLOC_C_HEAP_ARRAY(type, old, size, memflags)\ (type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags)) -#define FREE_C_HEAP_ARRAY(type, old, memflags) \ +#define FREE_C_HEAP_ARRAY(type,old,memflags) \ FreeHeap((char*)(old), memflags) -// allocate type in heap without calling ctor -// WARNING: type must not have virtual functions!!! There is no way to initialize vtable. #define NEW_C_HEAP_OBJ(type, memflags)\ NEW_C_HEAP_ARRAY(type, 1, memflags) + #define NEW_C_HEAP_ARRAY2(type, size, memflags, pc)\ (type*) (AllocateHeap((size) * sizeof(type), memflags, pc)) #define REALLOC_C_HEAP_ARRAY2(type, old, size, memflags, pc)\ (type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags, pc)) -#define NEW_C_HEAP_ARRAY3(type, size, memflags, pc, allocfail) \ - (type*) AllocateHeap(size * sizeof(type), memflags, pc, allocfail); - -// !!! Attention, see comments above about the usage !!! +#define NEW_C_HEAP_OBJ2(type, memflags, pc)\ + NEW_C_HEAP_ARRAY2(type, 1, memflags, pc) -// allocate type in heap and call ctor -#define NEW_C_HEAP_OBJECT(objname, type, memflags, pc, allocfail)\ - { \ - objname = (type*)AllocateHeap(sizeof(type), memflags, pc, allocfail); \ - if (objname != NULL) ::new ((void *)objname) type(); \ - } - -// allocate array of type, call ctor for every element in the array -#define NEW_C_HEAP_OBJECT_ARRAY(array_name, type, size, memflags, pc, allocfail) \ - { \ - array_name = (type*)AllocateHeap(size * sizeof(type), memflags, pc, allocfail); \ - if (array_name != NULL) { \ - for (int index = 0; index < size; index++) { \ - ::new ((void*)&array_name[index]) type(); \ - } \ - } \ - } - -// deallocate type in heap, call dtor -#define FREE_C_HEAP_OBJECT(type, objname, memflags) \ - if (objname != NULL) { \ - ((type*)objname)->~type(); \ - FREE_C_HEAP_ARRAY(type, objname, memflags); \ - } - -// deallocate array of type with size, call dtor for every element in the array -#define FREE_C_HEAP_OBJECT_ARRAY(type, array_name, size, memflags) \ - { \ - if (array_name != NULL) { \ - for (int index = 0; index < size; index++) { \ - ((type*)&array_name[index])->~type(); \ - } \ - FREE_C_HEAP_ARRAY(type, array_name, memflags); \ - } \ - } extern bool warn_new_operator; diff --git a/src/share/vm/memory/allocation.inline.hpp b/src/share/vm/memory/allocation.inline.hpp index 628b2a29e7fa8e44cc82f37f2b21bfc7a9f1296e..79bd774e358049832cb9a5284bff0d388f4c2142 100644 --- a/src/share/vm/memory/allocation.inline.hpp +++ b/src/share/vm/memory/allocation.inline.hpp @@ -82,39 +82,30 @@ inline void FreeHeap(void* p, MEMFLAGS memflags = mtInternal) { template void* CHeapObj::operator new(size_t size, address caller_pc){ - void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC)); #ifdef ASSERT + void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC)); if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p); -#endif return p; +#else + return (void *) AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC)); +#endif } template void* CHeapObj::operator new (size_t size, const std::nothrow_t& nothrow_constant, address caller_pc) { +#ifdef ASSERT void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC), AllocFailStrategy::RETURN_NULL); -#ifdef ASSERT if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p); -#endif return p; -} - -template void* CHeapObj::operator new [](size_t size, - address caller_pc){ - return CHeapObj::operator new(size, caller_pc); -} - -template void* CHeapObj::operator new [](size_t size, - const std::nothrow_t& nothrow_constant, address caller_pc) { - return CHeapObj::operator new(size, nothrow_constant, caller_pc); +#else + return (void *) AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC), + AllocFailStrategy::RETURN_NULL); +#endif } template void CHeapObj::operator delete(void* p){ - FreeHeap(p, F); -} - -template void CHeapObj::operator delete [](void* p){ - FreeHeap(p, F); + FreeHeap(p, F); } template diff --git a/src/share/vm/memory/cardTableModRefBS.cpp b/src/share/vm/memory/cardTableModRefBS.cpp index ad9a684d2b23af45162d71d7c8912f37d953419f..3c65d29a5f272ab93ece768ef9e8d170259a4570 100644 --- a/src/share/vm/memory/cardTableModRefBS.cpp +++ b/src/share/vm/memory/cardTableModRefBS.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,13 +78,17 @@ CardTableModRefBS::CardTableModRefBS(MemRegion whole_heap, assert(card_size <= 512, "card_size must be less than 512"); // why? - NEW_C_HEAP_OBJECT_ARRAY(_covered, MemRegion, max_covered_regions, mtGC, 0, AllocFailStrategy::RETURN_NULL); - NEW_C_HEAP_OBJECT_ARRAY(_committed, MemRegion, max_covered_regions, mtGC, 0, AllocFailStrategy::RETURN_NULL); - if (_covered == NULL || _committed == NULL) { + _covered = new MemRegion[max_covered_regions]; + _committed = new MemRegion[max_covered_regions]; + if (_covered == NULL || _committed == NULL) vm_exit_during_initialization("couldn't alloc card table covered region set."); + int i; + for (i = 0; i < max_covered_regions; i++) { + _covered[i].set_word_size(0); + _committed[i].set_word_size(0); } - _cur_covered_regions = 0; + const size_t rs_align = _page_size == (size_t) os::vm_page_size() ? 0 : MAX2(_page_size, (size_t) os::vm_allocation_granularity()); ReservedSpace heap_rs(_byte_map_size, rs_align, false); @@ -130,7 +134,7 @@ CardTableModRefBS::CardTableModRefBS(MemRegion whole_heap, || _lowest_non_clean_base_chunk_index == NULL || _last_LNC_resizing_collection == NULL) vm_exit_during_initialization("couldn't allocate an LNC array."); - for (int i = 0; i < max_covered_regions; i++) { + for (i = 0; i < max_covered_regions; i++) { _lowest_non_clean[i] = NULL; _lowest_non_clean_chunk_size[i] = 0; _last_LNC_resizing_collection[i] = -1; @@ -149,33 +153,6 @@ CardTableModRefBS::CardTableModRefBS(MemRegion whole_heap, } } -CardTableModRefBS::~CardTableModRefBS() { - if (_covered) { - FREE_C_HEAP_OBJECT_ARRAY(MemRegion, _covered, _max_covered_regions, mtGC); - _covered = NULL; - } - if (_committed) { - FREE_C_HEAP_OBJECT_ARRAY(MemRegion, _committed, _max_covered_regions, mtGC); - _committed = NULL; - } - if (_lowest_non_clean) { - FREE_C_HEAP_ARRAY(CardArr, _lowest_non_clean, mtGC); - _lowest_non_clean = NULL; - } - if (_lowest_non_clean_chunk_size) { - FREE_C_HEAP_ARRAY(size_t, _lowest_non_clean_chunk_size, mtGC); - _lowest_non_clean_chunk_size = NULL; - } - if (_lowest_non_clean_base_chunk_index) { - FREE_C_HEAP_ARRAY(uintptr_t, _lowest_non_clean_base_chunk_index, mtGC); - _lowest_non_clean_base_chunk_index = NULL; - } - if (_last_LNC_resizing_collection) { - FREE_C_HEAP_ARRAY(int, _last_LNC_resizing_collection, mtGC); - _last_LNC_resizing_collection = NULL; - } -} - int CardTableModRefBS::find_covering_region_by_base(HeapWord* base) { int i; for (i = 0; i < _cur_covered_regions; i++) { diff --git a/src/share/vm/memory/cardTableModRefBS.hpp b/src/share/vm/memory/cardTableModRefBS.hpp index 6b5de2a4460b30504d355d1002c3869250c01c50..69af2daa8e19fba14c50975e42afd71b852d6a7b 100644 --- a/src/share/vm/memory/cardTableModRefBS.hpp +++ b/src/share/vm/memory/cardTableModRefBS.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -280,7 +280,6 @@ public: } CardTableModRefBS(MemRegion whole_heap, int max_covered_regions); - ~CardTableModRefBS(); // *** Barrier set functions. diff --git a/src/share/vm/memory/cardTableRS.cpp b/src/share/vm/memory/cardTableRS.cpp index 7c21869945b2fce91d182917bf0dbc6e1c372884..bd1cd9dd2cd0d7123bdc65891a59656aeef7148b 100644 --- a/src/share/vm/memory/cardTableRS.cpp +++ b/src/share/vm/memory/cardTableRS.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,10 +54,9 @@ CardTableRS::CardTableRS(MemRegion whole_heap, _ct_bs = new CardTableModRefBSForCTRS(whole_heap, max_covered_regions); #endif set_bs(_ct_bs); - _last_cur_val_in_gen = NEW_C_HEAP_ARRAY3(jbyte, GenCollectedHeap::max_gens + 1, - mtGC, 0, AllocFailStrategy::RETURN_NULL); + _last_cur_val_in_gen = new jbyte[GenCollectedHeap::max_gens + 1]; if (_last_cur_val_in_gen == NULL) { - vm_exit_during_initialization("Could not create last_cur_val_in_gen array."); + vm_exit_during_initialization("Could not last_cur_val_in_gen array."); } for (int i = 0; i < GenCollectedHeap::max_gens + 1; i++) { _last_cur_val_in_gen[i] = clean_card_val(); @@ -65,16 +64,6 @@ CardTableRS::CardTableRS(MemRegion whole_heap, _ct_bs->set_CTRS(this); } -CardTableRS::~CardTableRS() { - if (_ct_bs) { - delete _ct_bs; - _ct_bs = NULL; - } - if (_last_cur_val_in_gen) { - FREE_C_HEAP_ARRAY(jbyte, _last_cur_val_in_gen, mtInternal); - } -} - void CardTableRS::resize_covered_region(MemRegion new_region) { _ct_bs->resize_covered_region(new_region); } diff --git a/src/share/vm/memory/cardTableRS.hpp b/src/share/vm/memory/cardTableRS.hpp index 234b3972db5b104daa9d2d73c298b10982a05577..7ac9e4162bd17b7b456617c857df976a3e23bdc3 100644 --- a/src/share/vm/memory/cardTableRS.hpp +++ b/src/share/vm/memory/cardTableRS.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -102,7 +102,6 @@ class CardTableRS: public GenRemSet { public: CardTableRS(MemRegion whole_heap, int max_covered_regions); - ~CardTableRS(); // *** GenRemSet functions. GenRemSet::Name rs_kind() { return GenRemSet::CardTable; } diff --git a/src/share/vm/memory/collectorPolicy.cpp b/src/share/vm/memory/collectorPolicy.cpp index 5c190b3cf2920965600d6f645dd7b11c7ba11054..a2049597af768722c78aa1069d8dd970d2c5b1a7 100644 --- a/src/share/vm/memory/collectorPolicy.cpp +++ b/src/share/vm/memory/collectorPolicy.cpp @@ -842,7 +842,7 @@ MarkSweepPolicy::MarkSweepPolicy() { } void MarkSweepPolicy::initialize_generations() { - _generations = NEW_C_HEAP_ARRAY3(GenerationSpecPtr, number_of_generations(), mtGC, 0, AllocFailStrategy::RETURN_NULL); + _generations = new GenerationSpecPtr[number_of_generations()]; if (_generations == NULL) vm_exit_during_initialization("Unable to allocate gen spec"); diff --git a/src/share/vm/opto/idealGraphPrinter.hpp b/src/share/vm/opto/idealGraphPrinter.hpp index f2892d5a9c3029eb83a37f100da1706e704e09ed..7d1863f4a2a62c67ee9cd9a642c6f8f0a310946d 100644 --- a/src/share/vm/opto/idealGraphPrinter.hpp +++ b/src/share/vm/opto/idealGraphPrinter.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,8 +41,9 @@ class Node; class InlineTree; class ciMethod; -class IdealGraphPrinter : public CHeapObj { - private: +class IdealGraphPrinter +{ +private: static const char *INDENT; static const char *TOP_ELEMENT; @@ -120,7 +121,7 @@ class IdealGraphPrinter : public CHeapObj { IdealGraphPrinter(); ~IdealGraphPrinter(); - public: +public: static void clean_up(); static IdealGraphPrinter *printer(); @@ -134,6 +135,8 @@ class IdealGraphPrinter : public CHeapObj { void print_method(Compile* compile, const char *name, int level=1, bool clear_nodes = false); void print(Compile* compile, const char *name, Node *root, int level=1, bool clear_nodes = false); void print_xml(const char *name); + + }; #endif diff --git a/src/share/vm/runtime/handles.hpp b/src/share/vm/runtime/handles.hpp index b15ed96476c4766ae41b5979e477c4a2fedb0a1a..8c643d7c20601cbb80a7f80383c57b66f281c2b4 100644 --- a/src/share/vm/runtime/handles.hpp +++ b/src/share/vm/runtime/handles.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -280,10 +280,10 @@ class HandleArea: public Arena { // If h has to be preserved, it can be converted to an oop or a local JNI handle // across the HandleMark boundary. -// The only special case for HandleMark is when a Thread is created, the first -// HandleMark of the Thread is allocated in heap. +// The base class of HandleMark should have been StackObj but we also heap allocate +// a HandleMark when a thread is created. -class HandleMark : public StackObj { +class HandleMark { private: Thread *_thread; // thread that owns this mark HandleArea *_area; // saved handle area @@ -293,6 +293,7 @@ class HandleMark : public StackObj { // Link to previous active HandleMark in thread HandleMark* _previous_handle_mark; + void initialize(Thread* thread); // common code for constructors void set_previous_handle_mark(HandleMark* mark) { _previous_handle_mark = mark; } HandleMark* previous_handle_mark() const { return _previous_handle_mark; } @@ -302,7 +303,6 @@ class HandleMark : public StackObj { HandleMark(Thread* thread) { initialize(thread); } ~HandleMark(); - void initialize(Thread* thread); // common code for constructors // Functions used by HandleMarkCleaner // called in the constructor of HandleMarkCleaner void push(); diff --git a/src/share/vm/runtime/reflectionUtils.hpp b/src/share/vm/runtime/reflectionUtils.hpp index d51b2ab7874abd7a3db52a0b038a22575add96a5..7641fa769234086b112e3b806d55068261e727f5 100644 --- a/src/share/vm/runtime/reflectionUtils.hpp +++ b/src/share/vm/runtime/reflectionUtils.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -136,10 +136,10 @@ class FieldStream : public KlassStream { } }; -class FilteredField : public CHeapObj { +class FilteredField { private: Klass* _klass; - int _field_offset; + int _field_offset; public: FilteredField(Klass* klass, int field_offset) { diff --git a/src/share/vm/runtime/synchronizer.cpp b/src/share/vm/runtime/synchronizer.cpp index da4259ea2047bf05bedbecddd69813ec81e187c4..6e28286c1a8517485aecd87c384ba9d634525a51 100644 --- a/src/share/vm/runtime/synchronizer.cpp +++ b/src/share/vm/runtime/synchronizer.cpp @@ -1012,8 +1012,7 @@ ObjectMonitor * ATTR ObjectSynchronizer::omAlloc (Thread * Self) { // Both the local and global free lists are empty -- resort to malloc(). // In the current implementation objectMonitors are TSM - immortal. assert (_BLOCKSIZE > 1, "invariant") ; - ObjectMonitor * temp; - NEW_C_HEAP_OBJECT_ARRAY(temp, ObjectMonitor, _BLOCKSIZE, mtInternal, 0, AllocFailStrategy::RETURN_NULL); + ObjectMonitor * temp = new ObjectMonitor[_BLOCKSIZE]; // NOTE: (almost) no way to recover if allocation failed. // We might be able to induce a STW safepoint and scavenge enough diff --git a/src/share/vm/runtime/thread.cpp b/src/share/vm/runtime/thread.cpp index 15ac8e2b75dbfebd10aeb771e6194e884f08fdea..cf0297de0992a5f5a9c91c327c03c60daf827dd9 100644 --- a/src/share/vm/runtime/thread.cpp +++ b/src/share/vm/runtime/thread.cpp @@ -228,8 +228,8 @@ Thread::Thread() { _oops_do_parity = 0; // the handle mark links itself to last_handle_mark - HandleMark *hm = NEW_C_HEAP_OBJ(HandleMark, mtThread); - hm->initialize(this); + new HandleMark(this); + // plain initialization debug_only(_owned_locks = NULL;) debug_only(_allow_allocation_count = 0;) @@ -352,8 +352,8 @@ Thread::~Thread() { // since the handle marks are using the handle area, we have to deallocated the root // handle mark before deallocating the thread's handle area, assert(last_handle_mark() != NULL, "check we have an element"); - FREE_C_HEAP_OBJECT(HandleMark, last_handle_mark(), mtThread); - set_last_handle_mark(NULL); + delete last_handle_mark(); + assert(last_handle_mark() == NULL, "check we have reached the end"); // It's possible we can encounter a null _ParkEvent, etc., in stillborn threads. // We NULL out the fields for good hygiene. diff --git a/src/share/vm/runtime/vmStructs.cpp b/src/share/vm/runtime/vmStructs.cpp index 429d9aca6f27389e058f12201db522a7e415c8f6..b00f6825ddd57faf8aa6c9c7c4ff6eec2b0d788a 100644 --- a/src/share/vm/runtime/vmStructs.cpp +++ b/src/share/vm/runtime/vmStructs.cpp @@ -3116,15 +3116,15 @@ static int recursiveFindType(VMTypeEntry* origtypes, const char* typeName, bool // Search for the base type by peeling off const and * size_t len = strlen(typeName); if (typeName[len-1] == '*') { - char * s = NEW_C_HEAP_ARRAY(char, len, mtInternal); + char * s = new char[len]; strncpy(s, typeName, len - 1); s[len-1] = '\0'; // tty->print_cr("checking \"%s\" for \"%s\"", s, typeName); if (recursiveFindType(origtypes, s, true) == 1) { - FREE_C_HEAP_ARRAY(char, s, mtInternal); + delete [] s; return 1; } - FREE_C_HEAP_ARRAY(char, s, mtInternal); + delete [] s; } const char* start = NULL; if (strstr(typeName, "GrowableArray<") == typeName) { @@ -3135,15 +3135,15 @@ static int recursiveFindType(VMTypeEntry* origtypes, const char* typeName, bool if (start != NULL) { const char * end = strrchr(typeName, '>'); int len = end - start + 1; - char * s = NEW_C_HEAP_ARRAY(char, len, mtInternal); + char * s = new char[len]; strncpy(s, start, len - 1); s[len-1] = '\0'; // tty->print_cr("checking \"%s\" for \"%s\"", s, typeName); if (recursiveFindType(origtypes, s, true) == 1) { - FREE_C_HEAP_ARRAY(char, s, mtInternal); + delete [] s; return 1; } - FREE_C_HEAP_ARRAY(char, s, mtInternal); + delete [] s; } if (strstr(typeName, "const ") == typeName) { const char * s = typeName + strlen("const "); diff --git a/src/share/vm/utilities/events.hpp b/src/share/vm/utilities/events.hpp index 804fe77df2dcbf3f06438d85de6394f0eb4b85d8..c2e543da9763d2a218fad642b95d03c529241469 100644 --- a/src/share/vm/utilities/events.hpp +++ b/src/share/vm/utilities/events.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,7 +69,7 @@ class EventLog : public CHeapObj { // semantics aren't appropriate. The name is used as the label of the // log when it is dumped during a crash. template class EventLogBase : public EventLog { - template class EventRecord : public CHeapObj { + template class EventRecord { public: double timestamp; Thread* thread; diff --git a/src/share/vm/utilities/quickSort.cpp b/src/share/vm/utilities/quickSort.cpp index 86c33a208a2795c94d706f8201d3d9cf1306cf65..e3cfa1efa5ed7513d77b664c1ac945c99244c848 100644 --- a/src/share/vm/utilities/quickSort.cpp +++ b/src/share/vm/utilities/quickSort.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,8 +30,6 @@ #include "runtime/os.hpp" #include "utilities/quickSort.hpp" -#include "memory/allocation.hpp" -#include "memory/allocation.inline.hpp" #include static int test_comparator(int a, int b) { @@ -189,8 +187,8 @@ void QuickSort::test_quick_sort() { // test sorting random arrays for (int i = 0; i < 1000; i++) { int length = os::random() % 100; - int* test_array = NEW_C_HEAP_ARRAY(int, length, mtInternal); - int* expected_array = NEW_C_HEAP_ARRAY(int, length, mtInternal); + int* test_array = new int[length]; + int* expected_array = new int[length]; for (int j = 0; j < length; j++) { // Choose random values, but get a chance of getting duplicates test_array[j] = os::random() % (length * 2); @@ -212,8 +210,8 @@ void QuickSort::test_quick_sort() { sort(test_array, length, test_even_odd_comparator, true); assert(compare_arrays(test_array, expected_array, length), "Sorting already sorted array changed order of elements - not idempotent"); - FREE_C_HEAP_ARRAY(int, test_array, mtInternal); - FREE_C_HEAP_ARRAY(int, expected_array, mtInternal); + delete[] test_array; + delete[] expected_array; } } diff --git a/src/share/vm/utilities/workgroup.cpp b/src/share/vm/utilities/workgroup.cpp index 59d347b04075f218030f72c37ed414bb0626a2e3..3225ccacbb82f8b5b70b1e8771f492253e93387d 100644 --- a/src/share/vm/utilities/workgroup.cpp +++ b/src/share/vm/utilities/workgroup.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -528,7 +528,7 @@ bool FreeIdSet::_safepoint; FreeIdSet::FreeIdSet(int sz, Monitor* mon) : _sz(sz), _mon(mon), _hd(0), _waiters(0), _index(-1), _claimed(0) { - _ids = NEW_C_HEAP_ARRAY(int, sz, mtInternal); + _ids = new int[sz]; for (int i = 0; i < sz; i++) _ids[i] = i+1; _ids[sz-1] = end_of_list; // end of list. if (_stat_init) { @@ -548,7 +548,6 @@ FreeIdSet::FreeIdSet(int sz, Monitor* mon) : FreeIdSet::~FreeIdSet() { _sets[_index] = NULL; - FREE_C_HEAP_ARRAY(int, _ids, mtInternal); } void FreeIdSet::set_safepoint(bool b) { diff --git a/src/share/vm/utilities/workgroup.hpp b/src/share/vm/utilities/workgroup.hpp index e1184a67972c0b7c2b9f1519fccd76f7076d0c10..6a93536246bc849952dd76ec08510bf8b2f3d11a 100644 --- a/src/share/vm/utilities/workgroup.hpp +++ b/src/share/vm/utilities/workgroup.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -494,7 +494,7 @@ public: }; // Represents a set of free small integer ids. -class FreeIdSet : public CHeapObj { +class FreeIdSet { enum { end_of_list = -1, claimed = -2