Skip to content

Commit

Permalink
Assert that all allocated memory is used
Browse files Browse the repository at this point in the history
  • Loading branch information
pliden committed Oct 27, 2020
1 parent ced555a commit 0cb3a80
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/hotspot/share/gc/z/zForwardingAllocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ZForwardingAllocator {

void reset(size_t size);
size_t size() const;
bool is_full() const;

void* alloc(size_t size);
};
Expand Down
5 changes: 5 additions & 0 deletions src/hotspot/share/gc/z/zForwardingAllocator.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@
#define SHARE_GC_Z_ZFORWARDINGALLOCATOR_INLINE_HPP

#include "gc/z/zForwardingAllocator.hpp"
#include "utilities/debug.hpp"

inline size_t ZForwardingAllocator::size() const {
return _end - _start;
}

inline bool ZForwardingAllocator::is_full() const {
return _top == _end;
}

inline void* ZForwardingAllocator::alloc(size_t size) {
char* const addr = _top;
_top += size;
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/gc/z/zRelocationSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "gc/z/zRelocationSet.hpp"
#include "gc/z/zStat.hpp"
#include "memory/allocation.hpp"
#include "utilities/debug.hpp"

ZRelocationSet::ZRelocationSet() :
_allocator(),
Expand Down Expand Up @@ -62,6 +63,8 @@ void ZRelocationSet::populate(ZPage* const* small, size_t nsmall,
_forwardings[j++] = ZForwarding::alloc(&_allocator, small[i]);
}

assert(_allocator.is_full(), "Should be full");

// Update statistics
ZStatRelocation::set_at_populate_relocation_set(_allocator.size());
}
Expand Down

0 comments on commit 0cb3a80

Please sign in to comment.