Optimize String's length/isEmpty for constant strings
If at compile time we know the length of the string, we can insert
that constant into the graph.
As part of this CL, I introduced VisitArrayLength in
ConstantFolding. This is done because:
* We are folding the instrucion into a constant so it makes
logical sense, and
* It plays better with isEmpty since that's an ArrayLength+Equal
which can be dealt with in one ConstantFolding pass.
As a note, there's VisitArrayLength in InstructionSimplifier which
would make sense to also move to ConstantFolding. However, in doing
so we get code size regressions. Added a TODO to see if we can deal
with that in the future.
Locally speed-compiling in a Pixel 5:
* SystemServer: -4.38 KB (-0.01%)
* SystemUIGoogle: -23.92KB (-0.09%)
* AGSA: -217.66KB (-0.07%)
Bug: 276416001
Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b
Change-Id: Ic2081d489482157b016762e0ec103319d3b9a46e
7 files changed