Skip to content

Commit

Permalink
tbv2: re-add indirection to list
Browse files Browse the repository at this point in the history
`std::list` was intended to have an extra layer to represent the overhead of
each list element similar to map implementations. This wasn't currently being
output which meant the size of each list element was being undercounted.

Add the extra layer of indirection to list elements and include this in the
tests.

Test Plan:
- CI
- Updated test cases
  • Loading branch information
JakeHillion committed Jan 11, 2024
1 parent d232a5d commit 9d122f8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
30 changes: 18 additions & 12 deletions test/integration/std_list.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ definitions = '''
param_types = ["const std::list<int>&"]
setup = "return {{1,2,3}};"
expect_json = '[{"staticSize":24, "dynamicSize":12, "length":3, "capacity":3, "elementStaticSize":4}]'
expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "size":36, "length":3, "capacity":3, "members":[
{"staticSize":4, "exclusiveSize":4, "size":4},
{"staticSize":4, "exclusiveSize":4, "size":4},
{"staticSize":4, "exclusiveSize":4, "size":4}
expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "size":96, "length":3, "capacity":3, "members":[
{"staticSize":24, "exclusiveSize":20, "size":24},
{"staticSize":24, "exclusiveSize":20, "size":24},
{"staticSize":24, "exclusiveSize":20, "size":24}
]}]'''
[cases.struct_some]
param_types = ["const std::list<SimpleStruct>&"]
setup = "return {{{}, {}, {}}};"
expect_json = '[{"staticSize":24, "dynamicSize":48, "length":3, "capacity":3, "elementStaticSize":16}]'
expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "size":72, "length":3, "capacity":3, "members":[
{"staticSize":16, "exclusiveSize":3, "size":16},
{"staticSize":16, "exclusiveSize":3, "size":16},
{"staticSize":16, "exclusiveSize":3, "size":16}
expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "size":120, "length":3, "capacity":3, "members":[
{"staticSize":32, "exclusiveSize":16, "size":32},
{"staticSize":32, "exclusiveSize":16, "size":32},
{"staticSize":32, "exclusiveSize":16, "size":32}
]}]'''
[cases.list_int_empty]
param_types = ["const std::list<std::list<int>>&"]
Expand All @@ -52,8 +52,14 @@ definitions = '''
{"staticSize":24, "dynamicSize":4, "exclusiveSize":28, "length":1, "capacity":1, "elementStaticSize":4},
{"staticSize":24, "dynamicSize":8, "exclusiveSize":32, "length":2, "capacity":2, "elementStaticSize":4}
]}]'''
expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "size":120, "length":3, "capacity": 3, "members":[
{"staticSize":24, "exclusiveSize":24, "size":36, "length":3, "capacity": 3},
{"staticSize":24, "exclusiveSize":24, "size":28, "length":1, "capacity": 1},
{"staticSize":24, "exclusiveSize":24, "size":32, "length":2, "capacity": 2}
expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "size":288, "length":3, "capacity": 3, "members":[
{"name":"[]", "staticSize":40, "exclusiveSize":16, "size":112, "members": [{
"name":"*", "staticSize":24, "exclusiveSize":24, "size":96, "length":3, "capacity": 3
}]},
{"name":"[]", "staticSize":40, "exclusiveSize":16, "size":64, "members": [{
"name":"*", "staticSize":24, "exclusiveSize":24, "size":48, "length":1, "capacity": 1
}]},
{"name":"[]", "staticSize":40, "exclusiveSize":16, "size":88, "members": [{
"name":"*", "staticSize":24, "exclusiveSize":24, "size":72, "length":2, "capacity": 2
}]}
]}]'''
3 changes: 1 addition & 2 deletions types/cxx11_list_type.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ static constexpr inst::Field element{
child_field,
std::array<inst::ProcessorInst, 0>{},
};
static constexpr auto childField = make_field<Ctx, T0>("[]");
auto list = std::get<ParsedData::List>(d.val);
el.container_stats.emplace(result::Element::ContainerStats{
Expand All @@ -81,5 +80,5 @@ el.container_stats.emplace(result::Element::ContainerStats{
});
el.exclusive_size += (el.container_stats->capacity - el.container_stats->length) * sizeof(T0);
stack_ins(inst::Repeat{ list.length, childField });
stack_ins(inst::Repeat{ list.length, element });
"""
3 changes: 1 addition & 2 deletions types/list_type.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ static constexpr inst::Field element{
child_field,
std::array<inst::ProcessorInst, 0>{},
};
static constexpr auto childField = make_field<Ctx, T0>("[]");
auto list = std::get<ParsedData::List>(d.val);
el.container_stats.emplace(result::Element::ContainerStats{
Expand All @@ -81,5 +80,5 @@ el.container_stats.emplace(result::Element::ContainerStats{
});
el.exclusive_size += (el.container_stats->capacity - el.container_stats->length) * sizeof(T0);
stack_ins(inst::Repeat{ list.length, childField });
stack_ins(inst::Repeat{ list.length, element });
"""

0 comments on commit 9d122f8

Please sign in to comment.