History log of /art/runtime/quick_exception_handler.h
Revision Date Author Comments
8578ab081fc328b7b7c4ff85e94630a4edbc15b8 23-May-2016 Mingyao Yang <mingyao@google.com> Partial fragment deoptimization

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.

(cherry picked from commit f711f2cf3c28dfe865e36f17419a16f06a0ebb5a)

Bug: 28769520
Change-Id: I875c694791cc8ebd5121abcd92ce7b0db95aca38
524e7ea8cd17bad17bd9f3e0ccbb19ad0d4d9c02 16-Oct-2015 Nicolas Geoffray <ngeoffray@google.com> Remove ArtCode.

- 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
639bdd13993644a267f177f8f5936496bda65e2b 03-Jun-2015 Andreas Gampe <agampe@google.com> ART: Single-frame deopt

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
77a48ae01bbc5b05ca009cf09e2fcb53e4c8ff23 15-Sep-2015 David Brazdil <dbrazdil@google.com> Revert "Revert "ART: Register allocation and runtime support for try/catch""

The original CL triggered b/24084144 which has been fixed
by Ib72e12a018437c404e82f7ad414554c66a4c6f8c.

This reverts commit 659562aaf133c41b8d90ec9216c07646f0f14362.

Change-Id: Id8980436172457d0fcb276349c4405f7c4110a55
659562aaf133c41b8d90ec9216c07646f0f14362 14-Sep-2015 David Brazdil <dbrazdil@google.com> Revert "ART: Register allocation and runtime support for try/catch"

Breaks libcore test org.apache.harmony.security.tests.java.security.KeyStorePrivateKeyEntryTest#testGetCertificateChain. Need to investigate.

This reverts commit b022fa1300e6d78639b3b910af0cf85c43df44bb.

Change-Id: Ib24d3a80064d963d273e557a93469c95f37b1f6f
b022fa1300e6d78639b3b910af0cf85c43df44bb 20-Aug-2015 David Brazdil <dbrazdil@google.com> ART: Register allocation and runtime support for try/catch

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
520633bebd2bf4d70884d30f179dbde9f275aac6 08-Sep-2015 Sebastien Hertz <shertz@google.com> Support deoptimization on exception

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
b995c0ab7d6313f32e704e79c1e7dd21f5f160d4 24-Aug-2015 Sebastien Hertz <shertz@google.com> Update instrumentation stack after exception event

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
90443477f9a0061581c420775ce3b7eeae7468bc 17-Jul-2015 Mathieu Chartier <mathieuc@google.com> Move to newer clang annotations

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
3d21bdf8894e780d349c481e5c9e29fe1556051c 22-Apr-2015 Mathieu Chartier <mathieuc@google.com> Move mirror::ArtMethod to native

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

(cherry picked from commit e401d146407d61eeb99f8d6176b2ac13c4df1e33)

Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d

Fix some ArtMethod related bugs

Added root visiting for runtime methods, not currently required
since the GcRoots in these methods are null.

Added missing GetInterfaceMethodIfProxy in GetMethodLine, fixes
--trace run-tests 005, 044.

Fixed optimizing compiler bug where we used a normal stack location
instead of double on ARM64, this fixes the debuggable tests.

TODO: Fix JDWP tests.

Bug: 19264997

Change-Id: I7c55f69c61d1b45351fd0dc7185ffe5efad82bd3

ART: Fix casts for 64-bit pointers on 32-bit compiler.

Bug: 19264997
Change-Id: Ief45cdd4bae5a43fc8bfdfa7cf744e2c57529457

Fix JDWP tests after ArtMethod change

Fixes Throwable::GetStackDepth for exception event detection after
internal stack trace representation change.

Adds missing ArtMethod::GetInterfaceMethodIfProxy call in case of
proxy method.

Bug: 19264997
Change-Id: I363e293796848c3ec491c963813f62d868da44d2

Fix accidental IMT and root marking regression

Was always using the conflict trampoline. Also included fix for
regression in GC time caused by extra roots. Most of the regression
was IMT.

Fixed bug in DumpGcPerformanceInfo where we would get SIGABRT due to
detached thread.

EvaluateAndApplyChanges:
From ~2500 -> ~1980
GC time: 8.2s -> 7.2s due to 1s less of MarkConcurrentRoots

Bug: 19264997
Change-Id: I4333e80a8268c2ed1284f87f25b9f113d4f2c7e0

Fix bogus image test assert

Previously we were comparing the size of the non moving space to
size of the image file.

Now we properly compare the size of the image space against the size
of the image file.

Bug: 19264997
Change-Id: I7359f1f73ae3df60c5147245935a24431c04808a

[MIPS64] Fix art_quick_invoke_stub argument offsets.

ArtMethod reference's size got bigger, so we need to move other args
and leave enough space for ArtMethod* and 'this' pointer.

This fixes mips64 boot.

Bug: 19264997
Change-Id: I47198d5f39a4caab30b3b77479d5eedaad5006ab
e401d146407d61eeb99f8d6176b2ac13c4df1e33 22-Apr-2015 Mathieu Chartier <mathieuc@google.com> Move mirror::ArtMethod to native

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
65b798ea10dd716c1bb3dda029f9bf255435af72 06-Apr-2015 Andreas Gampe <agampe@google.com> ART: Enable more Clang warnings

Change-Id: Ie6aba02f4223b1de02530e1515c63505f37e184c
0aa50ce2fb75bfc2e815a0c33adf9b049561923b 10-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> Remove ThrowLocation.

Note that this is a cleanup change, and has no functionality change.
The ThrowLocation had no use anymore.

Change-Id: I3d2126af1dc673cec3a0453ff3d56a172663a5f6
14691c5e786e8c2c5734f687e4c96217340771be 05-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> Compute the right catch location for the debugger.

Also remove tls ThrowLocation, it is not needed anymore.

Change-Id: I78fddf09ce968ca475e39c17fa76d699c589c8d9
7642cfc90fc9c3ebfd8e3b5041915705c93b5cf0 26-Feb-2015 Nicolas Geoffray <ngeoffray@google.com> Change how we report exceptions to the debugger.

This is only a refactoring/cleanup. Bug fixes with respect
to catch location, and more cleanups will follow.

Change-Id: I30d3c6260b0c8f8115a811621397225b88f2063a
794ad76e8d5b5b9132819d5b08a0570e27615644 23-Feb-2015 Andreas Gampe <agampe@google.com> ART: Introduce NO_RETURN, Mark DoLongJump noreturn

Add NO_RETURN macro that adds C++11 noreturn attribute. Mark
DoLongJump methods as noreturn.

Change-Id: Ifde4318e370493237050d4c1349285a0382df23f
956af0f0cb05422e38c1d22cbef309d16b8a1a12 11-Dec-2014 Elliott Hughes <enh@google.com> Remove portable.

Change-Id: I3bf3250fa866fd2265f1b115d52fa5dedc48a7fc
2c4257be8191c5eefde744e8965fcefc80a0a97d 24-Oct-2014 Ian Rogers <irogers@google.com> Tidy logging code not using UNIMPLEMENTED.

Change-Id: I7a79c1671a6ff8b2040887133b3e0925ef9a3cfe
2e981cbaa2e869ec3910ebdc5cce9d4ab9edb758 13-Aug-2014 Hiroshi Yamauchi <yamauchi@google.com> More efficient stack walk in exception throwing.

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.

(cherry pick commit 649278cec7119cdd1bea3d0b710dbb2aa7c650b6)

Bug: 16800209
Change-Id: Ie815df1e3e8fb9d82e40685d4cc2b8838fd8aa07
649278cec7119cdd1bea3d0b710dbb2aa7c650b6 13-Aug-2014 Hiroshi Yamauchi <yamauchi@google.com> More efficient stack walk in exception throwing.

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
9f1020305292a21fd14a402b189c765a125226ab 23-May-2014 Sebastien Hertz <shertz@google.com> Fix exception reporting from interpreter

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
ffddfdf6fec0b9d98a692e27242eecb15af5ead2 03-Jun-2014 Tim Murray <timmurray@google.com> DO NOT MERGE

Merge ART from AOSP to lmp-preview-dev.

Change-Id: I0f578733a4b8756fd780d4a052ad69b746f687a9
5cf98196d488437acd1e989c08a554ef697fded1 30-May-2014 Ian Rogers <irogers@google.com> Don't report down-calls as unhandled exceptions.

Bug: 15310540
Also, narrow scope of catch/deoptimize stack visitors that are specific to
quick exception delivery.

Change-Id: Ib13a006ce1347acb93a36b0186550d4c3ec2034b
cf4035a4c41ccfcc3e89a0cee25f5218a11b0705 29-May-2014 Andreas Gampe <agampe@google.com> ART: Use StackReference in Quick Stack Frame

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
714f175bd66d03225927a84f3d5dbc923c5a3e7e 28-Apr-2014 Sebastien Hertz <shertz@google.com> Visit deoptimized shadow frames as roots

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
fd3077e4b9ebadd281777310d26e64443858f653 23-Apr-2014 Sebastien Hertz <shertz@google.com> Refactor exception handling for deoptimization

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