From 7ee34a1eeba20c1b438f7bcad75adba65dd2a840 Mon Sep 17 00:00:00 2001 From: Evgeny Astigeevich Date: Tue, 10 Dec 2019 11:36:33 +0000 Subject: Add OptimizingUnitTestHelper::GraphChecker methods GraphChecker should be always used in gtests where it is possible. Currently only ImprovedOptimizingUnitTest allows unit tests to use GraphChecker. Unit tests based on OptimizingUnitTest cannot use this functionality. Another issue is that GraphChecker has reference type information checks which unit tests cannot satisfy. The CL resolves the issues by: * Adding a public GraphChecker::SetRefTypeInfoCheckEnabled. * Adding a private OptimizingUnitTestHelper::CheckGraph(HGraph* graph, bool check_ref_type_info). * Adding a public OptimizingUnitTestHelper::CheckGraph(graph) to perform all checks. * Adding a public OptimizingUnitTestHelper::CheckGraphSkipRefTypeInfoChecks(graph) to perform all checks but reference type information checks. * Updating ImprovedOptimizingUnitTest::CheckGraph to use OptimizingUnitTestHelper::CheckGraph. To demonstrate how the new API can be used, unit tests for the Load-Store-Analysis pass are updated. Test: test.py --host --optimizing --jit --gtest Test: test.py --target --optimizing --jit Test: run-gtests.sh Change-Id: I7ca0983e66d9904073f0d711b3de96cccfe42746 --- compiler/optimizing/graph_checker.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'compiler/optimizing/graph_checker.h') diff --git a/compiler/optimizing/graph_checker.h b/compiler/optimizing/graph_checker.h index d085609197..564b1377ec 100644 --- a/compiler/optimizing/graph_checker.h +++ b/compiler/optimizing/graph_checker.h @@ -95,6 +95,15 @@ class GraphChecker : public HGraphDelegateVisitor { } } + // Enable/Disable the reference type info check. + // + // Return: the previous status of the check. + bool SetRefTypeInfoCheckEnabled(bool value = true) { + bool old_value = check_reference_type_info_; + check_reference_type_info_ = value; + return old_value; + } + protected: // Report a new error. void AddError(const std::string& error) { @@ -111,6 +120,10 @@ class GraphChecker : public HGraphDelegateVisitor { const char* const dump_prefix_; ScopedArenaAllocator allocator_; ArenaBitVector seen_ids_; + // Whether to perform the reference type info check for instructions which use or produce + // object references, e.g. HNewInstance, HLoadClass. + // The default value is true. + bool check_reference_type_info_ = true; DISALLOW_COPY_AND_ASSIGN(GraphChecker); }; -- cgit v1.2.3-59-g8ed1b