harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlyd...@apache.org
Subject svn commit: r572316 - /harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/opcode.c
Date Mon, 03 Sep 2007 13:21:22 GMT
Author: dlydick
Date: Mon Sep  3 06:21:21 2007
New Revision: 572316

URL: http://svn.apache.org/viewvc?rev=572316&view=rev
Log:
Finished out ATHROW opcode.

Corrected ATHROW exception range check and explained
better the use of specific range comparisons.

Modified:
    harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/opcode.c

Modified: harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/opcode.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/opcode.c?rev=572316&r1=572315&r2=572316&view=diff
==============================================================================
--- harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/opcode.c (original)
+++ harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/opcode.c Mon Sep  3 06:21:21 2007
@@ -1035,8 +1035,8 @@
                 /* Retrieve next virtual opcode */
                 opcode = pcode[pc->offset++];
 
-/*
- * Due to the significant complexity of this @c @b switch
+/*!
+ * @internal Due to the significant complexity of this @c @b switch
  * statement, the indentation is being reset to permit wider lines
  * of code with out breaking up expressions with the intention of
  * creating better readability of the code.
@@ -3730,29 +3730,37 @@
      * else throw java.lang.NullPointerException
      * instead of class of parameter from stack
      */
-    if (jvm_object_hash_null != jotmp1)
+    if (jvm_object_hash_null == jotmp1)
     {
-        clsidxmisc = OBJECT_CLASS_LINKAGE(jotmp1)->clsidx;
+        /* Loading NPE will load java.lang.Throwable also */
+        clsidxmisc = class_load_from_prchar(
+                                JVMCLASS_JAVA_LANG_NULLPOINTEREXCEPTION,
+                                            rfalse,
+                                            (jint *) rnull);
 
-        pcfsmisc   = OBJECT_CLASS_LINKAGE(jotmp1)->pcfs;
+        pcfsmisc   = CLASS_OBJECT_LINKAGE(clsidxmisc)->pcfs;
 
-        /* Check if operand is a java.lang.Throwable or subclass */
-        clsidxmisc2 =
-            class_load_from_prchar(JVMCLASS_JAVA_LANG_THROWABLE,
-                                   rfalse,
-                                   (jint *) rnull);
+        /* Will not need to load, but still need to find */
+        clsidxmisc2 =class_find_by_prchar(JVMCLASS_JAVA_LANG_THROWABLE);
 
-        if (rfalse == classutil_class_is_a(clsidxmisc, clsidxmisc2))
-        {
-            exit_throw_exception(EXIT_JVM_CLASS,
-                                 JVMCLASS_JAVA_LANG_VERIFYERROR);
-        }
+        jotmp1 = object_instance_new(OBJECT_STATUS_EMPTY,
+                                     pcfsmisc,
+                                     clsidxmisc,
+                                     0,
+                                     (jint *) rnull,
+                                     rtrue,
+                                     thridx,
+                                     (CONSTANT_Utf8_info *) rnull);
     }
     else
+
+    /* If locked, but not by this thread, monitor error */
+    if (objectutil_is_somehow_locked(jotmp1) &&
+        (!objectutil_is_lock_owner(jotmp1, thridx)))
     {
-        /* Loading NPE will load java.lang.Throwable also */
+        /* Loading IMSE will load java.lang.Throwable also */
         clsidxmisc = class_load_from_prchar(
-                                JVMCLASS_JAVA_LANG_NULLPOINTEREXCEPTION,
+                        JVMCLASS_JAVA_LANG_ILLEGALMONITORSTATEEXCEPTION,
                                             rfalse,
                                             (jint *) rnull);
 
@@ -3770,13 +3778,31 @@
                                      thridx,
                                      (CONSTANT_Utf8_info *) rnull);
     }
+    else
+    {
+        clsidxmisc = OBJECT_CLASS_LINKAGE(jotmp1)->clsidx;
+
+        pcfsmisc   = OBJECT_CLASS_LINKAGE(jotmp1)->pcfs;
+
+        /* Check if operand is a java.lang.Throwable or subclass */
+        clsidxmisc2 =
+            class_load_from_prchar(JVMCLASS_JAVA_LANG_THROWABLE,
+                                   rfalse,
+                                   (jint *) rnull);
+
+        if (rfalse == classutil_class_is_a(clsidxmisc, clsidxmisc2))
+        {
+            exit_throw_exception(EXIT_JVM_CLASS,
+                                 JVMCLASS_JAVA_LANG_VERIFYERROR);
+        }
+    }
 
     /*
      * Examine the exception table for the current method,
      * looking for a handler that is of class 'clsidxmisc'.
      * If found, clear operand stack, push operand again (or
      * its substituted value), and transfer control to that
-     * address.  If not, work up the stack frame until one
+     * address.  If not, work through the stack frame until one
      * is found.  If not found, then call the default
      * ThreadGroup.uncaughtException() later in this function.
      */
@@ -3785,6 +3811,8 @@
     pca = ATR_CODE_AI(pcfsmisc
                         ->methods[pc->mthidx]
                           ->attributes[pc->codeatridx]);
+
+    /* Load pointer to exception table here and at end of while() */
     pet = pca->exception_table;
 
 #define GET_FPTMP_PC_WORD(thridx, idx) \
@@ -3810,14 +3838,28 @@
                  *
                  * The reason for this is that pc->offset by this time
                  * points to the NEXT INSTRUCTION, not the CURRENT one.
+                 *
+                 * Notice that the 'pc - 1' expression means the size
+                 * of the one-byte ATHROW opcode, which has no
+                 * parameter bytes to process after its opcode.
+                 */
+
+                /*!
+                 * @todo: HARMONY-6-jvm-opcode.c-162  is the range
+                 *        logic correct for valid exception coverage?
                  */
-                if (pet[etidx].start_pc > pc->offset - 1)
+
+                             /* Use of '>=' means exclusive range */
+                if (pet[etidx].start_pc >
+                    pc->offset - (1 * sizeof(jvm_virtual_opcode)))
                 {
                     /* PC is below coverage range of handler */
                     continue;
                 }
 
-                if (pet[etidx].end_pc < pc->offset - 1)
+                           /* Use of '<' means inclusive range */
+                if (pet[etidx].end_pc <=
+                    pc->offset - (1 * sizeof(jvm_virtual_opcode)))
                 {
                     /* PC is above coverage range of handler */
                     continue;
@@ -3846,9 +3888,19 @@
                     }
                 }
 
-                /* This handler is the one to invoke.  Go run its code*/
+                /*
+                 * This handler is the one to invoke.
+                 */
+
+                /* Strip operand stack */
                 PUT_SP_STRIP_OPERAND_STACK(thridx);
 
+                /*
+                 * Push the original object hash (as possibly modified)
+                 */
+                PUSH(thridx, jotmp1);
+
+                /* Transfer control to handler, setting block flags */
                 pc->offset = pet[etidx].handler_pc;
 
                 handler_found = rtrue;
@@ -3857,6 +3909,7 @@
 
             } /* for (etidx) */
 
+
             /* ALSO leave the while(rtrue) loop when handler located */
 
             if (rtrue == handler_found)
@@ -3866,6 +3919,17 @@
 
         } /* if (pet) */
 
+
+        /* If this was a synchronized method, remove synchronization */
+
+        if (ACC_SYNCHRONIZED &
+            METHOD(pc->clsidx, pc->mthidx)->access_flags)
+        {
+            (rvoid) objectutil_unsynchronize(
+                        CLASS(pc->clsidx).class_objhash,
+                        thridx);
+        }
+
         /* Strip operand stack */
         PUT_SP_STRIP_OPERAND_STACK(thridx);
 
@@ -3879,6 +3943,7 @@
             /* Kill thread due to unhandled exception */
             PORTABLE_LONGJMP(&opcode_end_thread_nonlocal_return,
                              EXIT_JVM_THROWABLE);
+/*NOTREACHED*/
         }
 
         /* Set up pointers to look at next stack frame */
@@ -3889,6 +3954,8 @@
         pca = ATR_CODE_AI(pcfsmisc
                             ->methods[GET_FPTMP_PC_WORD(thridx, MTHIDX)]
                    ->attributes[GET_FPTMP_PC_WORD(thridx, CODEATRIDX)]);
+
+        /* Load pointer to exception table here and before while() */
         pet = pca->exception_table;
 
     } /* while (rtrue) */



Mime
View raw message