The code was previously pretty messy and hard to follow. This reworks some
things to make it more manageable. Among the changes:
* Pull out fragments of code into their own method, so the high level steps are
more apparent in methods like DexViewBuilder::Start.
* Pull frequently used types into global constants in dex_layout_compiler.cc.
* Rework register handling to track liveness so a strict stack discipline is no
longer needed.
Change-Id: Idb4b41f88c96a1ac4efb2c7b9bed05c2de0da999
This allows us to generate code that can read static fields in a class. Once we
include several other field operations, we will be able to generate more
specialized inflation code in the view compiler.
Bug: 111895153
Change-Id: Ia11195b1cea6d5a3ddbc60d972922586a062c853
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
* Add explicit to conversion constructors/operators
Bug: 28341362
Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,google-explicit-constructor
Change-Id: I9e7b929cfa65c68f4cdb4710c1c5c6760d56e4d5
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
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
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
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
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
This is planned to ship on device, so by convention the view_compiler should not
be in a tools directory.
Change-Id: I0eb03812d77ec38edc3908725acb40bacb345ecd