summaryrefslogtreecommitdiff
path: root/compiler/driver/compiler_driver.cc
AgeCommit message (Collapse)Author
2019-03-11Move CompilerDriver to dex2oat/. Vladimir Marko
Also DexToDexCompiler, QuickCompilerCallbacks and tests. aosp_taimen-userdebug: - before: lib64/libart-compiler.so: 3112344 lib/libart-compiler.so: 2312908 bin/dex2oat: 563176 - after: lib64/libart-compiler.so: 2986720 (-123KiB) lib/libart-compiler.so: 2219852 (-91KiB) bin/dex2oat: 635832 (+71KiB) Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --jit Change-Id: I36e63b83dff1d5c731d05de27d3663cfc81de6ad
2019-03-05Refactor compiler tests around CompilerDriver. Vladimir Marko
Introduce CommonCompilerDriverTest and inherit that in tests that need to use CompilerDriver. This is in preparation for moving the CompilerDriver to dex2oat/. Test: m test-art-host-gtest Change-Id: I46cf0bc1df4327569eef5526eeab0781473173a1
2019-02-21Merge changes Ifd690cda,I7bcbe947 David Brazdil
* changes: Fix vdex fast-verify performance regression Improve `verified`, add `redefined` class status in VerifierDeps
2019-02-20Fix vdex fast-verify performance regression David Brazdil
Recent CL I0d06b82e31088c58d4493723a5435309740f1d0c generalized the fast-verify class redefinition check by checking that all vdex-verified classes resolve to dex files covered by the vdex and are not duplicates of classes in parent class loaders. This introduced a performance and allocated memory regression for dex2oat invoked with compiler-filter=verify(-profile). This patch removes the regression by acquiring a list of classpath dex files from the compiler driver and boot classpath dex files from the class linker, avoiding class resolution altogether. A small performance overhead remains as previously only boot classpath was being searched. Test: run `dex2oat filter=interpret-only; dex2oat filter=verify` compare time and allocated memory numbers before CL and after Change-Id: Ifd690cdafdc99d3eafb9847d67775fc11a5b5023
2019-02-20Improve `verified`, add `redefined` class status in VerifierDeps David Brazdil
Changes implementation of `unverified_classes_` in VerifierDeps from std::set<dex::TypeIndex> to `verified_classes_` of type std::vector<bool> indexed by class def indices. This cleans up the implementation and speeds up access during fast-verify. Encoding remains the same - a set of indices of unverified classes - only these are now class def indices. A second bit vector `redefined_classes_` is added, also indexed by class def indices. It records classes that were not verified because they were eclipsed by classes that took precedence during resolution. This allows VerifierDeps::VerifyInternalClasses to succeed when a class redefined now was also redefined when the deps were being created because the class was treated as external and dependencies on it were recorded. Test: m test-art-gtest-verifier_deps_test Change-Id: I7bcbe947c3c74535306e6dbb5b288076f320a7bc
2019-02-20ART: Reduce dependencies on CompilerDriver. Vladimir Marko
Preparation for moving CompilerDriver and other stuff from libart-compiler.so to dex2oat. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Ic221ebca4b8c79dd1549316921ace655f2e3f0fe
2019-02-11Merge changes Id4ffa9f9,I1bb5d05d Vladimir Marko
* changes: Replace MergeSets() with std::set::merge(). Replace StringPiece with std::string_view.
2019-02-08Replace MergeSets() with std::set::merge(). Vladimir Marko
And clear up ownership of the VerifierDeps being merged by using std::unique_ptr<>. Test: m test-art-host-gtest Test: testrunner.py --host Bug: 123750182 Change-Id: Id4ffa9f9fa1968fa762b9e825f25827240f6d45d
2019-02-07Merge "Generalize vdex class redefinition check" David Brazdil
2019-02-06Generalize vdex class redefinition check David Brazdil
The check introduced in CL If0c56b1970d8ebe701d198ffccec52f586aea9e6 skips fast verification if an apk's class is overshadowed by a class in boot classpath because the vdex dependencies do not contain intra-apk dependencies. However, the change only checks for presence of a duplicate class in the boot classloader, while a duplicate class could be in any of the parent classloaders. Fix this and move the check into VerifierDeps to make it a proper part of the verification process. The CL also refactors VerifierDeps::ValidateDependencies to output an error string for better logging. Bug: 122968669 Test: test/testrunner/testrunner.py -t 719 Test: m test-art-gtest-verifier_deps_test Change-Id: I0d06b82e31088c58d4493723a5435309740f1d0c
2019-02-06Replace StringPiece with std::string_view in HashSet. Vladimir Marko
Update HashSet comment and related code. Also remove dead CompilerOptions declarations with StringPiece parameters. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 123750182 Change-Id: I4a39d0e8e0392a414129369c5b304ec4813e9ed5
2019-01-31Ensure the correctness of fast verify Calin Juravle
We cannot guarantee that the resolution recorded in the vdex file is correct when the boot classes are redefined. For example we might be doing only sdk verification and not have the entire context available - as such, if an app redefines a class that is in the boot classpath but not the sdk we might record the wrong resolution. Another example is OTA time, when the boot classpath may change. The CL discards the vdex file when the app redefines classes from boot classpath. Test: test/testrunner/testrunner.py -t 719 Bug: 122968669 Change-Id: If0c56b1970d8ebe701d198ffccec52f586aea9e6
2019-01-02ART: Move dex structs into own header Andreas Gampe
Separating out the structs from DexFile allows them to be forward- declared, which reduces the need to include the dex_file header. Bug: 119869270 Test: m Change-Id: I32dde5a632884bca7435cd584b4a81883de2e7b4
2018-12-28Merge "ART: Refactor for bugprone-argument-comment" Treehugger Robot
2018-12-27Add dumping for number of classes initialized Mathieu Chartier
For --dump-stats, dump how many classes are each status after attempting initialization. Test: <compile_apk> --instruction-set=arm64 --app-image-file=generated.art --dump-stats Sample output: dex2oat I 12-21 19:18:56 58439 58439 compiler_driver.cc:109] 100% of instance fields resolved for 1575 cases dex2oat I 12-21 19:18:56 58439 58439 compiler_driver.cc:109] 1.88679% of check-casts removed based on type information for 53 cases dex2oat I 12-21 19:18:56 58439 58439 compiler_driver.cc:109] 0% of classes with status NotReady for 32155 cases dex2oat I 12-21 19:18:56 58439 58439 compiler_driver.cc:109] 0% of classes with status Retired for 32155 cases dex2oat I 12-21 19:18:56 58439 58439 compiler_driver.cc:109] 0% of classes with status ErrorResolved for 32155 cases dex2oat I 12-21 19:18:56 58439 58439 compiler_driver.cc:109] 0% of classes with status ErrorUnresolved for 32155 cases dex2oat I 12-21 19:18:56 58439 58439 compiler_driver.cc:109] 0% of classes with status Idx for 32155 cases dex2oat I 12-21 19:18:56 58439 58439 compiler_driver.cc:109] 0% of classes with status Loaded for 32155 cases dex2oat I 12-21 19:18:56 58439 58439 compiler_driver.cc:109] 0% of classes with status Resolving for 32155 cases dex2oat I 12-21 19:18:56 58439 58439 compiler_driver.cc:109] 0% of classes with status Resolved for 32155 cases dex2oat I 12-21 19:18:56 58439 58439 compiler_driver.cc:109] 0% of classes with status Verifying for 32155 cases dex2oat I 12-21 19:18:56 58439 58439 compiler_driver.cc:109] 0.0186596% of classes with status RetryVerificationAtRuntime for 32155 cases dex2oat I 12-21 19:18:56 58439 58439 compiler_driver.cc:109] 0% of classes with status VerifyingAtRuntime for 32155 cases dex2oat I 12-21 19:18:56 58439 58439 compiler_driver.cc:109] 28.1916% of classes with status Verified for 32155 cases dex2oat I 12-21 19:18:56 58439 58439 compiler_driver.cc:109] 0% of classes with status SuperclassValidated for 32155 cases dex2oat I 12-21 19:18:56 58439 58439 compiler_driver.cc:109] 0% of classes with status Initializing for 32155 cases dex2oat I 12-21 19:18:56 58439 58439 compiler_driver.cc:109] 71.7898% of classes with status Initialized for 32155 cases Bug: 70735003 Test: test-art-host Change-Id: I57e8a977ee202c0ce85030208caa183344a5567a
2018-12-27ART: Refactor for bugprone-argument-comment Andreas Gampe
Handles compiler. Bug: 116054210 Test: WITH_TIDY=1 mmma art Change-Id: I5cdfe73c31ac39144838a2736146b71de037425e
2018-12-19Remove unresolved classes from image classes. Vladimir Marko
This allows compiling partial boot image, without conscrypt, while using the current image classes in preloaded-classes. Excluding the conscrypt makes the class android.security.net.config.TrustedCertificateStoreAdapter unresolved because it extends the class com.android.org.conscrypt.TrustedCertificateStore . Without pruning, we hit a DCHECK() in ImageWriter, checking that image classes are not erroneous. And we clearly do not want to put erroneous classes in the partial boot image. Test: Build partial boot image without conscrypt. Bug: 119868597 Change-Id: I6017462366a4b9e69abe1fb3d22461cab35f84c5
2018-12-13ART: Rewrite EnsureInitialized hit case Andreas Gampe
When an initialized class is found during EnsureInitialized, do not check whether verification was attempted and fix up bits. Instead, ensure that all class-loading paths have that done when eventually getting here. Special runtime-constructed classes (primitives, arrays, proxies) need code to do this work. "Normal" classes have the work done during VerifyClass. Leave a DCHECK in as a state check. Protect state transfers with additional checks. This reduces the overhead of the interpreter which cannot elide initialization checks for static accesses. Bug: 115834172 Test: m test-art-host Change-Id: Iacd6652583364509c37eafe81fed1198abb1b71a
2018-12-06Refactor CompilerDriver::CompileAll(). Vladimir Marko
Treat verification results and image classes as mutable only in CompilerDriver::PreCompile(), and treat them as immutable during compilation, accessed through the CompilerOptions. This severs the dependency of the inliner on the CompilerDriver. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I594a0213ca6a5003c19b4bd488af98db4358d51d
2018-11-21Merge "ART: Add profile-compile-check support" Andreas Gampe
2018-11-19Remove CompiledMethod dependency on CompilerDriver. Vladimir Marko
Test: m test-art-host-gtest Change-Id: Ibee78d5c54d3ff8162258963fde25065b579a000
2018-11-08Delete IsClassToCompile Mathieu Chartier
Compiled classes filtering is no longer a thing. Bug: 26687569 Bug: 76145463 Test: test-art-host Change-Id: Iaf4b9dcea5d9fe1eae564fbd6d373af2fdc87b14
2018-11-08Merge "Move profile compilation info to CompilerOptions." Vladimir Marko
2018-11-08Move profile compilation info to CompilerOptions. Vladimir Marko
Remove one HInliner dependency on the CompilerDriver. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: If6f0ab864095641b5697c8c6f5100520f91d5e53
2018-11-07ART: Small compiler-driver cleanup Andreas Gampe
Remove some unused or unimplemented methods and typedefs. Move some code. Bug: 115837065 Test: mmma art Change-Id: I96070444007d4f67b14bb563c1b7252a5a012523
2018-11-01Do not cache RequiresConstructorBarrier() results. Vladimir Marko
Avoid caching the results. Caching was broken for JIT in the presence of class unloading; entries for unloaded dex files were leaked and potentially used erroneously with a newly loaded dex file. Test: m test-art-host-gtest Test: testrunner.py --host Test: Pixel 2 XL boots. Test: m test-art-target-gtest Test: testrunner.py --target Bug: 118808764 Change-Id: Ic1163601170364e060c2e3009752f543c9bb37b7
2018-10-30Add PreResolved strings dex cache array Mathieu Chartier
For app images, this dex cache may be prepopulated to speed up application startup. This new dex cache array is created when --resolve-startup-const-strings=true. Test: test-art-host Bug: 116059983 Bug: 118385560 Change-Id: I379dc15174281665d7f4ceb106f7fbf51f89b921
2018-10-19Merge "ART: Use ObjPtr for GetSuperClass" Treehugger Robot
2018-10-19Resolve const-string of clinit Mathieu Chartier
Resolve the const strings of the clinit for classes that are loaded in the profile. For Maps, the number of strings is ~4400. This would take ~100k RAM if each string is around 20 characters. Note that these strings are mostly already loaded during startup, so there might not be a net RAM usage increase. Test: test-art-host Bug: 117621117 Change-Id: I632a91633c1b3757523ef6e655f192305554499b
2018-10-16ART: Add profile-compile-check support Andreas Gampe
Add --check-profiled-methods, which verifies that all methods mentioned in a profile for a guided compilation are actually compiled instead of being punted. As outcome it may log or abort dex2oat. TODO: Extend dex2oat_test Bug: 76145463 Test: mmma art Test: m test-art-host Change-Id: I956113b55796d0666db9dbfd387105a7d27b0868
2018-10-16Add logic to eagerly resolve const-string for startup methods Mathieu Chartier
Added dex2oat option --resolve-startup-const-strings=<true|false> If true, this option causes the compiler driver to resolve all const-strings that are referenced from methods marked as "startup" in the profile. Bug: 116059983 Test: test-art-host Change-Id: I61cf9e945c125671fc4ab4b50458a911318a837f
2018-10-16ART: Use ObjPtr for GetSuperClass Andreas Gampe
Bug: 37224696 Test: mmma art Test: m test-art-host Change-Id: If55db6e26bb1bb05a13c59b849bed17839fca6cf
2018-10-05Merge "Implemented a new method for walking string references in AppImages." Christian Wailes
2018-10-04Implemented a new method for walking string references in AppImages. Chris Wailes
* Defined a new section in the AppImage binary format. * Verify heap invariants having to do with native string references. * Collect managed and native references to managed strings. * Record the location of these references as offsets into the image. * Writes offsets into new image section. * Walk this list of offsets at load time to intern strings from the AppImage. * Verify that strings have been interned correctly. Test: art/test/testrunner/testrunner.py -b --host Test: m test-art-host-gtest Test: Built and ran Keep, Docs, Chrome, YouTube, and Facebook. Bug: 70734839 Change-Id: Ib5235abdebca018e8920d12318c31b9c0efb0ede
2018-10-01Dump Dex file checksums for profman --dump-only Mathieu Chartier
Make it easier to diagnose mismatched dex checksums. Add checksum verification in ProfileCompilationInfo::DumpInfo. Some refactoring to remove unnecessary code. Bug: 116509324 Test: test-art-host-gtest Change-Id: I11fb8d1aa987c0f0a975ef6dcb811bf41d58fad6
2018-09-06ART: Fix tidy warning in compiler-driver Andreas Gampe
Fix bugprone-lambda-function-name. Bug: 32619234 Test: mmma art Change-Id: If361a9031782be67b041219f10a53fc4de0a8d7d
2018-08-31Merge changes I207718d6,I700ef52e Andreas Gampe
* changes: ART: Restrict some checks in the verifier to P+ ART: Add API level to verifier
2018-08-28Remove superfluous 'virtual' specifiers in ART. Roland Levillain
Remove 'virtual' specifier on methods already bearing the 'override' specifier. Test: mmma art Change-Id: I114930969a5ca048d88de9ecd18e2c6403593e31
2018-08-28Use 'final' and 'override' specifiers directly in ART. Roland Levillain
Remove all uses of macros 'FINAL' and 'OVERRIDE' and replace them with 'final' and 'override' specifiers. Remove all definitions of these macros as well, which were located in these files: - libartbase/base/macros.h - test/913-heaps/heaps.cc - test/ti-agent/ti_macros.h ART is now using C++14; the 'final' and 'override' specifiers have been introduced in C++11. Test: mmma art Change-Id: I256c7758155a71a2940ef2574925a44076feeebf
2018-08-24ART: Add API level to verifier Andreas Gampe
Pass API level to verifier. In preparation for API-level dependent checks. Bug: 111969862 Test: m test-art-host Change-Id: I700ef52e28436a7fda8b9d9ef29841110ed6d3bb
2018-07-16Always produce PIC code for AOT compilation. Vladimir Marko
Change sharpening to use PIC load kinds for AOT compilation and add "Jit" to the direct addressing load kind names. Use PIC code also for the Integer.valueOf() intrinsic codegen. Remove all support for non-PIC linker patches. The dex2oat --compile-pic option is retained for now but ignored by the compiler. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: Pixel 2 XL boots. Test: testrunner.py --target --optimizing Bug: 77856493 Change-Id: I54d666f6522f160a1b6ece4045a15d19363acbb6
2018-07-12Fix HClinitCheck elimination in instruction builder. Vladimir Marko
To handle escaping instances of erroneous classes correctly, we can omit the HClinitCheck only when using a class in the static method of the very same class. Even for superclasses we need to do the check. The new test exposes the cases where we were previously diverging from the RI. Also clean up the CompilerDriver by inlining one function directly to the HInstructionBuild::IsInitialized(.) and removing some related functions that are no longer used. The size of the aosp_taimen-userdebug prebuilts: - before: arm/boot*.oat: 16891788 arm64/boot*.oat: 19815520 oat/arm64/services.odex: 20071624 - after: arm/boot*.oat: 16949532 (+56.4KiB, +0.34%) arm64/boot*.oat: 19889752 (+72.5KiB, +0.37%) oat/arm64/services.odex: 20224328 (+149.1KiB, +0.76%) with minor changes to other app prebuilts. Note: Some of that could be reclaimed by reinstating the old optimization for classes where no bytecode can be executed during initialization (no <clinit> to execute in that class or superclasses). Test: 174-escaping-instance-of-bad-class Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: testrunner.py --jvm -t 174 Test: Pixel 2 XL boots. Test: testrunner.py --target --optimizing Bug: 62478025 Change-Id: I41f026ea7fecc615c06e87f3b6cb847de0ede8a6
2018-06-28Remove CompilerDriver::support_boot_image_fixup_. Vladimir Marko
Check for non-PIC boot image as a testing config instead. Honor the config for HInvokeStaticOrDirect sharpening. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I3645f4fefe322f1fd64ea88a2b41a35ceccea688
2018-06-25Move instruction_set_ to CompilerOptions. Vladimir Marko
Removes CompilerDriver dependency from ImageWriter and several other classes. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: Pixel 2 XL boots. Test: m test-art-target-gtest Test: testrunner.py --target --optimizing Change-Id: I3c5b8ff73732128b9c4fad9405231a216ea72465
2018-06-25Move dex_files_for_oat_file_ to CompilerOptions. Vladimir Marko
A step toward removing the CompilerDriver dependency from several classes, including HSharpening and ImageWriter. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I364ef66511fdf855cb11b12c818a40572b037727
2018-06-25Move image_classes_ to CompilerOptions. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Ifb30e071d7b39ae939fc3f83d7eba82fd077c7e8
2018-06-21Use HashSet<std::string> instead of unordered_set<>. Vladimir Marko
Change the default parameters for HashSet<std::string> to allow passing StringPiece as a key, avoiding an unnecessary allocation. Use the HashSet<std::string> instead of std::unordered_set<std::string>. Rename HashSet<> functions that mirror std::unordered_multiset<> to lower-case. Fix CompilerDriver::LoadImageClasses() to avoid using invalidated iterator. Test: m test-art-host-gtest Test: testrunner.py --host Change-Id: I7f8b82ee0b07befc5a0ee1c420b08a2068ad931e
2018-06-07Refactor ClassAccessor to use an index instead of ClassDef pointer Mathieu Chartier
Removes a separate class_def_idx being required for getting the index of a ClassAccessor foreach loop. Bug: 79758018 Test: test-art-host-gtest Change-Id: Ie3010a17669f24cf492c678b55bdddba7ec62ea8
2018-05-31ObjPtr<>-ify ClassLinker::FindClass(), fix 1 stale reference use. Vladimir Marko
Thread::CreateAnnotatedStackTrace() was using a stale reference `aste_array_class`. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 31113334 Change-Id: I191907c0053456bb57de425aa6ccd9668df818a2
2018-05-29Add Method/Field iterator to ClassAccessor Mathieu Chartier
Enables ranged based for loops on fields and methods. For visiting both fields and methods, VisitFieldsAndMethods will be faster because of not needing to decode the fields twice for seeking purposes. Added test. Bug: 79758018 Bug: 77709234 Test: test-art-host-gtest Change-Id: I593e23ccd138b87a27d8bab6927ff2b685c057f3