You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2006/12/13 14:42:20 UTC
svn commit: r486649 - in /harmony/enhanced/drlvm/trunk/vm:
thread/src/thread_ti_timing.c vmcore/src/jvmti/jvmti_timer.cpp
Author: gshimansky
Date: Wed Dec 13 05:42:19 2006
New Revision: 486649
URL: http://svn.apache.org/viewvc?view=rev&rev=486649
Log:
Applied HARMONY-2306 [drlvm][jvmti] VM crashes if j.l.Thread is instrumented by JVMTI profiler
Tests passed on Ubuntu6 x86, Windows 2003 server and SuSE9 x86_64
Modified:
harmony/enhanced/drlvm/trunk/vm/thread/src/thread_ti_timing.c
harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_timer.cpp
Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_ti_timing.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_ti_timing.c?view=diff&rev=486649&r1=486648&r2=486649
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_ti_timing.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_ti_timing.c Wed Dec 13 05:42:19 2006
@@ -60,9 +60,14 @@
IDATA VMCALL jthread_get_thread_cpu_time(jthread java_thread, jlong *nanos_ptr) {
hythread_t tm_native_thread;
- assert(java_thread);
assert(nanos_ptr);
- tm_native_thread = vm_jthread_get_tm_data(java_thread);
+
+ if (NULL == java_thread) {
+ tm_native_thread = hythread_self();
+ } else {
+ tm_native_thread = vm_jthread_get_tm_data(java_thread);
+ }
+
return CONVERT_ERROR(apr_get_thread_time(tm_native_thread->os_handle,
(apr_int64_t*) nanos_ptr));
}
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_timer.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_timer.cpp?view=diff&rev=486649&r1=486648&r2=486649
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_timer.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_timer.cpp Wed Dec 13 05:42:19 2006
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
+/**
* @author Gregory Shimansky
* @version $Revision: 1.1.2.1.4.4 $
- */
+ */
/*
* JVMTI timer API
*/
@@ -64,7 +64,7 @@
*/
jvmtiError JNICALL
jvmtiGetCurrentThreadCpuTimerInfo(jvmtiEnv* env,
- jvmtiTimerInfo* UNREF info_ptr)
+ jvmtiTimerInfo* info_ptr)
{
TRACE2("jvmti.timer", "GetCurrentThreadCpuTimerInfo called");
// TRACE("GetCurrentThreadCpuTimerInfo called");
@@ -95,7 +95,7 @@
*/
jvmtiError JNICALL
jvmtiGetCurrentThreadCpuTime(jvmtiEnv* env,
- jlong* UNREF nanos_ptr)
+ jlong* nanos_ptr)
{
TRACE2("jvmti.timer", "GetCurrentThreadCpuTime called");
IDATA status;
@@ -110,8 +110,10 @@
if (NULL == nanos_ptr)
return JVMTI_ERROR_NULL_POINTER;
- status=jthread_get_thread_cpu_time(jthread_self(),nanos_ptr);
- if (status!=TM_ERROR_NONE)
+
+ status = jthread_get_thread_cpu_time(NULL, nanos_ptr);
+
+ if (status != TM_ERROR_NONE)
return JVMTI_ERROR_INTERNAL;
return JVMTI_ERROR_NONE;
@@ -128,7 +130,7 @@
*/
jvmtiError JNICALL
jvmtiGetThreadCpuTimerInfo(jvmtiEnv* env,
- jvmtiTimerInfo* UNREF info_ptr)
+ jvmtiTimerInfo* info_ptr)
{
TRACE2("jvmti.timer", "GetThreadCpuTimerInfo called");
SuspendEnabledChecker sec;
@@ -158,8 +160,8 @@
*/
jvmtiError JNICALL
jvmtiGetThreadCpuTime(jvmtiEnv* env,
- jthread UNREF thread,
- jlong* UNREF nanos_ptr)
+ jthread thread,
+ jlong* nanos_ptr)
{
TRACE2("jvmti.timer", "GetThreadCpuTime called");
IDATA status;
@@ -176,36 +178,38 @@
if (NULL == nanos_ptr)
return JVMTI_ERROR_NULL_POINTER;
- if (NULL != thread)
- {
- if (!is_valid_thread_object(thread))
+ if (NULL == thread) {
+ status = jthread_get_thread_cpu_time(NULL, nanos_ptr);
+
+ } else {
+ if (! is_valid_thread_object(thread))
return JVMTI_ERROR_INVALID_THREAD;
- }
- else
- thread = jthread_self();
- // lock thread manager to avoid occasional change of thread state
- hythread_global_lock();
-
- int state;// =thread_get_thread_state(thread);
- jvmtiError err=jvmtiGetThreadState(env,thread,&state);
- if (err != JVMTI_ERROR_NONE){
- return err;
- }
- switch (state)
- {
- case JVMTI_THREAD_STATE_TERMINATED: // thread is terminated
- case JVMTI_JAVA_LANG_THREAD_STATE_NEW: // thread is new
- hythread_global_unlock();
- return JVMTI_ERROR_THREAD_NOT_ALIVE;
- default: // thread is alive
- status=jthread_get_thread_cpu_time(thread,nanos_ptr);
+ // lock thread manager to avoid occasional change of thread state
+ hythread_global_lock();
+
+ int state;// =thread_get_thread_state(thread);
+ jvmtiError err = jvmtiGetThreadState(env, thread, &state);
+ if (err != JVMTI_ERROR_NONE){
+ return err;
+ }
+
+ switch (state)
+ {
+ case JVMTI_THREAD_STATE_TERMINATED: // thread is terminated
+ case JVMTI_JAVA_LANG_THREAD_STATE_NEW: // thread is new
+ hythread_global_unlock();
+ return JVMTI_ERROR_THREAD_NOT_ALIVE;
+ default: // thread is alive
+ status = jthread_get_thread_cpu_time(thread, nanos_ptr);
+
+ break;
+ }
- break;
+ hythread_global_unlock();
}
- hythread_global_unlock();
- if (status!=TM_ERROR_NONE)
+ if (status != TM_ERROR_NONE)
return JVMTI_ERROR_INTERNAL;
return JVMTI_ERROR_NONE;
@@ -223,7 +227,7 @@
*/
jvmtiError JNICALL
jvmtiGetTimerInfo(jvmtiEnv* env,
- jvmtiTimerInfo* UNREF info_ptr)
+ jvmtiTimerInfo* info_ptr)
{
TRACE2("jvmti.timer", "GetTimerInfo called");
SuspendEnabledChecker sec;