added value_footprint() and global_container_footprints() BiFs

This commit is contained in:
Vern Paxson 2022-04-28 16:42:14 -07:00
parent 02771168f0
commit 16c37034de
5 changed files with 287 additions and 0 deletions

View file

@ -121,6 +121,18 @@ public:
// size depends on the Val's type.
virtual ValPtr SizeVal() const;
/**
* Returns the Val's "footprint", i.e., how many atomic (non-container)
* values it includes, either directly or indirectly.
*
* @param count_entries If true, (recursively) include in the
* footprint the count of the number of container elements as well
* as each element's footprint.
*
* @return The total footprint, optionally including element counts.
*/
virtual unsigned int Footprint(bool count_entries) const { return 1; }
// Bytes in total value object.
[[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See "
"GHI-572.")]] virtual unsigned int
@ -666,6 +678,8 @@ public:
void Describe(ODesc* d) const override;
unsigned int Footprint(bool count_entries) const override;
[[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See "
"GHI-572.")]] unsigned int
MemoryAllocation() const override;
@ -941,6 +955,8 @@ public:
// the function in the frame allowing it to capture its closure.
void InitDefaultFunc(detail::Frame* f);
unsigned int Footprint(bool count_entries) const override;
[[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See "
"GHI-572.")]] unsigned int
MemoryAllocation() const override;
@ -1367,6 +1383,8 @@ public:
}
RecordValPtr CoerceTo(RecordTypePtr other, bool allow_orphaning = false);
unsigned int Footprint(bool count_entries) const override;
[[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See "
"GHI-572.")]] unsigned int
MemoryAllocation() const override;
@ -1624,6 +1642,8 @@ public:
const auto& RawYieldType() const { return yield_type; }
const auto& RawYieldTypes() const { return yield_types; }
unsigned int Footprint(bool count_entries) const override;
protected:
/**
* Returns the element at a given index or nullptr if it does not exist.