// A control-flow graph visitor performing various checks. class GraphChecker final : public CRTPGraphVisitor<GraphChecker> { public: explicit GraphChecker(HGraph* graph,
CodeGenerator* codegen = nullptr, constchar* dump_prefix = "art::GraphChecker: ")
: CRTPGraphVisitor(graph),
errors_(graph->GetAllocator()->Adapter(kArenaAllocGraphChecker)),
dump_prefix_(dump_prefix),
allocator_(graph->GetArenaStack()),
seen_ids_(&allocator_, graph->GetCurrentInstructionId(), false, kArenaAllocGraphChecker),
uses_per_instruction_(allocator_.Adapter(kArenaAllocGraphChecker)),
instructions_per_block_(allocator_.Adapter(kArenaAllocGraphChecker)),
phis_per_block_(allocator_.Adapter(kArenaAllocGraphChecker)),
codegen_(codegen) {}
// Check the whole graph. The pass_change parameter indicates whether changes // may have occurred during the just executed pass. The default value is // conservatively "true" (something may have changed). The last_size parameter // and return value pass along the observed graph sizes.
size_t Run(bool pass_change = true, size_t last_size = 0);
// The block currently visited.
HBasicBlock* current_block_ = nullptr; // Errors encountered while checking the graph.
ArenaVector<std::string> errors_;
void VisitReversePostOrder();
// Checks that the graph's flags are set correctly. void CheckGraphFlags();
// Checks if `instruction` is in its block's instruction/phi list. To do so, it searches // instructions_per_block_/phis_per_block_ which are set versions of that. If the set to // check hasn't been populated yet, it does so now. bool ContainedInItsBlockList(HInstruction* instruction);
// As part of VisitInstruction, we verify that the instruction's input_record is present in the // corresponding input's GetUses. If an instruction is used in many places (e.g. 200K+ uses), the // linear search through GetUses is too slow. We can use bookkeeping to search in a set, instead // of a list.
ScopedArenaSafeMap<int, ScopedArenaSet<const art::HUseListNode<art::HInstruction*>*>>
uses_per_instruction_;
// Extra bookkeeping to increase GraphChecker's speed while asking if an instruction is contained // in a list of instructions/phis.
ScopedArenaSafeMap<HBasicBlock*, ScopedArenaHashSet<HInstruction*>> instructions_per_block_;
ScopedArenaSafeMap<HBasicBlock*, ScopedArenaHashSet<HInstruction*>> phis_per_block_;
// Used to access target information.
CodeGenerator* codegen_;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.