summaryrefslogtreecommitdiff
path: root/runtime/quick_exception_handler.cc
AgeCommit message (Collapse)Author
2025-02-18Refactor `Instrumentation` out of `Runtime`. Vladimir Marko
Avoid indirectly `#include`-ing `instrumentation.h` in every compilation unit that needs the `runtime.h`. This reduces incremental compilation times when touching certain files. The additional load when accessing `Instrumentation` via the `Runtime` has negligible performance impact. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Ibaf96696693b105e843c7c2cbf4e7604b126808e
2025-02-17Refactor `ArtMethod` entrypoint initialization. Vladimir Marko
Introduce `Instrumentation::ReinitializeMethodsCode()` for the cases where we want to reset the entrypoint after the method has already been initialized. Keep the old function `Instrumentation::InitializeMethodsCode()` exclusively for the initialization of a newly loaded method's entrypoint, split out the work that can be done in suspended state and remove any unnecessary work. For example, we do not use the Nterp entrypoint until the class has been verified, so all the Nterp checks can be removed. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 329196666 Change-Id: I1d0c195b0118fe50434d496f56346a9f744fbaf7
2024-10-17Separate kRuntimeISA/kRuntimeQuickCodeISA Chris Jones
Currently ART has an implicit assumption that the ISA of the quick code (e.g.: app code) that is targeted to be run by ART will be the same as the machine that runs ART itself (e.g.: runtime code). This assumption is made by having a single value (kRuntimeISA) representing both of these types of code. Instead kRuntimeISA is split into two values so that it is possible to target the case where these two ISAs don't match, for example: in simulator mode. The two values are as follows. - kRuntimeISA: - Must match the ISA of the machine that ART will be run on. This ISA will be used for the native context, native stack frame and native ABI. - kRuntimeQuickCodeISA: - The ISA that ART will generate quick code for, i.e.: that java code will be compiled to. This ISA will be used for the quick context, quick stack frame and quick ABI. Therefore replace kRuntimeISA with kRuntimeQuickCodeISA where the semantics of quick code ISA is expected, not the ISA of the machine the code is running on. Also hardcode ISA for ISA specific QuickArgumentFrameInfo classes. Authors: Artem Serov <artem.serov@linaro.org> Artem Serov <artem.serov@arm.com> Chris Jones <christopher.jones@arm.com> Test: test.py --host --target Change-Id: Ibe6f3e27179f3baa49a8de89686341df0dcf16f5
2024-08-05Clean up after exception delivery rewrite. Vladimir Marko
Clean up after https://android-review.googlesource.com/2680017 and fix CFI for `art_quick_do_long_jump`. Test: m test-art-host-gest Test: testrunner.py --host --optimizing Change-Id: Ief6cda2c223c4225dc5b5145452d926674430caa
2024-08-01Rework exception delivery and deoptimization Chris Jones
Both exception delivery (various methods calling Thread::QuickDeliverException()) and deoptimization (via artDeoptimizeImpl) use QuickExceptionHandler to find the target context and do a long jump to it via QuickExceptionHandler::DoLongJump. The long jump is done directly from the C++ code, so the frames of the related C++ method are still on the stack before the change of the pc. Note that all those methods are marked as NO_RETURN to reflect that. This patch changes the approach; instead of having the long jump directly from the C++ methods related to exceptions and deoptimization, those methods now only prepare the long jump context and return. So their callers (mainly .S quick entry points and stubs) now need to do a long jump explicitly; thus there will be no C++ frames on the stack before the jump. This approach makes it possible to support exceptions and deoptimization in simulator mode; so we don't need to unwind native (C++ methods' frames) and simulated stacks at the same. Authors: Artem Serov <artem.serov@linaro.org>, Chris Jones <christopher.jones@arm.com> Test: test.py --host --target Change-Id: I5f90e6b5ba152fc2205728f1e814bbe3d609af9d
2024-05-23Reland "Report method unwind events for native methods" Mythri Alle
This reverts commit db0551d164783866acf0cdcf9a7741ee6f21f0f2. Reason for revert: Updated test to a use method declared in the Test class instead of the hidden java.lang.classForName. Change-Id: Ifa725b5465163fa73e4808d87a2b205b92aa110f
2024-05-22Revert "Report method unwind events for native methods" Chaitanya Cheemala
This reverts commit b42b645e26e206a2b1457cf9ea453b5021a873f5. Reason for revert: Likely culprit for b/342131895 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted. Change-Id: Ic2724b90528b5a9e299e0df7d909be60d5c1e0eb
2024-05-22Report method unwind events for native methods Mythri Alle
When we are returning from JNI with a pending exception we deoptimize to correctly handle the exception. We missed reporting an unwind event for the native method that was returning. Also adds a regression test for this case. Bug: 339662394 Test:art/test.py -t 989 Change-Id: I8336dc831e3801b8c0976a5588d1682363d10e64
2024-03-26Rename enums.h/.cc to pointer_size.h/.cc. Santiago Aboy Solanes
It was the only enum in the file Bug: 329378408 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: If0e385324afa3685f648135ba9b60e6bc79ba0ed
2024-02-07Add missing visibility attributes in runtime/ Dmitrii Ishcheikin
Bug: 260881207 Test: presubmit Test: abtd app_compat_drm Test: abtd app_compat_top_100 Test: abtd app_compat_banking Change-Id: I60055cdf49564ccf46fd70100d11f8b571a2be71
2024-01-30Reland^2 "Run optimizations with baseline compilation." Nicolas Geoffray
This reverts commit 3dccb13f4e92db37a13359e126c5ddc12cb674b5. Also includes the fix for incrementing hotness that got reverted: aosp/2906378 Bug: 313040662 Reduces jank on compose view scrolling for 4 iterations: - For Go Mokey: - Before: ~698 frames drawn / ~13.87% janky frames - After: ~937 frames drawn / ~5.52% janky frames - For Pixel 8 pro: - Before: ~2440 frames drawn / ~0.90% janky frames - After: ~2450 frames drawn / ~0.55% janky frames Reason for revert: Reduce inlining threshold for baseline. Change-Id: Iee5cd4c3ceb7715caf9299b56551aae6f0259769
2024-01-19Move files related to compiled code into oat/ directory Dmitrii Ishcheikin
Test: art/test.py -b --host Change-Id: Icedd3a82c6bca5147c3bc9dc50de5a729003d66f
2024-01-15Revert "Reland "Run optimizations with baseline compilation."" Nicolas Geoffray
This reverts commit 1a6b5b318aa69903a74dd10312a77bd8ee7c4cf6. Reason for revert: asan failure Change-Id: Ie9da0b04c899d6cb37148e7a3542190e65737787
2024-01-05Reland "Run optimizations with baseline compilation." Nicolas Geoffray
This reverts commit c8309515d099992b7cab8f2b8c6db3ed77671ff4. Bug: 313040662 Reason for revert: remove call to slow path on back edges. Change-Id: I3fe52295afcb0be4b4062f8d9060adb4abb64375
2024-01-04Revert "Run optimizations with baseline compilation." Almaz Mingaleev
This reverts commit 41c5dde40d1c75d36a7f984c8d72ec65fbff3111. Reason for revert: breaks test.java.util.Arrays.Sorting Change-Id: I03385c9f1efff4b8e8bd315827dde6ed774bbb52
2024-01-03Run optimizations with baseline compilation. Nicolas Geoffray
And introduce inlined inline caches, which customize an inline cache for the top-level method being compiled. Reduces jank on compose view scrolling for 20 seconds: - For Go Mokey: - Before: ~525 frames drawn / ~14.64% janky frames - After: ~891 frames drawn / ~4.74% janky frames - For Pixel 8 pro: - Before: ~2443 frames drawn / ~0.91% janky frames - After: ~2447 frames drawn / ~0.65% janky frames Bug: 313040662 Test: test.py Change-Id: Ibaa746c6bd3c665b18ec9cd29cb477cf21023467
2023-11-07Reland "Fix pathological deoptimization case." Nicolas Geoffray
This reverts commit 4384e944119846a2bc1d699a8c366baf9ac24c8e. Reason for revert: use the right bottom shadow frame for the inline cache. Change-Id: Ia3208bd0792dd3a615763ef146973e0c84cf31b4
2023-11-06Revert "Fix pathological deoptimization case." Nicolas Geoffray
This reverts commit cd576b2e7927067319f6e7e790d5e3f3a1db7a62. Reason for revert: Broken luci libcore tests. Change-Id: I4ceb85bccce9c698a96bb02f4805a2cf98f5b4bb
2023-11-06Fix pathological deoptimization case. Nicolas Geoffray
It may be the baseline compiled code never sees the type that made us deoptimize. So explicitly record it when we deoptimize. Test: test.py Change-Id: Ic51060d725ab24e7ec8e31430ba5a8f194ee92c9
2023-01-16We no longer use instrumentation stubs remove the support code Mythri Alle
Remove the code to handle instrumentation stubs. We no longer use them. Bug: 206029744 Test: art/test.py Change-Id: I2b7eabf80bd34989314c0d2b299d7b1b35de0b85
2023-01-11Check if we need a deopt after method entry / exit callbacks Mythri Alle
We need to check if we need a deopt after method entry / exit callbacks. We were using the proxy of IsDeoptimized(method) to check if we need a deopt but that isn't sufficient always. For example, when there is a frame pop request or other requests that don't explicitly deopt the method. Checking for a deopt after method exit callback requires special care to avoid calling method exit callbacks again from the interpreter after a deopt. We already have a mechanism to skip method exit listeners so it just involves updating the shadow frame to skip method exit listeners. Bug: 206029744 Test: art/test.py Change-Id: Ib95ab4348e40de345583e0718617879300828cb7
2023-01-04Fix method tracing in non-debuggable runtimes Mythri Alle
There are a few fixes needed for correctly supporting method tracing in non-debuggable runtimes: 1. When we start method tracing we report method entry events for methods already on the stack with the expectation that method exit events would be called when method finishes. In non-debuggable runtimes some of these may not support method exit events, so report method entry events only if the frame supports them. 2. When method tracing is enabled, we switch the runtime to debuggable. When we switch to debuggable runtime, we missed updating entrypoints and deoptimizing boot image. Fix it so we get method entry / exit events for all methods. Also updates test 2246-method-trace to work in non-debuggable runtimes. Bug: 259258187 Test: art/testrunner.py -t 2246 Change-Id: I040416c7cb72062c02312eedb5bcd41da09e53dc
2022-10-13Make sure we delete the dex_pc_list vector Santiago Aboy Solanes
We were leaking memory by not destroying it before long jumping. Test: Opened the AOSP calendar app and looked for unreachable memory Bug: 251892250 Change-Id: Ib44613174cfe6e315fa77368a74db1005730ba51
2022-10-07Runtime implementation of try catch inlining Santiago Aboy Solanes
The main differences in the runtime are: 1) We now use a list of dex_pcs to find the correct catch handler instead of a single dex pc 2) We now need to restore vregs of the whole frame, which may be an inline frame. Bug: 227283224 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: I95d2f32088e1d420c83962a1693be18f3b63f8b4
2022-09-12Cleanups around shadow frame creation. Nicolas Geoffray
Make sure it's never linked to another shadow frame before it starts doing execution. Test: test.py Change-Id: Ie34608fc2fdcf2dcfad9620349c0cc8a5e1c175f
2022-07-14Reland "Introduce a flag to check if JITed code has instrumentation support" Mythri Alle
This reverts commit 26aef1213dbdd7ab03688d898cf802c8c8d7e610. Reason for revert: Relanding after a fix. When checking if the caller is deoptimizaeble we should consider the outer caller and not the inlined method that we could be executing currently. Bug: 222479430 Change-Id: I37cbc8f1b34113a36a92c3801db72b16d2b9c81a
2022-07-13Revert "Introduce a flag to check if JITed code has instrumentation support" Mythri Alle
This reverts commit fc067a360d14db5f84fd4b58e0dee6cb04ee759b. Reason for revert: test failures on jit-on-first-use: https://android-build.googleplex.com/builds/submitted/8821659/art-jit-on-first-use/latest/view/logs/build_error.log Change-Id: Ie9bc243baac777ecc4f47cc961494ca6ab3ef4c6
2022-07-12Introduce a flag to check if JITed code has instrumentation support Mythri Alle
Introduce a new flag to identify if JITed code was compiled with instrumentation support. We used to check if the runtime is java debuggable to check for instrumentation support of JITed code. We only set the java debuggable at runtime init and never changed it after. So this check was sufficient since we always JIT code with instrumentation support in debuggable runtimes. We want to be able to change the runtime to debuggable after the runtime has started. As a first step, introduce a new flag to explicitly check if JITed code was compiled with instrumentation support. Use this flag to check if code needs entry / exit stubs and to check if code is async deoptimizeable. Bug: 222479430 Test: art/test.py Change-Id: Ibcaeab869aa8ce153920a801dcc60988411c775b
2022-07-06Reland^2 "Don't use instrumentation stubs for native methods in debuggable" Mythri Alle
This reverts commit 1d1d25eea72cf22aed802352a82588d97403f7b6. Reason for revert: Relanding after fix to failures: https://android-review.googlesource.com/c/platform/cts/+/2145979 Bug: 206029744 Change-Id: Id3c7508c86f9aeb0ddfc1c4792ed54f003b88e77
2022-07-04Revert "Reland "Don't use instrumentation stubs for native methods in ↵ Mythri Alle
debuggable"" This reverts commit 6fb0acc14459a856c35b642e3368aff853259260. Reason for revert: Breaks android.jvmti.cts.JvmtiHostTest https://buganizer.corp.google.com/issues/237991413 Change-Id: I00fb58080693ddebc03c7b62ea67c91150ef7a21
2022-07-04Reland "Don't use instrumentation stubs for native methods in debuggable" Mythri Alle
This reverts commit 5c9b55aa95295a287abd86f1e7fbe98c3f35ffd6. Reason for revert: Relanding with fixes for failure Fixes: 1. Arm64 needs to use 64-bit registers 2. We cannot deoptimize directly from GenericJniEndTrampoline since we only have a refs and args frame. So call the method exit hooks from art_quick_generic_jni_trampoline. Change-Id: If1f08eca69626f60f42f10205b482a3764610846
2022-06-24Revert "Don't use instrumentation stubs for native methods in debuggable" Mythri Alle
This reverts commit 90f12677f80169dc3ef919c2067349f94b943e7f. Reason for revert: Failures on device https://ci.chromium.org/ui/p/art/builders/ci/angler-armv7-ndebug/3058/overview https://ci.chromium.org/ui/p/art/builders/ci/angler-armv8-ndebug/3049/overview Change-Id: I43f943f9180b8c76db02a2a5c228a209a2f18a82
2022-06-24Don't use instrumentation stubs for native methods in debuggable Mythri Alle
Don't install instrumentation stubs for native methods in debuggable runtimes. The GenericJniTrampoline is updated to call method entry / exit hooks. When JITing JNI stubs in debuggable runtimes we also include calls to method entry / exit hooks when required. Bug: 206029744 Test: art/test.py Change-Id: I1d92ddb1d03daed74d88f5c70d38427dc6055446
2022-06-21Skip method unwind callbacks if exception was thrown by method exit Mythri Alle
When a method exit callback is called the method is still on the stack. This is required because we should allow the method being exited to be force popped and re-execute the caller frame. The way it is implemented currently requires the method that is being exited on the stack. However, method exit callbacks could also throw which triggers a stack unwind. We should not call method unwind events for methods that already called the method exit event. This CL makes sure method unwind events are not called when an exception is thrown from method exit callbacks. Currently, method entry / exit callbacks force interpreter entry points so this isn't a problem. This is in preperation for future CLs that change this. Change-Id: I6124898acf0c20b8c9944c0e1e5b9f23c5633b14
2022-05-24Update implementation of method unwind callbacks Mythri Alle
Earlier method unwind callbacks for quick / native methods was based on the instrumentation stack entries. JITed code no longer have entries in instrumentation stack and native code also will soon not use instrumentation stack. So update the implementation to record the methods on the stack as we walk them for finding the catch block and use them to call the method unwind callbacks when necessary. Bug: 206029744 Test: art/test.py Change-Id: I9a5f6e544cadc78e1e93d8b2f4e5ec58b04d6ea3
2022-01-24On partial fragment deopts, update return PC only when necessary Mythri Alle
JITed code in debuggable apps don't have instrumentation stubs installed and hence don't have an entry in the instrumentation stack. In the case of a deopt the last frame that is popped from instrumentation stack could be different from that of the actual stack. Hence we shouldn't update the return PC unconditionally incase of a partial fragment deopt. Test: art/test.py -t 989-method-trace-throw Bug: 214001306 Change-Id: I10cf74b3a1481429502b46e9d69b5274cce0f000
2022-01-24Reland "Use InitializeMethodsCode when we need to reinitialize a method ↵ Nicolas Geoffray
entrypoint." This reverts commit b0f63c93e44bf53a34dda90c74b8725a932922da. Reason for revert: Fix For proxy init. Test: test.py Change-Id: I6b4796115d73a093f86309cec1f03cafd981c2e9
2022-01-14Revert "Use InitializeMethodsCode when we need to reinitialize a method ↵ Nicolas Geoffray
entrypoint." This reverts commit 82e525a4f5f08a72ea1b6907c0a10dacb77a8a87. Reason for revert: Fails a test Change-Id: Iab83b543b99fb6f6d5d9be22cd10d4eb88312d4b
2022-01-13Use InitializeMethodsCode when we need to reinitialize a method entrypoint. Nicolas Geoffray
To make sure we use the best available entrypoint in such situations. Test: test.py Change-Id: I255b708464d62d7f628f51a200af465303f92fba
2021-11-09Revert^2 "Add support for calling entry / exit hooks directly from JIT code"" Mythri Alle
This reverts commit 72be14ed06b76cd0e83392145cec9025ff43d174. Reason for revert: A reland of commit 2d4feeb67912d64b9e980e6687794826a5c22f9d with a fix for no-image tests Change-Id: I79f719f0d4d9b903db301a1636fde5689da35a29
2021-11-01Revert "Add support for calling entry / exit hooks directly from JIT code" Mythri Alle
This reverts commit 2d4feeb67912d64b9e980e6687794826a5c22f9d. Reason for revert: This breaks no-image tests. Example failure: https://android-build.googleplex.com/builds/submitted/7871904/art-no-image/latest/view/logs/build_error.log Change-Id: I0f97c672c2d48f125931171ee1041a7c1cf20127
2021-11-01Add support for calling entry / exit hooks directly from JIT code Mythri Alle
The idea of this CL is to avoid maintaining the instrumentation stack and manipulating the return addresses on the stack to call the entry / exit hooks. This Cl only addresses this for JITed code. In follow up CLs, we will extend this to others (native, nterp). Once we have everything in place we could remove the complexity of instrumentation stack. This CL introduces new nodes (HMethodEntry / HMethodExit(Void)) that generate code to call the trace entry / exit hooks when instrumentation_stubs are installed. Currently these are introduced for JITed code in debuggable mode. The entry / exit hooks roughly do the same this as instrumentation entry / exit points. We also extend the JITed frame slots by adding a ShouldDeoptimize slot. This will be used to force deoptimization of frames when requested by jvmti (for ex: structural re-definition). Test: art/testrunner.py Change-Id: Id4aa439731d214a8d2b820a67e75415ca1d5424e
2020-09-02Fix bug in StackVisitor::GetVReg. Nicolas Geoffray
Floats can be stored in core registers within compiled code, so use the representation returned by the stack maps to know which register to read a value. Bug: 147572335 Test: 457-regs Change-Id: Ibe6642f2fae8206f2c230006ae85d73b47501c3b
2020-03-03Check vreg count on debuggable Alex Light
Previously we were only performing a check that we got the correct number of vregs on deoptimization when kIsDebugBuild. Extend this check to also occur when the runtime is JavaDebuggable. Bug: 144947842 Test: none Change-Id: I7d240008391a1499c159e478b59a509e2362e99f
2020-02-05Code cleanup around exception handling and stack walking. Nicolas Geoffray
- Remove unused code setting the method and dex pc below an upcall. - Clear cur_oat_quick_method_header when stack walking to be consistent in having a runtime method and a null oat method header. Test: test.py Change-Id: I87672d193eb2e62add3ae7b8a42f2202e8eb927c
2020-01-31Replace instrumention id with stack pointers. Nicolas Geoffray
Replace instrumentation ids for instrumentation frames, which are inherently broken (see b/72608560), and use stack addresses instead to properly identify which frames to pop / unwind. Bug: 72608560 Bug: 148166031 Test: ./art/test/testrunner/testrunner.py --trace --debuggable --ndebuggable --optimizing --interpreter --jit --debug --ndebug -j32 Test: run-libjdwp-tests.sh Test: 2011-stack-walk-concurrent-instrument Test: ./art/test/run-test --host --dev --runtime-option -verbose:deopt,plugin --prebuild --compact-dex-level fast --jit --no-relocate --create-runner --runtime-option -Xcheck:jni 1965-get-set-local-primitive-no-tables art/tools/parallel_run.py -j80 /tmp/path/to/runit.sh --out failure.txt Change-Id: I71f6e55b9da608796cd3142b147f7b50bbd292ec
2019-12-18Add an implementation of Nterp for x64. Nicolas Geoffray
And enable it on x64 when runtime and ArtMethod requirements are met (see nterp.cc). Test: test.py Bug: 112676029 Change-Id: I772cd20a20fdc0ff99529df7495801d773091584
2019-12-17Introduce the notion of an nterp frame. Nicolas Geoffray
See comments in nterp_helpers.cc. An nterp frame follows the calling conventions and exception handling of the compiler. There are no ManagedStack transitions, and the compiler and interpreter can just call each other directly. For the stack walker, an nterp frame looks like a compiled frame. This CL introduces an nterp frame, another CL will contain an implementation for x64. Bug: 119800099 Test: test.py Change-Id: Ie9b691f58908b7f283b4cd63b84b651526155d27
2019-07-22Add fast path for exception vreg copying. David Srbecky
It is not necessary to decode CodeInfo in GetVReg since the caller already did it. Test: ./art/test.py -b --host --64 --interpreter Change-Id: I0f8941f43acdc0f2c43b78ef87d3e796e320c959
2019-07-15ART: Introduce stackmap with no DexRegInfo. Artem Serov
Some of safepoints don't need to have DexRegisterMap info; this will decrease the stackmap size. .oat file size reduction: - boot.oat: -233 kb (-5.4%) - boot-framework.oat: -704 kb (-4.9%) Test: 461-get-reference-vreg, 466-get-live-vreg. Test: 543-env-long-ref, 616-cha*. Test: test-art-target, +gc-stress. Change-Id: Idbad355770e30a30dcf14127642e03ee666878b8