[vm] Refactor handling of kernel data in compiler frontend

a) Remove 2 fields in our object representation:

  * PatchClass::library_data_
  * Library::kernel_data_

=> This saves O(#libraries + #patch-classes) which can amount up to
  10+ MB for big apps, as we save not just the slots but the
  [ExternalTypedData] objects they used to reference.

Instead we'll compute the KernelLibraryData when we need it by making a
[TypedDataView] of sub parts of the component.

b) We make a kernel binary be represented by a single [ExternalTypedData].

Whenever we need a sub-part of a kernel binary (e.g. one for each
component for concatinated kernels, or one for a library inside a
component) we use proper [TypedDataView]s for that.

c) As we sometimes need to create a view of only a particular library
within a component we need to find start/end of a library based on
index.

=> We store the library index instead of the library offset on
Library/PatchClass.
=> We can easily derive the start/end of a library from it's index by
looking at the kernel component encoding.

d) We make the [Reader] object work purely based on a pointer - instead
of making it have if/else when reading bytes (either from pointer or
from a view).

e) We make the [KernelProgramInfo] store the kernel_component and
various TD views into it.

TEST=ci

Change-Id: Ibe160881ff48635e834c3d647a977a144b5d0565
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313561
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
This commit is contained in:
Martin Kustermann
2023-07-14 10:15:06 +00:00
committed by Commit Queue
parent 006b3a8780
commit 0ae3368fb6
23 changed files with 554 additions and 534 deletions
+1 -3
View File
@@ -30,7 +30,6 @@ namespace dart {
F(Class, invocation_dispatcher_cache_) \
F(PatchClass, wrapped_class_) \
F(PatchClass, script_) \
F(PatchClass, library_kernel_data_) \
F(Function, name_) \
F(Function, owner_) \
F(Function, signature_) \
@@ -64,7 +63,6 @@ namespace dart {
F(Library, imports_) \
F(Library, exports_) \
F(Library, dependencies_) \
F(Library, kernel_data_) \
F(Library, resolved_names_) \
F(Library, exported_names_) \
F(Library, loaded_scripts_) \
@@ -72,6 +70,7 @@ namespace dart {
F(Namespace, show_names_) \
F(Namespace, hide_names_) \
F(Namespace, owner_) \
F(KernelProgramInfo, kernel_component_) \
F(KernelProgramInfo, string_offsets_) \
F(KernelProgramInfo, string_data_) \
F(KernelProgramInfo, canonical_names_) \
@@ -82,7 +81,6 @@ namespace dart {
F(KernelProgramInfo, constants_table_) \
F(KernelProgramInfo, libraries_cache_) \
F(KernelProgramInfo, classes_cache_) \
F(KernelProgramInfo, retained_kernel_blob_) \
F(WeakSerializationReference, target_) \
F(WeakSerializationReference, replacement_) \
F(WeakArray, length_) \