[vm] Enable annotations on libraries in AOT

We have no use cases for this until the dependent CL.
TEST=dependent CL

Closes: https://github.com/dart-lang/sdk/issues/50539

Change-Id: Iee91f90ddd474cef3b7218def4d3e716ab2639ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272421
Reviewed-by: Martin Kustermann <kustermann@google.com>
This commit is contained in:
Daco Harkes
2023-01-18 21:08:38 +00:00
committed by Commit Queue
parent 5d18663a7d
commit 476e13a5e9
2 changed files with 6 additions and 2 deletions
+3 -1
View File
@@ -1027,7 +1027,9 @@ LibraryPtr KernelLoader::LoadLibrary(intptr_t index) {
FinishTopLevelClassLoading(toplevel_class, library, library_index);
}
if (FLAG_enable_mirrors && annotation_count > 0) {
// Used for mirrors and allows VM to recognize @pragma annotations on
// libraries.
if (annotation_count > 0) {
ASSERT(annotations_kernel_offset > 0);
library.AddMetadata(library, annotations_kernel_offset);
}
+3 -1
View File
@@ -4017,7 +4017,9 @@ bool Library::FindPragma(Thread* T,
auto Z = T->zone();
auto& lib = Library::Handle(Z);
if (obj.IsClass()) {
if (obj.IsLibrary()) {
lib = Library::Cast(obj).ptr();
} else if (obj.IsClass()) {
auto& klass = Class::Cast(obj);
if (!klass.has_pragma()) return false;
lib = klass.library();