OSDN Git Service

JDWP: allocate DebugInvokeReq only when requested
authorSebastien Hertz <shertz@google.com>
Wed, 25 Feb 2015 14:05:59 +0000 (15:05 +0100)
committerSebastien Hertz <shertz@google.com>
Mon, 9 Mar 2015 14:19:49 +0000 (15:19 +0100)
commit1558b577907b613864e98f05862543557263e864
tree5498d8d15f198341fe46a8badc7e7591611a09b5
parent2cfdabd2bb4833d7092819d27ef08a9e1cdffead
JDWP: allocate DebugInvokeReq only when requested

Only allocates thread-local DebugInvokeReq when the debugger requests
a thread to invoke a method. The JDWP thread allocates that structure
then attaches it to the target thread. When the thread is resumed, it
executes the method. Once the invocation completes, the thread
detaches the DebugInvokeReq, signals the JDWP thread then suspends.
Finally, the JDWP thread wakes up, prepares the reply with the invoke
result (or exception) and deallocates the DebugInvokeReq.

Also ensures GC safety for object returned by the invoke. We add the
object to the JDWP object registry right after the invoke. We now
reference that object with a JDWP ObjectID instead of an Object* in
the DebugInvokeReq struct. This prevent from accessing a stale
reference if the GC runs and moves the Object*.

This CL includes the following changes:
- Move former DebugInvokeReq::ready flag to
  Thread::tls_32bit_sized_values::ready_for_debug_invoke. It's needed
  to know whether a thread has been suspended by an event, thus ready
  to invoke a method from the debugger.
- Remove DebugInvokeReq::invoke_needed: we now test if we attached a
  DebugInvokeReq* to the thread.
- Rename misleading FinishMethod function to RequestMethod.

Bug: 19142632
Bug: 18166750
Change-Id: I351fb4eb94bfe69fcafb544d21d55ff35a033000
runtime/debugger.cc
runtime/debugger.h
runtime/jdwp/jdwp_event.cc
runtime/jdwp/jdwp_handler.cc
runtime/oat.h
runtime/thread.cc
runtime/thread.h
runtime/thread_list.cc