Skip to content

Commit

Permalink
[stable] [vm/compiler] Avoid searching static functions in the import…
Browse files Browse the repository at this point in the history
…ed libraries

References to members are fully resolved in kernel. So, when
looking for a static function in the library scope, there is no need to
search in the imported libraries.

Searching in the imported libraries could be very slow as they can be
huge (e.g. the whole Flutter framework).
TEST=manually verified repro from flutter/flutter#133195

Fixes flutter/flutter#133195
Cherry-pick-request: #53541
Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/323201
Change-Id: Ib84478cebf761ef574356e8e63bd3e9b5ba1507d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326242
Reviewed-by: Daco Harkes <[email protected]>
Commit-Queue: Siva Annamalai <[email protected]>
Reviewed-by: Alexander Markov <[email protected]>
  • Loading branch information
a-siva authored and Commit Queue committed Sep 26, 2023
1 parent c05b29e commit b872320
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ This is a patch release that:
such as shared libraries loaded through `dart:ffi`, that may have different
versions of the same symbols (issue [#53267]).

- Fixes an issue with super slow access to variables while debugging.
The fix avoids searching static functions in the imported libraries
as references to members are fully resolved by the front-end. (issue
[#53541])

[#53579]: https://github.com/dart-lang/sdk/issues/53579
[#53267]: https://github.com/dart-lang/sdk/issues/53267
[#53541]: https://github.com/dart-lang/sdk/issues/53541

## 3.1.2 - 2023-09-13

Expand Down
27 changes: 18 additions & 9 deletions runtime/vm/compiler/frontend/kernel_translation_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -658,23 +658,32 @@ FunctionPtr TranslationHelper::LookupStaticMethodByKernelProcedure(
// The parent is either a library or a class (in which case the procedure is a
// static method).
NameIndex enclosing = EnclosingName(procedure);
Function& function = Function::Handle(Z);
Class& klass = Class::Handle(Z);
if (IsLibrary(enclosing)) {
Library& library = Library::Handle(
Z, LookupLibraryByKernelLibrary(enclosing, /*required=*/false));
if (!library.IsNull()) {
function = library.LookupFunctionAllowPrivate(procedure_name);
if (library.IsNull()) {
if (required) {
LookupFailed(procedure);
}
return Function::null();
}
klass = library.toplevel_class();
} else {
ASSERT(IsClass(enclosing));
Class& klass = Class::Handle(
Z, LookupClassByKernelClass(enclosing, /*required=*/false));
if (!klass.IsNull()) {
const auto& error = klass.EnsureIsFinalized(thread_);
ASSERT(error == Error::null());
function = klass.LookupFunctionAllowPrivate(procedure_name);
klass = LookupClassByKernelClass(enclosing, /*required=*/false);
if (klass.IsNull()) {
if (required) {
LookupFailed(procedure);
}
return Function::null();
}
}

const auto& error = klass.EnsureIsFinalized(thread_);
ASSERT(error == Error::null());
Function& function =
Function::Handle(Z, klass.LookupFunctionAllowPrivate(procedure_name));
if (function.IsNull() && required) {
LookupFailed(procedure);
}
Expand Down

0 comments on commit b872320

Please sign in to comment.