harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r472664 - in /incubator/harmony/enhanced/drlvm/trunk/vm/vmcore: include/version_svn_tag.h src/jvmti/jvmti_capability.cpp src/jvmti/jvmti_heap.cpp src/jvmti/jvmti_heap.h src/jvmti/jvmti_roots.cpp
Date Wed, 08 Nov 2006 22:25:20 GMT
Author: gshimansky
Date: Wed Nov  8 14:25:19 2006
New Revision: 472664

URL: http://svn.apache.org/viewvc?view=rev&rev=472664
Log:
Applied HARMONY-2112 [drlvm][jvmti] Fix error codes in heap functions

Tests passed on gentoo linux


Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/version_svn_tag.h
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_capability.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_heap.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_heap.h
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_roots.cpp

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/version_svn_tag.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/version_svn_tag.h?view=diff&rev=472664&r1=472663&r2=472664
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/version_svn_tag.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/version_svn_tag.h Wed Nov  8
14:25:19 2006
@@ -18,6 +18,6 @@
 #ifndef _VERSION_SVN_TAG_
 #define _VERSION_SVN_TAG_
 
-#define VERSION_SVN_TAG  "472440"
+#define VERSION_SVN_TAG  "472634"
 
 #endif // _VERSION_SVN_TAG_

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_capability.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_capability.cpp?view=diff&rev=472664&r1=472663&r2=472664
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_capability.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_capability.cpp Wed Nov
 8 14:25:19 2006
@@ -233,6 +233,15 @@
     unsigned char* available = (unsigned char*)available_caps;
     unsigned char* p_posessed = (unsigned char*)&posessed;
 
+    DebugUtilsTI *ti = ti_env->vm->vm_env->TI;
+
+    // if the global capability can_tag_objects has already been enabled,
+    // requested by this environment, but not yet posessed by this environment,
+    // reject the request
+    if (ti->get_global_capability(DebugUtilsTI::TI_GC_ENABLE_TAG_OBJECTS)
+            && !posessed.can_tag_objects && capabilities_ptr->can_tag_objects)
+        return JVMTI_ERROR_NOT_AVAILABLE;
+
     // Allow to turn on any capabilities that are listed in potential capabilities
     for (int i = 0; i < int(sizeof(jvmtiCapabilities)); i++)
     {
@@ -248,7 +257,6 @@
     ti_env->posessed_capabilities = posessed;
 
     // Update global capabilities
-    DebugUtilsTI *ti = ti_env->vm->vm_env->TI;
     if (capabilities_ptr->can_generate_method_entry_events)
         ti->set_global_capability(DebugUtilsTI::TI_GC_ENABLE_METHOD_ENTRY);
 
@@ -278,6 +286,7 @@
 
     if (capabilities_ptr->can_tag_objects) {
         ti->set_global_capability(DebugUtilsTI::TI_GC_ENABLE_TAG_OBJECTS);
+        assert(ManagedObject::_tag_pointer == false);
         ManagedObject::_tag_pointer = true;
     }
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_heap.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_heap.cpp?view=diff&rev=472664&r1=472663&r2=472664
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_heap.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_heap.cpp Wed Nov  8 14:25:19
2006
@@ -46,7 +46,7 @@
 #include "jvmti_trace.h"
 
 // FIXME: use TLS to store ti_env
-TIEnv* ti_env;
+TIEnv* global_ti_env;
 
 /*
  * Get Tag
@@ -72,14 +72,14 @@
 
     CHECK_EVERYTHING();
 
-    if (NULL == tag_ptr || !is_jobject_valid(object)) 
-        return JVMTI_ERROR_ILLEGAL_ARGUMENT;
-
     TIEnv* ti_env = reinterpret_cast<TIEnv *>(env);
 
-    if (!ti_env->posessed_capabilities.can_tag_objects) {
+    if (!ti_env->posessed_capabilities.can_tag_objects)
         return JVMTI_ERROR_MUST_POSSESS_CAPABILITY;
-    }
+    if (NULL == tag_ptr)
+        return JVMTI_ERROR_NULL_POINTER;
+    if (!is_jobject_valid(object))
+        return JVMTI_ERROR_INVALID_OBJECT;
 
     if (ti_env->tags == NULL) {
         *tag_ptr = 0;
@@ -116,14 +116,13 @@
     jvmtiPhase phases[] = {JVMTI_PHASE_START, JVMTI_PHASE_LIVE};
 
     CHECK_EVERYTHING();
-    if (!is_jobject_valid(object)) 
-        return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 
     TIEnv* ti_env = reinterpret_cast<TIEnv *>(env);
 
-    if (!ti_env->posessed_capabilities.can_tag_objects) {
+    if (!ti_env->posessed_capabilities.can_tag_objects)
         return JVMTI_ERROR_MUST_POSSESS_CAPABILITY;
-    }
+    if (!is_jobject_valid(object))
+        return JVMTI_ERROR_INVALID_OBJECT;
 
     if (ti_env->tags == NULL) {
         assert(ti_env->lock);
@@ -251,11 +250,13 @@
 
     CHECK_EVERYTHING();
 
-    if (!is_jobject_valid(object)) {
-        return JVMTI_ERROR_ILLEGAL_ARGUMENT;
-    }
-
     TIEnv* ti_env = reinterpret_cast<TIEnv *>(env);
+
+    if (!ti_env->posessed_capabilities.can_tag_objects)
+        return JVMTI_ERROR_MUST_POSSESS_CAPABILITY;
+    if (!is_jobject_valid(object))
+        return JVMTI_ERROR_INVALID_OBJECT;
+
     hythread_global_lock();
 
     jvmtiError r;
@@ -269,7 +270,7 @@
     hythread_iterator_t iterator;
     hythread_suspend_all(&iterator, NULL);
 
-    ::ti_env = ti_env; // FIXME: use TLS to store TIEnv pointer
+    global_ti_env = ti_env; // FIXME: use TLS to store TIEnv pointer
 
     ti_env->iteration_state->user_data = user_data;
     ti_env->iteration_state->object_ref_callback = object_ref_callback;
@@ -327,6 +328,10 @@
     CHECK_EVERYTHING();
 
     TIEnv* ti_env = reinterpret_cast<TIEnv *>(env);
+
+    if (!ti_env->posessed_capabilities.can_tag_objects)
+        return JVMTI_ERROR_MUST_POSSESS_CAPABILITY;
+
     hythread_global_lock();
 
     jvmtiError r;
@@ -340,7 +345,7 @@
     hythread_iterator_t iterator;
     hythread_suspend_all(&iterator, NULL);
 
-    ::ti_env = ti_env; // FIXME: use TLS to store TIEnv pointer
+    global_ti_env = ti_env; // FIXME: use TLS to store TIEnv pointer
 
     ti_env->iteration_state->user_data = user_data;
     ti_env->iteration_state->heap_root_callback = heap_root_callback;
@@ -361,7 +366,7 @@
 
 bool vm_iterate_object(Managed_Object_Handle obj)
 {
-    TIEnv* ti_env = ::ti_env;  // FIXME: use TLS to store ti_env
+    TIEnv* ti_env = global_ti_env;  // FIXME: use TLS to store ti_env
 
     TRACE2("vm.iterate", "vm_iterate_object " << (ManagedObject*)obj);
     assert(ti_env->tags);
@@ -428,6 +433,12 @@
 
     TIEnv* ti_env = reinterpret_cast<TIEnv *>(env);
 
+    if (!ti_env->posessed_capabilities.can_tag_objects)
+        return JVMTI_ERROR_MUST_POSSESS_CAPABILITY;
+    if (object_filter != JVMTI_HEAP_OBJECT_TAGGED
+            && object_filter != JVMTI_HEAP_OBJECT_UNTAGGED
+            && object_filter != JVMTI_HEAP_OBJECT_EITHER)
+        return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 
     // heap iteration requires stop-the-world
     hythread_global_lock();
@@ -447,7 +458,7 @@
     hythread_suspend_all(&iterator, NULL);
     TRACE2("ti.iterate", "suspended all threads");
     
-    ::ti_env = ti_env; // FIXME: use TLS to store TIEnv pointer
+    global_ti_env = ti_env; // FIXME: use TLS to store TIEnv pointer
     state->user_data = user_data;
     state->heap_object_callback = heap_object_callback;
     state->object_filter = object_filter;
@@ -499,6 +510,12 @@
 
     TIEnv* ti_env = reinterpret_cast<TIEnv *>(env);
 
+    if (!ti_env->posessed_capabilities.can_tag_objects)
+        return JVMTI_ERROR_MUST_POSSESS_CAPABILITY;
+    if (object_filter != JVMTI_HEAP_OBJECT_TAGGED
+            && object_filter != JVMTI_HEAP_OBJECT_UNTAGGED
+            && object_filter != JVMTI_HEAP_OBJECT_EITHER)
+        return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 
     // heap iteration requires stop-the-world
     TRACE2("ti.iterate", "acquire tm lock");
@@ -520,7 +537,7 @@
     hythread_suspend_all(&iterator, NULL);
     TRACE2("ti.iterate", "suspended all threads");
     
-    ::ti_env = ti_env; // FIXME: use TLS to store TIEnv pointer
+    global_ti_env = ti_env; // FIXME: use TLS to store TIEnv pointer
     state->user_data = user_data;
     state->heap_object_callback = heap_object_callback;
     state->object_filter = object_filter;
@@ -569,12 +586,16 @@
     jvmtiPhase phases[] = {JVMTI_PHASE_LIVE};
 
     CHECK_EVERYTHING();
-    if (count_ptr == NULL || tags == NULL || tag_count <= 0 ||
-            (object_result_ptr == NULL && tag_result_ptr == NULL)) {
-        return JVMTI_ERROR_ILLEGAL_ARGUMENT;
-    }
 
-    hythread_suspend_disable(); // ---------------vv
+    TIEnv* ti_env = reinterpret_cast<TIEnv *>(env);
+
+    if (!ti_env->posessed_capabilities.can_tag_objects)
+        return JVMTI_ERROR_MUST_POSSESS_CAPABILITY;
+    if (count_ptr == NULL || tags == NULL ||
+            (object_result_ptr == NULL && tag_result_ptr == NULL))
+        return JVMTI_ERROR_NULL_POINTER;
+    if (tag_count <= 0)
+        return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 
     std::set<jlong> tag_set;
     std::list<tag_pair> objects;
@@ -582,13 +603,25 @@
 
     int i;
     for (i = 0; i < tag_count; i++) {
+        if (tags[i] == 0)
+            return JVMTI_ERROR_ILLEGAL_ARGUMENT;
         tag_set.insert(tags[i]);
     }
 
+    hythread_suspend_disable(); // ---------------vv
+
     ti_env->tags->get_objects_with_tags(tag_set, objects);
     int count = objects.size();
     *count_ptr = count;
-    if (count > 0) {
+    if (count == 0) {
+        // set output args to NULL
+        // for compatibility
+        if (object_result_ptr)
+            *object_result_ptr = NULL;
+        if (tag_result_ptr)
+            *tag_result_ptr = NULL;
+    } else {
+        assert(count > 0);
         if (object_result_ptr != NULL) {
             jvmtiError r = _allocate(count * sizeof(jobject),
                     (unsigned char **)object_result_ptr);

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_heap.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_heap.h?view=diff&rev=472664&r1=472663&r2=472664
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_heap.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_heap.h Wed Nov  8 14:25:19
2006
@@ -78,7 +78,7 @@
     int bytes;
 };
 
-extern TIEnv* ti_env; // FIXME: store it in TLS
+extern TIEnv* global_ti_env; // FIXME: store it in TLS
 
 /**
  * returns object tag.

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_roots.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_roots.cpp?view=diff&rev=472664&r1=472663&r2=472664
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_roots.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_roots.cpp Wed Nov  8
14:25:19 2006
@@ -164,7 +164,7 @@
  */
 static void ti_enumerate_root(void* root, Managed_Object_Handle obj)
 {
-    TIEnv* ti_env = ::ti_env; // FIXME: load ti_env from TLS
+    TIEnv* ti_env = global_ti_env; // FIXME: load ti_env from TLS
     TIIterationState *state = ti_env->iteration_state;
     assert(state);
     if (JVMTI_HEAP_ROOT_STACK_LOCAL == state->root_kind
@@ -312,10 +312,10 @@
 {
     StackIterator* si;
     si = si_create_from_native(thread);
-    ti_enumerate_thread_stack(ti_env, si);    
+    ti_enumerate_thread_stack((TIEnv*)env, si);    
 
     // Enumerate references associated with a thread that are not stored on the thread's
stack.
-    ti_enumerate_thread_not_on_stack(ti_env, thread);
+    ti_enumerate_thread_not_on_stack((TIEnv*)env, thread);
 }
 
 static void ti_enumerate_thread(TIEnv *ti_env, VM_thread* thread)



Mime
View raw message