[kaffe] CVS kaffe-extras (guilhem): Updated propagation patch and protected access patch.

Kaffe CVS cvs-commits at kaffe.org
Thu Aug 14 00:16:02 PDT 2003


PatchSet 12 
Date: 2003/08/14 08:15:04
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Updated propagation patch and protected access patch.

Protected field are now also accessible like the method from a nested class.
Variable propagation simpler and less expansive in number of variables involved:
the variable is now allocated on the first block context encountered when
crawling the stack.

Members: 
	build.xml:1.6->1.7 
	patches/kjc-method-access-nested.diff:1.1->1.2 
	patches/kjc-variable-propagation.diff:1.3->1.4 

Index: kaffe-extras/build.xml
diff -u kaffe-extras/build.xml:1.6 kaffe-extras/build.xml:1.7
--- kaffe-extras/build.xml:1.6	Wed Aug 13 06:45:44 2003
+++ kaffe-extras/build.xml	Thu Aug 14 00:15:04 2003
@@ -270,7 +270,7 @@
 	<!-- FIXME: Kaffe's jar doesn't seem to work either -->
 	<mkdir dir="${kjcsuite_dir}/classroot"/>
 	<echo message="RT Jar ${rtjar_file}"/>
-	<exec executable="make"
+	<exec executable="/usr/bin/make"
 		dir="${kjcsuite_dir}/src"
 		failonerror="true">
 		<env key="CLASSROOT" file="${kjcsuite_dir}/classroot"/>
Index: kaffe-extras/patches/kjc-method-access-nested.diff
diff -u kaffe-extras/patches/kjc-method-access-nested.diff:1.1 kaffe-extras/patches/kjc-method-access-nested.diff:1.2
--- kaffe-extras/patches/kjc-method-access-nested.diff:1.1	Wed Aug 13 06:45:44 2003
+++ kaffe-extras/patches/kjc-method-access-nested.diff	Thu Aug 14 00:15:05 2003
@@ -2,6 +2,8 @@
 package and from a nested class.
 
 	Guilhem.
+
+Addendum: Updated for protected field access also.
  
 
 --- kopi-2.1B/src/kjc/CMethod.java	2002-07-15 20:53:32.000000000 +0200
@@ -11,7 +13,18 @@
            return true;
          } else {
 -          if (from.isAnonymous() && primary.getCClass().descendsFrom(from.getOwner())) {
-+          if ((from.isNested() || from.isAnonymous()) && primary.getCClass().descendsFrom(from.getOwner())) {
++          if (from.isNested() && primary.getCClass().descendsFrom(from.getOwner())) {
              return true;
            }
            return primary.getCClass().descendsFrom(from);
+--- kopi-2.1B/src/kjc/CField.java	2002-07-15 20:53:32.000000000 +0200
++++ kopi-2.1B.new/src/kjc/CField.java	2003-08-14 09:18:31.000000000 +0200
+@@ -81,7 +81,7 @@
+           && !isStatic() 
+           && !(getOwner().getPackage() == from.getPackage())
+           && !(primary == null)) {
+-        if (from.isAnonymous() && primary.getCClass().descendsFrom(from.getOwner())) {
++        if (from.isNested() && primary.getCClass().descendsFrom(from.getOwner())) {
+           return true;
+         }
+         return primary.descendsFrom(from);
Index: kaffe-extras/patches/kjc-variable-propagation.diff
diff -u kaffe-extras/patches/kjc-variable-propagation.diff:1.3 kaffe-extras/patches/kjc-variable-propagation.diff:1.4
--- kaffe-extras/patches/kjc-variable-propagation.diff:1.3	Thu Jul 31 09:40:08 2003
+++ kaffe-extras/patches/kjc-variable-propagation.diff	Thu Aug 14 00:15:05 2003
@@ -54,9 +54,20 @@
  		Iterator succs = nodes[nodeIndex].getSuccessors();
  		while (succs.hasNext()) {
  		    out.or(ins[((Node)succs.next()).getIndex()]);
-diff -ur kopi-2.1B.orig/src/kjc/CBlockContext.java kopi-2.1B/src/kjc/CBlockContext.java
---- kopi-2.1B.orig/src/kjc/CBlockContext.java	2002-07-15 20:53:32.000000000 +0200
-+++ kopi-2.1B/src/kjc/CBlockContext.java	2003-07-31 09:26:59.000000000 +0200
+diff -ur kopi-2.1B.orig/src/kjc/JTryFinallyStatement.java kopi-2.1B/src/kjc/JTryFinallyStatement.java
+--- kopi-2.1B.orig/src/kjc/JTryFinallyStatement.java	2002-07-15 20:53:32.000000000 +0200
++++ kopi-2.1B/src/kjc/JTryFinallyStatement.java	2003-07-31 09:27:44.000000000 +0200
+@@ -78,7 +78,7 @@
+   public void analyse(CBodyContext context) throws PositionedError {
+     CBlockContext	self = new CBlockContext(context, context.getEnvironment()){
+         public void addMonitorVariable(JLocalVariable var)  throws UnpositionedError {
+-          addVariable(var);
++          addVariableWithFix(var);
+         }
+       };
+     CType               integerType = context.getTypeFactory().getPrimitiveType(TypeFactory.PRM_INT);
+--- kopi-2.1B/src/kjc/CBlockContext.java	2002-07-15 20:53:32.000000000 +0200
++++ kopi-2.1B.new/src/kjc/CBlockContext.java	2003-08-02 15:05:05.000000000 +0200
 @@ -59,6 +59,8 @@
      this.localVars = localVars == 0 ? null : new ArrayList(localVars);
      this.localsPosition = 0;
@@ -82,7 +93,7 @@
    }
  
    // ----------------------------------------------------------------------
-@@ -165,6 +171,61 @@
+@@ -165,32 +171,78 @@
      localsPosition += var.getType().getSize();
    }
  
@@ -93,23 +104,40 @@
 +     childrenBlock.add(child);
 +  }
 +
-+  /**
+   /**
+-   * Adds the variable for the monitor of the synchronized statement to the 
+-   * correct context.
+-   *
+-   * @param     var     monitor variable 
 +   * Fix the position of local variables as a monitor variable has been
 +   * added to the stack.
 +   * 
 +   * @param     incr     the update increment for local variables
-+   */
+    */
+-  public void addMonitorVariable(JLocalVariable var)  throws UnpositionedError {
+-    if (parent instanceof CMethodContext) {
+-      addVariable(var);
+-    } else {
+-      parent.addMonitorVariable(var);
+-      // correct index
+-      int       size = var.getType().getSize();
+-
+-      localsPosition += size;
+-      parentIndex++;
+-      for (int i=0; i < localVars.size(); i++) {
+-        JLocalVariable  localVar = (JLocalVariable) localVars.get(i);
 +  public void fixVariablePositions(int increment) throws UnpositionedError {
 +       localsPosition += increment;
 +       parentIndex++;
 +       for (int i=0; i < localVars.size(); i++) {
 +           JLocalVariable  localVar = (JLocalVariable) localVars.get(i);
-+
+ 
+-        localVar.setPosition(localVar.getPosition()+size);
 +           localVar.setPosition(localVar.getPosition()+increment);
-+        // fix 27.03.02 lackner
-+        // synthetic variable has no entry in CVariableInfo
-+        // not necessary  think
-+        //  localVar.setIndex(localVar.getIndex()+1);
+         // fix 27.03.02 lackner
+         // synthetic variable has no entry in CVariableInfo
+         // not necessary  think
+         //  localVar.setIndex(localVar.getIndex()+1);
 +       }
 +
 +       if (childrenBlock != null) {
@@ -138,38 +166,31 @@
 +	   
 +	   child.fixVariablePositions(increment);
 +        }
-+      }
+       }
+-    }
 +  }
 +
-   /**
-    * Adds the variable for the monitor of the synchronized statement to the 
-    * correct context.
-@@ -173,23 +234,9 @@
-    */
-   public void addMonitorVariable(JLocalVariable var)  throws UnpositionedError {
-     if (parent instanceof CMethodContext) {
--      addVariable(var);
++  /**
++   * Adds the variable for the monitor of the synchronized statement to the 
++   * correct context.
++   *
++   * @param     var     monitor variable 
++   */
++  public void addMonitorVariable(JLocalVariable var)  throws UnpositionedError {
++//    Commented out the full propagation to the top of the tree. After
++//    discussion with Helmer Kraemer <hkraemer at freenet.de> it appears
++//    that we only need to add the variable in the first block context
++//    encountered.
++
++//    if (parent instanceof CMethodContext) {
 +      addVariableWithFix(var);
-     } else {
-       parent.addMonitorVariable(var);
--      // correct index
--      int       size = var.getType().getSize();
--
--      localsPosition += size;
--      parentIndex++;
--      for (int i=0; i < localVars.size(); i++) {
--        JLocalVariable  localVar = (JLocalVariable) localVars.get(i);
--
--        localVar.setPosition(localVar.getPosition()+size);
--        // fix 27.03.02 lackner
--        // synthetic variable has no entry in CVariableInfo
--        // not necessary  think
--        //  localVar.setIndex(localVar.getIndex()+1);
--      }
-     }
++//    } else {
++//      parent.addMonitorVariable(var);
++//    }
    }
    /**
-@@ -287,6 +334,7 @@
+    * lookupLocalVariable
+@@ -287,6 +339,7 @@
  
    private Hashtable				localClasses;
    private ArrayList				localVars;
@@ -177,15 +198,3 @@
  
    private /*final*/ int				parentIndex;
    private int					localsIndex;
-diff -ur kopi-2.1B.orig/src/kjc/JTryFinallyStatement.java kopi-2.1B/src/kjc/JTryFinallyStatement.java
---- kopi-2.1B.orig/src/kjc/JTryFinallyStatement.java	2002-07-15 20:53:32.000000000 +0200
-+++ kopi-2.1B/src/kjc/JTryFinallyStatement.java	2003-07-31 09:27:44.000000000 +0200
-@@ -78,7 +78,7 @@
-   public void analyse(CBodyContext context) throws PositionedError {
-     CBlockContext	self = new CBlockContext(context, context.getEnvironment()){
-         public void addMonitorVariable(JLocalVariable var)  throws UnpositionedError {
--          addVariable(var);
-+          addVariableWithFix(var);
-         }
-       };
-     CType               integerType = context.getTypeFactory().getPrimitiveType(TypeFactory.PRM_INT);




More information about the kaffe mailing list