db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r426825 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode: CodeChunk.java GClass.java
Date Sat, 29 Jul 2006 16:44:48 GMT
Author: djd
Date: Sat Jul 29 09:44:47 2006
New Revision: 426825

URL: http://svn.apache.org/viewvc?rev=426825&view=rev
Log:
DERBY-766 (partial) Add check to ensure a generated method is no split if it contains a return
instruction in the middle.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/CodeChunk.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/GClass.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/CodeChunk.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/CodeChunk.java?rev=426825&r1=426824&r2=426825&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/CodeChunk.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/CodeChunk.java
Sat Jul 29 09:44:47 2006
@@ -976,6 +976,7 @@
     private String getTypeDescriptor(ClassHolder ch, int pc) {
         int cpi = getU2(pc);
 
+
         // Field reference or method reference
         CONSTANT_Index_info cii = (CONSTANT_Index_info) ch.getEntry(cpi);
 
@@ -1329,9 +1330,24 @@
             // than the VM can handle. Save one for
             // return instruction.
             if (splitLength > BCMethod.CODE_SPLIT_LENGTH - 1) {
+                splitLength = -1;
+            }
+            else if (CodeChunk.isReturn(opcode))
+            {
+                // Don't handle a return in the middle of
+                // an instruction stream. Don't think this
+                // is generated, but be safe.           
+                splitLength = -1;
+            }
+            
+            // if splitLenth was set to -1 above then there
+            // is no possible split at this instruction.
+            if (splitLength == -1)
+            {
+                // no earlier split at all
                 if (possibleSplitLength == -1)
                     return -1;
-
+ 
                 // Decide if the earlier possible split is
                 // worth it. 100 is an arbitary number,
                 // a real low limit would be the number of
@@ -1512,5 +1528,26 @@
         mb.maxStack = replaceChunk.findMaxStack(ch, 0, replaceChunk.getPC());
 
         return postSplit_pc;
+    }
+    
+    /**
+     * See if the opcode is a return instruction.
+     * @param opcode opcode to be checked
+     * @return true for is a return instruction, false otherwise.
+     */
+    private static boolean isReturn(short opcode)
+    {
+        switch (opcode)
+        {
+        case VMOpcode.RETURN:
+        case VMOpcode.ARETURN:
+        case VMOpcode.IRETURN:
+        case VMOpcode.FRETURN:
+        case VMOpcode.DRETURN:
+        case VMOpcode.LRETURN:
+            return true;
+         default:
+            return false;
+        }        
     }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/GClass.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/GClass.java?rev=426825&r1=426824&r2=426825&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/GClass.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/GClass.java Sat
Jul 29 09:44:47 2006
@@ -93,7 +93,7 @@
 		}
 	}
 
-	public final void validateType(String typeName1)
+	final void validateType(String typeName1)
 	{
 	    if (SanityManager.DEBUG)
 	    {
@@ -101,6 +101,8 @@
 
             String typeName = typeName1.trim();
 
+            if ("void".equals(typeName)) return;
+
 	        // first remove all array-ness
 	        while (typeName.endsWith("[]")) typeName = typeName.substring(0,typeName.length()-2);
 
@@ -115,7 +117,6 @@
 	        if ("int".equals(typeName)) return;
 	        if ("long".equals(typeName)) return;
 	        if ("short".equals(typeName)) return;
-	        if ("void".equals(typeName)) return;
 
 	        // then see if it can be found
 	        // REVISIT: this will fail if ASSERT is on and the



Mime
View raw message