8297718: Make NMT free:ing protocol more granular

Reviewed-by: stuefe, gziemski
This commit is contained in:
Johan Sjölen 2022-12-08 12:32:59 +00:00
parent fbe7b00738
commit 165dcdd27d
7 changed files with 72 additions and 25 deletions

View file

@ -88,7 +88,7 @@ class outputStream;
*/
class MallocHeader {
NONCOPYABLE(MallocHeader);
NOT_LP64(uint32_t _alt_canary);
const size_t _size;
const uint32_t _mst_marker;
@ -115,6 +115,12 @@ class MallocHeader {
void set_footer(uint16_t v) { footer_address()[0] = v >> 8; footer_address()[1] = (uint8_t)v; }
public:
// Contains all of the necessary data to to deaccount block with NMT.
struct FreeInfo {
const size_t size;
const MEMFLAGS flags;
const uint32_t mst_marker;
};
inline MallocHeader(size_t size, MEMFLAGS flags, uint32_t mst_marker);
@ -123,7 +129,12 @@ class MallocHeader {
inline uint32_t mst_marker() const { return _mst_marker; }
bool get_stack(NativeCallStack& stack) const;
// Return the necessary data to deaccount the block with NMT.
FreeInfo free_info() {
return FreeInfo{this->size(), this->flags(), this->mst_marker()};
}
inline void mark_block_as_dead();
inline void revive();
// If block is broken, fill in a short descriptive text in out,
// an option pointer to the corruption in p_corruption, and return false.