harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r449221 - in /incubator/harmony/enhanced/drlvm/trunk/vm: interpreter/src/ vmcore/include/ vmcore/src/jit/ vmcore/src/jvmti/
Date Sat, 23 Sep 2006 12:10:00 GMT
Author: geirm
Date: Sat Sep 23 05:10:00 2006
New Revision: 449221

URL: http://svn.apache.org/viewvc?view=rev&rev=449221
Log:
HARMONY-1527

By declaration jvmti_field_access_callback() & jvmti_field_modification_callback() must
recieve pointer to jobject 
(GC-safe object handle). But actually JIT transfers non GC-safe direct pointers to managed
objects. This results in 
crash on any attempt to use recieved object.
Also JIT passes direct pointer instead of gc-safe handle in jvalue.l field of new_value argument
to 
jvmti_field_modification_callback().

Proposed patch fixes callbacks interface and implementation according to actual data type
passed from JIT.

Ubuntu 6 - smoke and c-unit


Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter_ti.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_interface.h
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_watch.cpp

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter_ti.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter_ti.cpp?view=diff&rev=449221&r1=449220&r2=449221
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter_ti.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter_ti.cpp Sat Sep 23
05:10:00 2006
@@ -537,21 +537,16 @@
     jlocation pc = frame.ip - (uint8*)method->get_code_addr();
 
     M2N_ALLOC_MACRO;
-    ObjectHandle handle = oh_allocate_local_handle();
-    handle->object = obj;
 
-    tmn_suspend_enable();
-    jvmti_process_field_access_event(field, (jmethodID) method, pc, &handle);
-    tmn_suspend_disable();
+    jvmti_process_field_access_event(field, (jmethodID) method, pc, obj);
+
     M2N_FREE_MACRO;
 }
 
-static inline void field_modification_callback(Field *field, StackFrame& frame, jobject
obj, jvalue val) {
+static inline void field_modification_callback(Field *field, StackFrame& frame, ManagedObject
* obj, jvalue val) {
     Method *method = frame.method;
     jlocation pc = frame.ip - (uint8*)method->get_code_addr();
-    tmn_suspend_enable();
-    jvmti_process_field_modification_event(field, (jmethodID) method, pc, &obj, val);
-    tmn_suspend_disable();
+    jvmti_process_field_modification_event(field, (jmethodID) method, pc, obj, val);
 }
 
 void getfield_callback(Field *field, StackFrame& frame) {
@@ -616,10 +611,8 @@
     }
 
     M2N_ALLOC_MACRO;
-    ObjectHandle handle = oh_allocate_local_handle();
-    handle->object = UNCOMPRESS_REF(cref);
     jvalue val = new_field_value(field, frame);
-    field_modification_callback(field, frame, handle, val);
+    field_modification_callback(field, frame, UNCOMPRESS_REF(cref), val);
     M2N_FREE_MACRO;
 }
 

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=449221&r1=449220&r2=449221
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h Sat Sep 23 05:10:00
2006
@@ -129,9 +129,9 @@
 VMEXPORT void jvmti_process_method_entry_event(jmethodID method);
 VMEXPORT void jvmti_process_method_exit_event(jmethodID method, jboolean exn_flag, jvalue
ret_val);
 VMEXPORT void jvmti_process_field_access_event(Field_Handle field,
-    jmethodID method, jlocation location, jobject* object);
+    jmethodID method, jlocation location, ManagedObject* object);
 VMEXPORT void jvmti_process_field_modification_event(Field_Handle field,
-    jmethodID method, jlocation location, jobject* object, jvalue new_value);
+    jmethodID method, jlocation location, ManagedObject* object, jvalue new_value);
 
 #ifdef __cplusplus
 extern "C" {

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_interface.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_interface.h?view=diff&rev=449221&r1=449220&r2=449221
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_interface.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_interface.h Sat Sep 23
05:10:00 2006
@@ -49,13 +49,13 @@
  * @param field - handle of the field under access
  * @param method - handle of the method, which accesses field
  * @param location - location of code which accesses field
- * @param object - pointer to the reference of the object, which field is beeng
- *      accessed or NULL for static field
+ * @param object - non GC-safe pointer to the object, which field is beeng 
+ *     accessed or NULL for static field
  */
 void jvmti_field_access_callback(Field_Handle field,
                                        Method_Handle method,
                                        jlocation location,
-                                       jobject* object);
+                                       ManagedObject* object);
 
 /**
  * Field modification callback which is called from JITted code compiled with <field modification>
flag whenever
@@ -64,14 +64,14 @@
  * @param field - handle of the field under modification
  * @param method - handle of the method, which modifies field
  * @param location - location of code which modifies field
- * @param object - pointer to the reference of the object, which field is beeng
- *      modified or NULL for static field
+ * @param object - non GC-safe pointer to the object, which field is beeng 
+ *     accessed or NULL for static field
  * @param new_value - pointer to the new value for the field
  */
 void jvmti_field_modification_callback(Field_Handle field,
                                        Method_Handle method,
                                        jlocation location,
-                                       jobject* object,
+                                       ManagedObject* object,
                                        jvalue* new_value);
 
 /**

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=449221&r1=449220&r2=449221
==============================================================================
--- 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 Sat Sep
23 05:10:00 2006
@@ -1833,7 +1833,7 @@
         return addr;
         }
     void (*jvmti_field_access_callback_ptr)(Field_Handle, Method_Handle,
-            jlocation, jobject*) = jvmti_field_access_callback;
+            jlocation, ManagedObject*) = jvmti_field_access_callback;
 
     LilCodeStub* cs = lil_parse_code_stub("entry 0:managed:pint,pint,g8,pint:void;");
     assert(cs);
@@ -1880,8 +1880,8 @@
     if (addr) {
         return addr;
         }
-void (*jvmti_field_modification_callback_ptr)(Field_Handle, Method_Handle,
-                                              jlocation, jobject*, jvalue*) = jvmti_field_modification_callback;
+    void (*jvmti_field_modification_callback_ptr)(Field_Handle, Method_Handle,
+            jlocation, ManagedObject*, jvalue*) = jvmti_field_modification_callback;
     LilCodeStub* cs = lil_parse_code_stub("entry 0:managed:pint,pint,g8,pint,pint:void;");
     assert(cs);
     if (dyn_count) {

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=449221&r1=449220&r2=449221
==============================================================================
--- 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 Sat Sep 23
05:10:00 2006
@@ -807,8 +807,20 @@
 }
 
 VMEXPORT void jvmti_process_field_access_event(Field_Handle field,
-    jmethodID method, jlocation location, jobject* p_object)
+    jmethodID method, jlocation location, ManagedObject* managed_object)
 {
+    SuspendDisabledChecker sdc;
+
+    // create handle for object
+    jobject object = NULL;
+
+    if (NULL != managed_object) {
+        object = oh_allocate_local_handle();
+        object->object = managed_object;
+    }
+
+    tmn_suspend_enable();
+
     DebugUtilsTI *ti = VM_Global_State::loader_env->TI;
     if (!ti->isEnabled() )
         return;
@@ -819,9 +831,6 @@
     if (!ti->get_global_capability(DebugUtilsTI::TI_GC_ENABLE_FIELD_ACCESS_EVENT))
         return;
 
-    // unreference pointer to object handle
-    jobject object = (p_object) ? *p_object : NULL ;
-
     // 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);
@@ -865,11 +874,25 @@
                     method, location, field_klass, object, (jfieldID) field);
         ti_env = next_env;
     }
+
+    tmn_suspend_disable();
 } // jvmti_process_field_access_event
 
 VMEXPORT void jvmti_process_field_modification_event(Field_Handle field,
-    jmethodID method, jlocation location, jobject* p_object, jvalue new_value)
+    jmethodID method, jlocation location, ManagedObject* managed_object, jvalue new_value)
 {
+    SuspendDisabledChecker sdc;
+
+    // create handle for object
+    jobject object = NULL;
+
+    if (NULL != managed_object) {
+        object = oh_allocate_local_handle();
+        object->object = managed_object;
+    }
+
+    tmn_suspend_enable();
+
     DebugUtilsTI *ti = VM_Global_State::loader_env->TI;
     if (!ti->isEnabled() )
         return;
@@ -880,9 +903,6 @@
     if (!ti->get_global_capability(DebugUtilsTI::TI_GC_ENABLE_FIELD_MODIFICATION_EVENT))
         return;
 
-    // unreference pointer to object handle
-    jobject object = (p_object) ? *p_object : NULL ;
-
     // 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);
@@ -930,6 +950,8 @@
                     signature_type, new_value);
         ti_env = next_env;
     }
+
+    tmn_suspend_disable();
 } // jvmti_process_field_modification_event
 
 /*

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_watch.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_watch.cpp?view=diff&rev=449221&r1=449220&r2=449221
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_watch.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_watch.cpp Sat Sep 23
05:10:00 2006
@@ -310,30 +310,38 @@
 void jvmti_field_access_callback(Field_Handle field,
                                        Method_Handle method,
                                        jlocation location,
-                                       jobject* object)
+                                       ManagedObject* object)
 {
     BEGIN_RAISE_AREA;
-    tmn_suspend_enable();
 
     jvmti_process_field_access_event(field, (jmethodID) method, location,
              object);
 
-    tmn_suspend_disable();
     END_RAISE_AREA;
 }
 
 void jvmti_field_modification_callback(Field_Handle field,
                                        Method_Handle method,
                                        jlocation location,
-                                       jobject* object,
-                                       jvalue* new_value)
+                                       ManagedObject* object,
+                                       jvalue* p_new_value)
 {
     BEGIN_RAISE_AREA;
-    tmn_suspend_enable();
+
+    jvalue new_value = *p_new_value;
+
+    if (! field->get_field_type_desc()->is_primitive() && NULL != new_value.l)
{
+        // if new_value.l is not a handle but a direct pointer to java heap
+        if ((ManagedObject*)new_value.l >= (ManagedObject*)Class::heap_base &&
+            (ManagedObject*)new_value.l <= (ManagedObject*)Class::heap_end)
+        {
+            new_value.l = oh_allocate_local_handle();
+            new_value.l->object = (ManagedObject*)p_new_value->l;
+        }
+    }
 
     jvmti_process_field_modification_event(field, (jmethodID) method, location,
-            object, *new_value);
+            object, new_value);
 
-    tmn_suspend_disable();
     END_RAISE_AREA;
 }



Mime
View raw message