summaryrefslogtreecommitdiff
path: root/runtime/quick_exception_handler.h
AgeCommit message (Collapse)Author
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
2018-07-10Correctly send MethodExit events from exception handlersAlex Light
Due to the way that exceptions are handled it was possible for a MethodExit event to be sent multiple times for the same exception. This fixes that issue by correctly keeping track of which exception events have already been sent and correctly tracking the current exception being thrown. Test: ./test/testrunner/testrunner.py --host --runtime-option=-Xplugin:libtracefast-trampolined.so Test: ./test.py --host Change-Id: I7fa09f0f3f82181430b18805da5ba8daf68d4b89
2017-12-07ART: Replace base/logging with android-base/loggingAndreas Gampe
Replace wherever possible. ART's base/logging is now mainly VLOG and initialization code that is unnecessary to pull in and makes changes to verbose logging more painful than they have to be. Test: m test-art-host Change-Id: I3e3a4672ba5b621e57590a526c7d1c8b749e4f6e
2017-09-28Check the to-space invariant on a delivered exception.Roland Levillain
Test: art/test/testrunner/testrunner.py Bug: 62339341 Bug: 12687968 Change-Id: Ida5e91031cd94429a72fcc9d4d1333d21dd07421
2017-05-10Add runtime reasons for deopt.Nicolas Geoffray
Currently to help investigate. Also: 1) Log when deoptimization happens (which method and what reason) 2) Trace when deoptimization happens (to make it visible in systrace) bug:37655083 Test: test-art-host test-art-target Change-Id: I0c2d87b40db09e8e475cf97a7c784a034c585e97
2017-01-10Move most of art::Thread to ObjPtrMathieu Chartier
Bug: 31113334 Test: test-art-host Change-Id: I73d0de3c875d3ec3d732034fdc961dae79ef4070
2016-09-02Clean up some includes.Vladimir Marko
Remove some unnecessary includes from header files, replace others with forward references and add includes to source files as needed. Reduce dependency on stack.h by pulling StackReference<> out to its own file. Test: m test-art-host Change-Id: I0fb182145e328870cbd918b0ef6ae2950223c1b2
2016-08-30ART: SHARED_REQUIRES to REQUIRES_SHAREDAndreas Gampe
This coincides with the actual attribute name and upstream usage. Preparation for deferring to libbase. Test: m Test: m test-art-host Change-Id: Ia8986b5dfd926ba772bf00b0a35eaf83596d8518
2016-05-26Partial fragment deoptimizationMingyao Yang
We used to do either single frame deoptimization, or full fragment deoptimization which deoptimizes all the frames in a fragment. This change allows some methods to be not deoptimizeable, likely due to some kind of optimization. So we need another deoptimization mode that unwinds partial fragment. Deoptimizations are now generalized into either full or partial fragment. A full fragment deoptimization will deopt all frames in the fragment, and then returns from the invoke stub to enter interpreter. A partial fragment deoptimization will deopt a single frame, or all frames up to the method that's not deoptimizeable, and then jumps to the interpreter bridge. Currently code not deoptimizeable is the code in boot image since the code may not be compiled with debuggable flag. Bug: 28769520 Change-Id: I875c694791cc8ebd5121abcd92ce7b0db95aca38
2015-10-20Remove ArtCode.Nicolas Geoffray
- Instead use OatQuickMethodHeader. - Various cleanups now that we don't have all those ArtMethod -> ArtCode -> OatQuickMethodHeader indirections. As a consequence of this cleanup, exception handling got a bit faster. ParserCombinators benchmark (exception intensive) on x64: (lower is better) Before: ParserCombinators(RunTime): 1062500.0 us. After: ParserCombinators(RunTime): 833000.0 us. Change-Id: Idac917b6f1b0dc254ad68fb3781cd61bccadb0f3
2015-09-28ART: Single-frame deoptAndreas Gampe
Add deoptimization of a single frame. Works by removing the managed code frame and jumping into the quick-to-interpreter bridge, and the bridge understanding a stored ShadowFrame. We need a separate fixup pass. For x86, we leave the return address on the stack so we don't need to push it there. Bug: 21611912 Change-Id: I06625685ced8b054244f8685ab50b238a705b9d2
2015-09-15Revert "Revert "ART: Register allocation and runtime support for try/catch""David Brazdil
The original CL triggered b/24084144 which has been fixed by Ib72e12a018437c404e82f7ad414554c66a4c6f8c. This reverts commit 659562aaf133c41b8d90ec9216c07646f0f14362. Change-Id: Id8980436172457d0fcb276349c4405f7c4110a55
2015-09-14Revert "ART: Register allocation and runtime support for try/catch"David Brazdil
Breaks libcore test org.apache.harmony.security.tests.java.security.KeyStorePrivateKeyEntryTest#testGetCertificateChain. Need to investigate. This reverts commit b022fa1300e6d78639b3b910af0cf85c43df44bb. Change-Id: Ib24d3a80064d963d273e557a93469c95f37b1f6f
2015-09-14ART: Register allocation and runtime support for try/catchDavid Brazdil
This patch completes a series of CLs that add support for try/catch in the Optimizing compiler. With it, Optimizing can compile all methods containing try/catch, provided they don't contain catch loops. Future work will focus on improving performance of the generated code. SsaLivenessAnalysis was updated to propagate liveness information of instructions live at catch blocks, and to keep location information on instructions which may be caught by catch phis. RegisterAllocator was extended to spill values used after catch, and to allocate spill slots for catch phis. Catch phis generated for the same vreg share a spill slot as the raw value must be the same. Location builders and slow paths were updated to reflect the fact that throwing an exception may not lead to escaping the method. Instruction code generators are forbidden from using of implicit null checks in try blocks as live registers need to be saved before handing over to the runtime. CodeGenerator emits a stack map for each catch block, storing locations of catch phis. CodeInfo and StackMapStream recognize this new type of stack map and store them separate from other stack maps to avoid dex_pc conflicts. After having found the target catch block to deliver an exception to, QuickExceptionHandler looks up the dex register maps at the throwing instruction and the catch block and copies the values over to their respective locations. The runtime-support approach was selected because it allows for the best performance in the normal control-flow path, since no propagation of catch phi values is necessary until the exception is thrown. In addition, it also greatly simplifies the register allocation phase. ConstantHoisting was removed from LICMTest because it instantiated (now abstract) HConstant and was bogus anyway (constants are always in the entry block). Change-Id: Ie31038ad8e3ee0c13a5bbbbaf5f0b3e532310e4e
2015-09-10Support deoptimization on exceptionSebastien Hertz
Allows to deoptimize when an exception is being thrown. We only deoptimize if an executable frame (starting from the catch handler) needs to be executed with the interpreter. Before executing deoptimized frames, the exception is restored. The interpreter starts by handling this exception at the point of the throwing instruction. Bug: 23714835 Change-Id: I0c5f7d4b257644acf12210aae8e5b6bb0f4af1f7
2015-08-24Update instrumentation stack after exception eventSebastien Hertz
If instrumentation is updated on an exception event, we must update the instrumentation stack (to remove all frames that will be unwound by the exception) before doing the long jump. Bug: 23471864 Change-Id: Ic91552bb7280c54bcc58b7ba03a17040b0b0f5ef
2015-07-22Move to newer clang annotationsMathieu Chartier
Also enable -Wthread-safety-negative. Changes: Switch to capabilities and negative capabilities. Future work: Use capabilities to implement uninterruptible annotations to work with AssertNoThreadSuspension. Bug: 20072211 Change-Id: I42fcbe0300d98a831c89d1eff3ecd5a7e99ebf33
2015-05-29Move mirror::ArtMethod to nativeMathieu Chartier
Optimizing + quick tests are passing, devices boot. TODO: Test and fix bugs in mips64. Saves 16 bytes per most ArtMethod, 7.5MB reduction in system PSS. Some of the savings are from removal of virtual methods and direct methods object arrays. Bug: 19264997 Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d
2015-04-06ART: Enable more Clang warningsAndreas Gampe
Change-Id: Ie6aba02f4223b1de02530e1515c63505f37e184c
2015-03-10Remove ThrowLocation.Nicolas Geoffray
Note that this is a cleanup change, and has no functionality change. The ThrowLocation had no use anymore. Change-Id: I3d2126af1dc673cec3a0453ff3d56a172663a5f6
2015-03-09Compute the right catch location for the debugger.Nicolas Geoffray
Also remove tls ThrowLocation, it is not needed anymore. Change-Id: I78fddf09ce968ca475e39c17fa76d699c589c8d9
2015-03-03Change how we report exceptions to the debugger.Nicolas Geoffray
This is only a refactoring/cleanup. Bug fixes with respect to catch location, and more cleanups will follow. Change-Id: I30d3c6260b0c8f8115a811621397225b88f2063a
2015-02-23ART: Introduce NO_RETURN, Mark DoLongJump noreturnAndreas Gampe
Add NO_RETURN macro that adds C++11 noreturn attribute. Mark DoLongJump methods as noreturn. Change-Id: Ifde4318e370493237050d4c1349285a0382df23f
2014-12-12Remove portable.Elliott Hughes
Change-Id: I3bf3250fa866fd2265f1b115d52fa5dedc48a7fc
2014-10-24Tidy logging code not using UNIMPLEMENTED.Ian Rogers
Change-Id: I7a79c1671a6ff8b2040887133b3e0925ef9a3cfe
2014-08-13More efficient stack walk in exception throwing.Hiroshi Yamauchi
In the exception handling code, we currently walk down the stack twice, once to get the stack height which we use to compute frame IDs (the bottom frame is zero), and once more to find the catch block to jump to. For a deep stack, this could result in very slow exception handling. That is, if have a lot of finally or catch blocks that we end up jumping to in a deep stack, we need to do a lot of catch/rethrow chains. Since we'd need to walk down to the bottom each time to compute frames IDs in each catch/rethrow, we'd need to walk down O(N^2) frames at the worst case. Instead of frames IDs ((the bottom frame is zero), we will use the frame depth (the top frame is zero) and no longer need to walk down the stack just to get the stack height. We walk down O(N) frames. This was what was happening with code.google.gson.functional.CircularReferenceTest. With this change, the test run time went from ~120s down to ~3s on N5 and it no longer crashes due to the thread suspension timeout. Bug: 16800209 Change-Id: Ie815df1e3e8fb9d82e40685d4cc2b8838fd8aa07
2014-06-11Fix exception reporting from interpreterSebastien Hertz
To comply with JDWP exception report rules, we must report an exception at the location of the throw (or the first instruction encountered after a native call). To do this, we use the CatchLocationFinder visitor to look for a catch handler until we reach a native frame or the top frame. Because interpreter handles pending exception on a method-by-method basis, we need a flag to remember we already reported the exception and avoid reporting it multiple times when unwinding methods. The drawback is we need to maintain the state of this flag. We clear it when the exception is cleared. In the case we temporarily clear the exception (when finding a catch handler for instance), we restore the flag to its previous value at the same time we restore the pending exception. Bump oat version to force recompilation because we modify Thread offsets. Bug: 14402770 Change-Id: Ic059c58f80b2023b118038301f8f0a24f1e18241
2014-05-30Don't report down-calls as unhandled exceptions.Ian Rogers
Bug: 15310540 Also, narrow scope of catch/deoptimize stack visitors that are specific to quick exception delivery. Change-Id: Ib13a006ce1347acb93a36b0186550d4c3ec2034b
2014-05-29ART: Use StackReference in Quick Stack FrameAndreas Gampe
The method reference at the bottom of a quick frame is a stack reference and not a native pointer. This is important for 64b architectures, where the notions do not coincide. Change key methods to have StackReference<mirror::ArtMethod>* parameter instead of mirror::ArtMethod**. Make changes to invoke stubs for 64b archs, change the frame setup for JNI code (both generic JNI and compilers), tie up loose ends. Tested on x86 and x86-64 with host tests. On x86-64, tests succeed with jni compiler activated. x86-64 QCG was not tested. Tested on ARM32 with device tests. Fix ARM64 not saving x19 (used for wSUSPEND) on upcalls. Tested on ARM64 in interpreter-only + generic-jni mode. Fix ARM64 JNI Compiler to work with the CL. Tested on ARM64 in interpreter-only + jni compiler. Change-Id: I77931a0cbadd04d163b3eb8d6f6a6f8740578f13
2014-04-29Visit deoptimized shadow frames as rootsSebastien Hertz
During deoptimization, we create shadow frames but do not attach them to the stack until we transition to interpreter mode. If a GC happens before that, these shadow frames are not visited by GC so they may contain stale references. This CL addresses this issue by visiting the shadow frames "under contruction" in Thread::VisitRoots so we correctly update all references they hold. To make them visible, we now save the top shadow frame (the first one created) in the field Thread::tls_ptr_sized_values::deoptimization_shadow_frame. This field will then be cleared when transitioning to interpreter mode. Bug: 14324885 Change-Id: Ib213ddc80f19cfcdfcec6f20acaa7f1a0e9ce2c1
2014-04-25Refactor exception handling for deoptimizationSebastien Hertz
This CL refactors the exception handling (on the quick side) by isolating the search of catch handler and the preparation of deoptimization. We rename the CatchFinder class to QuickExceptionHandler so it's less specific to catch handler search. Finding catch handler happens in QuickExceptionHandler::FindCatch. Since the CatchBlockStackVisitor resolves exception types, it may cause thread suspension and breaks the assertion current thread can't be suspended. Therefore, we place the exception in a SirtRef (while it is detached from the current thread) and remove the thread suspension assertion. Deoptimization now happens in QuickExceptionHandler::DeoptimizeStack. It uses the new DeoptimizeStackVisitor class to create shadow frames. We also add the Thread::GetDeoptimizationException method to get the definition of the fake exception in only one place. Change-Id: I01b19fa72af64329b5c3b6c7f0c3339d2d724978