summaryrefslogtreecommitdiff
path: root/runtime/quick_exception_handler.cc
AgeCommit message (Collapse)Author
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
2015-02-13ART: Allow class-loading during deoptAndreas Gampe
When deoptimizing, we might touch code that uses unloaded classes. Bug: 19290147 (cherry picked from commit 44fb719e5f0f5ee7dcf4b1eae703593f1043a169) Change-Id: I5776f08ba366e9742336caba0d6af85f00629afc
2015-01-23Fix exception handling during deoptimizationSebastien Hertz
When interpreting a deoptimized shadow frame, we may start with a pending exception thrown by a previous deoptimized shadow frame (from a previous invoke). Therefore, we need to handle it before executing any instruction, otherwise we execute incorrect code. Because we need the DEX pc of the throwing instruction to find a matching catch handler, we initialize deoptimized shadow frames with the current DEX pc at the time the stack is deoptimized. When we are about to interpret a deoptimized shadow frame, we need to update the shadow frame with the DEX pc of the next instruction to interpret. There are three cases: - if there is no pending exception, this is the instruction following the current one. - if there is a pending exception and we found a matching catch handler, this is the first instruction of this handler. - if there is a pending exception but there is no matching catch handler, we do not execute the deoptimized shadow frame and continue to its caller. The verifier now fails when a method starts with a move-exception instruction. Indeed we cannot start executing a method with a pending exception. Bug: 19057915 Bug: 19041195 Bug: 18607595 Change-Id: I355ac81e6ac098edc7e3cc8c13dbfa24a2969ab2
2015-01-06Don't allow suspension from FindLocksAtDexPcMathieu Chartier
Transitioning to suspended from runnable sometimes runs dump checkpoints in ThreadStress which can cause deadlocks. This happens since FindLocksAtDexPC runs the verifier which calls AllowThreadSuspension. This results in a blocked thread which holds the monitor lock, and if another thread tries to do a monitor enter, it deadlocks while holding the mutator lock (assuming the GC is suspending all). The fix for avoiding this deadlock is not calling AllowThreadSuspension from FindLocksAtDexPc. Bug: 18576985 Change-Id: I7e5faaf3bbbd5b5f680de95d53c33b5106705b0c
2014-11-03Remove -Wno-unused-parameter and -Wno-sign-promo from base cflags.Ian Rogers
Fix associated errors about unused paramenters and implict sign conversions. For sign conversion this was largely in the area of enums, so add ostream operators for the effected enums and fix tools/generate-operator-out.py. Tidy arena allocation code and arena allocated data types, rather than fixing new and delete operators. Remove dead code. Change-Id: I5b433e722d2f75baacfacae4d32aef4a828bfe1b
2014-10-22C++11 related clean-up of DISALLOW_..Ian Rogers
Move DISALLOW_COPY_AND_ASSIGN to delete functions. By no having declarations with no definitions this prompts better warning messages so deal with these by correcting the code. Add a DISALLOW_ALLOCATION and use for ValueObject and mirror::Object. Make X86 assembly operand types ValueObjects to fix compilation errors. Tidy the use of iostream and ostream. Avoid making cutils a dependency via mutex-inl.h for tests that link against libart. Push tracing dependencies into appropriate files and mutex.cc. x86 32-bit host symbols size is increased for libarttest, avoid copying this in run-test 115 by using symlinks and remove this test's higher than normal ulimit. Fix the RunningOnValgrind test in RosAllocSpace to not use GetHeap as it returns NULL when the heap is under construction by Runtime. Change-Id: Ia246f7ac0c11f73072b30d70566a196e9b78472b
2014-10-16Make ART compile with GCC -O0 again.Ian Rogers
Tidy up InstructionSetFeatures so that it has a type hierarchy dependent on architecture. Add to instruction_set_test to warn when InstructionSetFeatures don't agree with ones from system properties, AT_HWCAP and /proc/cpuinfo. Clean-up class linker entry point logic to not return entry points but to test whether the passed code is the particular entrypoint. This works around image trampolines that replicate entrypoints. Bug: 17993736 Change-Id: I5f4b49e88c3b02a79f9bee04f83395146ed7be23
2014-09-30Enable -Wunreachable-codeIan Rogers
Caught bugs in DeoptimizeStackVisitor and assemble_x86 SIB encoding. Add UNREACHABLE macro to document code expected to be unreachable. Bug: 17731047 Change-Id: I2e363fe5b38a1246354d98be18c902a6031c0b9e
2014-09-12Compile time performance improvements focusing on interpret-only.Ian Rogers
Reduce virtual method dispatch in the method verifier and make more code inline-able. Add a StringPiece with const char* equality operator to avoid redundant StringPieces and strlens. Remove back link from register line to verifier and pass as argument to reduce size of RegisterLine. Remove instruction length from instruction flags and compute from the instruction, again to reduce size. Add suspend checks to resolve and verify to allow for more easy monitor inflation and reduce contention on Locks::thread_list_suspend_thread_lock_. Change ThrowEarlierClassFailure to throw pre-allocated exception. Avoid calls to Thread::Current() by passing self. Template specialize IsValidClassName. Make ANR reporting with SIGQUIT run using checkpoints rather than suspending all threads. This makes the stack/lock analysis less lock error prone. Extra Barrier assertions and condition variable time out is now returned as a boolean both from Barrier and ConditionVariable::Wait. 2 threaded host x86-64 interpret-only numbers from 341 samples: Before change: Avg 176.137ms 99% CI 3.468ms to 1060.770ms After change: Avg 139.163% 99% CI 3.027ms to 838.257ms Reduction in average compile time after change is 20.9%. Slow-down without change is 26.5%. Bug: 17471626 - Fix bug where RegTypeCache::JavaLangObject/String/Class/Throwable could return unresolved type when class loading is disabled. Bug: 17398101 Change-Id: Id59ce3cc520701c6ecf612f7152498107bc40684
2014-08-23Clean up Handle usage.Mathieu Chartier
Prefer using ConstHandle instead of Handle as function arguments since you can't assign new references to ConstHandle which helps prevent bugs. Changed NullHandle to be a ConstHandle so that you can never modify it to be a non null reference. Change-Id: I81cb979f6f8d5b49e5614966a2caf28c3701dd4f
2014-08-22Handlerize MethodVerifier::mirror_method_.Hiroshi Yamauchi
The method (mirror_method_) wasn't handlerized across some allocation/GC points such as the ResolveType() call in ScanTryCatchBlocks() and the GetReturnType() calls in CodeFlowVerifyInstruction(). Bug: 12687968 Change-Id: I95323de14459eb5a7c4abfcf44f882f86d59be64
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-07-17Fix access to long/double stack values from debuggerSebastien Hertz
Long and double values live in a pair of DEX registers. When we compile DEX code with the Quick compiler, a DEX register either lives in the stack or is promoted to a physical register. In the case of a pair of DEX registers, the Quick compiler assumes both registers live in the same "area": both live in the stack or both are promoted to physical registers. From the debugger, we used to access these values by reading/writing each DEX register separately. However, this does not work when only one DEX register of a pair is promoted and the other lives in the stack. In this case, the compiled code reads from/writes to the stack only. To fix that, the debugger must follow the same rule than the Quick compiler: if both DEX registers are promoted, read/write them from/to physical registers, otherwise read/write them from/to the stack. We add StackVisitor:GetVRegPair and StackVisitor:SetVRegPair for this purpose. We also follow the same rule when deoptimizing. However we need to do that only when we know two consecutive DEX registers are part of a pair (long or double). We know that thanks to the verifier. Bug: 15527793 Change-Id: I04812285ff26ef0129f39792a1cf776f3591ca2d
2014-07-15Break apart header files.Ian Rogers
Create libart-gtest for common runtime and compiler gtest routines. Rename CompilerCallbacksImpl that is quick compiler specific. Rename trace clock source constants to not use the overloaded profiler term. Change-Id: I4aac4bdc7e7850c68335f81e59a390133b54e933
2014-07-11Improve performance of invokevirtual/invokeinterface with embedded imt/vtableMingyao Yang
Add an embedded version of imt/vtable into class object. Both tables start at fixed offset within class object so method/entry point can be loaded directly from class object for invokeinterface/invokevirtual. Bug: 8142917 Change-Id: I4240d58cfbe9250107c95c0708c036854c455968
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-06-09Change MethodHelper to use a Handle.Mathieu Chartier
Added ConstHandle to help prevent errors where you modify the value stored in the handle of the caller. Also fixed compaction bugs related to not knowing MethodHelper::GetReturnType can resolve types. This bug was present in interpreter RETURN_OBJECT. Bug: 13077697 Change-Id: I71f964d4d810ab4debda1a09bc968af8f3c874a3
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-05-13Add Handle/HandleScope and delete SirtRef.Mathieu Chartier
Delete SirtRef and replaced it with Handle. Handles are value types which wrap around StackReference*. Renamed StackIndirectReferenceTable to HandleScope. Added a scoped handle wrapper which wraps around an Object** and restores it in its destructor. Renamed Handle::get -> Get. Bug: 8473721 Change-Id: Idbfebd4f35af629f0f43931b7c5184b334822c7a
2014-05-01Fix a few 64-bit compilation of 32-bit code issues.Ian Rogers
Bug: 13423943 Change-Id: I939389413af0a68c0d95b23cd598b7c42afa4383
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