mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 13:14:55 +00:00
Fix exclusive_size for F14NodeMap
This commit is contained in:
parent
7b5baca3b0
commit
593a1412d8
@ -8,7 +8,7 @@ definitions = '''
|
||||
folly::F14NodeMap<int, int> m1;
|
||||
folly::F14NodeMap<int, Bar> m2;
|
||||
folly::F14NodeMap<int, int> m3;
|
||||
folly::F14NodeMap<int, int> m4;
|
||||
folly::F14NodeMap<int, long> m4;
|
||||
};
|
||||
'''
|
||||
|
||||
@ -42,7 +42,7 @@ definitions = '''
|
||||
'''
|
||||
expect_json = '''[{
|
||||
"staticSize":96,
|
||||
"dynamicSize":500,
|
||||
"dynamicSize":572,
|
||||
"members":[
|
||||
{"name":"m1", "staticSize":24, "dynamicSize":72, "length":3, "capacity":3, "elementStaticSize":8},
|
||||
{
|
||||
@ -65,14 +65,31 @@ definitions = '''
|
||||
{"staticSize":8, "members":[{"name":"a"}, {"name": "b"}]}
|
||||
]},
|
||||
{"name":"m3", "staticSize":24, "dynamicSize":136, "length":7, "capacity":7, "elementStaticSize":8},
|
||||
{"name":"m4", "staticSize":24, "dynamicSize":168, "length":9, "capacity":9, "elementStaticSize":8}
|
||||
{"name":"m4", "staticSize":24, "dynamicSize":240, "length":9, "capacity":9, "elementStaticSize":12}
|
||||
]}]'''
|
||||
expect_json_v2 = '''[{
|
||||
"staticSize":96,
|
||||
"exclusiveSize": 0,
|
||||
"members":[
|
||||
{"name":"m1", "staticSize":24, "exclusiveSize": 24, "length": 3, "capacity": 3},
|
||||
{"name":"m2", "staticSize":24, "exclusiveSize": 24, "length": 5, "capacity": 5},
|
||||
{"name":"m3", "staticSize":24, "exclusiveSize": 24, "length": 7, "capacity": 7},
|
||||
{"name":"m4", "staticSize":24, "exclusiveSize": 24, "length": 9, "capacity": 9}
|
||||
]}]'''
|
||||
{"name":"m1", "staticSize":24, "exclusiveSize": 72, "length": 3, "capacity": 3},
|
||||
{"name":"m2", "staticSize":24, "exclusiveSize": 88, "length": 5, "capacity": 5},
|
||||
{"name":"m3", "staticSize":24, "exclusiveSize": 104, "length": 7, "capacity": 7},
|
||||
{
|
||||
"name":"m4",
|
||||
"staticSize":24,
|
||||
"exclusiveSize": 120,
|
||||
"length": 9,
|
||||
"capacity": 9,
|
||||
"members":[
|
||||
{"staticSize":16, "exclusiveSize": 4},
|
||||
{"staticSize":16, "exclusiveSize": 4},
|
||||
{"staticSize":16, "exclusiveSize": 4},
|
||||
{"staticSize":16, "exclusiveSize": 4},
|
||||
{"staticSize":16, "exclusiveSize": 4},
|
||||
{"staticSize":16, "exclusiveSize": 4},
|
||||
{"staticSize":16, "exclusiveSize": 4},
|
||||
{"staticSize":16, "exclusiveSize": 4},
|
||||
{"staticSize":16, "exclusiveSize": 4}
|
||||
]
|
||||
}]
|
||||
}]'''
|
||||
|
@ -71,11 +71,9 @@ struct TypeHandler<DB, %1%<T0, T1, T2, T3, T4>> {
|
||||
"""
|
||||
|
||||
traversal_func = """
|
||||
// TODO: This implementation enables the traversal of the container,
|
||||
// but doesn't report the memory footprint accurately.
|
||||
// Revisit this implementation and fix memory footprint reporting.
|
||||
auto tail = returnArg
|
||||
.write((uintptr_t)&container)
|
||||
.write((uintptr_t)container.getAllocatedMemorySize())
|
||||
.write((uintptr_t)container.bucket_count())
|
||||
.write(container.size());
|
||||
|
||||
for (auto &&entry: container) {
|
||||
@ -94,6 +92,14 @@ return tail.finish();
|
||||
type = "types::st::VarInt<DB>"
|
||||
func = "el.pointer = std::get<ParsedData::VarInt>(d.val).value;"
|
||||
|
||||
[[codegen.processor]]
|
||||
type = "types::st::VarInt<DB>"
|
||||
func = """
|
||||
el.container_stats.emplace(result::Element::ContainerStats {
|
||||
.capacity = std::get<ParsedData::VarInt>(d.val).value,
|
||||
});
|
||||
"""
|
||||
|
||||
[[codegen.processor]]
|
||||
type = """
|
||||
types::st::List<DB, types::st::Pair<DB,
|
||||
@ -101,11 +107,15 @@ types::st::List<DB, types::st::Pair<DB,
|
||||
typename TypeHandler<DB, T1>::type>>
|
||||
"""
|
||||
func = """
|
||||
static constexpr size_t element_size = sizeof(typename container_type::value_type);
|
||||
|
||||
auto allocationSize = el.pointer.value();
|
||||
el.pointer.reset();
|
||||
|
||||
auto list = std::get<ParsedData::List>(d.val);
|
||||
el.container_stats.emplace(result::Element::ContainerStats {
|
||||
.capacity = list.length,
|
||||
.length = list.length,
|
||||
});
|
||||
el.container_stats->length = list.length;
|
||||
|
||||
el.exclusive_size += allocationSize - list.length * element_size;
|
||||
|
||||
static constexpr std::array<inst::Field, 2> element_fields{
|
||||
make_field<DB, T0>("key"),
|
||||
@ -113,7 +123,9 @@ static constexpr std::array<inst::Field, 2> element_fields{
|
||||
};
|
||||
|
||||
static constexpr inst::Field element{
|
||||
0, 0, "[]",
|
||||
element_size,
|
||||
element_size - sizeof(T0) - sizeof(T1),
|
||||
"[]",
|
||||
std::array<std::string_view, 0>{},
|
||||
element_fields,
|
||||
std::array<inst::ProcessorInst, 0>{},
|
||||
|
Loading…
Reference in New Issue
Block a user