From 92f7f3ce3b01f7c7df1c15b81c900e087248093f Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Tue, 31 Oct 2017 11:38:30 +0000 Subject: Use intrinsic codegen for compiling intrinsic methods. When compiling an intrinsic method, generate a graph that invokes the same method and try to compile it. If the call is actually intrinsified (or simplified to other HIR) and yields a leaf method, use the result of this compilation attempt, otherwise compile the actual code or JNI stub. Note that CodeGenerator::CreateThrowingSlowPathLocations() actually marks the locations as kNoCall if the throw is not in a catch block, thus considering some throwing methods (for example, String.charAt()) as leaf methods. We would ideally want to use the intrinsic codegen for all intrinsics that do not generate a slow-path call to the default implementation. Relying on the leaf method is suboptimal as we're missing out on methods that do other types of calls, for example runtime calls. This shall be fixed in a subsequent CL. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 67717501 Change-Id: I640fda7c22d4ff494b5ff77ebec3b7f5f75af652 --- compiler/optimizing/builder.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'compiler/optimizing/builder.h') diff --git a/compiler/optimizing/builder.h b/compiler/optimizing/builder.h index 5a860f1e43..0bb3a051f7 100644 --- a/compiler/optimizing/builder.h +++ b/compiler/optimizing/builder.h @@ -21,17 +21,19 @@ #include "dex_file-inl.h" #include "dex_file.h" #include "driver/compiler_driver.h" -#include "driver/dex_compilation_unit.h" #include "nodes.h" namespace art { +class ArtMethod; class CodeGenerator; +class DexCompilationUnit; class OptimizingCompilerStats; class HGraphBuilder : public ValueObject { public: HGraphBuilder(HGraph* graph, + const DexFile::CodeItem* code_item, const DexCompilationUnit* dex_compilation_unit, const DexCompilationUnit* outer_compilation_unit, CompilerDriver* driver, @@ -47,8 +49,8 @@ class HGraphBuilder : public ValueObject { VariableSizedHandleScope* handles, DataType::Type return_type = DataType::Type::kInt32) : graph_(graph), - dex_file_(dex_compilation_unit->GetDexFile()), - code_item_(code_item), + dex_file_(&graph->GetDexFile()), + code_item_(&code_item), dex_compilation_unit_(dex_compilation_unit), outer_compilation_unit_(nullptr), compiler_driver_(nullptr), @@ -59,6 +61,7 @@ class HGraphBuilder : public ValueObject { return_type_(return_type) {} GraphAnalysisResult BuildGraph(); + void BuildIntrinsicGraph(ArtMethod* method); static constexpr const char* kBuilderPassName = "builder"; @@ -67,7 +70,7 @@ class HGraphBuilder : public ValueObject { HGraph* const graph_; const DexFile* const dex_file_; - const DexFile::CodeItem& code_item_; + const DexFile::CodeItem* const code_item_; // null for intrinsic graph. // The compilation unit of the current method being compiled. Note that // it can be an inlined method. -- cgit v1.2.3-59-g8ed1b