You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by zo...@apache.org on 2007/04/13 20:50:57 UTC

svn commit: r528589 - in /xalan/java/trunk/src/org/apache/xalan/xsltc/compiler: ParameterRef.java VariableBase.java VariableRef.java

Author: zongaro
Date: Fri Apr 13 11:50:56 2007
New Revision: 528589

URL: http://svn.apache.org/viewvc?view=rev&rev=528589
Log:
Patch for XALANJ-2377

VariableBase.removeReference was effectively being used to decrement a reference
counter for local variables.

At one time, XSLTC used to release JVM stack slots as soon as the last
reference to a local variable occurred, but that resulted in a bug if loops
were involved.  So the code was changed to release a local variable slot only
when the containing construct went out of scope - this was done with a call to
VariableBase.unmapRegister from SytaxTreeNode.translateContents.

However, VariableBase.unmapRegister still contained a vestige of the old
reference counting code - it was checking whether any references to the variable
still existed.  In the presence of "Closures," the number of calls to
VariableBase.addReference did not equal the number of calls to
VariableBase.removeReference (for no good reason), so the variable was not
marked by VariableBase.unmapRegister as going out of scope.  This caused later
problems for outlining in org.apache.xalan.xsltc.compiler.util.MethodGenerator.

The fix is to remove VariableBase.removeReference, since XSLTC should no longer
on that to determine whether it can release a variable slot.  The
VariableBase.addReference method remains, however, because XSLTC uses that to
determine whether a variable can be discarded completely.


Reviewed by Christine Li (jycli () ca ! ibm ! com).

Modified:
    xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/ParameterRef.java
    xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/VariableBase.java
    xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/VariableRef.java

Modified: xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/ParameterRef.java
URL: http://svn.apache.org/viewvc/xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/ParameterRef.java?view=diff&rev=528589&r1=528588&r2=528589
==============================================================================
--- xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/ParameterRef.java (original)
+++ xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/ParameterRef.java Fri Apr 13 11:50:56 2007
@@ -82,12 +82,10 @@
 		}
 		else {
 		    il.append(_variable.loadInstruction());
-		    _variable.removeReference(this);
 		}
 	    }
 	    else {
 		il.append(_variable.loadInstruction());
-		_variable.removeReference(this);
 	    }
 	}
 	else {

Modified: xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/VariableBase.java
URL: http://svn.apache.org/viewvc/xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/VariableBase.java?view=diff&rev=528589&r1=528588&r2=528589
==============================================================================
--- xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/VariableBase.java (original)
+++ xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/VariableBase.java Fri Apr 13 11:50:56 2007
@@ -82,14 +82,6 @@
     }
 
     /**
-     * Remove a reference to this variable. Called by VariableRef when this
-     * variable goes out of scope.
-     */
-    public void removeReference(VariableRefBase vref) {
-	_refs.remove(vref);
-    }
-
-    /**
      * Map this variable to a register
      */
     public void mapRegister(MethodGenerator methodGen) {
@@ -105,7 +97,7 @@
      * Called when we leave the AST scope of the variable's declaration
      */
     public void unmapRegister(MethodGenerator methodGen) {
-	if (_refs.isEmpty() && (_local != null)) {
+	if (_local != null) {
 	    _local.setEnd(methodGen.getInstructionList().getEnd());
 	    methodGen.removeLocalVariable(_local);
 	    _refs = null;

Modified: xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/VariableRef.java
URL: http://svn.apache.org/viewvc/xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/VariableRef.java?view=diff&rev=528589&r1=528588&r2=528589
==============================================================================
--- xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/VariableRef.java (original)
+++ xalan/java/trunk/src/org/apache/xalan/xsltc/compiler/VariableRef.java Fri Apr 13 11:50:56 2007
@@ -68,12 +68,10 @@
 		}
 		else {
 		    il.append(_variable.loadInstruction());
-		    _variable.removeReference(this);
 		}
 	    }
 	    else {
 		il.append(_variable.loadInstruction());
-		_variable.removeReference(this);
 	    }
 	}
 	else {



---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org