Codegen support for debugger
Add the ability to generate code with support for debugging.
This involves generating a callout to an equivalent of the
old "updateDebugger()" before each Dalvik opcode, method
entry and method exit.
The added code is fairly compact - 8 bytes per Dalvik opcode,
plus 4 additional bytes per safe point.
I dislike the idea of always making this call, so I'm reusing
the dedicated register rSUSPEND to hold the address of the callout.
rSUSPEND is normally used to reduce the frequency of full suspend
checks, but when debugging this isn't necessary - allowing
us to resuse this register to hold the address of the callout.
If it is non-null we make the callout, otherwise we continue. I refresh
this register from a slot in the Thread structure on method entry
and also following the return of taken suspend checks. In this way,
the debugger has the ability to control updates on a per-thread basis,
and the performance penalty is greatly reduced for threads that don't
have any pending debugger requests. Once the debugger attaches,
it would suspend all threads, walk through the thread list, set
thread->pUpdateDebuggerFromCode to art_update_debugger and then
turn everything loose.
One thing I'm not doing, though, is debugger updates before and after
calls to native methods. This is something that will have to be done
by the stubs, because I don't know which invokes are native. Oh, and
there will also need to be an artUpdateDebugger call on the exception
path.
I'm passing the DalvikPC to the stub, and am using special
codes (-1 and -2) to denote method entry and exit. The stub
recovers the current Method* and Thread* and passes them on to
artUpdateDebugger().
When we're compiling in this special mode, all optimizations which
might result in code motion or suppressed load/store of a Dalvik
register are turned off. No register promotion is done, so everything
will be in its home location.
Change-Id: Iaf66f4d0d094a1699269d0a1ad1ed33e7613aef8
12 files changed