Commit Graph

38 Commits

Author SHA1 Message Date
Chih-Hung Hsieh
34cd77a651 Add default code reviewers into OWNERS
Bug: 33166666
Test: gerrit uploader
Change-Id: Ief5d4bf9005bb3a712803101f98dd2b876662eb8
2019-02-06 22:19:19 -08:00
Chih-Hung Hsieh
2b61bddc1a Work around clang-tidy bug in dex_builder.cc.
Bug: 123880763
Test: build with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=*,-readability-*,
    -google-readability-*,-google-runtime-references,-cppcoreguidelines-*,
    -modernize-*,-llvm-*,-bugprone-narrowing-conversions,
    -misc-non-private-member-variables-in-classes,
    -misc-unused-parameters,-hicpp-*,-fuchsia-*

Change-Id: Ibf80f951ae2369a55570770febe8a1c4422181e1
2019-02-05 17:11:05 -08:00
Chih-Hung Hsieh
7ae7f169fb Temporarily disable clang-tidy for dex_builder.cc.
Bug: 123880763
Test: build with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=*,-readability-*,
-google-readability-*,-google-runtime-references,-cppcoreguidelines-*,
-modernize-*,-llvm-*,-bugprone-narrowing-conversions,
-misc-non-private-member-variables-in-classes,
-misc-unused-parameters,-hicpp-*,-fuchsia-*

Change-Id: I7be72b9db232a375bf7caf3b2dbeb9c6f7368a8e
2019-02-04 10:35:55 -08:00
Treehugger Robot
f96ebc501e Merge "[viewcompiler] Support more than 16 registers in invoke instructions" 2019-02-01 18:57:18 +00:00
Eric Holk
d1b4383660 [viewcompiler] Support more than 16 registers in invoke instructions
This was causing the viewcompiler to crash on deeper layout hierarchies.

We fix this by reserving several scratch registers. When an invoke instruction
uses registers that don't fit in a 4-bit field, we move all of these values into
the scratch registers and use an invoke/range instruction instead. The scratch
registers are all above the highest allocated register, so they are guaranteed
not to clobber meaningful values.

Supporting more registers for invoke also required supporting
register-to-register moves, which some how we'd gotten by without so far.

Finally, to make viewcompiler fail more loudly when things go wrong, many
DCHECKs have been changed to CHECKs.

Bug: 123517491
Test: atest
Change-Id: I9eb7c9bcf1fc7d713e664b331804bdcddafc95a4
2019-01-31 15:15:14 -08:00
Eric Holk
8c933e5a9d [viewcompiler] Add PrecompiledLayoutTest to TEST_MAPPING
PrecompiledLayoutTest makes sure that layouts generated by the viewcompiler are
equivalent to inflating from the resource XML file. We'll want to run these
tests when making changes to the viewcompiler.

Bug: 111895153
Test: atest
Change-Id: Iffa6f0f01c3f43d43feaabd1a5cd36be76650975
2019-01-31 21:22:06 +00:00
Orion Hodson
ca1b80b52e startop: use static_lib dependency on libdexfile.
libdexfile.so is moving to APEX and the external API doesn't include
the features needed for startop.

Bug: 119632407
Test: Builds
Change-Id: I6d33e8737341a508637321921ca732af913827a3
2019-01-28 13:32:37 +00:00
Eric Holk
0e0e7dde92 [viewcompiler] Enable input from file descriptor
This is needed to be able to launch the viewcompiler from installd. We only
support FD-input mode when reading from APKs. For output to an FD, we rely on
stdout redirection.

Bug: 111895153
Change-Id: I3025d83c60494485bada5f2f4cd67e25354d1d53
2019-01-15 10:03:46 -08:00
Eric Holk
bf30e31acc Make viewcompiler available on device
We'll need this binary on device to be able to compile views at application
install time. There will be a followup CL to the build system to make sure
viewcompiler is built and installed by default.

Bug: 111895153
Change-Id: I2c98864118dfeca79e36be760bd44b9afa03b4d4
2019-01-14 10:25:40 -08:00
Eric Holk
b377e5177e [view compiler] Compile all layouts in an APK
Test: atest
Bug: 111895153
Change-Id: I5f4b9b4c1160acf1c04a4492f5e3a736fbaf2fdc
2019-01-07 14:40:44 -08:00
Eric Holk
4273457c9e [view compiler] Add XML to DEX compilation
Test: atest
Bug: 111895153
Change-Id: I91c01ff4474e080c87b902ae963b5d655346f859
2019-01-05 01:36:05 +00:00
Eric Holk
ddc8990f09 [view-compiler] Better namespacing of util functions
This moves some helper functions into our own namespace to avoid conflicting
with other util.h files.

Bug: 111895153
Change-Id: I2b4c77732a97b34a8528d69867c15ed802686703
2019-01-02 18:02:31 +00:00
Eric Holk
162c812b65 [view compiler] Re-enable host-side tests
TEST_MAPPING supports both host and device tests now, so we should run both.

Test: atest
Bug: 111895153
Change-Id: I48f26093fc0ae3cdaa9e5295375945b5a519e1c2
2018-12-21 16:10:49 -08:00
Chih-Hung Hsieh
81aff0fbab Fix/suppress startop google-explicit-constructor warnings
* Add explicit to conversion constructors/operators

Bug: 28341362
Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,google-explicit-constructor
Change-Id: I9e7b929cfa65c68f4cdb4710c1c5c6760d56e4d5
2018-12-20 13:53:28 -08:00
Treehugger Robot
bce4bd1745 Merge "[view-compiler] DexBuilder: Add check-cast instruction" 2018-12-18 23:27:46 +00:00
Eric Holk
44d8cdfb06 [view-compiler] DexBuilder: Add check-cast instruction
Bug: 111895153
Test: atest

Change-Id: I767e56713fab6beaa6970e58c4fc4d3560cc1304
2018-12-18 16:47:05 +00:00
Treehugger Robot
ceea877ddd Merge "[view-compiler] Add layout validation" 2018-12-17 21:28:37 +00:00
Eric Holk
3cbf176e7c [view-compiler] Add layout validation
Layout validation walks over a layout resource and verifies that the layout only
uses features the layout compiler supports.

Currently this means we reject layouts that use any of the following tags:
  * include
  * fragment
  * merge
  * view

In the future, we will extend the layout compiler to handle these, but for now
we want to be liberal in what we reject.

Bug: 111895153
Test: atest view-compiler-tests
Change-Id: I8dca30c035a83b6763497a36fc60c68438fa1b0c
2018-12-14 09:36:14 -08:00
Eric Holk
c69449d95c [view-compiler] DexBuilder: Add more instructions
This CL adds the ability to generate code that calls static and virtual methods
which return objects, as well as the not-equal-to-zero comparison operator.

Bug: 111895153
Change-Id: I4ae9b3cb2edc6540671112b73c02bf6380d23051
2018-12-14 09:14:12 -08:00
Xin Li
15b123ef45 DO NOT MERGE - Merge pie-platform-release (PPRL.181205.001) into master
Bug: 120502534
Change-Id: Idc8bfb6d97a869b76cfb87ca1a494201baf9e8bd
2018-12-11 14:13:44 -08:00
Elliott Hughes
60a42ccac5 C++17 is the default now.
Test: builds
Change-Id: I64495775afe4ded7d3312cc35a154fecba64adc3
2018-12-03 09:38:35 -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
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
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
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
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
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
Treehugger Robot
22fe21df93 Merge "iorap: Remove blank newline in TEST_MAPPING" 2018-10-17 01:50:35 +00: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
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
Treehugger Robot
4ddd969fb9 Merge "startop: Add iorapd binder integration test" 2018-10-04 17:46:47 +00: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
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