Commit Graph

82 Commits

Author SHA1 Message Date
Jake Hillion
b88dabae5c CycleFinder: support containers 2023-07-18 10:34:21 -07:00
Jake Hillion
b8b6afda43 type_graph: add CycleFinder pass 2023-07-18 10:32:58 -07:00
Alastair Robertson
ec9f98f0e1 AddPadding: Pad unions when necessary 2023-07-18 17:45:46 +01:00
Alastair Robertson
a0acaaea65 AddPadding: Pad classes with zero members 2023-07-18 17:45:46 +01:00
Alastair Robertson
1e1b319a69 TypeIdentifier: Create custom visitor for Class types
This is just laying some foundations - it doesn't do anything useful
yet.
2023-07-18 17:33:25 +01:00
Alastair Robertson
3b6b739d55 CodeGen: Add comments explaining the order of passes 2023-07-18 17:20:59 +01:00
Jake Hillion
31f46831c2 typing: handle padding only structs 2023-07-18 17:17:32 +01:00
Jake Hillion
011292f2b0 type_graph: deduplicate has_node_id 2023-07-14 16:03:56 +01:00
Alastair Robertson
30cd23fa53 TypeGraph: Introduce TypeGraphParser to simplify unit testing
TypeGraphParser parses a textual type graph, as emitted by Printer.

It also doubles as a way of ensuring that Printer displays all
information about a type graph, to aid with debugging.

Convert Flattener unit tests over to this new framework as a first step.
2023-07-13 17:38:49 +01:00
Jake Hillion
bd948152b7 add exporters::TypeCheckingWalker 2023-07-13 16:05:24 +01:00
Jake Hillion
032c28c0ea type checking: add description of data segment type 2023-07-13 16:05:24 +01:00
Alastair Robertson
9f9d1eb568 TypeGraph: Better handling for anonymous types
- Assign names to anonymous types
- Deduplicate all enums (anonymous or not)
- Add tests
2023-07-12 17:44:38 +01:00
Alastair Robertson
3e8464e691 RemoveIgnored: Set names for removed members to AddPadding::MemberPrefix
This means they will be treated as padding, so CodeGen will not try to
store any data for them.
2023-07-12 14:40:10 +01:00
Alastair Robertson
e7549db949 TypeGraph: Introduce NodeTracker for efficient cycle detection
Added to Flattener and TypeIdentifier passes for now as a
proof-of-concept. Other passes can come later.
2023-07-12 14:39:56 +01:00
arsarwade
28b813c6db
Stop stubbing tuple (#224)
Summary:

Stubbing tuple without alignment info can cause failures. I added a test
case for this which failed before this fix but works now.

Test Plan:

Ran the test.
2023-07-11 09:10:40 -07:00
arsarwade
188a2a82d0
Add container without template params to container map (#223)
Summary:

If a container has 0 template params (e.g. IOBuf, IOBufQueue), it wasn't
being added to containerTypeMap. This causes the deserialization to go wrong
as TreeBuilder doesn't treat the types as container

Test Plan:

make test
2023-07-11 08:54:16 -07:00
Alastair Robertson
f676112bbc AddChildren: Filter out false children
Use fully qualified names to determine if a class is really the child of
our type. It may be that it is the child of another type with an
identical name in another namespace.
2023-07-11 13:52:39 +01:00
Alastair Robertson
11ca1b0b00 Flattener: Fix seg-fault in the case of specific bad DWARF
Also add negative tests for fixAllocatorParams(), covering this case and
more.
2023-07-11 13:52:15 +01:00
Alastair Robertson
df68002bd6 NameGen: Remove invalid characters from member names
GCC includes dots in vptr member names, e.g. "_vptr.MyClass". These
aren't valid in C++, so we must replace them.
2023-07-11 13:51:54 +01:00
Jake Hillion
02defdb859 comment existing typed data segment work 2023-07-10 21:09:43 +01:00
Alastair Robertson
43303ae6d3 Flattener: Pull up children of children 2023-07-10 16:40:29 +01:00
Jake Hillion
17633983b5 create strict mode and enable it for tests 2023-07-07 16:09:46 +01:00
Alastair Robertson
56b5873e77 TypeGraph: Rename visit(Type) functions to accept(Type)
visit(Type&) and visit(Type*) were helper functions than did cycle
detection and provided nicer syntax for the type.accept(*this) calls.

However, because they overloaded the visit() function, it was easy to
accidentally call a concrete visit method (e.g. visit(Class&)) instead
of the virtual-dispatching visit(Type&).

By changing the name of this wrapper, it will make it much more obvious
when code is introduced which bypasses the cycle detection.
2023-07-07 15:45:29 +01:00
Alastair Robertson
8cb082372e TypeIdentifier: Preserve container types
Pass-through-types represent classes to be turned into containers. We
don't want these to turn these containers into Dummy's on a second run
of TypeIdentifier.
2023-07-06 18:39:20 +01:00
Alastair Robertson
3ec81aaa5f TypeGraph: Add "--tree-builder-v2" flag
This will eventually be used to enable running with Tree Builder v2.

For now, when it is disabled it puts CodeGen v2 into compatibility mode,
disabling features which weren't present in CodeGen v1 so that its
output can be understood by Tree Builder v1.
2023-07-06 17:43:09 +01:00
Alastair Robertson
e1b16a3d7e TypeGraph: Switch from pointers to references
References must always have a value, so are semantically clearer than
pointers for variables which must always be set.

No functional changes.
2023-07-06 17:24:33 +01:00
Alastair Robertson
23efc8d2d6 TypeGraph: Add Node IDs to non-leaf types
These aren't used for anything yet, but should be useful for stable IDs
when printing nodes before and after passes and for faster cycle
detection than the current map of pointers.
2023-07-06 14:54:30 +01:00
Jake Hillion
099be82459 thrift isset: add type handler 2023-07-05 17:52:42 +01:00
Alastair Robertson
8805480653 TypeGraph: Make Primitive types singletons
Should save some memory and improve performance by not having loads of
copies of primitive types.
2023-07-05 16:06:57 +01:00
Alastair Robertson
0330ef8945 Take list of pass-through types from config instead of hardcoding
As we now store ContainerInfo objects in OICodeGen::Config, we can not
copy it any more. Change all places that took copies to take const
references instead.

The copy in OICodeGen modified membersToStub, the contents of which form
part of OICache's hash. However, as OICache also previously had its own
copy, it would not have been OICodeGen's modifications.
2023-07-05 13:39:19 +01:00
Alastair Robertson
e86ebb7aff TypeGraph: Support bitfields
- Change member and parent offsets to work in bits, not bytes
- Printer still displays offsets in bytes, with decimals when using
  bitfields
- AddPadding: Don't pad bitfields
- CodeGen: Emit code for bitfields
2023-07-05 13:23:23 +01:00
Alastair Robertson
c9bcf5e760 TopoSorter: Fix sorting of container template parameters
For std::vector and std::list, template parameters are not required to
be defined before they can be used. Delay sorting them until the end.

Also fix a CodeGen bug where we were defining typedefs in the middle of
the forward declarations. They only need to be defined when other types
are defined.
2023-07-05 13:10:28 +01:00
Alastair Robertson
31050735d6 CodeGen: Add support for capturing Thrift isset data 2023-07-04 15:36:27 +01:00
Jake Hillion
01c9573acb add jit timing feature 2023-07-03 18:02:09 +01:00
Jake Hillion
63ac468a1f TypedDataSegment: clean up type of fixed suffix 2023-07-03 18:02:09 +01:00
Jake Hillion
3da628b852 help: improve feature descriptions 2023-07-03 16:57:43 +01:00
Jake Hillion
db243d9845 codegen: store prev defined containers as a class field 2023-07-03 16:04:08 +01:00
Jake Hillion
6aead62652 static types: place in own header for testing 2023-06-30 12:54:02 +01:00
Jake Hillion
8e48c6ca52 ci: enable testing for typed data segment 2023-06-29 17:31:29 +01:00
Jake Hillion
046e5f57bb add dummy handler to dummy containers 2023-06-29 17:31:29 +01:00
Alastair Robertson
b50ab57e33 AddPadding: Move common code into a function 2023-06-29 14:10:05 +01:00
Alastair Robertson
24d707cf56 Flattener: Flatten class template parameters 2023-06-29 11:58:39 +01:00
Alastair Robertson
04715e2015 TypeGraph: Create dummy containers
These represent types which don't store any interesting data for us to
measure, but which are required by a real container so can not be
replaced with our own generated class types.

std::allocator often has bad DWARF, so it must be replaced after the
DWARF is fixed up in Flattener. The others could be replaced earlier in
the transformation process if desired, but I've left them all together
for simplicity for now.

This fixes the folly::fbstring tests.
2023-06-28 16:11:50 +01:00
Alastair Robertson
1bb0c62987 Flattener: Attempt to take params from parent allocator in case of bad DWARF 2023-06-27 14:06:02 +01:00
Jon Haslam
5204753497
remove unused old code from trace code (#186) 2023-06-27 11:31:05 +01:00
Jon Haslam
7bb23386f1
feature flag jit-logging (#183) 2023-06-26 18:44:18 +01:00
Alastair Robertson
f5b5885666 TypeGraph: Make original fully qualified names available for Class types
The worry about doing this earlier was performance, but on a further
reading of the code, both legacy OICodeGen and new DrgnParser have been
calling into drgn_type_fully_qualified_name() for every class for a long
time already.
2023-06-26 16:11:24 +01:00
Alastair Robertson
4bfa932b9b DrgnParser: Handle enum values in template params
We want to use the fully qualified name for scoped enums to keep the C++
compiler happy. When a parameter expects an enum value, we must supply
an enum value and not its underlying integer value.

Before:
  isset_bitset<1, 0>

After:
  isset_bitset<1, apache::thrift::detail::IssetBitsetOption::Unpacked>
2023-06-26 15:13:21 +01:00
Jake Hillion
f130f3c470 features: add GenJitDebug 2023-06-26 14:39:38 +01:00
Alastair Robertson
b0ef913b19 NameGen: Handle containers with zero template params
Previously we always deleted the last two characters and appended a `>`.

Old:
  MyContaine>

New:
  MyContainer
2023-06-26 11:27:38 +01:00