mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-14 14:26:55 +00: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
77 lines
1.9 KiB
TOML
77 lines
1.9 KiB
TOML
[info]
|
|
type_name = "std::vector"
|
|
stub_template_params = [1]
|
|
header = "vector"
|
|
|
|
# Old:
|
|
ctype = "SEQ_TYPE"
|
|
typeName = "std::vector<"
|
|
ns = ["namespace std"]
|
|
numTemplateParams = 1
|
|
allocatorIndex = 1
|
|
|
|
[codegen]
|
|
decl = """
|
|
template<typename T, typename Allocator>
|
|
void getSizeType(const %1%<T, Allocator> &container, size_t& returnArg);
|
|
"""
|
|
|
|
func = """
|
|
template<typename T, typename Allocator>
|
|
void getSizeType(const %1%<T, Allocator> &container, size_t& returnArg)
|
|
{
|
|
SAVE_SIZE(sizeof(%1%<T>));
|
|
|
|
SAVE_DATA((uintptr_t)&container);
|
|
SAVE_DATA((uintptr_t)container.capacity());
|
|
SAVE_DATA((uintptr_t)container.size());
|
|
|
|
SAVE_SIZE((container.capacity() - container.size()) * sizeof(T));
|
|
|
|
// The double ampersand is needed otherwise this loop doesn't work with vector<bool>
|
|
for (auto&& it: container) {
|
|
getSizeType(it, returnArg);
|
|
}
|
|
}
|
|
"""
|
|
|
|
traversal_func = """
|
|
auto tail = returnArg.write((uintptr_t)&container)
|
|
.write(container.capacity())
|
|
.write(container.size());
|
|
|
|
// The double ampersand is needed otherwise this loop doesn't work with
|
|
// vector<bool>
|
|
for (auto&& it : container) {
|
|
tail = tail.delegate([&ctx, &it](auto ret) {
|
|
return OIInternal::getSizeType<Ctx>(ctx, it, ret);
|
|
});
|
|
}
|
|
|
|
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 = "types::st::List<DB, typename TypeHandler<Ctx, T0>::type>"
|
|
func = """
|
|
static constexpr auto childField = make_field<Ctx, T0>("[]");
|
|
|
|
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(T0);
|
|
|
|
stack_ins(inst::Repeat{ list.length, childField });
|
|
"""
|