harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r487342 - in /harmony/enhanced/drlvm/trunk/vm/vmcore: include/class_member.h src/class_support/Class.cpp src/class_support/classloader.cpp
Date Thu, 14 Dec 2006 20:31:22 GMT
Author: gshimansky
Date: Thu Dec 14 12:31:22 2006
New Revision: 487342

URL: http://svn.apache.org/viewvc?view=rev&rev=487342
Log:
Applied HARMONY-2541 [drlvm][jvmti] VM in OPT mode returns NULL values by GetThreadInfo if
java.lang.Thread is instrumented by profiler

Tests passed on Ubuntu6 x86, WindowsXP and SuSE9 x86_64


Modified:
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/class_member.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/class_member.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/class_member.h?view=diff&rev=487342&r1=487341&r2=487342
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/class_member.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/class_member.h Thu Dec 14 12:31:22 2006
@@ -514,6 +514,12 @@
     void add_vtable_patch(void *);
     void apply_vtable_patches();
 
+    NativeCodePtr get_registered_native_func() 
+            { return _registered_native_func; }
+
+    void set_registered_native_func(NativeCodePtr native_func) 
+            { _registered_native_func = native_func; }
+
     /**
      * This returns a block for jitted code. It is not used for native methods.
      * It is safe to call this function from multiple threads.
@@ -587,6 +593,9 @@
     Method_Side_Effects _side_effects;
     Method_Signature *_method_sig;
 
+    /** set by JNI RegisterNatives() funcs */
+    NativeCodePtr _registered_native_func;
+
 public:
     Method();
     // destructor should be instead of this function, but it's not allowed to use it because
copy for Method class is
@@ -607,11 +616,8 @@
     bool is_clinit()        {return _flags.is_clinit?true:false;}
     bool is_finalize()      {return _flags.is_finalize?true:false;}
     bool is_overridden()    {return _flags.is_overridden?true:false;}
-    bool is_registered()    {return _flags.is_registered?true:false;}
     Boolean  is_nop()       {return _flags.is_nop;}
 
-    void set_registered( bool flag ) { _flags.is_registered = flag; }
-
     unsigned get_index()    {return _index;}
 
     // Fake methods are interface methods inherited by an abstract class that are not (directly
or indirectly)
@@ -665,7 +671,6 @@
         unsigned is_finalize    : 1;    // is finalize() method
         unsigned is_overridden  : 1;    // has this virtual method been overridden by a loaded
subclass?
         unsigned is_nop         : 1;
-        unsigned is_registered  : 1;    // the method is registred native method
     } _flags;
 
     //

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp?view=diff&rev=487342&r1=487341&r2=487342
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp Thu Dec 14 12:31:22
2006
@@ -602,6 +602,7 @@
     _vtable_patch = 0;
 
     _code = NULL;
+    _registered_native_func = NULL;
 
     _state = ST_NotCompiled;
     _jits = NULL;
@@ -622,7 +623,6 @@
     _flags.is_overridden = 0;
     _flags.is_finalize = 0;
     _flags.is_nop = FALSE;
-    _flags.is_registered = 0;
 
     _line_number_table = NULL;
     _local_vars_table = NULL;
@@ -990,54 +990,50 @@
         const String *desc = pool.lookup(methods[index].signature);
 
         // find method from class
-        bool not_found = true;
+        Method *class_method = NULL;
+        bool found = false;
+
         for(int count = 0; count < klass->get_number_of_methods(); count++ ) {
-            Method *class_method = klass->get_method(count);
-            const String *method_name = class_method->get_name();
-            const String *method_desc = class_method->get_descriptor();
-            if( method_name == name && method_desc == desc )
-            {
-                // trace
-                TRACE2("class.native", "Register native method: "
-                    << klass->get_name()->bytes
-                    << "." << name->bytes << desc->bytes);
+            class_method = klass->get_method(count);
 
+            if( class_method->get_name() == name && 
+                    class_method->get_descriptor() == desc ) {
                 // found method
-                not_found = false;
-
-                // Calling callback for NativeMethodBind event
-                NativeCodePtr native_addr = methods[index].fnPtr;
-
-                jvmti_process_native_method_bind_event( (jmethodID) class_method, native_addr,
&native_addr);
-
-                if (interpreter_enabled()) {
-                    //lock class
-                    klass->lock();
-                    class_method->set_code_addr( native_addr );
-                    class_method->set_registered( true );
-                    klass->unlock();
-                } else {
-                    NativeCodePtr stub = compile_create_lil_jni_stub(class_method, native_addr,
NULL);
-                    if (!stub)
-                        return true;
-
-                    class_method->lock();
-                    class_method->set_code_addr(stub);
-                    class_method->unlock();
-
-                    // the following lines were copy-pasted from compile_do_compilation()
function
-                    // it is not obvious that they should be here.
-                    //compile_flush_generated_code();
-                    //class_method->set_state(Method::ST_Compiled);
-                    //class_method->do_jit_recompiled_method_callbacks();
-
-                    class_method->apply_vtable_patches();
-                }
-
+                found = true;
                 break;
             }
         }
-        if( not_found ) {
+
+        if (found) {
+            TRACE2("class.native", "Register native method: "
+                << klass->get_name()->bytes
+                << "." << name->bytes << desc->bytes);
+
+            // Calling callback for NativeMethodBind event
+            NativeCodePtr native_addr = methods[index].fnPtr;
+
+            jvmti_process_native_method_bind_event( (jmethodID) class_method, native_addr,
&native_addr);
+
+            if (! interpreter_enabled()) {
+                NativeCodePtr stub = compile_create_lil_jni_stub(class_method, native_addr,
NULL);
+                if (!stub)
+                    return true;
+
+                class_method->lock();
+                class_method->set_code_addr(stub);
+                class_method->unlock();
+
+                // the following lines were copy-pasted from compile_do_compilation() function
+                // it is not obvious that they should be here.
+                compile_flush_generated_code();
+                //class_method->set_state(Method::ST_Compiled);
+                //class_method->do_jit_recompiled_method_callbacks();
+
+                class_method->apply_vtable_patches();
+            }
+
+            class_method->set_registered_native_func(native_addr);
+        } else {
             // create error string "<class_name>.<method_name><method_descriptor>
             int clen = klass->get_name()->len;
             int mlen = name->len;
@@ -1050,7 +1046,6 @@
             memcpy(error + clen + 1 + mlen, desc->bytes, dlen);
             error[len] = '\0';
 
-            // trace
             TRACE2("class.native", "Native could not be registered: "
                 << klass->get_name()->bytes << "." << name->bytes
<< desc->bytes);
 
@@ -1071,14 +1066,14 @@
     klass->lock();
     for(int count = 0; count < klass->get_number_of_methods(); count++ ) {
         Method* method = klass->get_method(count);
-        if( method->is_registered() ) {
+        if (NULL != method->get_registered_native_func()) {
             // trace
             TRACE2("class.native", "Unregister native method: "
                 << klass->get_name() << "." << method->get_name()->bytes
                 << method->get_descriptor()->bytes);
 
-            // reset registered flag
-            method->set_registered(false);
+            // reset registered_native_func
+            method->set_registered_native_func(NULL);
         }
     }
     // unlock class

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp?view=diff&rev=487342&r1=487341&r2=487342
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp Thu Dec 14 12:31:22
2006
@@ -1048,8 +1048,8 @@
         << method_name->bytes << method_desc->bytes);
 
     // return if method is already registered
-    if( method->is_registered() ) {
-        return (GenericFunctionPointer)method->get_code_addr();
+    if (NULL != method->get_registered_native_func()) {
+        return (GenericFunctionPointer) method->get_registered_native_func();
     }
     
     // find throughout all the libraries 



Mime
View raw message