[vm/compiler] Minor improvements for AOT compilation time

* When testing for pragmas in the inliner, call function.has_pragma()
  early to avoid more expensive Library::FindPragma query.

* When scanning through object pool entries in
  Precompiler::AddCalleesOfHelper, skip over OneByteString and null
  objects quickly. They are leaf and there could be a huge number of
  those objects.

AOT gen_snapshot time of a large Flutter application built in
flutter/release mode for arm64 (best of 5 runs):
Before: 81.589s
After:  74.415s (-8.79%)

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/43299
Change-Id: I960451c73b42dab9845f0e0eafacaa9bb23720e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213288
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
Alexander Markov 2021-09-13 21:25:30 +00:00 committed by commit-bot@chromium.org
parent f9512796e2
commit 4744f66f6f
3 changed files with 18 additions and 0 deletions

View file

@ -782,6 +782,7 @@ void Precompiler::Iterate() {
}
void Precompiler::CollectCallbackFields() {
PRECOMPILER_TIMER_SCOPE(this, CollectCallbackFields);
HANDLESCOPE(T);
Library& lib = Library::Handle(Z);
Class& cls = Class::Handle(Z);
@ -883,6 +884,7 @@ void Precompiler::ProcessFunction(const Function& function) {
}
void Precompiler::AddCalleesOf(const Function& function, intptr_t gop_offset) {
PRECOMPILER_TIMER_SCOPE(this, AddCalleesOf);
ASSERT(function.HasCode());
const Code& code = Code::Handle(Z, function.CurrentCode());
@ -987,6 +989,12 @@ static bool IsPotentialClosureCall(const String& selector) {
void Precompiler::AddCalleesOfHelper(const Object& entry,
String* temp_selector,
Class* temp_cls) {
const intptr_t cid = entry.GetClassId();
if ((cid == kOneByteStringCid) || (cid == kNullCid)) {
// Skip common leaf constants early in order to
// process object pools faster.
return;
}
if (entry.IsUnlinkedCall()) {
const auto& call_site = UnlinkedCall::Cast(entry);
// A dynamic call.
@ -1603,6 +1611,7 @@ void Precompiler::AddAnnotatedRoots() {
}
void Precompiler::CheckForNewDynamicFunctions() {
PRECOMPILER_TIMER_SCOPE(this, CheckForNewDynamicFunctions);
HANDLESCOPE(T);
Library& lib = Library::Handle(Z);
Class& cls = Class::Handle(Z);

View file

@ -2310,6 +2310,9 @@ static bool IsInlineableOperator(const Function& function) {
}
bool FlowGraphInliner::FunctionHasPreferInlinePragma(const Function& function) {
if (!function.has_pragma()) {
return false;
}
Thread* thread = dart::Thread::Current();
COMPILER_TIMINGS_TIMER_SCOPE(thread, CheckForPragma);
Object& options = Object::Handle();
@ -2319,6 +2322,9 @@ bool FlowGraphInliner::FunctionHasPreferInlinePragma(const Function& function) {
}
bool FlowGraphInliner::FunctionHasNeverInlinePragma(const Function& function) {
if (!function.has_pragma()) {
return false;
}
Thread* thread = dart::Thread::Current();
COMPILER_TIMINGS_TIMER_SCOPE(thread, CheckForPragma);
Object& options = Object::Handle();

View file

@ -20,6 +20,9 @@
V(CompileAll) \
V(Iterate) \
V(CompileFunction) \
V(AddCalleesOf) \
V(CheckForNewDynamicFunctions) \
V(CollectCallbackFields) \
V(PrecompileConstructors) \
V(AttachOptimizedTypeTestingStub) \
V(TraceForRetainedFunctions) \