[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug: method inlining reverses trap tables



FYI,

The following patch fixes a bug in SiteInliner [1]. The trap table of
the inlined method was being merged in in reverse order.

Please review & commit as appropriate.

Thanks,
-Archie

 [1] http://www.sable.mcgill.ca/sootbugs/incoming?id=94

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com

diff -ur original.src/soot/jimple/toolkits/invoke/SiteInliner.java src/soot/jimple/toolkits/invoke/SiteInliner.java
--- original.src/soot/jimple/toolkits/invoke/SiteInliner.java	Tue Jun  3 07:12:25 2003
+++ src/soot/jimple/toolkits/invoke/SiteInliner.java	Sat Jul 17 14:55:19 2004
@@ -248,9 +248,10 @@
             }
         }
 
-        // Copy & backpatch the traps.
+        // Copy & backpatch the traps; preserve their same order.
         {
             Iterator trapsIt = inlineeB.getTraps().iterator();
+	    Trap prevTrap = null;
 
             while (trapsIt.hasNext())
             {
@@ -262,9 +263,13 @@
                 if (newBegin == null || newEnd == null || newHandler == null)
                     throw new RuntimeException("couldn't map trap!");
 
-                containerB.getTraps().addFirst(Jimple.v().newTrap
-                                               (t.getException(),
-                                                newBegin, newEnd, newHandler));
+		Trap trap = Jimple.v().newTrap(t.getException(),
+		    newBegin, newEnd, newHandler);
+		if (prevTrap == null)
+			containerB.getTraps().addFirst(trap);
+		else
+			containerB.getTraps().insertAfter(trap, prevTrap);
+		prevTrap = trap;
             }
         }