mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-09-19 19:19:05 +01:00
b117150f83
Summary: tbv2: add dynamic context passed through all functions Previously for we had some shared state between all requests, noticeably the pointers set. This change adds a by reference value to all requests which can hold additional mutable state. The pointers set is moved into this mutable state for OIL, which means each concurrent request will have its own pointer set. Doing things this way allows more features to be added in the future without such a big code modification. Closes https://github.com/facebookexperimental/object-introspection/issues/404 Pull Request resolved: https://github.com/facebookexperimental/object-introspection/pull/410 Test Plan: - CI Differential Revision: D51394035 Pulled By: JakeHillion fbshipit-source-id: 55d2ba9b5e056148a29dc821020cfc3d94e5175a
103 lines
3.2 KiB
TOML
103 lines
3.2 KiB
TOML
[info]
|
|
type_name = "folly::sorted_vector_map"
|
|
ctype = "MAP_SEQ_TYPE"
|
|
header = "folly/sorted_vector_types.h"
|
|
stub_template_params = [2,3]
|
|
|
|
# Old:
|
|
typeName = "folly::sorted_vector_map<"
|
|
ns = ["namespace std", "folly::sorted_vector_map"]
|
|
numTemplateParams = 2
|
|
replaceTemplateParamIndex = []
|
|
|
|
[codegen]
|
|
decl = """
|
|
template <class Key, class Value, class Compare, class Allocator, class GrowthPolicy, class Container>
|
|
void getSizeType(const %1%<Key, Value, Compare, Allocator, GrowthPolicy, Container> &container, size_t& returnArg);
|
|
"""
|
|
|
|
func = """
|
|
template <class Key, class Value, class Compare, class Allocator, class GrowthPolicy, class Container>
|
|
void getSizeType(const %1%<Key, Value, Compare, Allocator, GrowthPolicy, Container> &container, size_t& returnArg)
|
|
{
|
|
SAVE_SIZE(sizeof(%1%<Key,Value,Compare,Allocator,GrowthPolicy,Container>));
|
|
|
|
SAVE_DATA((uintptr_t)&container);
|
|
SAVE_DATA((uintptr_t)container.capacity());
|
|
SAVE_DATA((uintptr_t)container.size());
|
|
|
|
SAVE_SIZE((container.capacity() - container.size()) * (sizeof(Key) + sizeof(Value)));
|
|
|
|
for (auto const& it : container)
|
|
{
|
|
getSizeType(it.first, returnArg);
|
|
getSizeType(it.second, returnArg);
|
|
}
|
|
}
|
|
"""
|
|
|
|
traversal_func = '''
|
|
auto tail = returnArg.write((uintptr_t)&container)
|
|
.write(container.capacity())
|
|
.write(container.size());
|
|
|
|
for (const auto& kv : container) {
|
|
tail = tail.delegate([&ctx, &kv](auto ret) {
|
|
auto start = maybeCaptureKey<captureKeys, Ctx, T0>(ctx, kv.first, ret);
|
|
auto next = start.delegate([&ctx, &kv](typename TypeHandler<Ctx, T0>::type ret) {
|
|
return OIInternal::getSizeType<Ctx>(ctx, kv.first, ret);
|
|
});
|
|
return OIInternal::getSizeType<Ctx>(ctx, kv.second, next);
|
|
});
|
|
}
|
|
|
|
return tail.finish();
|
|
'''
|
|
|
|
[[codegen.processor]]
|
|
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 = '''
|
|
std::conditional_t<captureKeys,
|
|
types::st::List<DB, types::st::Pair<DB,
|
|
typename CaptureKeyHandler<Ctx, T0>::type,
|
|
types::st::Pair<DB,
|
|
typename TypeHandler<Ctx, T0>::type,
|
|
typename TypeHandler<Ctx, T1>::type>>>,
|
|
types::st::List<DB, types::st::Pair<DB,
|
|
typename TypeHandler<Ctx, T0>::type,
|
|
typename TypeHandler<Ctx, T1>::type>>>
|
|
'''
|
|
func = '''
|
|
using element_type = std::pair<T0, T1>;
|
|
|
|
static constexpr std::array<inst::Field, 2> entryFields{
|
|
make_field<Ctx, T0>("key"),
|
|
make_field<Ctx, T1>("value"),
|
|
};
|
|
static constexpr auto processors = maybeCaptureKeysProcessor<captureKeys, Ctx, T0>();
|
|
static constexpr auto entry = inst::Field {
|
|
sizeof(element_type),
|
|
sizeof(element_type) - sizeof(T0) - sizeof(T1),
|
|
"[]",
|
|
std::array<std::string_view, 0>{},
|
|
entryFields,
|
|
processors,
|
|
};
|
|
|
|
auto list = std::get<ParsedData::List>(d.val);
|
|
el.container_stats->length = list.length;
|
|
el.exclusive_size += (el.container_stats->capacity - el.container_stats->length) * sizeof(element_type);
|
|
|
|
for (size_t i = 0; i < list.length; i++)
|
|
stack_ins(entry);
|
|
'''
|