diff options
author | Sebastien Hertz <shertz@google.com> | 2015-02-25 15:05:59 +0100 |
---|---|---|
committer | Sebastien Hertz <shertz@google.com> | 2015-03-09 15:19:49 +0100 |
commit | 1558b577907b613864e98f05862543557263e864 (patch) | |
tree | 5498d8d15f198341fe46a8badc7e7591611a09b5 /runtime/thread.h | |
parent | 2cfdabd2bb4833d7092819d27ef08a9e1cdffead (diff) | |
download | art-1558b577907b613864e98f05862543557263e864.zip art-1558b577907b613864e98f05862543557263e864.tar.gz art-1558b577907b613864e98f05862543557263e864.tar.bz2 |
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
Diffstat (limited to 'runtime/thread.h')
-rw-r--r-- | runtime/thread.h | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/runtime/thread.h b/runtime/thread.h index af02dc7..325c821 100644 --- a/runtime/thread.h +++ b/runtime/thread.h @@ -707,6 +707,16 @@ class Thread { return tlsPtr_.single_step_control; } + // Indicates whether this thread is ready to invoke a method for debugging. This + // is only true if the thread has been suspended by a debug event. + bool IsReadyForDebugInvoke() const { + return tls32_.ready_for_debug_invoke; + } + + void SetReadyForDebugInvoke(bool ready) { + tls32_.ready_for_debug_invoke = ready; + } + // Activates single step control for debugging. The thread takes the // ownership of the given SingleStepControl*. It is deleted by a call // to DeactivateSingleStepControl or upon thread destruction. @@ -715,6 +725,17 @@ class Thread { // Deactivates single step control for debugging. void DeactivateSingleStepControl(); + // Sets debug invoke request for debugging. When the thread is resumed, + // it executes the method described by this request then suspends itself. + // The thread does not take ownership of the given DebugInvokeReq*, it is + // owned by the JDWP thread which is waiting for the execution of the + // method. + void SetDebugInvokeReq(DebugInvokeReq* req); + + // Clears debug invoke request for debugging. When the thread completes + // method invocation, it clears its debug invoke request, signals the + // JDWP thread and suspends itself. + void ClearDebugInvokeReq(); // Returns the fake exception used to activate deoptimization. static mirror::Throwable* GetDeoptimizationException() { @@ -966,7 +987,8 @@ class Thread { explicit tls_32bit_sized_values(bool is_daemon) : suspend_count(0), debug_suspend_count(0), thin_lock_thread_id(0), tid(0), daemon(is_daemon), throwing_OutOfMemoryError(false), no_thread_suspension(0), - thread_exit_check_count(0), handling_signal_(false), suspended_at_suspend_check(false) { + thread_exit_check_count(0), handling_signal_(false), suspended_at_suspend_check(false), + ready_for_debug_invoke(false) { } union StateAndFlags state_and_flags; @@ -1010,6 +1032,11 @@ class Thread { // used to distinguish runnable threads that are suspended due to // a normal suspend check from other threads. bool32_t suspended_at_suspend_check; + + // True if the thread has been suspended by a debugger event. This is + // used to invoke method from the debugger which is only allowed when + // the thread is suspended by an event. + bool32_t ready_for_debug_invoke; } tls32_; struct PACKED(8) tls_64bit_sized_values { |