object-introspection/types/f14_node_map.toml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

104 lines
2.9 KiB
TOML
Raw Permalink Normal View History

2022-12-19 14:37:51 +00:00
[info]
type_name = "folly::F14NodeMap"
stub_template_params = [2,3,4]
2022-12-19 14:37:51 +00:00
ctype = "F14_MAP"
header = "folly/container/F14Map.h"
# Old:
typeName = "folly::F14NodeMap<"
2022-12-19 14:37:51 +00:00
ns = ["folly::F14NodeMap"]
numTemplateParams = 2
2022-12-19 14:37:51 +00:00
replaceTemplateParamIndex = [2, 3]
allocatorIndex = 4
[codegen]
decl = """
template <typename Key, typename Mapped, typename Hasher, typename KeyEqual, typename Alloc>
void getSizeType(const %1%<Key, Mapped, Hasher, KeyEqual, Alloc> &container, size_t& dataSegOffset);
"""
func = """
template <typename Key, typename Mapped, typename Hasher, typename KeyEqual, typename Alloc>
void getSizeType(const %1%<Key, Mapped, Hasher, KeyEqual, Alloc> &container, size_t& returnArg)
{
size_t memorySize = container.getAllocatedMemorySize();
SAVE_SIZE(sizeof(%1%<Key, Mapped, Hasher, KeyEqual>) + memorySize);
SAVE_DATA(memorySize);
SAVE_DATA(container.bucket_count());
SAVE_DATA(container.size());
// The double ampersand is needed otherwise this loop doesn't work with vector<bool>
for (auto&& it: container) {
getSizeType(it.first, returnArg);
getSizeType(it.second, returnArg);
}
}
"""
2023-09-07 15:07:31 +01:00
traversal_func = """
auto tail = returnArg
2023-10-06 17:41:50 +01:00
.write((uintptr_t)container.getAllocatedMemorySize())
.write((uintptr_t)container.bucket_count())
2023-09-07 15:07:31 +01:00
.write(container.size());
for (auto &&entry: container) {
tail = tail.delegate([&ctx, &key = entry.first, &value = entry.second](auto ret) {
auto next = ret.delegate([&ctx, &key](typename TypeHandler<Ctx, T0>::type ret) {
return OIInternal::getSizeType<Ctx>(ctx, key, ret);
2023-09-07 15:07:31 +01:00
});
return OIInternal::getSizeType<Ctx>(ctx, value, next);
2023-09-07 15:07:31 +01:00
});
}
return tail.finish();
"""
[[codegen.processor]]
type = "types::st::VarInt<DB>"
func = "el.pointer = std::get<ParsedData::VarInt>(d.val).value;"
2023-10-06 17:41:50 +01:00
[[codegen.processor]]
type = "types::st::VarInt<DB>"
func = """
el.container_stats.emplace(result::Element::ContainerStats {
.capacity = std::get<ParsedData::VarInt>(d.val).value,
});
"""
2023-09-07 15:07:31 +01:00
[[codegen.processor]]
type = """
types::st::List<DB, types::st::Pair<DB,
tbv2: replace DB template param with Ctx (#409) Summary: tbv2: replace DB template param with Ctx TreeBuilder v2 adds a DB template parameter to every function. This is used as part of the static type to decide what type of DataBuffer is being used: currently `BackInserterDataBuffer<std::vector<uint8_t>>` for OIL and it would be `DataSegmentDataBuffer` for OID. This change replaces the `DB` template parameter with a more general `Ctx`. Due to issues with dependent naming it also adds a `using DB` to each `TypeHandler` which has the same function as before. This allows us to add more "static context" (typedefs and constants) to functions without changing this signature again, because changing the signature of everything is a massive pain. Currently this change achieves nothing because Ctx contains only DB in a static wrapper. In the next change I'm going to pass a reference of type Ctx around to add a "dynamic context" to invocations which will contain the pointer array. In future we'll then be able to add either static or dynamic context without any signature adjustments. Test Plan: - CI --- Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebookexperimental/object-introspection/pull/409). * https://github.com/facebookexperimental/object-introspection/issues/410 * __->__ https://github.com/facebookexperimental/object-introspection/issues/409 Reviewed By: ajor Differential Revision: D51352092 Pulled By: JakeHillion
2023-11-15 19:28:21 +00:00
typename TypeHandler<Ctx, T0>::type,
typename TypeHandler<Ctx, T1>::type>>
2023-09-07 15:07:31 +01:00
"""
func = """
2023-10-06 17:41:50 +01:00
static constexpr size_t element_size = sizeof(typename container_type::value_type);
auto allocationSize = el.pointer.value();
el.pointer.reset();
2023-09-07 15:07:31 +01:00
auto list = std::get<ParsedData::List>(d.val);
2023-10-06 17:41:50 +01:00
el.container_stats->length = list.length;
el.exclusive_size += allocationSize - list.length * element_size;
2023-09-07 15:07:31 +01:00
static constexpr std::array<inst::Field, 2> element_fields{
tbv2: replace DB template param with Ctx (#409) Summary: tbv2: replace DB template param with Ctx TreeBuilder v2 adds a DB template parameter to every function. This is used as part of the static type to decide what type of DataBuffer is being used: currently `BackInserterDataBuffer<std::vector<uint8_t>>` for OIL and it would be `DataSegmentDataBuffer` for OID. This change replaces the `DB` template parameter with a more general `Ctx`. Due to issues with dependent naming it also adds a `using DB` to each `TypeHandler` which has the same function as before. This allows us to add more "static context" (typedefs and constants) to functions without changing this signature again, because changing the signature of everything is a massive pain. Currently this change achieves nothing because Ctx contains only DB in a static wrapper. In the next change I'm going to pass a reference of type Ctx around to add a "dynamic context" to invocations which will contain the pointer array. In future we'll then be able to add either static or dynamic context without any signature adjustments. Test Plan: - CI --- Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebookexperimental/object-introspection/pull/409). * https://github.com/facebookexperimental/object-introspection/issues/410 * __->__ https://github.com/facebookexperimental/object-introspection/issues/409 Reviewed By: ajor Differential Revision: D51352092 Pulled By: JakeHillion
2023-11-15 19:28:21 +00:00
make_field<Ctx, T0>("key"),
make_field<Ctx, T1>("value"),
2023-09-07 15:07:31 +01:00
};
static constexpr inst::Field element{
2023-10-06 17:41:50 +01:00
element_size,
element_size - sizeof(T0) - sizeof(T1),
"[]",
2023-09-07 15:07:31 +01:00
std::array<std::string_view, 0>{},
element_fields,
std::array<inst::ProcessorInst, 0>{},
element_fields[0].is_primitive && element_fields[1].is_primitive,
2023-09-07 15:07:31 +01:00
};
for (size_t i = 0; i < list.length; i++)
stack_ins(element);
2023-09-07 15:07:31 +01:00
"""