History log of /art/runtime/verifier/verifier_deps.cc
Revision Date Author Comments
76c1965179bdf34ed9d0dded046c7ad6f277de3f 24-Apr-2017 Andreas Gampe <agampe@google.com> ART: More header cleanup - method_verifier.h

Move enumerations to own header. Move the compiler interface (of what
the compiler can tolerate) into its own header. Replace or remove
method_verifier.h where possible.

Test: mmma art
Change-Id: I075fcb10b02b6c1c760daad31cb18eaa42067b6d
(cherry picked from commit 6d7abbd2324f544c6b6da42bb6b9b531df0ce3cd)
a1d2f957a21319d1110bebb9a52f46fd1c67ffaf 21-Apr-2017 Andreas Gampe <agampe@google.com> ART: Clean up art_field.h

Clean up the header. Fix up other headers including the -inl file,
in an effort to prune the include graph. Fix broken transitive
includes by making includes explicit.

Test: m
Change-Id: I6ff2d6f89b741d8188e19426eccf4743fec688fc
c6ea7d00ad069a2736f603daa3d8eaa9a1f8ea11 02-Feb-2017 Andreas Gampe <agampe@google.com> ART: Clean up art_method.h

Clean up the header. Fix up other headers including the -inl file,
in an effort to prune the include graph. Fix broken transitive
includes by making includes explicit. Introduce new -inl files
for method handles and reference visiting.

Test: source build/envsetup.sh && lunch aosp_angler-userdebug && mmma art
Test: source build/envsetup.sh && lunch aosp_mips64-userdebug && mmma art
Change-Id: I8f60f1160c2a702fdf3598149dae38f6fa6bc851
bdb540dc8d09c48ee19cf035f418bcae0f00660e 19-Apr-2017 Nicolas Geoffray <ngeoffray@google.com> Vdex: Workaround arrays with erroneous component type.

The assignability DCHECK is only reliable when classes are not
erroneous. For arrays whose component type could be erroneous,
the verifier can join types even if they're not assignable.

bug:33770646
Test: verifier_deps_test
Change-Id: I4ec1b12b2e2c7d5b57b51a64aea381f951a38dcd
fc38e919bad23670e38a484d4728f300406415c3 16-Mar-2017 Nicolas Geoffray <ngeoffray@google.com> Do not assume type relationship when recording "not assignable"

The verifier may record that an interface I does not extend a
class A. If A is not j.l.Object, this is always true, but
A might change after a system update from a class to an interface.

bug: 34849974
test: verifier_deps_test
Change-Id: Ic2876edce9a2a6f7b402420a5e01763aba2b39a4
6e54f78c7c1e01c1a91a458c6e51cca1c7d13ad4 08-Mar-2017 Nicolas Geoffray <ngeoffray@google.com> Only look at vdex related access flags for class/fields/methods.

class/fields/methods can have a lot of flags, but only a handful
of them affect verification.

bug: 35913145
test: verifier_deps_test
Change-Id: I5c374b50e811b5e134cdb868a2cc674900a1bdec
fa4333dcb481e564f54726b4e6f8153612df835e 14-Feb-2017 Andreas Gampe <agampe@google.com> ART: Add operator == and != with nullptr to Handle

Get it in line with ObjPtr and prettify our code.

Test: m
Change-Id: I1322e2a9bc7a85d7f2441034a19bf4d807b81a0e
865cf901e9f16680ca3594a5ab8d8e17b0b6f9d4 18-Jan-2017 Nicolas Geoffray <ngeoffray@google.com> vdex optimization: avoid doing application type resolution.

When looking up for methods/fields, we can take the class
that was originally found as holding the method. If a subclass
of that class ends up redefining it after an OTA, it cannot
alter the expected flags anyways (eg a public method cannot be
overridden with a non-public method).

bug: 30937355
test: test-art-host
Change-Id: Ie3fbe0e829a27db61c534c4a49e945cc1afed9b9
0e2fe0ff28a89721bcf225027093ac693d568a5c 21-Dec-2016 Nicolas Geoffray <ngeoffray@google.com> Find the classpath boundary for being assignable to an interface.

Test: verifier_deps_test, test-art-host

Change-Id: Icab3a5a9f94f6a38fa8ef320f93ac14691a732d3
0f1cb17d23b664b96b6966e5d0f280df5925f56f 05-Jan-2017 Nicolas Geoffray <ngeoffray@google.com> Actually record arrays in classpath.

With https://android-review.googlesource.com/#/c/316151/,
I was under the wrong impression arrays all have the same
access flags. They actually have the visibility of the inner
most component type.

Therefore, we still need to record visibility of array types whose
innermost component type is in the classpath.

Test: verifier_deps_test
Change-Id: If7b1004efb679e320330258f42ced83b8eedae87
2709b5fc91e9b151f0c48c52b3401d49e1e3c4ba 21-Dec-2016 Nicolas Geoffray <ngeoffray@google.com> Do not record dependencies on arrays.

We do not record dependencies on arrays with component types in
the compiled DEX files, as the only thing that might change is their
access flags. If we were to change these flags in a breaking way, we would
need to enforce full verification again anyways.

Saves on doing type resolution during vdex update.

Test: test-art-host
Change-Id: Ib85e172a5cb99c2999eed8b6b37390aa6b5cac37
119e846b04c7c12c5b332122e71e9365b4a462f0 21-Dec-2016 Nicolas Geoffray <ngeoffray@google.com> Point optimizations for vdex.

- Do not record assignability due to not optimized CHECKCAST.
- Do not record that j.l.Object must not be assignable to other types.
- Chase the super class boundary to avoid recording a dependency
on a local class. This avoids doing type resolution of that class when
verifying the VerifierDeps.

Test: test-art-host
bug: 30937355
Change-Id: Ibcee205451f23958c759ddcca7f88fe9003d37a9
d1665a03ddad0e19f71e186efd8b5d2c217f1b40 12-Dec-2016 Nicolas Geoffray <ngeoffray@google.com> Handle primitive types in VerifierTypes::AddAssignability.

The dex2dex compiler might indirectly call it with arrays
of primitives.

Also remove dead APUT_OBJECT optimization in VerifiedMethod.
It was added for optimizing Quick:
https://googleplex-android-review.googlesource.com/#/c/371193

Commit hash:
a9a8254c920ce8e22210abfc16c9842ce0aea28f

But Quick is gone.

Test: 630-safecast-array
bug: 33498750, 32546807, 32546608

Change-Id: Icfd3f8d915bfe225f05dbec42f9ba25dc1243fdc
8a0128a5ca0784f6d2b4ca27907e8967a74bc4c5 28-Nov-2016 Andreas Gampe <agampe@google.com> ART: Add dex::StringIndex

Add abstraction for uint32_t string index.

Test: m test-art-host
Change-Id: I917c2881702fe3df112c713f06980f2278ced7ed
fc2dd6110c7ce5fc272836d1a7e48f3b40612c2d 22-Nov-2016 Mathieu Chartier <mathieuc@google.com> Speed up verified methods

Switch to an array of atomic pointers instead of a map. Removes lock
and map lookup. Also address comments from previous CL.

GetVerifiedMethod: 1.59% -> 0.18% of compilation time.

Install time seems to goes down by around 1%.

Also has significant RAM savings (FB host compile):
dex2oat native alloc: 84695472B -> 71268736B

For the JIT case, the old method is used to prevent any increase in
RAM usage.

Bug: 32641252

Test: test-art-host
Change-Id: I47b4b8a4a3cb3f8ef23e36a888b8885e12168787
340dafabc8e88378e395cda9027cf17726910e91 18-Nov-2016 Nicolas Geoffray <ngeoffray@google.com> Use a per-thread VerifierDeps.

Avoid lock contention on a singleton VerifierDeps by allocating
temporary per-thread VerifierDeps that get merged after verification.

This saves around ~35% compile-times on interpret-only.

Only the creation of extra strings is guarded by a lock, for simplicity.

Test: test-art-host, test-art-target
bug: 32641252
bug: 30937355

Change-Id: I11a2367da882b58e39afa7b42cba2e74a209b75d
32b50302d9826430013e008b45d5c71e6b7a2469 17-Nov-2016 Mathieu Chartier <mathieuc@google.com> Check same dex file for finding class descriptor string id

Use ClassDef for finding same dex file class descriptor string id
for vdex. Removes some calls to FindStringId, the remaining calls to
FindStringId are due to multidex or referring to types in the boot
class path.

Also check method index slot to see if we get lucky.

Host perf:
DexFile::FindStringId: 2.57% -> 0.94%

Not done for fields since these do not seem to reach the FindStringId
case accordingto perf. The remaining calls to FindStringId come from:
100.00% verifier::VerifierDeps::GetClassDescriptorStringId
-> 66.62% verifier::VerifierDeps::AddAssignability
-> 33.38% verifier::VerifierDeps::AddMethodResolution

FB install time: 35.54s -> 34.41s (avg of 40 samples at 960MHZ N6P).

Bug: 32641252

Test: test-art-host

Change-Id: If50408cf1be5c2d2127140780b8d5af66306939c
a5b09a67034e57a6e10231dd4bd92f4cb50b824c 18-Nov-2016 Andreas Gampe <agampe@google.com> ART: Add dex::TypeIndex

Add abstraction for uint16_t type index.

Test: m test-art-host
Change-Id: I47708741c7c579cbbe59ab723c1e31c5fe71f83a
6bb7f1b60f4b6b2214457d19d66d2b7b50685feb 03-Nov-2016 Nicolas Geoffray <ngeoffray@google.com> Integrate VerifierDeps in compiler driver.

If a VerifierDeps is given, try fast verify. Otherwise create
a new VerifierDeps and do the full verification.

test: test-art-host, verifier_deps_test
bug: 30937355
Change-Id: Ifb030d7b5232c95872164f601057a56ab96038e1
8904b6f0e496ab389551e960426069c9deff4101 28-Oct-2016 Nicolas Geoffray <ngeoffray@google.com> Add VerifierDeps::Verify.

Method verifies that the recorded dependencies still hold.

test: verifier_deps_test.cc
bug: 30937355
Change-Id: I137f77739355141e46994b4cb6043dbbc9353637
e70dd560154ea38af87ce8b783ab6e382eb49d4b 30-Oct-2016 Nicolas Geoffray <ngeoffray@google.com> Dump VerifierDeps in oatdump.

bug:30937355
test: oatdump_test
Change-Id: I344726a20f21a6c6986047c21278c753b9e24575
d01f60cbed4ba360b84f1310d2e0d422d6a16534 28-Oct-2016 Nicolas Geoffray <ngeoffray@google.com> Add a VerifierDeps::Dump method.

Also, fix the Encode/Decode logic around dex file order:
iterating over a std::map doesn't guarantee insertion order.

test: verifier_deps_test
bug: 30937355

Change-Id: Id3efd703b3c8ca21ab49c2600c612c132fb021cd
0802518a6a5af8182131eb3fe66bf58dd77f9fe2 25-Oct-2016 Nicolas Geoffray <ngeoffray@google.com> Save the non-verified classes in the VerifierDeps.

We will need that information when taking an OTA to make sure
the same set of classes needs to be verified at runtime.

Currently, the vdex file will contain a list of unverified
classes. We could alternatively encode a bit vector of the size
of the type_id array, but the few experiments I did show that
the bit vector is actually larger. We can refine this later.

bug: 30937355
test: m test-art-host
test: verifier_deps_test.cc

Change-Id: I2670e4fd2e54ee7a148246baa705fda3a56617ff
709b070044354d9f47641f273edacaeeb0240ab7 13-Oct-2016 David Sehr <sehr@google.com> Remove mirror:: and ArtMethod deps in utils.{h,cc}

The latest chapter in the ongoing saga of attempting to dump a DEX
file without having to start a whole runtime instance. This episode
finds us removing references to ArtMethod/ArtField/mirror.

One aspect of this change that I would like to call out specfically
is that the utils versions of the "Pretty*" functions all were written
to accept nullptr as an argument. I have split these functions up as
follows:
1) an instance method, such as PrettyClass that obviously requires
this != nullptr.
2) a static method, that behaves the same way as the util method, but
calls the instance method if p != nullptr.
This requires using a full class qualifier for the static methods,
which isn't exactly beautiful. I have tried to remove as many cases
as possible where it was clear p != nullptr.

Bug: 22322814
Test: test-art-host
Change-Id: I21adee3614aa697aa580cd1b86b72d9206e1cb24
3398c7874e002beaa6c2b2fadf183e7d1ddad23a 30-Sep-2016 Mathieu Chartier <mathieuc@google.com> Move ArtField to ObjPtr

Added EXPECT_OBJ_PTR_EQ and variants to gtests.

Fixed moving GC bugs in:
ClassLinker::CreatePathClassLoader
ClassLinkerTest: StaticFields

ObjPtr Decode call sites: 186 -> 181.

Some tests fail due to ResolvedFieldAccessTest, will fix in follow
up CL.

Bug: 31113334

Test: test-art-host CC baker

Change-Id: I8b266ad00f3c20c8cbe7cfdf280d175083df0b88
6f82fbddf69388180e4dca9bcb5ce2e183e42bfa 14-Sep-2016 David Brazdil <dbrazdil@google.com> Implement VerifierDeps encoding/decoding

This patch implements serialization and deserialization of the data
recorded by VerifierDeps.

Test: m test-art-host-gtest-verifier_deps_test
Bug: 30937355
Change-Id: I19320b8e70d5c5128653d09a5cdb5b6f677a2f2d
ca3c8c33501bf199d6fd0a5db30a27d8e010cb23 06-Sep-2016 David Brazdil <dbrazdil@google.com> Collect verifier dependencies

MethodVerifier tests whether a DEX method is valid w.r.t. the classes
in class path. Since the APK does not change across OTA updates, it
is not necessary to analyze the bytecode again with MethodVerifier,
as long as its dependencies on the class path (which may have changed)
are satisfied.

This patch introduces VerifierDeps, a class path dependency collector,
and adds hooks into MethodVerifier where classes/methods/fields are
resolved and where assignability of types is tested.

Test: m test-art-host-gtest-verifier_deps_test
Bug: 30937355
Change-Id: Iee0b321d772a5c7d1cb471aaa6e13918310b7e2f