Commit e91be6b0 authored by smaier's avatar smaier Committed by Commit bot

Turning on optimizations for chromium code

This saves us 357kb of .dex size and 44kb of memory per process.

BUG=625704

Review-Url: https://codereview.chromium.org/2127973003
Cr-Commit-Position: refs/heads/master@{#406099}
parent 3052b731
...@@ -12,6 +12,15 @@ from util import build_utils ...@@ -12,6 +12,15 @@ from util import build_utils
from util import proguard_util from util import proguard_util
_DANGEROUS_OPTIMIZATIONS = [
# See crbug.com/625992
"code/allocation/variable",
# See crbug.com/625994
"field/propagation/value",
"method/propagation/parameter",
"method/propagation/returnvalue",
]
def _ParseOptions(args): def _ParseOptions(args):
parser = optparse.OptionParser() parser = optparse.OptionParser()
build_utils.AddDepfileOption(parser) build_utils.AddDepfileOption(parser)
...@@ -31,6 +40,8 @@ def _ParseOptions(args): ...@@ -31,6 +40,8 @@ def _ParseOptions(args):
parser.add_option('--classpath', action='append', parser.add_option('--classpath', action='append',
help='Classpath for proguard.') help='Classpath for proguard.')
parser.add_option('--stamp', help='Path to touch on success.') parser.add_option('--stamp', help='Path to touch on success.')
parser.add_option('--enable-dangerous-optimizations', action='store_true',
help='Enable optimizations which are known to have issues.')
parser.add_option('--verbose', '-v', action='store_true', parser.add_option('--verbose', '-v', action='store_true',
help='Print all proguard output') help='Print all proguard output')
...@@ -62,6 +73,8 @@ def main(args): ...@@ -62,6 +73,8 @@ def main(args):
classpath = list(set(options.classpath)) classpath = list(set(options.classpath))
proguard.libraryjars(classpath) proguard.libraryjars(classpath)
proguard.verbose(options.verbose) proguard.verbose(options.verbose)
if not options.enable_dangerous_optimizations:
proguard.disable_optimizations(_DANGEROUS_OPTIMIZATIONS)
input_paths = proguard.GetInputs() input_paths = proguard.GetInputs()
......
...@@ -45,6 +45,7 @@ class ProguardCmdBuilder(object): ...@@ -45,6 +45,7 @@ class ProguardCmdBuilder(object):
self._outjar = None self._outjar = None
self._cmd = None self._cmd = None
self._verbose = False self._verbose = False
self._disabled_optimizations = []
def outjar(self, path): def outjar(self, path):
assert self._cmd is None assert self._cmd is None
...@@ -87,6 +88,10 @@ class ProguardCmdBuilder(object): ...@@ -87,6 +88,10 @@ class ProguardCmdBuilder(object):
assert self._cmd is None assert self._cmd is None
self._verbose = verbose self._verbose = verbose
def disable_optimizations(self, optimizations):
assert self._cmd is None
self._disabled_optimizations += optimizations
def build(self): def build(self):
if self._cmd: if self._cmd:
return self._cmd return self._cmd
...@@ -123,6 +128,9 @@ class ProguardCmdBuilder(object): ...@@ -123,6 +128,9 @@ class ProguardCmdBuilder(object):
'-libraryjars', ':'.join(self._libraries), '-libraryjars', ':'.join(self._libraries),
] ]
for optimization in self._disabled_optimizations:
cmd += [ '-optimizations', '!' + optimization ]
cmd += [ cmd += [
'-injars', ':'.join(self._injars) '-injars', ':'.join(self._injars)
] ]
......
...@@ -701,6 +701,11 @@ if (enable_java_templates) { ...@@ -701,6 +701,11 @@ if (enable_java_templates) {
if (defined(invoker.args)) { if (defined(invoker.args)) {
args += invoker.args args += invoker.args
} }
if (defined(invoker.proguard_jar_path)) {
# We assume that if we are using a different ProGuard, this new version
# can handle the 'dangerous' optimizaions.
args += [ "--enable-dangerous-optimizations" ]
}
} }
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
-keep @interface *** -keep @interface ***
# Disable obfuscation for the following two packages. # Disable obfuscation for the following two packages.
-keepnames class com.google.android.apps.chrome.**,org.chromium.** { -keepnames,allowoptimization class com.google.android.apps.chrome.**,org.chromium.** {
*; *;
} }
......
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