Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: tools/binary_size/libsupersize/file_format.py

Issue 2851473003: supersize: Track symbol aliases and shared symbols (Closed)
Patch Set: fix regression in calculate padding introduced in ps3 Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/binary_size/libsupersize/diff.py ('k') | tools/binary_size/libsupersize/helpers.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/binary_size/libsupersize/file_format.py
diff --git a/tools/binary_size/libsupersize/file_format.py b/tools/binary_size/libsupersize/file_format.py
index 537523a8a3834f135aded908c96339df086c6eb5..867d29c5e063030a817baa5eabe231381ff8286a 100644
--- a/tools/binary_size/libsupersize/file_format.py
+++ b/tools/binary_size/libsupersize/file_format.py
@@ -80,10 +80,14 @@ def _SaveSizeInfoToFile(size_info, file_obj):
delta=True)
_LogSize(file_obj, 'path indices') # For libchrome: adds 125kb.
+ prev_aliases = None
for group in by_section:
for symbol in group:
# Do not write name when full_name exists. It will be derived on load.
file_obj.write(symbol.full_name or symbol.name)
+ if symbol.aliases and symbol.aliases is not prev_aliases:
+ file_obj.write('\t0%x' % symbol.num_aliases)
+ prev_aliases = symbol.aliases
if symbol.flags:
file_obj.write('\t%x' % symbol.flags)
file_obj.write('\n')
@@ -132,14 +136,24 @@ def _LoadSizeInfoFromFile(file_obj):
raw_symbols = [None] * sum(section_counts)
symbol_idx = 0
for section_index, cur_section_name in enumerate(section_names):
+ alias_counter = 0
for i in xrange(section_counts[section_index]):
- line = next(lines)[:-1]
- name = line
- flags = 0
- last_tab_idx = line.find('\t', -3) # Allows for two digits of flags.
- if last_tab_idx != -1:
- flags = int(line[last_tab_idx + 1:], 16)
- name = line[:last_tab_idx]
+ parts = next(lines)[:-1].split('\t')
+ flags_part = None
+ aliases_part = None
+
+ if len(parts) == 3:
+ aliases_part = parts[1]
+ flags_part = parts[2]
+ elif len(parts) == 2:
+ if parts[1][0] == '0':
+ aliases_part = parts[1]
+ else:
+ flags_part = parts[1]
+
+ name = parts[0]
+ flags = int(flags_part, 16) if flags_part else 0
+ num_aliases = int(aliases_part, 16) if aliases_part else 0
new_sym = models.Symbol.__new__(models.Symbol)
new_sym.section_name = cur_section_name
@@ -152,6 +166,18 @@ def _LoadSizeInfoFromFile(file_obj):
new_sym.flags = flags
new_sym.padding = 0 # Derived
new_sym.full_name = None # Derived
+
+ if num_aliases:
+ assert alias_counter == 0
+ new_sym.aliases = [new_sym]
+ alias_counter = num_aliases - 1
+ elif alias_counter > 0:
+ new_sym.aliases = raw_symbols[symbol_idx - 1].aliases
+ new_sym.aliases.append(new_sym)
+ alias_counter -= 1
+ else:
+ new_sym.aliases = None
+
raw_symbols[symbol_idx] = new_sym
symbol_idx += 1
@@ -160,7 +186,7 @@ def _LoadSizeInfoFromFile(file_obj):
def SaveSizeInfo(size_info, path):
"""Saves |size_info| to |path}."""
- if os.environ.get('MEASURE_GZIP') == '1':
+ if os.environ.get('SUPERSIZE_MEASURE_GZIP') == '1':
with gzip.open(path, 'wb') as f:
_SaveSizeInfoToFile(size_info, f)
else:
« no previous file with comments | « tools/binary_size/libsupersize/diff.py ('k') | tools/binary_size/libsupersize/helpers.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698