harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r470512 - in /incubator/harmony/enhanced/drlvm/trunk/vm: include/ vmcore/include/ vmcore/src/class_support/ vmcore/src/jit/ vmcore/src/jvmti/ vmcore/src/thread/ vmcore/src/util/
Date Thu, 02 Nov 2006 20:36:45 GMT
Author: gshimansky
Date: Thu Nov  2 12:36:44 2006
New Revision: 470512

URL: http://svn.apache.org/viewvc?view=rev&rev=470512
Log:
Applied HARMONY-1985 [drlvm][jvmti] VMObjectAlloc event support

Tests passed on Gentoo linux


Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/include/jvmti_types.h
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_capability.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_general.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/object_generic.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/vm_strings.cpp

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/include/jvmti_types.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/include/jvmti_types.h?view=diff&rev=470512&r1=470511&r2=470512
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/include/jvmti_types.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/include/jvmti_types.h Thu Nov  2 12:36:44 2006
@@ -283,6 +283,8 @@
         JVMTI_MAX_EVENT_TYPE_VAL = 84
     } jvmtiEvent;
 
+#define TOTAL_EVENT_TYPE_NUM (JVMTI_MAX_EVENT_TYPE_VAL - JVMTI_MIN_EVENT_TYPE_VAL + 1)
+
     /**
      * Root types.
      */

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h?view=diff&rev=470512&r1=470511&r2=470512
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h Thu Nov  2 12:36:44
2006
@@ -50,8 +50,8 @@
     VMBreakInterface *brpt_intf;
     TIEnv* next;
 
-    bool global_events[JVMTI_MAX_EVENT_TYPE_VAL - JVMTI_MIN_EVENT_TYPE_VAL];
-    TIEventThread *event_threads[JVMTI_MAX_EVENT_TYPE_VAL - JVMTI_MIN_EVENT_TYPE_VAL];
+    bool global_events[TOTAL_EVENT_TYPE_NUM];
+    TIEventThread *event_threads[TOTAL_EVENT_TYPE_NUM];
 
     /**
      * Returns pointer to a callback function that was set by SetEventCallbacks
@@ -137,6 +137,8 @@
     jmethodID method, jlocation location, ManagedObject* object);
 VMEXPORT void jvmti_process_field_modification_event(Field_Handle field,
     jmethodID method, jlocation location, ManagedObject* object, jvalue new_value);
+VMEXPORT Managed_Object_Handle vm_alloc_and_report_ti(unsigned size, 
+    Allocation_Handle p_vtable, void *thread_pointer, Class* object_class);
 
 #ifdef __cplusplus
 extern "C" {

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp?view=diff&rev=470512&r1=470511&r2=470512
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp Thu
Nov  2 12:36:44 2006
@@ -1114,8 +1114,8 @@
 
         tmn_suspend_disable(); // -----------------vvv
         ManagedObject* new_java_lang_Class =
-            (ManagedObject*)gc_alloc(root_class->instance_data_size,
-                root_class->allocation_handle, vm_get_gc_thread_local());
+            (ManagedObject*) vm_alloc_and_report_ti(root_class->instance_data_size,
+                root_class->allocation_handle, vm_get_gc_thread_local(), root_class);
         if(new_java_lang_Class == NULL)
         {
             tmn_suspend_enable();

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp?view=diff&rev=470512&r1=470511&r2=470512
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp Thu Nov
 2 12:36:44 2006
@@ -2077,9 +2077,9 @@
     vtable->clss->num_bytes_allocated += vtable->allocated_size;
 #endif //VM_STATS
     // From vm_types.h: this is the same as instance_data_size with the constraint bit cleared.
-    ManagedObject* o = (ManagedObject *)
-        gc_alloc(vtable->allocated_size, 
-            vtable->clss->allocation_handle, vm_get_gc_thread_local());
+    ManagedObject* o = (ManagedObject *) vm_alloc_and_report_ti(
+            vtable->allocated_size, vtable->clss->allocation_handle, 
+            vm_get_gc_thread_local(), vtable->clss);
     if (!o) {
         exn_raise_object(
             VM_Global_State::loader_env->java_lang_OutOfMemoryError);

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=470512&r1=470511&r2=470512
==============================================================================
--- 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 Thu Nov
 2 12:36:44 2006
@@ -60,7 +60,7 @@
     1, // can_generate_all_class_hook_events
     1, // can_generate_compiled_method_load_events
     1, // can_generate_monitor_events
-    0, // can_generate_vm_object_alloc_events
+    1, // can_generate_vm_object_alloc_events
     0, // can_generate_native_method_bind_events
     0, // can_generate_garbage_collection_events
     0  // can_generate_object_free_events
@@ -97,7 +97,7 @@
     1, // can_generate_all_class_hook_events
     1, // can_generate_compiled_method_load_events
     1, // can_generate_monitor_events
-    0, // can_generate_vm_object_alloc_events
+    1, // can_generate_vm_object_alloc_events
     0, // can_generate_native_method_bind_events
     0, // can_generate_garbage_collection_events
     0  // can_generate_object_free_events
@@ -136,7 +136,7 @@
     1, // can_generate_all_class_hook_events
     1, // can_generate_compiled_method_load_events
     0, // can_generate_monitor_events
-    0, // can_generate_vm_object_alloc_events
+    1, // can_generate_vm_object_alloc_events
     0, // can_generate_native_method_bind_events
     0, // can_generate_garbage_collection_events
     0  // can_generate_object_free_events

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp?view=diff&rev=470512&r1=470511&r2=470512
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp Thu Nov  2
12:36:44 2006
@@ -40,6 +40,7 @@
 #include "jvmti_break_intf.h"
 #include "stack_iterator.h"
 #include "m2n.h"
+#include "suspend_checker.h"
 
 /*
  * Set Event Callbacks
@@ -925,8 +926,6 @@
         object->object = managed_object;
     }
 
-    tmn_suspend_enable();
-
     DebugUtilsTI *ti = VM_Global_State::loader_env->TI;
     if (!ti->isEnabled() )
         return;
@@ -937,6 +936,8 @@
     if (!ti->get_global_capability(DebugUtilsTI::TI_GC_ENABLE_FIELD_ACCESS_EVENT))
         return;
 
+    tmn_suspend_enable();
+
     // get field class
     //Type_Info_Handle field_type = field_get_type_info_of_field_value(field);
     //Class_Handle clss = type_info_get_class(field_type);
@@ -997,8 +998,6 @@
         object->object = managed_object;
     }
 
-    tmn_suspend_enable();
-
     DebugUtilsTI *ti = VM_Global_State::loader_env->TI;
     if (!ti->isEnabled() )
         return;
@@ -1010,6 +1009,8 @@
         return;
 
     // get field class
+    tmn_suspend_enable();
+
     //Type_Info_Handle field_type = field_get_type_info_of_field_value(field);
     //Class_Handle clss = type_info_get_class(field_type);
     //ASSERT(clss, "Can't get class handle for field type.");
@@ -1059,6 +1060,90 @@
 
     tmn_suspend_disable();
 } // jvmti_process_field_modification_event
+
+static void jvmti_process_vm_object_alloc_event(ManagedObject** p_managed_object,
+    Class* object_clss, unsigned size)
+{
+    SuspendDisabledChecker sdc;
+
+    DebugUtilsTI *ti = VM_Global_State::loader_env->TI;
+    if (!ti->isEnabled() )
+        return;
+
+    if (JVMTI_PHASE_LIVE != ti->getPhase())
+        return;
+
+    // check the j.l.Thread is already initialized
+    hythread_t curr_thread = hythread_self();
+    jthread thread = jthread_get_java_thread(curr_thread);
+    if (NULL == thread)
+        return;
+
+    ManagedObject* managed_object = *p_managed_object;
+    // create handle for object
+    jobject object = NULL;
+
+    if (NULL != managed_object) {
+        object = oh_allocate_local_handle();
+        object->object = managed_object;
+    }
+
+    tmn_suspend_enable();
+
+    // get class
+    jclass klass = struct_Class_to_java_lang_Class_Handle(object_clss);
+
+    jvmtiEvent event_type = JVMTI_EVENT_VM_OBJECT_ALLOC;
+    TIEnv *ti_env = ti->getEnvironments();
+    TIEnv *next_env;
+    while (NULL != ti_env)
+    {
+        next_env = ti_env->next;
+        // check that event is enabled in this environment.
+        if (!ti_env->global_events[event_type - JVMTI_MIN_EVENT_TYPE_VAL]) {
+            TIEventThread *thr = ti_env->event_threads[event_type - JVMTI_MIN_EVENT_TYPE_VAL];
+            while (thr)
+            {
+                if (thr->thread == curr_thread)
+                    break;
+                thr = thr->next;
+            }
+
+            if (!thr)
+            {
+                ti_env = next_env;
+                continue;
+            }
+        }
+
+        // event is enabled in this environment
+        JNIEnv *jni_env = p_TLS_vmthread->jni_env;
+        jvmtiEnv *jvmti_env = (jvmtiEnv*) ti_env;
+
+        if (NULL != ti_env->event_table.VMObjectAlloc)
+            ti_env->event_table.VMObjectAlloc(jvmti_env, jni_env, thread,
+                    object, klass, (jlong)size);
+
+        ti_env = next_env;
+    }
+
+    tmn_suspend_disable();
+
+    // restore object pointer. As et could be relocated by GC.
+    *p_managed_object = object->object;
+} // jvmti_process_vm_object_alloc_event
+
+VMEXPORT Managed_Object_Handle vm_alloc_and_report_ti(unsigned size, 
+    Allocation_Handle p_vtable, void *thread_pointer, Class* object_class)
+{
+    SuspendDisabledChecker sdc;
+    Managed_Object_Handle handle = gc_alloc(size, p_vtable, thread_pointer);
+
+    if (handle) 
+        jvmti_process_vm_object_alloc_event((ManagedObject**) &handle, object_class,
size);
+
+    return handle;
+} // vm_alloc_and_report_ti
 
 /*
  * Send Exception event

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_general.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_general.cpp?view=diff&rev=470512&r1=470511&r2=470512
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_general.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_general.cpp Thu Nov 
2 12:36:44 2006
@@ -88,7 +88,7 @@
 
     // Disable all global events for this environment
     int iii;
-    for (iii = JVMTI_MIN_EVENT_TYPE_VAL; iii < JVMTI_MAX_EVENT_TYPE_VAL; iii++)
+    for (iii = JVMTI_MIN_EVENT_TYPE_VAL; iii <= JVMTI_MAX_EVENT_TYPE_VAL; iii++)
         remove_event_from_global(env, (jvmtiEvent)iii);
 
     // Disable all thread local events for this environment, do it only in live phase
@@ -103,7 +103,7 @@
         jthread *threads;
         jvmtiGetAllThreads(env, &threads_number, &threads);
         for (int jjj = 0; jjj < threads_number; jjj++)
-            for (iii = JVMTI_MIN_EVENT_TYPE_VAL; iii < JVMTI_MAX_EVENT_TYPE_VAL; iii++)
+            for (iii = JVMTI_MIN_EVENT_TYPE_VAL; iii <= JVMTI_MAX_EVENT_TYPE_VAL; iii++)
                 remove_event_from_thread(env, (jvmtiEvent)iii, threads[jjj]);
         _deallocate((unsigned char *)threads);
     }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/object_generic.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/object_generic.cpp?view=diff&rev=470512&r1=470511&r2=470512
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/object_generic.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/object_generic.cpp Thu Nov
 2 12:36:44 2006
@@ -144,7 +144,8 @@
             return NULL;
         }
         size = vt->allocated_size;
-        result = (ManagedObject *) gc_alloc(size, vt->clss->allocation_handle, vm_get_gc_thread_local());
+        result = (ManagedObject *) vm_alloc_and_report_ti(size, 
+            vt->clss->allocation_handle, vm_get_gc_thread_local(), vt->clss);
     }
     if (result == NULL) {
         tmn_suspend_enable(); 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/vm_strings.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/vm_strings.cpp?view=diff&rev=470512&r1=470511&r2=470512
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/vm_strings.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/vm_strings.cpp Thu Nov  2 12:36:44
2006
@@ -244,7 +244,8 @@
     assert(clss);
 
     unsigned sz = vm_array_size(clss->vtable, unicode_length);
-    Vector_Handle array = gc_alloc(sz, clss->allocation_handle, vm_get_gc_thread_local());
+    Vector_Handle array = vm_alloc_and_report_ti(sz, clss->allocation_handle, 
+            vm_get_gc_thread_local(), clss);
     if (!array) { // OutOfMemory should be thrown
         *str = NULL;
         exn_raise_object(VM_Global_State::loader_env->java_lang_OutOfMemoryError);



Mime
View raw message