Early inlining of simple methods.

Inlining "special" methods: empty methods, methods returning
constants or their arguments, simple getters and setters.

Bug: 8164439
Change-Id: I8c7fa9c14351fbb2470000b378a22974daaef236
diff --git a/compiler/dex/mir_method_info.cc b/compiler/dex/mir_method_info.cc
index 4580e76..2c33ef1 100644
--- a/compiler/dex/mir_method_info.cc
+++ b/compiler/dex/mir_method_info.cc
@@ -75,10 +75,14 @@
     int fast_path_flags = compiler_driver->IsFastInvoke(
         soa, dex_cache, class_loader, mUnit, referrer_class.get(), resolved_method, &invoke_type,
         &target_method, devirt_target, &it->direct_code_, &it->direct_method_);
-    uint16_t other_flags = it->flags_ & ~kFlagFastPath & ~(kInvokeTypeMask << kBitSharpTypeBegin);
+    bool needs_clinit =
+        compiler_driver->NeedsClassInitialization(referrer_class.get(), resolved_method);
+    uint16_t other_flags = it->flags_ &
+        ~(kFlagFastPath | kFlagNeedsClassInitialization | (kInvokeTypeMask << kBitSharpTypeBegin));
     it->flags_ = other_flags |
         (fast_path_flags != 0 ? kFlagFastPath : 0u) |
-        (static_cast<uint16_t>(invoke_type) << kBitSharpTypeBegin);
+        (static_cast<uint16_t>(invoke_type) << kBitSharpTypeBegin) |
+        (needs_clinit ? kFlagNeedsClassInitialization : 0u);
     it->target_dex_file_ = target_method.dex_file;
     it->target_method_idx_ = target_method.dex_method_index;
     it->stats_flags_ = fast_path_flags;