Commit 51b9bbb4 authored by Peter Wen's avatar Peter Wen Committed by Commit Bot

Supersize: Add sources for large .other symbols

These large binary files are copied over to the root output directory
and then copied into the apk. There is no good way to propagate their
source paths like pak or dex since they are plainly copied.

These files rarely, if ever, change. Some are even renamed from the
actual source file to this final name. Thus adding them as constants.

Bug: 827196
Change-Id: I20611da9784fc9b355cc29845a61c3814306e291
Reviewed-on: https://chromium-review.googlesource.com/1007884
Commit-Queue: Peter Wen <wnwen@chromium.org>
Reviewed-by: default avataragrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549970}
parent afc83676
......@@ -57,6 +57,14 @@ class SectionSizeKnobs(object):
# change.
self.pak_compression_ratio = 0.33
# File name: Source file.
self.apk_other_files = {
'icudtl.dat': 'third_party/icu/android/icudtl.dat',
'snapshot_blob_32.bin': 'v8/snapshot_blob_32.bin',
'snapshot_blob_64.bin': 'v8/snapshot_blob_64.bin',
'natives_blob.bin': 'v8/natives_blob.bin',
}
def _OpenMaybeGz(path):
"""Calls `gzip.open()` if |path| ends in ".gz", otherwise calls `open()`."""
......@@ -811,7 +819,7 @@ def _ParseDexSymbols(section_sizes, apk_path, output_directory):
return symbols
def _ParseApkOtherSymbols(section_sizes, apk_path, apk_so_path):
def _ParseApkOtherSymbols(section_sizes, apk_path, apk_so_path, knobs):
apk_name = os.path.basename(apk_path)
apk_symbols = []
zip_info_total = 0
......@@ -823,7 +831,9 @@ def _ParseApkOtherSymbols(section_sizes, apk_path, apk_so_path):
or zip_info.filename.endswith('.dex')
or zip_info.filename.endswith('.pak')):
continue
path = os.path.join(apk_name, 'other', zip_info.filename)
file_name = os.path.basename(zip_info.filename)
path = knobs.apk_other_files.get(
file_name, os.path.join(apk_name, 'other', zip_info.filename))
apk_symbols.append(models.Symbol(
models.SECTION_OTHER, zip_info.compress_size,
object_path=path, full_name=os.path.basename(zip_info.filename)))
......@@ -941,7 +951,7 @@ def CreateSectionSizesAndSymbols(
raw_symbols.extend(
_ParseDexSymbols(section_sizes, apk_path, output_directory))
raw_symbols.extend(
_ParseApkOtherSymbols(section_sizes, apk_path, apk_so_path))
_ParseApkOtherSymbols(section_sizes, apk_path, apk_so_path, knobs))
elif pak_files and pak_info_file:
pak_symbols_by_id = _FindPakSymbolsFromFiles(
pak_files, pak_info_file, output_directory)
......@@ -1068,7 +1078,8 @@ def _AutoIdentifyInputFile(args):
format_text = file_output[file_output.find(': ') + 2:]
# File-not-found -> 'cannot ...' and directory -> 'directory', which don't
# match anything here, so they are handled by the final 'return False'.
if format_text.startswith('Java archive data '):
if (format_text.startswith('Java archive data') or
format_text.startswith('Zip archive data')):
logging.info('Auto-identified --apk-file.')
args.apk_file = args.f
return True
......
......@@ -45,6 +45,7 @@ _TEST_APK_PATH = os.path.join(_TEST_OUTPUT_DIR, 'test.apk')
_TEST_APK_SO_PATH = 'test.so'
_TEST_APK_SMALL_SO_PATH = 'smalltest.so'
_TEST_APK_DEX_PATH = 'test.dex'
_TEST_APK_OTHER_FILE_PATH = 'icudtl.dat'
update_goldens = False
......@@ -134,9 +135,12 @@ class IntegrationTest(unittest.TestCase):
elf_file.write(IntegrationTest._CreateBlankData(27))
with zipfile.ZipFile(_TEST_APK_PATH, 'w') as apk_file:
apk_file.write(_TEST_ELF_PATH, _TEST_APK_SO_PATH)
# Exactly 8MB of data (2^23).
# Exactly 4MB of data (2^22).
apk_file.writestr(
_TEST_APK_SMALL_SO_PATH, IntegrationTest._CreateBlankData(22))
# Exactly 1MB of data (2^20).
apk_file.writestr(
_TEST_APK_SMALL_SO_PATH, IntegrationTest._CreateBlankData(23))
_TEST_APK_OTHER_FILE_PATH, IntegrationTest._CreateBlankData(20))
pak_rel_path = os.path.relpath(_TEST_APK_PAK_PATH, _TEST_APK_ROOT_DIR)
apk_file.write(_TEST_APK_PAK_PATH, pak_rel_path)
# Exactly 8MB of data (2^23).
......
apk_file_name=test.apk
apk_size=151002494
apk_size=147856862
elf_arch=arm
elf_build_id=WhatAnAmazingBuildId
elf_file_name=elf
......@@ -42,8 +42,8 @@ Section .pak.translations: has 100.0% of 6821 bytes accounted for from 207 symbo
* Padding accounts for 0 bytes (0.0%)
* Contains 0 aliases
* 0 symbols have shared ownership
Section .other: has 100.0% of 42373191 bytes accounted for from 3 symbols. 0 bytes are unaccounted for.
* Padding accounts for 33984583 bytes (80.2%)
Section .other: has 100.0% of 39227559 bytes accounted for from 4 symbols. 0 bytes are unaccounted for.
* Padding accounts for 33984679 bytes (86.6%)
* Contains 0 aliases
* 0 symbols have shared ownership
.data@2de7000(size_without_padding=4,padding=0,full_name=google::protobuf::internal::pLinuxKernelCmpxchg,object_path=base/base/page_allocator.o,source_path=base/page_allocator.cc,flags={},num_aliases=1)
......@@ -254,8 +254,9 @@ Section .other: has 100.0% of 42373191 bytes accounted for from 3 symbols. 0 byt
.dex.method@0(size_without_padding=79,padding=0,full_name=org.chromium.chrome.browser.compositor.layouts.phone.stack.StackAnimationLandscape float getScreenPositionInScrollDirection(org.chromium.chrome.browser.compositor.layouts.phone.stack.StackTab),object_path=test.apk/prebuilt/org/chromium/chrome/browser/compositor/layouts/phone/stack/StackAnimationLandscape,source_path=,flags={gen},num_aliases=1)
.dex.method@0(size_without_padding=54,padding=0,full_name=org.chromium.chrome.browser.compositor.layouts.phone.stack.StackAnimationLandscape float getScreenSizeInScrollDirection(),object_path=test.apk/prebuilt/org/chromium/chrome/browser/compositor/layouts/phone/stack/StackAnimationLandscape,source_path=,flags={gen},num_aliases=1)
.dex.method@0(size_without_padding=52,padding=0,full_name=org.chromium.chrome.browser.compositor.layouts.phone.stack.StackAnimationLandscape boolean isDefaultDiscardDirectionPositive(),object_path=test.apk/prebuilt/org/chromium/chrome/browser/compositor/layouts/phone/stack/StackAnimationLandscape,source_path=,flags={gen},num_aliases=1)
.other@0(size_without_padding=8388608,padding=0,full_name=smalltest.so,object_path=test.apk/other/smalltest.so,source_path=,flags={},num_aliases=1)
.other@0(size_without_padding=0,padding=412,full_name=Overhead: APK file,object_path=,source_path=,flags={},num_aliases=1)
.other@0(size_without_padding=4194304,padding=0,full_name=smalltest.so,object_path=test.apk/other/smalltest.so,source_path=,flags={},num_aliases=1)
.other@0(size_without_padding=1048576,padding=0,full_name=icudtl.dat,object_path=third_party/icu/android/icudtl.dat,source_path=,flags={},num_aliases=1)
.other@0(size_without_padding=0,padding=508,full_name=Overhead: APK file,object_path=,source_path=,flags={},num_aliases=1)
.other@0(size_without_padding=0,padding=33984171,full_name=Overhead: ELF file,object_path=,source_path=,flags={},num_aliases=1)
.rodata@266e600(size_without_padding=5,padding=0,full_name=string literal,object_path=base/base/page_allocator.o,source_path=base/page_allocator.cc,flags={},num_aliases=2)
.rodata@266e600(size_without_padding=5,padding=0,full_name=string literal,object_path=third_party/icu/icuuc/ucnv_ext.o,source_path=third_party/icu/ucnv_ext.c,flags={gen},num_aliases=2)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment