xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ytal...@apache.org
Subject cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util MethodGenerator.java
Date Thu, 17 Feb 2005 19:08:03 GMT
ytalwar     2005/02/17 11:08:03

  Modified:    java/src/org/apache/xalan/xsltc/compiler Mode.java
                        TestSeq.java
               java/src/org/apache/xalan/xsltc/compiler/util
                        MethodGenerator.java
  Log:
  This is a fix for XALANJ-2058.
  In the code, the problem is that a pattern gets compiled once, 
  and then this compiled pattern get re-used whenever the pattern is
  needed in any method.
  
  The fix is that pattern should get compiled once per method.  So, pattern get reused only
within a given method.
  For any new method, a pattern is recompiled.
  
  This fix has been reviewed by Henry Zongaro.
  Henry had also provided suggestions about the fix to resolve this issue.
  Thanks Henry for his valuable input.
  
  Revision  Changes    Path
  1.36      +2 -26     xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Mode.java
  
  Index: Mode.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Mode.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- Mode.java	9 Feb 2005 22:45:15 -0000	1.35
  +++ Mode.java	17 Feb 2005 19:08:02 -0000	1.36
  @@ -120,14 +120,7 @@
        */
       private TestSeq[] _testSeq;
   
  -    /**
  -     * A mapping between patterns and instruction lists used by 
  -     * test sequences to avoid compiling the same pattern multiple 
  -     * times. Note that patterns whose kernels are "*", "node()" 
  -     * and "@*" can between shared by test sequences.
  -     */
  -    private Hashtable _preCompiled = new Hashtable();
  -
  +    
       /**
        * A mapping between templates and test sequences.
        */
  @@ -205,23 +198,6 @@
       }
   
       /**
  -     * Add a pre-compiled pattern to this mode. 
  -     */
  -    public void addInstructionList(Pattern pattern, 
  -	InstructionList ilist) 
  -    {
  -	_preCompiled.put(pattern, ilist);
  -    }
  -
  -    /**
  -     * Get the instruction list for a pre-compiled pattern. Used by 
  -     * test sequences to avoid compiling patterns more than once.
  -     */
  -    public InstructionList getInstructionList(Pattern pattern) {
  -	return (InstructionList) _preCompiled.get(pattern);
  -    }
  -
  -    /**
        * Shortcut to get the class compiled for this mode (will be inlined).
        */
       private String getClassName() {
  
  
  
  1.12      +3 -3      xml-xalan/java/src/org/apache/xalan/xsltc/compiler/TestSeq.java
  
  Index: TestSeq.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/TestSeq.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- TestSeq.java	16 Feb 2004 22:25:10 -0000	1.11
  +++ TestSeq.java	17 Feb 2005 19:08:03 -0000	1.12
  @@ -238,10 +238,10 @@
   	    il.append(methodGen.loadCurrentNode());
   
   	    // Apply the test-code compiled for the pattern
  -	    InstructionList ilist = _mode.getInstructionList(pattern);
  +	    InstructionList ilist = methodGen.getInstructionList(pattern);
   	    if (ilist == null) {
   		ilist = pattern.compile(classGen, methodGen);
  -		_mode.addInstructionList(pattern, ilist);
  +		methodGen.addInstructionList(pattern, ilist);
   	    }
   
   	    // Make a copy of the instruction list for backpatching
  
  
  
  1.16      +29 -1     xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/MethodGenerator.java
  
  Index: MethodGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/MethodGenerator.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- MethodGenerator.java	16 Feb 2004 22:26:44 -0000	1.15
  +++ MethodGenerator.java	17 Feb 2005 19:08:03 -0000	1.16
  @@ -19,6 +19,8 @@
   
   package org.apache.xalan.xsltc.compiler.util;
   
  +import java.util.Hashtable;
  +
   import org.apache.bcel.generic.ALOAD;
   import org.apache.bcel.generic.ASTORE;
   import org.apache.bcel.generic.ConstantPoolGen;
  @@ -32,6 +34,7 @@
   import org.apache.bcel.generic.LocalVariableGen;
   import org.apache.bcel.generic.MethodGen;
   import org.apache.bcel.generic.Type;
  +import org.apache.xalan.xsltc.compiler.Pattern;
   
   /**
    * @author Jacek Ambroziak
  @@ -75,6 +78,14 @@
   
       private SlotAllocator _slotAllocator;
       private boolean _allocatorInit = false;
  +	/**
  +		 * A mapping between patterns and instruction lists used by 
  +		 * test sequences to avoid compiling the same pattern multiple 
  +		 * times. Note that patterns whose kernels are "*", "node()" 
  +		 * and "@*" can between shared by test sequences.
  +		 */
  +	private Hashtable _preCompiled = new Hashtable();
  +
       
       public MethodGenerator(int access_flags, Type return_type,
   			   Type[] arg_types, String[] arg_names,
  @@ -305,4 +316,21 @@
   	super.setMaxLocals(maxLocals);
       }
   
  +	/**
  +	 * Add a pre-compiled pattern to this mode. 
  +	 */
  +	public void addInstructionList(Pattern pattern, 
  +	InstructionList ilist) 
  +	{
  +	_preCompiled.put(pattern, ilist);
  +	}
  +
  +	/**
  +	 * Get the instruction list for a pre-compiled pattern. Used by 
  +	 * test sequences to avoid compiling patterns more than once.
  +	 */
  +	public InstructionList getInstructionList(Pattern pattern) {
  +	return (InstructionList) _preCompiled.get(pattern);
  +	}
  +
   }
  
  
  

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


Mime
View raw message