changeset 374:45e6c5abee0a

enrich local variable live length
author mali
date Fri, 13 Mar 2009 00:11:40 -0400
parents c9df2948e105
children 41f82ae9b195
files src/share/classes/com/sun/tools/javac/jvm/Code.java src/share/classes/com/sun/tools/javac/jvm/Gen.java
diffstat 2 files changed, 16 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/jvm/Code.java	Thu Mar 12 23:42:13 2009 -0400
+++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java	Fri Mar 13 00:11:40 2009 -0400
@@ -1900,11 +1900,27 @@
                     v.length = length;
                     putVar(v);
                 }
+                fillLocalVarPosition(v);
             }
         }
         state.defined.excl(adr);
     }
 
+    private void fillLocalVarPosition(LocalVar lv) {
+        if (lv == null || lv.sym == null
+                || lv.sym.typeAnnotations == null)
+            return;
+        for (TypeAnnotations ta : lv.sym.typeAnnotations) {
+            TypeAnnotations.Position p = ta.position;
+            while (p != null) {
+                p.offset = (int)lv.start_pc;
+                p.length = (int)lv.length;
+                p.index = (int)lv.reg;
+                p = p.wildcard_position;
+            }
+        }
+    }
+
     /** Put a live variable range into the buffer to be output to the
      *  class file.
      */
--- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Thu Mar 12 23:42:13 2009 -0400
+++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Fri Mar 13 00:11:40 2009 -0400
@@ -941,8 +941,6 @@
                                  startpcCrt,
                                  code.curPc());
 
-                // End the scope of all local variables in variable info.
-                fillLocalVarPositions();
                 code.endScopes(0);
 
                 // If we exceeded limits, panic
@@ -963,26 +961,6 @@
             }
         }
 
-        // Needs to be called before closing any scope
-        void fillLocalVarPositions() {
-            if (code != null && code.lvar != null) {
-                for (LocalVar lv : code.lvar) {
-                    if (lv == null || lv.sym == null
-                            || lv.sym.typeAnnotations == null)
-                        continue;
-                    for (TypeAnnotations ta : lv.sym.typeAnnotations) {
-                        TypeAnnotations.Position p = ta.position;
-                        while (p != null) {
-                            p.offset = (int)lv.start_pc;
-                            p.length = (int)lv.length;
-                            p.index = (int)lv.reg;
-                            p = p.wildcard_position;
-                        }
-                    }
-                }
-            }
-        }
-
         private int initCode(JCMethodDecl tree, Env<GenContext> env, boolean fatcode) {
             MethodSymbol meth = tree.sym;
 
@@ -1053,7 +1031,6 @@
         // End the scope of all block-local variables in variable info.
         if (env.tree.getTag() != JCTree.METHODDEF) {
             code.statBegin(tree.endpos);
-            fillLocalVarPositions();
             code.endScopes(limit);
             code.pendingStatPos = Position.NOPOS;
         }
@@ -1071,7 +1048,6 @@
         int limit = code.nextreg;
         genStats(tree.init, env);
         genLoop(tree, tree.body, tree.cond, tree.step, true);
-        fillLocalVarPositions();
         code.endScopes(limit);
     }
     //where
@@ -1269,7 +1245,6 @@
                 }
             }
         }
-        fillLocalVarPositions();
         code.endScopes(limit);
     }
 //where
@@ -1327,7 +1302,6 @@
         };
         syncEnv.info.gaps = new ListBuffer<Integer>();
         genTry(tree.body, List.<JCCatch>nil(), syncEnv);
-        fillLocalVarPositions();
         code.endScopes(limit);
     }
 
@@ -1504,7 +1478,6 @@
                 items.makeLocalItem(exparam).store();
                 code.statBegin(TreeInfo.firstStatPos(tree.body));
                 genStat(tree.body, env, CRT_BLOCK);
-                fillLocalVarPositions();
                 code.endScopes(limit);
                 code.statBegin(TreeInfo.endPos(tree.body));
             }
@@ -1640,7 +1613,6 @@
                 genStat(tree.elsepart, env,CRT_STATEMENT | CRT_FLOW_TARGET);
         }
         code.resolve(thenExit);
-        fillLocalVarPositions();
         code.endScopes(limit);
     }
 
@@ -1689,7 +1661,6 @@
             code.emitop0(return_);
         }
         endFinalizerGaps(env, targetEnv);
-        fillLocalVarPositions();
         code.endScopes(limit);
     }
 
@@ -2254,7 +2225,6 @@
         int limit = code.nextreg;
         genStats(tree.defs, env);
         result = genExpr(tree.expr, tree.expr.type).load();
-        fillLocalVarPositions();
         code.endScopes(limit);
     }