8240590: Add MemRegion::destroy_array to complement introduced create_array
Reviewed-by: lkorinth, sjohanss
This commit is contained in:
parent
e7204cbc52
commit
cc83c45595
@ -269,7 +269,7 @@ G1CMRootMemRegions::G1CMRootMemRegions(uint const max_regions) :
|
|||||||
_should_abort(false) { }
|
_should_abort(false) { }
|
||||||
|
|
||||||
G1CMRootMemRegions::~G1CMRootMemRegions() {
|
G1CMRootMemRegions::~G1CMRootMemRegions() {
|
||||||
FREE_C_HEAP_ARRAY(MemRegion, _root_regions);
|
MemRegion::destroy_array(_root_regions, _max_regions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void G1CMRootMemRegions::reset() {
|
void G1CMRootMemRegions::reset() {
|
||||||
|
@ -62,8 +62,8 @@ CardTable::CardTable(MemRegion whole_heap, bool conc_scan) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
CardTable::~CardTable() {
|
CardTable::~CardTable() {
|
||||||
FREE_C_HEAP_ARRAY(MemRegion, _covered);
|
MemRegion::destroy_array(_covered, _max_covered_regions);
|
||||||
FREE_C_HEAP_ARRAY(MemRegion, _committed);
|
MemRegion::destroy_array(_committed, _max_covered_regions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardTable::initialize() {
|
void CardTable::initialize() {
|
||||||
|
@ -1782,10 +1782,11 @@ bool FileMapInfo::map_heap_data(MemRegion **heap_mem, int first,
|
|||||||
|
|
||||||
struct Cleanup {
|
struct Cleanup {
|
||||||
MemRegion* _regions;
|
MemRegion* _regions;
|
||||||
|
uint _length;
|
||||||
bool _aborted;
|
bool _aborted;
|
||||||
Cleanup(MemRegion* regions) : _regions(regions), _aborted(true) { }
|
Cleanup(MemRegion* regions, uint length) : _regions(regions), _length(length), _aborted(true) { }
|
||||||
~Cleanup() { if (_aborted) { FREE_C_HEAP_ARRAY(MemRegion, _regions); } }
|
~Cleanup() { if (_aborted) { MemRegion::destroy_array(_regions, _length); } }
|
||||||
} cleanup(regions);
|
} cleanup(regions, max);
|
||||||
|
|
||||||
FileMapRegion* si;
|
FileMapRegion* si;
|
||||||
int region_num = 0;
|
int region_num = 0;
|
||||||
|
@ -102,10 +102,20 @@ MemRegion MemRegion::minus(const MemRegion mr2) const {
|
|||||||
return MemRegion();
|
return MemRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
MemRegion* MemRegion::create_array(uint length, MEMFLAGS flags) {
|
MemRegion* MemRegion::create_array(size_t length, MEMFLAGS flags) {
|
||||||
MemRegion* result = NEW_C_HEAP_ARRAY(MemRegion, length, flags);
|
MemRegion* result = NEW_C_HEAP_ARRAY(MemRegion, length, flags);
|
||||||
for (uint i = 0; i < length; i++) {
|
for (size_t i = 0; i < length; i++) {
|
||||||
::new (&result[i]) MemRegion();
|
::new (&result[i]) MemRegion();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MemRegion::destroy_array(MemRegion* array, size_t length) {
|
||||||
|
if (array == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < length; i++) {
|
||||||
|
array[i].~MemRegion();
|
||||||
|
}
|
||||||
|
FREE_C_HEAP_ARRAY(MemRegion, array);
|
||||||
|
}
|
@ -94,7 +94,8 @@ public:
|
|||||||
bool is_empty() const { return word_size() == 0; }
|
bool is_empty() const { return word_size() == 0; }
|
||||||
|
|
||||||
// Creates and initializes an array of MemRegions of the given length.
|
// Creates and initializes an array of MemRegions of the given length.
|
||||||
static MemRegion* create_array(uint length, MEMFLAGS flags);
|
static MemRegion* create_array(size_t length, MEMFLAGS flags);
|
||||||
|
static void destroy_array(MemRegion* array, size_t length);
|
||||||
};
|
};
|
||||||
|
|
||||||
// For iteration over MemRegion's.
|
// For iteration over MemRegion's.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user