harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r448414 - /incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.cpp
Date Thu, 21 Sep 2006 00:22:31 GMT
Author: geirm
Date: Wed Sep 20 17:22:30 2006
New Revision: 448414

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

applied and tested - all tests pass

Ubuntu 6

Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.cpp

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.cpp?view=diff&rev=448414&r1=448413&r2=448414
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.cpp
(original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.cpp
Wed Sep 20 17:22:30 2006
@@ -66,52 +66,36 @@
     return struct_Class_to_jclass((Class*)method_get_class(frame.method));
 }
 
-inline static bool isReflectionFrame(Method_Handle method) {
-    const char *method_name = method_get_name(method);
-    const char *class_name = class_get_name(method_get_class(method));
-    static Method *invoke = 0;
-    static Method *invokeMethod = 0;
-
-    // if java.lang.reflect.Method.invoke()
-    if (invoke) {
-        if (method == invoke) return true;
-    } else if (0 == strcmp(method_name, "invoke") &&
-            0 == strcmp(class_name, "java/lang/reflect/Method") ) {
-        invoke = method;
-        return true;
-    }
-
-    // if java.lang.reflect.VMReflection.invokeMethod()
-    if (invokeMethod) {
-        if (method == invokeMethod) return true;
-    } else if (0 == strcmp(method_name, "invokeMethod") &&
-            0 == strcmp(class_name, "java/lang/reflect/VMReflection") ) {
-        invokeMethod = method;
-        return true;
-    }
-
-    // non reflection frame
-    return false;
+inline static bool isReflectionFrame(Method* method, Global_Env* genv) {
+    // for simplicity, any method of 
+    // java/lang/reflect/VMReflection or java/lang/reflect/Method 
+    static Class *VMReflection = genv->LoadCoreClass("java/lang/reflect/VMReflection");
+    
+    Class* mc = method->get_class();
+    return (mc == VMReflection || mc == genv->java_lang_reflect_Method_Class);
 }
 
-inline static bool isPrivilegedFrame(Method_Handle method) {
-    static Method *doPrivileged = 0;
+inline static bool isPrivilegedFrame(Method_Handle method, Global_Env* genv) {
+    static Method_Handle doPrivileged[4];
 
-    if (doPrivileged) {
-        return method == doPrivileged;
+    if (!doPrivileged[0]) {
+        Class* ac = genv->LoadCoreClass("java/security/AccessController");
+        doPrivileged[3] = (Method_Handle)class_lookup_method(ac, "doPrivileged", 
+            "(Ljava/security/PrivilegedAction;)Ljava/lang/Object;");
+        doPrivileged[2] = (Method_Handle)class_lookup_method(ac, "doPrivileged", 
+            "(Ljava/security/PrivilegedExceptionAction;)Ljava/lang/Object;");
+        doPrivileged[1] = (Method_Handle)class_lookup_method(ac, "doPrivileged", 
+            "(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;");
+        doPrivileged[0] = (Method_Handle)class_lookup_method(ac, "doPrivileged", 
+            "(Ljava/security/PrivilegedExceptionAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;");
+        unsigned i = 0;
+        for (; i < 4; i++) assert(doPrivileged[i]);
     }
 
-    const char *method_name = method_get_name(method);
-    const char *class_name = class_get_name(method_get_class(method));
-
-    // if java.security.AccessController.doPrivileged()
-    if (0 == strcmp(method_name, "doPrivileged") &&
-            0 == strcmp(class_name, "java/security/AccessController") ) {
-        doPrivileged = method;
-        return true;
+    unsigned i = 0;
+    for (; i < 4; i++) {
+        if (method == doPrivileged[i]) return true;
     }
-
-    // non privileged frame
     return false;
 }
 
@@ -138,15 +122,17 @@
     // For details look at the org/apache/harmony/vm/VMStack.java file. Thus skipping 2 frames.
     unsigned skip = 2;
 
+    Global_Env* genv = ((JNIEnv_Internal*)jenv)->vm->vm_env;
+
     // count target array length ignoring reflection frames
     unsigned length = 0, s;
     for (s = skip; s < size && length < maxSize; s++) {
         Method_Handle method = frames[s].method;
 
-        if (isReflectionFrame(method))
+        if (isReflectionFrame(method, genv))
             continue;
 
-        if (considerPrivileged && isPrivilegedFrame(method) 
+        if (considerPrivileged && isPrivilegedFrame(method, genv) 
                 && maxSize > length + 2)
             maxSize = length + 2;
 
@@ -155,7 +141,7 @@
 
     assert(hythread_is_suspend_enabled());
 
-    jclass ste = struct_Class_to_java_lang_Class_Handle(VM_Global_State::loader_env->JavaLangClass_Class);
+    jclass ste = struct_Class_to_java_lang_Class_Handle(genv->JavaLangClass_Class);
     assert(ste);
 
     // creating java array
@@ -172,7 +158,7 @@
     for (s = skip; s < size && i < length; s++) {
         Method_Handle method = frames[s].method;
 
-        if (isReflectionFrame(method))
+        if (isReflectionFrame(method, genv))
             continue;
 
         // obtain frame class



Mime
View raw message