134 Commits

Author SHA1 Message Date
Eric Holk
ee8fbc72e1 Merge "[view_compiler] cleanup: Use format-specific bytecode encoding functions" am: 9d599fde8e am: 6eeb8bef8d
am: decaa96ae1

Change-Id: Id65479b53822303bfb26fe1f220e9881a97f1cfc
2018-11-15 10:37:17 -08:00
Eric Holk
eb0db2f2a8 Merge "[view_compiler] DexBuilder: Add support for new and calling constructors" am: 2583def750 am: d6d6097c16
am: ae1a057780

Change-Id: Ie092cb59bf118d66362d654ad5e38c33807bb4cb
2018-11-15 10:25:32 -08:00
Eric Holk
1c0f3f099c [view_compiler] cleanup: Use format-specific bytecode encoding functions
This change corrals most of the bit shifting and ORing needed to encode Dex
instructions into EncodeXXX functions that follow the naming scheme at
https://source.android.com/devices/tech/dalvik/instruction-formats. Overall, it
makes the code easier to follow and probably even less error prone because we
only have to make the format right in one place.

Bug: 111895153
Change-Id: I902ec3c8bca6b5dc4ad900503af7aef58d4bbf5f
2018-11-15 17:44:03 +00:00
Eric Holk
8ee9d7d11d Merge "[view_compiler] DexBuilder: add support for string literals and null pointers" am: c96993154a am: f1c4799cb3
am: 32cdabf510

Change-Id: Ic0f834a704afafda2a644bd35e7cfe5e6448bbef
2018-11-15 06:01:20 -08:00
Eric Holk
b392758a65 [view_compiler] DexBuilder: Add support for new and calling constructors
This change also includes support for calling methods with more that one
argument. In fact, we can go up to four.

Bug: 111895153
Change-Id: I49472171cefcf57cdfce2ac4d41646ed4df29074
2018-11-13 13:47:29 -08:00
Eric Holk
3cc4afc610 [view_compiler] DexBuilder: add support for string literals and null pointers
Bug: 111895153
Change-Id: If6bdd9a280f6feed175be4da57733f3442e6dd14
2018-11-13 13:41:56 -08:00
Eric Holk
254fe344ed Merge "[view compiler] Add conditional branch instruction" am: d659ad62f4 am: 9d82929472
am: a60e020ac5

Change-Id: I4fc1500995770d5adbf5d6905ec4b74067b27648
2018-11-12 13:45:10 -08:00
Eric Holk
d62c5aa954 [view compiler] Add conditional branch instruction
This CL adds support for the if-eqz instruction. It should be easy to add
additional comparisons as needed.

This also introduces a new kind of Value called a Label. Labels may be created
any time and then must be bound to a location in code at some point. References
to labels are tracked, and when a label is bound all references are patched to
refer to the concrete address.

Bug: 111895153
Change-Id: I15424aec75425004f0f1f4bbc6e760bac3a6c7de
2018-11-10 00:46:07 +00:00
Eric Holk
1bf3b364a9 Merge "[view_compiler] Add end-to-end DexBuilder tests" am: 60b722a005 am: 66f78192a9
am: b6d1454fe3

Change-Id: Ifc10927b1dbf043648815aed57a686b9bd413689
2018-11-09 13:51:47 -08:00
Eric Holk
d683f9fa31 [view_compiler] Add end-to-end DexBuilder tests
These tests verify that code produced by DexBuilder can be loaded and run on
device. It works by introducing a new tool, dex_testcase_generator, which writes
out a couple of DEX files with test cases. This tool runs as a build step. The
generated DEX are then copied over to the device where they are loaded and run
the on-device DexBuilderTest.

Bug: 111895153

Change-Id: I06f5edd0e3e2f4e9ec2d14a0db7d22b75b424119
2018-11-08 21:14:32 +00:00
Eric Holk
bc120bcce6 Merge "[view-compiler] Support method declaration and invocation in Dex builder" am: 0b16b3c07f am: 4f60333798
am: 48d7de33fa

Change-Id: Ibe56507dd96e26dd14af4a7642b710b7fbb49c57
2018-11-07 12:59:13 -08:00
Eric Holk
faefd4f6c7 [view-compiler] Support method declaration and invocation in Dex builder
The Dex builder can now generate calls to methods (although not in all forms
yet). To help do this, we add a new virtual Instruction and Value class. This is
needed to generate code with values that are not known until the entire method
has been generated. In particular, we can now refer to function parameters.

The test method now accepts a String and returns the the length of the string.

Bug: 111895153
Change-Id: I11d52b083ae51d8151fccb1a65e45d40ff05fd81
2018-11-07 00:05:48 +00:00
Eric Holk
be452b24b5 Merge "Move startop/tools/view_compiler to startop/view_compiler" am: af22f56863 am: d99adc0e45
am: 4c8a976a0e

Change-Id: I09a8bcd5a4bc6420bb1b71ca27c0197b1d8aa5fd
2018-10-25 18:11:12 -07:00
Eric Holk
acf3fbde82 Move startop/tools/view_compiler to startop/view_compiler
This is planned to ship on device, so by convention the view_compiler should not
be in a tools directory.

Change-Id: I0eb03812d77ec38edc3908725acb40bacb345ecd
2018-10-22 11:13:42 -07:00
Igor Murashkin
013d97ca09 Merge "iorap: Remove blank newline in TEST_MAPPING" am: 22fe21df93 am: cbe655e781
am: d40cb164d5

Change-Id: I6637b6233ce90ec19437465050394232731540bb
2018-10-16 21:12:30 -07:00
Treehugger Robot
22fe21df93 Merge "iorap: Remove blank newline in TEST_MAPPING" 2018-10-17 01:50:35 +00:00
Igor Murashkin
3f12e8cc20 Merge "iorap: Add presubmit/postsubmit support" am: 7cbabff3f0 am: ff3a8bf0f7
am: eaef91f7aa

Change-Id: Ifa811049b34a90ea607e8d18d423890217dd4b0c
2018-10-16 16:22:28 -07:00
Treehugger Robot
7cbabff3f0 Merge "iorap: Add presubmit/postsubmit support" 2018-10-16 22:21:33 +00:00
Igor Murashkin
e53713c514 iorap: Remove blank newline in TEST_MAPPING
Change-Id: I378e86327951daa05512efd2ac491d27f9995ddd
2018-10-16 15:15:21 -07:00
Eric Holk
2014c4f051 Merge "Start on DexBuilder" am: 3e7d810a2f am: d4d3e215d7
am: d8a522c89c

Change-Id: I20614099a342c5ff2db14633c17672d471f72831
2018-10-16 10:30:44 -07:00
Eric Holk
dbc36e2bcb Start on DexBuilder
This change begins work on DexBuilder, which will allow us to generate DEX files
directly from layouts. This version is rather limited, but we will expand its
functionality in future CLs. The DexBuilder in this CL can create a DEX file
from scratch, define classes, and define methods on those classes. Within
methods, it supports extremely simple instructions, such as storing a small
constant in a register and returning a value from a register. Additionally,
there are tests to make sure that at least at a structural level, the generated
DEX files are valid.

DexBuilder and its associated builder classes use functionality from
libartdexfile and the Dex Slicer tool to support the actual encoding of DEX
files.

Test: atest, also manually tested by loaded a generated DEX file in an Android
app and verifying its behavior.

Change-Id: Iaa01aa7e3a0c7e4d5f4fa8dbce1492499c93c222
2018-10-15 15:26:11 -07:00
Igor Murashkin
b624fc1623 iorap: Add presubmit/postsubmit support
Also add support for temporarily disabling selinux
while running the iorap binder integration tests.

Test: atest --test-mapping frameworks/base/startop/iorap
Bug: 72170747
Change-Id: I0a5a006e28d4e1775aea4087c1b4731ebd3898a4
2018-10-15 14:28:19 -07:00
Igor Murashkin
ec5c04f4ab Merge "startop: Add iorapd binder integration test" am: 4ddd969fb9 am: 2c5f2a5d8a
am: 8e2b745c85

Change-Id: Ie85bcf0c226965d35d14c038d1f81e3ce50fb46f
2018-10-04 12:20:03 -07:00
Treehugger Robot
4ddd969fb9 Merge "startop: Add iorapd binder integration test" 2018-10-04 17:46:47 +00:00
Igor Murashkin
712c7974d0 Merge "startop: Add iorap parcelables for AIDL interfaces" am: 7b532b7370 am: 671842809a
am: 63613495a0

Change-Id: I870c29dfb99048c7c5a850e91d2fc5b6d3085efc
2018-10-03 19:55:09 -07:00
Treehugger Robot
7b532b7370 Merge "startop: Add iorap parcelables for AIDL interfaces" 2018-10-04 01:13:47 +00:00
Igor Murashkin
292a9347f7 startop: Add iorapd binder integration test
Connects to the binder 'iorapd' service as a client
and tests round-trip callback functionality.

Also adds mockito-inline to the test build, allowing us to mock
any class/methods, even if it's static or final.

Note: selinux is currently not supported, need to use
 $> adb shell setenforce 0

Prior to running any tests relying on binder connectivity.

Bug: 72170747
Test: atest libiorap-java-tests
Change-Id: Id5ba579845105e331d764838c357924810a64c6c
2018-10-02 17:51:38 -07:00
Igor Murashkin
ca4fee198a startop: Add iorap parcelables for AIDL interfaces
Bug: 72170747
Test: atest frameworks/base/startop/iorap
Change-Id: Icd3feebcd2342e66b63fbb0c0e8f08bade618c76
2018-10-02 17:51:34 -07:00
Eric Holk
77a0e97fb4 Merge "Prototype XML view compiler" am: 956791cee8 am: dcdd224bc0
am: 2bee1b09fc

Change-Id: Ifecd800f41fa06a4fedad3e53cc3744619f326ff
2018-10-01 18:52:48 -07:00
Eric Holk
c4239ac4a8 Prototype XML view compiler
This is an initial step towards a tool for pre-compiling layout XML files.  It
accepts an XML file and produces a Java language class called CompiledView with
a static method, inflate. Calling CompiledView.inflate should then return a view
object that is equivalent to calling LayoutInflater.inflate on the same
resource.

There are still several important limitations, but this works well enough to do
some experimentation. The limitations include:
* Currently only one layout can be compiled at a time.
* `merge` and `include` nodes are not supported.
* View compilation is a manual process that requires code changes in the
  application.
* The tests in this CL do not yet exercise any interesting behavior.

Bug: 111895153
Change-Id: I3e6880b08c52087d24ae7486495bd7fa282f4ff7
2018-10-01 14:05:10 -07:00
Igor Murashkin
973a2dcd6a startop: app_startup script fixes for youtube/chrome
Fix remote_pkill function to work on multiple pids,
this was breaking chrome (which has 3 pids).

Fix activity inference to the "$pkg/$activity"
pattern where previously it could accidentally parse
the wrong token.

Fix app launching to handle activities with '$' in
the name which adb shell treated as a variable.

Test: manual
Change-Id: Ifc9a72f1b9bb5e1416c7602f27f4614efd003849
2018-09-14 16:27:53 -07:00
Igor Murashkin
b622e783ca startop: Make app_startup_runner.py --compiler-filter force compilation
Adds a new script which is used by app_startup_runner.py and
run_app_with_prefetch in order to force the compilation filter.

Example:

  $> ./query_compiler_filter.py --package com.google.android.calculator
  speed-profile unknown arm64

(For example compiling to speed is extremely slow, compiling to
speed-profile is just marginally slow.)

Matching the compiler filter with what we actually need to measure is
extremely important as the performance will vary greatly.

Change-Id: I78ae76504208a672a7d17bab5001d11ab796d9d4
2018-09-13 18:19:26 -07:00
Igor Murashkin
45087deef4 startop: Add script to force dex2oat compilation filter for app
Example: ./force_compiler_filter --package com.google.android.apps.maps --compiler-filter speed-profile

Run the app just slightly enough to fully start up, then force it to
dump the profile and recompile the application with dex2oat under the
speed-profile filter.

(Also supports any other compilation filter such as quicken, speed,
etc).

Subsequently, this command can be used to manually validate that the
compiler filter was indeed changed:

 $ adb shell dumpsys package com.google.android.apps.maps | grep -A10 "Dexopt state"
 Dexopt state:
   [com.google.android.apps.maps]
     path: /data/app/com.google.android.apps.maps-D7s8PLidqqEq7Jc7UH_a5A==/base.apk
       arm64: [status=speed-profile] [reason=unknown]

Test: Manual (see above)
Change-Id: Iea6067f90dc287d1de651d1ab36df69d23b2e9c1
2018-09-13 13:56:58 -07:00
Igor Murashkin
25f394d681 startop: Add app startup measuring scripts
Test: python3 app_startup_runner_test.py
Change-Id: I4a3d0751ff4e3d74ea2937655cbafa5758e2ee1f
2018-09-11 16:43:22 -07:00