Revert "Dexpreopt: prepare to merge class loader context from al..."

Reason for revert: performance regression on AppStartup.
Reverted Changes:
I6522319a8:Dexpreopt: prepare to merge class loader context f...
Ic8528dffd:manifest_check.py: add uses-libraries propagaged v...

Bug: 235304939
Bug: 214255490
Change-Id: Iff6ad6f0d862df259bf9e3dd7017c268dbcbf8bf
This commit is contained in:
Ulya Trofimovich
2022-06-13 09:04:49 +00:00
parent 51ad6b81a8
commit 8b9f334eed
2 changed files with 52 additions and 87 deletions

View File

@@ -31,7 +31,6 @@ from __future__ import print_function
import json
from collections import OrderedDict
import os
import sys
@@ -43,9 +42,8 @@ def main():
# Read all JSON configs.
cfgs = []
for arg in sys.argv[1:]:
if os.stat(arg).st_size != 0:
with open(arg, 'r') as f:
cfgs.append(json.load(f, object_pairs_hook=OrderedDict))
with open(arg, 'r') as f:
cfgs.append(json.load(f, object_pairs_hook=OrderedDict))
# The first config is the dexpreopted library/app, the rest are its
# <uses-library> dependencies.
@@ -90,33 +88,6 @@ def main():
clcs2.append(clc)
clc_map2[sdk_ver] = clcs2
# Go over all uses-libraries in dependency dexpreopt.config files (these don't
# have to be uses-libraries themselves, they can be e.g. transitive static
# library dependencies) and merge their CLC to the current one
for ulib, cfg in uses_libs.items():
any_sdk_ver = 'any' # not interested in compatibility libraries
clcs = cfg['ClassLoaderContexts'].get(any_sdk_ver, [])
# If the dependency is a uses-library itself, its uses-library dependencies
# are added as a subcontext, so don't add them to top-level CLC.
dep_is_a_uses_lib = False
for clc2 in clc_map2[any_sdk_ver]:
if clc2['Name'] == cfg['ProvidesUsesLibrary']:
dep_is_a_uses_lib = True
if dep_is_a_uses_lib:
continue
# Check if CLC for these libraries is already present (avoid duplicates).
# Don't bother optimizing quadratic loop, since CLC is typically small.
for clc in clcs:
already_in_clc = False
for clc2 in clc_map2[any_sdk_ver]:
if clc2['Name'] == clc['Name']:
already_in_clc = True
break
if not already_in_clc:
clc_map2[any_sdk_ver] += clcs
# Overwrite the original class loader context with the patched one.
cfg0['ClassLoaderContexts'] = clc_map2