summaryrefslogtreecommitdiff
path: root/runtime/verifier/method_verifier.h
AgeCommit message (Collapse)Author
2025-01-15verifier: Clean up `HandleMoveException`. Vladimir Marko
Stop processing the instruction on hard failure. Previously, we could have hit a soft failure after a hard failure. (And we would also unnecessarily update the register type.) Pull the `move-exception` handling code out of the `PotentiallyMarkRuntimeThrow()`. The calls between this function and `Fail()` were confusing and seemingly recursive even though there was no recursion thanks to the parameters we were passing. The `PotentiallyMarkRuntimeThrow()` was also keeping `flags_.have_pending_runtime_throw_failure_` as false for `move-exception`, further adding to the confusion. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I991ff9b93c4d50a206cb0964de875e9687c07aba
2025-01-10verifier: Use `RegTypeCache::kUndefinedCacheId` more. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I941caf6c03bea0413f3d2b2af7aeadd5595ac0d6
2025-01-09verifier: Speed up failure recording. Vladimir Marko
Move the failure data to the `Arena` memory. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Change-Id: I92b503f366286c4ad73d1e0eacc815635c86c119
2024-12-05verifier: Refactor `Is{,Strictly}AssignableFrom(). Vladimir Marko
Move these functions to the `MethodVerifier`. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I32346a670074a8ab48bdf0aa084e8885e8a644e1
2024-11-28verifier: Create `std::ostringstream` only if needed. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Change-Id: I43f9c7ad5e4fb36606fefc6cfb31642d48a8357a
2024-11-21verifier: Use `ArenaAllocator` in verifier... Vladimir Marko
... instead of `ScopedArenaAllocator`. We do not use nested `ScopedArenaAllocator`s, so we can use the `ArenaAllocator` which guarantees zero-initialization of allcated memory and avoid an unnecessary `std::fill_n()`. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Change-Id: I04539c95ebf651a3e3b260a0c069ad6ee1eb1e5a
2024-10-31verifier: Track allocation dex pcs in `RegisterLine`. Vladimir Marko
Reduce the number of `RegTypes` stored in `RegTypeCache`. Reduce the chance of the `RegTypeCache` overflowing the 16-bit register type ids. The old `RegTypeCache::MarkUninitRefsAsInvalid()` code was essentially useless. Replace it with a debug mode check `RegTypeCache::DCheckUniqueNewInstanceDexPc()`. Add a FIXME comment for a no-op `move-object` breaking the structured locking verification. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: If3b1badd55b0b3ebabfc7c3bc8a9f2681293ac60
2024-10-29Reland "verifier: Cache types by type index." Vladimír Marko
This reverts commit de7910029c3400a11070e818ae1463614c302a16. Reason for revert: Relanding with a fix - keep forced class resolution in `MethodVerifier<>::ResolveClass<>()`. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --jit-on-first-use Bug: 181943478 Change-Id: Ibdf8b5515ca6c3e4106e1a09700ca65565ce36bb
2024-10-25Revert "verifier: Cache types by type index." Vladimír Marko
This reverts commit 38e9b0c97323368a5b3edd1cb24ab9a5fb38e06d. Reason for revert: Broke the "612-jit-dex-cache" test in "jit-on-first-use" configuration. Bug: 181943478 Change-Id: I2a67f49905565606f75532682d5138faa8f3960e
2024-10-25verifier: Cache types by type index. Vladimir Marko
Speed up `RegType` lookup in `RegTypeCache` by adding a cache based on `dex::TypeIndex` for types referenced by the current dex file. This slows down the construction of the `RegTypeCache` but the benefits of faster lookup outweigh the slower construction now that we're constructing the `RegTypeCache` only once per class and not once per method. Remove the `MethodParamListDescriptorIterator` as it was providing only descriptors from the resolved method's dex file and we can get the same descriptors from the current dex file based on the invoke's `dex::ProtoIndex`. This also allows using the new `TypeIndex`-based cache for this work. Clean up the `RegTypeCache` interface by inlining functions `FindClass()` and `InsertClass()` to the only remaining user `FromClass()` and update tests to use `FromClass()` instead. Move the descriptor retrieval from callers to `FromClass()`. Avoid some unnecessary string copy with `AddString()` in `RegTypeCache::FromClass()`. Add a TODO comment to avoid the string copy in `RegTypeCache::From()`. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Change-Id: Iea429a33983104165c2ad2cf108d2b7d88f8b9e7
2024-10-17Share `RegTypeCache` for all methods in a `Class`. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Change-Id: Ic5e2ad1a83a9013a428b51ef39641d8a1f34cee9
2024-10-16Remove dead `MethodVerifier::ResolveCheckedClass()`. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I5057dfd2b1354edce27e7374cc543e59cf9b051e
2024-06-13Clean up `MethodVerifier` fields. Vladimir Marko
Move `handles_` to `RegTypeCache` to avoid indirection. Remove `class_linker_` and use the one from `RegTypeCache`. Split `flags_` to `flags_` and `const_flags_` and move the `can_load_classes_` to the latter. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I5e2ebe15623088d7e4ce02fa06284beb46b9da8f
2024-01-17Add visibility attributes in runtime/verifier Dmitrii Ishcheikin
Bug: 260881207 Test: art/test.py -b --host Test: presubmit Test: abtd app_compat_drm Test: abtd app_compat_top_100 Test: abtd app_compat_banking Change-Id: I7fe3bef35482aaa87ec41d0525118eaf2e22a52c
2023-06-14Replace GcRoots in the verifier to use VariableSizedHandleScope. Nicolas Geoffray
This removes the cruft in creating static instances, and the need to explicitly visit verifier roots. Test: test.py Change-Id: Ia0f0a82cbc66bb57f30610587f080e75d4d32e92
2021-10-04Remove the notion of soft failure within the verifier. Nicolas Geoffray
Bug: 28313047 Test: test.py Change-Id: I58b9fb74161f24e095ae049f3c2886713f3213d5
2021-07-23verifier: Remove support for precise constants and RegisterTrackingMode. Nicolas Geoffray
These features were used when we were creating GC maps and deoptimization information with the quick compiler. Quick compiler has been removed, so we can remove these features. Test: test.py Change-Id: I633a7ada761b280b90e2d7c53cd5fbf2ae1d701d
2021-07-14Remove the need of VerifiedMethod in the compiler. Nicolas Geoffray
The compiler only needs to know if a method is compilable or not. So just record a set of uncompilable methods (in some cases, we cannot have an ArtMethod, but the method can still be compiled). Test: test.py Bug: 28313047 Change-Id: Ic4235bc8160ec91daa5ebf6504741089b43e99cb
2021-07-09Clean up verifier interface. Nicolas Geoffray
Remove verifier_callbacks and ArtMethod as argument. The verifier can operate without them. This allows removing the bogus DexCache::SetResolvedType in ti_redefine. Also turn runtime throw failures into VerifyError, for cleaner interface with users of the verifier. Test: test.py Bug: 28313047 Change-Id: I9ba1300f198aaf482ed43061465daea789ea732b
2021-07-02Verifier cleanups. Nicolas Geoffray
- For apps <= S, keep the behavior of not analyzing an unreachable handler. If >= T, we analyze it to simplify handling in the compiler. - Remove VERIFY_ERROR_SKIP_COMPILER and fold uncompilable methods into checking HasInstructionThatWillThrow. Test: test.py Bug: 28313047 Change-Id: I20b65cf50def2a4a95617a03142575b8591ae0ec
2021-06-30verifier: do not infer an instruction will throw. Nicolas Geoffray
Turning a regular instruction into a throwing one has currently undesirable consequences: 1) It leads to inconsistencies between the AOT verification and the runtime verification. 2) It treats the following code dead and does not analyze it. We treat this as an non-compilable method as it's a lot simpler for the compiler to consider all code verified. 3) It prevents verification optimizations like doing one-pass analysis over the code. To be AOT / runtime consistent and follow RI behavior, stop considering such instructions as throwing. We make this API version dependent for app compatibility reasons. Test: test.py Bug: 28313047 Change-Id: I9c847043d1f431f642731a70f651c93ef22fdf86
2021-06-30Remove experimental flag in verifier. Nicolas Geoffray
We don't use it anymore. If we add new opcodes in the future, we can test by disabling the verifier (something which was hard to do at the time). Test: test.py Bug: 28313047 Change-Id: Idce9a520995d12fdfc3bd314bc06b542492a0ab8
2021-03-22Explictly pass VerifierDeps when asking for class verification. Nicolas Geoffray
This will simplify creating and populating VerifierDeps at runtime, which is needed for doing and saving background verifcation of secondary dex files. Test: test.py Bug: 158463186 Change-Id: Ic17913ebd173700e866ba9309bf6ae131fcbc423
2020-11-05Change vdex format to store per-class assignable types. Nicolas Geoffray
Test: test.py Bug: 112676029 Change-Id: I6cd784381efb13a2c669ab77fe2c2b3e5da838f9
2020-10-21Remove the checkcast quickening optimization. Nicolas Geoffray
Quickening is now disabled, and the optimization uses VerifierDeps post-verification, which we plan on not supporting for future verifier improvements. Test: test.py Bug: 112676029 Change-Id: Ie9004b27c93e1189e6c1142494e79cd84b05400c
2019-10-28Perform reverify with shared mutator-lock. Alex Light
Despite comments that seemed to indicate otherwise the verifier is not capable of running with a strong mutator-lock in all circumstances. Specifically it relies on being able to allocate exceptions in a number of situations (for example when a field could not be found but the class could). This could lead to problems when trying to reverify a class. To fix this we changed the reverify step to happen outside of the strong mutator-lock and instead temporarily mark the redefined methods with every verifier fail flag. The new verification will then be performed and the flags reset (after suspending everything). This also fixes a related issue where performing the verification with an exclusive mutator lock changed how elements in the dex-cache were populated, causing the dex-cache to break invariants about methods always having their classes be present. This could cause crashes in some circumstances (for example test 1990). Test: ./test.py --host Test: go/lem Bug: 142876078 This partially reverts commit b1eebde9469914ad634a6dc3746ddfb222595609 This partially reverts commit db55a1121b2437765e732c8bbedf914f8a52f624 Change-Id: I0f1e8c47118cc84c8f23c4068944069ac74f5ea3
2019-10-22Revert^2 "Class redefinition sometimes needs to update verification" Alex Light
We were incorrectly preventing dex2oat from suspending during verification. This caused a major regression in memory use and compilation speed. This reverts commit 2cf00ede148bd9d77c291d4c0cb23edd5a9c36b4. Reason for revert: Fixed issue causing AOT slowdown. Test: go/lem Test: go/lem-allight-unrevert-verify-check Test: ./test.py --host Bug: 142876078 Change-Id: If699f71a06818856358859ed5e4e01e0ffc1c1a4
2019-10-22Revert "Class redefinition sometimes needs to update verification" Nicolas Geoffray
This reverts commit db55a1121b2437765e732c8bbedf914f8a52f624. Bug: 142876078 Reason for revert: up to 10x regressions on vdex-based compilation. Change-Id: Ib034c02617db2c8e4e15bc386631a612256f0ad4
2019-10-18Class redefinition sometimes needs to update verification Alex Light
In cases where class redefinition moves a class from having no verification failures to having soft verification failures we need to update the methods with new verification class flags. For example if a method is modified to have unbalanced monitors we need to make sure that future invokes of that method count locks and use the interpreter. Previously we would simply keep the same verification state as the original implementation, causing us to try to compile in situations the compiler cannot handle or leave monitors in inconsistent states. Test: ./test.py --host Bug: 142876078 Change-Id: I8adf59158639bdf237d691b20fad223f0a34db1f
2019-07-29ART: Verifier cleanup Andreas Gampe
Start making the method verifier more independent of externalities. This will be implemented as incremental changes. In this CL, require an ArenaPool in the constructor instead of explicitly using the Runtime one. Test: m test-art-host Change-Id: I2a526d869532da732202198fdac68c426008b09a
2019-07-29ART: Verifier cleanup Andreas Gampe
Start making the method verifier more independent of externalities. This will be implemented as incremental changes. In this CL, replace querrying Runtime::Current() for AoT status with a flag. Test: m test-art-host Change-Id: I91a3ad0208b544f47bb83db96edca6b4f86e5ce5
2019-07-29ART: Verifier cleanup Andreas Gampe
Start making the method verifier more independent of externalities. This will be implemented as incremental changes. In this CL, replace querrying Runtime::Current() for the classlinker with requiring the classlinker to use at construction time. Test: m test-art-host Change-Id: Id0a6a1f01c77bfe4cc9adfb490fc6ebc7bbf6392
2019-07-11ART: Prepare to remove VERIFY_ERROR_UNRESOLVED_CATCH Andreas Gampe
Add a parameter to Fail() that defines whether a runtime exception is expected at that point. Bug: 121245951 Test: m test-art-host Change-Id: Iff98ae24ef095df411804150d41c80493d42c09f
2019-07-10Revert "ART: Remove VERIFY_ERROR_UNRESOLVED_CATCH" Andreas Gampe
This reverts commit 7a82acc7ee79b198f7b4638a15cb1c3d1625ab6c. Reason for revert: NO_CLASS doesn't have the right semantics for the compiler Bug: 121245951 Change-Id: I8dbeb7fbd6a697fe536535f1c696187041d7fcab Test: m test-art-host
2019-07-08ART: Remove VERIFY_ERROR_UNRESOLVED_CATCH Andreas Gampe
Instead add a parameter to Fail() that defines whether a runtime exception is expected at that point. Bug: 121245951 Test: m test-art-host Change-Id: Id9132eabc26b71a305ccb87f2182b4ae2e5b8c35
2019-06-29ART: Coalesce verifier flags into bit struct Andreas Gampe
Makes it easier to add flags without increasing size or changing padding. Bug: 121245951 Test: m test-art-host Change-Id: I26d0491fb7eb26e441874188a8db9f276ce1aaf8
2019-05-22Revert^2 "Add verifier fallback for JVMTI Get/SetLocalVariable" Alex Light
This reverts commit 99cbfb55fc7ac0f65b1ccdc7076219fcee383b92. This unreverts commit e48fd0b4780efadc6b3433fe7a56aa5be2a84325. We were incorrectly bounds-checking the register number. We were treating it as unsigned when it was actual signed. Previously this wouldn't matter since normally the debug-info won't have any information for negative slots but by falling back to the verifier we hit some check failures. Reason for revert: Fixed underlying issue with bad bounds check. Bug: 131711256 Change-Id: I0b859ce322f3b23f937b72d735db8f6870c40602
2019-05-22Revert "Add verifier fallback for JVMTI Get/SetLocalVariable" David Srbecky
This reverts commit e48fd0b4780efadc6b3433fe7a56aa5be2a84325. Reason for revert: Fails libjdwp tests. In particular: org.apache.harmony.jpda.tests.jdwp.StackFrame_SetValuesTest Bug: 131711256 Change-Id: Id46da7c0d26769f8f4bd469cdfb8049f6812295a
2019-05-22Add verifier fallback for JVMTI Get/SetLocalVariable Alex Light
The JVMTI Get/SetLocalVariable functions used to rely entirely on the Dex DebugInfo to determine the types of each of the registers. This could lead to problems since, to prevent possible stack corruption, we would not allow stack modification if the data was not present. In order to remove this restriction we will instead make use of the method verifier to ensure the modification is sensible when the DebugInfo is not present. Since reconstructing this information using the verifier is quite slow (compared to reading it from a table) we will only do this when the table is missing. Since the verifier lacks some of the information available when creating the DebugLocalInfo table some semantics will change depending on if the table is present or not. - When the DebugLocalInfo table is not present we cannot always distinguish between floats, ints, and other single-register primitive types. For simplicity all single-register primitive types can be modified and read by both the Float and Int versions of the local variable functions. - Similarly we cannot always distinguish between long and double variables. - Reference types are checked against what the verifier thinks they need to be according to type unification. This might be more or less specific than the types recorded in the functions source code. - Constant int/float '0' values and 'null' cannot always be differentiated by the verifier. Therefore, one may not always be able to modify some null or constant 0 registers. Test: ./test.py --host Bug: 131711256 Change-Id: I1c9d857ccdec752bfd4ebad76cc9ad96e143866c
2019-04-22ART: Templatize internal method verifier class Andreas Gampe
Templatize over verifier-debug. Bug: 130907607 Test: mmma art Test: m test-art-host Change-Id: Iafde21602541aa3c878883cd793333ecc2121de9
2019-04-22ART: Refactor verifier Andreas Gampe
Move implementation to internal class, only keep minimal interface that other classes depend on public. An internal impl::anonymous namespace and duplicate MethodVerifier name was chosen so as to minimize the patch. In preparation for templatization. Bug: 130904871 Test: mmma art Test: m test-art-host Change-Id: I79de01139b8fbd8b4e828bb0e58faeb8666176d5
2019-04-22ART: Do not expose arena allocator from MethodVerifier Andreas Gampe
Bug: 130904871 Test: mmma art Test: m test-art-host Change-Id: I807b713215fa948f2cbeab929abb0986ce573702
2019-04-22ART: Clean up MethodVerifier Andreas Gampe
Remove unused methods. Move internal methods to be private. Bug: 130904871 Test: mmma art Test: m test-art-host Change-Id: I3b1a6a4495e3ddc4507881659d2c6d6d6049e8f6
2019-04-15ART: Make LogVerifyInfo newlines consistent Andreas Gampe
Use an RAII helper to make logging to the verifier's info_messages_ consistent - no caller needs to add a final newline. Test: m Test: manual Change-Id: Ic830b816293078873160808fe275b862a672ff47
2019-03-15ART: Add ClassVerifier Andreas Gampe
Remove class handling from MethodVerifier. Test: m test-art-host Change-Id: I0e125e0c8a852936ed7cff0f349a7fde97f62826
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-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-06-04Revert "Revert "Move runtime/ to ClassAccessor"" Mathieu Chartier
Fixed misplaced UnhideAccessFlags to be outside of a conditional that the code item is null / not deduped. This fixes an issue where these methods would not have had their access flags restored. Bug: 77709234 Bug: 79758018 Bug: 91962648 This reverts commit cc7e20f9ec7b4a7a57f7196e5e8be67a727f21d3. Test: test-art-host Test: atest FrameworksUiServicesTests Test: atest CtsInlineMockingTestCases Change-Id: I7e5712cdcccef81e19ce81d26743c517b0b8a67d
2018-06-02Merge "Revert "Move runtime/ to ClassAccessor"" Alex Light
2018-06-02Revert "Move runtime/ to ClassAccessor" Alex Light
Seems to cause 'atest CtsInlineMockingTestCases' and other tests to fail due to sending agents dex files with hiddenapi flags still present. This reverts commit 2649ecf6c59a29262556aa356fbf894d49df8fe7. Reason for revert: Seems to be causing sysui test failures, maybe Bug: 77709234 Bug: 79758018 Bug: 91962648 Test: Tree-Hugger Change-Id: I2cab5d0d58808dd8beb38400d2811307f26e1021