aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobm <none@none>2016-03-29 23:01:27 +0100
committerrobm <none@none>2016-03-29 23:01:27 +0100
commit0cf2513721093df3842176e141ea7277bb15089b (patch)
treeafd46ded511ad031835439d9b44569f9361695d4
parentc1e47be65d2cefc32c0948d1f192b2736914e522 (diff)
parent9bcc3d0692cfed9b750dfa648e29938cefe29dbe (diff)
downloadjdk8u_jaxp-0cf2513721093df3842176e141ea7277bb15089b.tar.gz
Merge
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/DOM.java6
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java20
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java37
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/compiler/Sort.java60
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java9
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/compiler/Template.java9
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/compiler/VariableBase.java53
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/compiler/WithParam.java43
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/dom/AdaptiveResultTreeImpl.java13
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/dom/DOMAdapter.java15
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/dom/MultiDOM.java49
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/dom/SAXImpl.java25
-rw-r--r--src/com/sun/org/apache/xalan/internal/xsltc/dom/SimpleResultTreeImpl.java10
13 files changed, 213 insertions, 136 deletions
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/DOM.java b/src/com/sun/org/apache/xalan/internal/xsltc/DOM.java
index bf6fbf1..25ce372 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/DOM.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/DOM.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,9 +17,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * $Id: DOM.java,v 1.2.4.1 2005/08/31 10:18:49 pvedula Exp $
- */
package com.sun.org.apache.xalan.internal.xsltc;
@@ -102,4 +99,5 @@ public interface DOM {
public int getDocument();
public String getUnparsedEntityURI(String name);
public Map<String, Integer> getElementsWithIDs();
+ public void release();
}
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java
index 174a1d1..d7bc1ca 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,9 +17,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * $Id: ApplyTemplates.java,v 1.2.4.1 2005/09/12 09:59:21 pvedula Exp $
- */
package com.sun.org.apache.xalan.internal.xsltc.compiler;
@@ -120,12 +117,10 @@ final class ApplyTemplates extends Instruction {
final int current = methodGen.getLocalIndex("current");
// check if sorting nodes is required
- final Vector sortObjects = new Vector();
- final Iterator<SyntaxTreeNode> children = elements();
- while (children.hasNext()) {
- final SyntaxTreeNode child = children.next();
+ final Vector<Sort> sortObjects = new Vector<>();
+ for (final SyntaxTreeNode child : getContents()) {
if (child instanceof Sort) {
- sortObjects.addElement(child);
+ sortObjects.addElement((Sort)child);
}
}
@@ -191,6 +186,13 @@ final class ApplyTemplates extends Instruction {
applyTemplatesSig);
il.append(new INVOKEVIRTUAL(applyTemplates));
+ // unmap parameters to release temporary result trees
+ for (final SyntaxTreeNode child : getContents()) {
+ if (child instanceof WithParam) {
+ ((WithParam)child).releaseResultTree(classGen, methodGen);
+ }
+ }
+
// Pop parameter frame
if (stylesheet.hasLocalParams() || hasContents()) {
il.append(classGen.loadTranslet());
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java
index caace08..2e2ca14 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java
@@ -1,6 +1,5 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Copyright 2001-2004 The Apache Software Foundation.
@@ -17,18 +16,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * $Id: CallTemplate.java,v 1.2.4.1 2005/09/12 10:02:41 pvedula Exp $
- */
package com.sun.org.apache.xalan.internal.xsltc.compiler;
-import com.sun.org.apache.bcel.internal.generic.ALOAD;
-import com.sun.org.apache.bcel.internal.generic.ASTORE;
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
import com.sun.org.apache.bcel.internal.generic.InstructionList;
-import com.sun.org.apache.bcel.internal.generic.LocalVariableGen;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
@@ -56,7 +49,7 @@ final class CallTemplate extends Instruction {
* this array can be either a WithParam or a Param if no WithParam
* exists for a particular parameter.
*/
- private Object[] _parameters = null;
+ private SyntaxTreeNode[] _parameters = null;
/**
* The corresponding template which this CallTemplate calls.
@@ -147,11 +140,10 @@ final class CallTemplate extends Instruction {
// If calling a simply named template, push actual arguments
if (_calleeTemplate != null) {
- Vector calleeParams = _calleeTemplate.getParameters();
int numParams = _parameters.length;
for (int i = 0; i < numParams; i++) {
- SyntaxTreeNode node = (SyntaxTreeNode)_parameters[i];
+ SyntaxTreeNode node = _parameters[i];
methodSig.append(OBJECT_SIG); // append Object to signature
// Push 'null' if Param to indicate no actual parameter specified
@@ -170,6 +162,15 @@ final class CallTemplate extends Instruction {
methodName,
methodSig.toString())));
+ // release temporary result trees
+ if (_parameters != null) {
+ for (int i = 0; i < _parameters.length; i++) {
+ if (_parameters[i] instanceof WithParam) {
+ ((WithParam)_parameters[i]).releaseResultTree(classGen, methodGen);
+ }
+ }
+ }
+
// Do not need to call Translet.popParamFrame() if we are
// calling a simple named template.
if (_calleeTemplate == null && (stylesheet.hasLocalParams() || hasContents())) {
@@ -203,9 +204,9 @@ final class CallTemplate extends Instruction {
private void buildParameterList() {
// Put the parameters from the called template into the array first.
// This is to ensure the order of the parameters.
- Vector defaultParams = _calleeTemplate.getParameters();
+ Vector<Param> defaultParams = _calleeTemplate.getParameters();
int numParams = defaultParams.size();
- _parameters = new Object[numParams];
+ _parameters = new SyntaxTreeNode[numParams];
for (int i = 0; i < numParams; i++) {
_parameters[i] = defaultParams.elementAt(i);
}
@@ -222,15 +223,15 @@ final class CallTemplate extends Instruction {
// Search for a Param with the same name
for (int k = 0; k < numParams; k++) {
- Object object = _parameters[k];
- if (object instanceof Param
- && ((Param)object).getName().equals(name)) {
+ SyntaxTreeNode parm = _parameters[k];
+ if (parm instanceof Param
+ && ((Param)parm).getName().equals(name)) {
withParam.setDoParameterOptimization(true);
_parameters[k] = withParam;
break;
}
- else if (object instanceof WithParam
- && ((WithParam)object).getName().equals(name)) {
+ else if (parm instanceof WithParam
+ && ((WithParam)parm).getName().equals(name)) {
withParam.setDoParameterOptimization(true);
_parameters[k] = withParam;
break;
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Sort.java b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Sort.java
index d8264a2..f7309e5 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Sort.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Sort.java
@@ -1,6 +1,5 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Copyright 2001-2005 The Apache Software Foundation.
@@ -17,32 +16,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * $Id: Sort.java,v 1.2.4.1 2005/09/12 11:08:12 pvedula Exp $
- */
package com.sun.org.apache.xalan.internal.xsltc.compiler;
-import java.text.Collator;
import java.util.ArrayList;
-import java.util.NoSuchElementException;
-import java.util.StringTokenizer;
import java.util.Vector;
import com.sun.org.apache.bcel.internal.classfile.Field;
-import com.sun.org.apache.bcel.internal.classfile.Method;
import com.sun.org.apache.bcel.internal.generic.ALOAD;
import com.sun.org.apache.bcel.internal.generic.ANEWARRAY;
import com.sun.org.apache.bcel.internal.generic.ASTORE;
import com.sun.org.apache.bcel.internal.generic.CHECKCAST;
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
import com.sun.org.apache.bcel.internal.generic.GETFIELD;
-import com.sun.org.apache.bcel.internal.generic.ICONST;
import com.sun.org.apache.bcel.internal.generic.ILOAD;
import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE;
import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL;
-import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC;
-import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
import com.sun.org.apache.bcel.internal.generic.InstructionHandle;
import com.sun.org.apache.bcel.internal.generic.InstructionList;
import com.sun.org.apache.bcel.internal.generic.LocalVariableGen;
@@ -76,13 +65,10 @@ final class Sort extends Instruction implements Closure {
private AttributeValue _order;
private AttributeValue _caseOrder;
private AttributeValue _dataType;
- private String _lang; // bug! see 26869
-
- private String _data = null;
-
+ private String _lang; // bug! see 26869
private String _className = null;
- private ArrayList _closureVars = null;
+ private ArrayList<VariableRefBase> _closureVars = null;
private boolean _needsSortRecordFactory = false;
// -- Begin Closure interface --------------------
@@ -115,7 +101,7 @@ final class Sort extends Instruction implements Closure {
*/
public void addVariable(VariableRefBase variableRef) {
if (_closureVars == null) {
- _closureVars = new ArrayList();
+ _closureVars = new ArrayList<>();
}
// Only one reference per variable
@@ -246,7 +232,7 @@ final class Sort extends Instruction implements Closure {
public static void translateSortIterator(ClassGenerator classGen,
MethodGenerator methodGen,
Expression nodeSet,
- Vector sortObjects)
+ Vector<Sort> sortObjects)
{
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
@@ -312,7 +298,7 @@ final class Sort extends Instruction implements Closure {
* Compiles code that instantiates a NodeSortRecordFactory object which
* will produce NodeSortRecord objects of a specific type.
*/
- public static void compileSortRecordFactory(Vector sortObjects,
+ public static void compileSortRecordFactory(Vector<Sort> sortObjects,
ClassGenerator classGen, MethodGenerator methodGen)
{
String sortRecordClass =
@@ -321,7 +307,7 @@ final class Sort extends Instruction implements Closure {
boolean needsSortRecordFactory = false;
final int nsorts = sortObjects.size();
for (int i = 0; i < nsorts; i++) {
- final Sort sort = (Sort) sortObjects.elementAt(i);
+ final Sort sort = sortObjects.elementAt(i);
needsSortRecordFactory |= sort._needsSortRecordFactory;
}
@@ -429,7 +415,7 @@ final class Sort extends Instruction implements Closure {
+ "[" + STRING_SIG + ")V")));
// Initialize closure variables in sortRecordFactory
- final ArrayList dups = new ArrayList();
+ final ArrayList<VariableRefBase> dups = new ArrayList<>();
for (int j = 0; j < nsorts; j++) {
final Sort sort = (Sort) sortObjects.get(j);
@@ -437,7 +423,7 @@ final class Sort extends Instruction implements Closure {
sort._closureVars.size();
for (int i = 0; i < length; i++) {
- VariableRefBase varRef = (VariableRefBase) sort._closureVars.get(i);
+ VariableRefBase varRef = sort._closureVars.get(i);
// Discard duplicate variable references
if (dups.contains(varRef)) continue;
@@ -455,11 +441,11 @@ final class Sort extends Instruction implements Closure {
}
}
- public static String compileSortRecordFactory(Vector sortObjects,
+ public static String compileSortRecordFactory(Vector<Sort> sortObjects,
ClassGenerator classGen, MethodGenerator methodGen,
String sortRecordClass)
{
- final XSLTC xsltc = ((Sort)sortObjects.firstElement()).getXSLTC();
+ final XSLTC xsltc = (sortObjects.firstElement()).getXSLTC();
final String className = xsltc.getHelperClassName();
final NodeSortRecordFactGenerator sortRecordFactory =
@@ -474,15 +460,15 @@ final class Sort extends Instruction implements Closure {
// Add a new instance variable for each var in closure
final int nsorts = sortObjects.size();
- final ArrayList dups = new ArrayList();
+ final ArrayList<VariableRefBase> dups = new ArrayList<>();
for (int j = 0; j < nsorts; j++) {
- final Sort sort = (Sort) sortObjects.get(j);
+ final Sort sort = sortObjects.get(j);
final int length = (sort._closureVars == null) ? 0 :
sort._closureVars.size();
for (int i = 0; i < length; i++) {
- final VariableRefBase varRef = (VariableRefBase) sort._closureVars.get(i);
+ final VariableRefBase varRef = sort._closureVars.get(i);
// Discard duplicate variable references
if (dups.contains(varRef)) continue;
@@ -600,10 +586,10 @@ final class Sort extends Instruction implements Closure {
/**
* Create a new auxillary class extending NodeSortRecord.
*/
- private static String compileSortRecord(Vector sortObjects,
+ private static String compileSortRecord(Vector<Sort> sortObjects,
ClassGenerator classGen,
MethodGenerator methodGen) {
- final XSLTC xsltc = ((Sort)sortObjects.firstElement()).getXSLTC();
+ final XSLTC xsltc = sortObjects.firstElement().getXSLTC();
final String className = xsltc.getHelperClassName();
// This generates a new class for handling this specific sort
@@ -619,10 +605,10 @@ final class Sort extends Instruction implements Closure {
// Add a new instance variable for each var in closure
final int nsorts = sortObjects.size();
- final ArrayList dups = new ArrayList();
+ final ArrayList<VariableRefBase> dups = new ArrayList<>();
for (int j = 0; j < nsorts; j++) {
- final Sort sort = (Sort) sortObjects.get(j);
+ final Sort sort = sortObjects.get(j);
// Set the name of the inner class in this sort object
sort.setInnerClassName(className);
@@ -644,8 +630,7 @@ final class Sort extends Instruction implements Closure {
}
}
- MethodGenerator init = compileInit(sortObjects, sortRecord,
- cpg, className);
+ MethodGenerator init = compileInit(sortRecord, cpg, className);
MethodGenerator extract = compileExtract(sortObjects, sortRecord,
cpg, className);
sortRecord.addMethod(init);
@@ -660,8 +645,7 @@ final class Sort extends Instruction implements Closure {
* collator in the super calls only when the stylesheet specifies a new
* language in xsl:sort.
*/
- private static MethodGenerator compileInit(Vector sortObjects,
- NodeSortRecordGenerator sortRecord,
+ private static MethodGenerator compileInit(NodeSortRecordGenerator sortRecord,
ConstantPoolGen cpg,
String className)
{
@@ -688,7 +672,7 @@ final class Sort extends Instruction implements Closure {
/**
* Compiles a method that overloads NodeSortRecord.extractValueFromDOM()
*/
- private static MethodGenerator compileExtract(Vector sortObjects,
+ private static MethodGenerator compileExtract(Vector<Sort> sortObjects,
NodeSortRecordGenerator sortRecord,
ConstantPoolGen cpg,
String className) {
@@ -730,7 +714,7 @@ final class Sort extends Instruction implements Closure {
// Append all the cases for the switch statment
for (int level = 0; level < levels; level++) {
match[level] = level;
- final Sort sort = (Sort)sortObjects.elementAt(level);
+ final Sort sort = sortObjects.elementAt(level);
target[level] = il.append(NOP);
sort.translateSelect(sortRecord, extractMethod);
il.append(ARETURN);
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java
index e9020cf..1e8ad86 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,9 +17,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * $Id: SyntaxTreeNode.java,v 1.6 2006/06/06 22:34:33 spericas Exp $
- */
package com.sun.org.apache.xalan.internal.xsltc.compiler;
@@ -519,9 +516,9 @@ public abstract class SyntaxTreeNode implements Constants {
// references falling out-of-scope inside the for-each element.
// (the cause of which being 'lazy' register allocation for references)
for (int i = 0; i < n; i++) {
- if( _contents.get(i) instanceof VariableBase) {
+ if ( _contents.get(i) instanceof VariableBase) {
final VariableBase var = (VariableBase)_contents.get(i);
- var.unmapRegister(methodGen);
+ var.unmapRegister(classGen, methodGen);
}
}
}
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Template.java b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Template.java
index b4d8228..c683744 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Template.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Template.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,9 +17,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * $Id: Template.java,v 1.2.4.1 2005/09/12 11:30:11 pvedula Exp $
- */
package com.sun.org.apache.xalan.internal.xsltc.compiler;
@@ -61,7 +58,7 @@ public final class Template extends TopLevelElement {
// The list of parameters in this template. This is only used
// for simple named templates.
- private Vector _parameters = new Vector();
+ private Vector<Param> _parameters = new Vector<>();
public boolean hasParams() {
return _parameters.size() > 0;
@@ -83,7 +80,7 @@ public final class Template extends TopLevelElement {
_parameters.addElement(param);
}
- public Vector getParameters() {
+ public Vector<Param> getParameters() {
return _parameters;
}
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/VariableBase.java b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/VariableBase.java
index 7ef4c1c..02e1a5f 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/VariableBase.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/VariableBase.java
@@ -1,6 +1,5 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Copyright 2001-2004 The Apache Software Foundation.
@@ -17,18 +16,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * $Id: VariableBase.java,v 1.5 2005/09/28 13:48:18 pvedula Exp $
- */
package com.sun.org.apache.xalan.internal.xsltc.compiler;
import java.util.Vector;
+import com.sun.org.apache.bcel.internal.generic.CHECKCAST;
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
import com.sun.org.apache.bcel.internal.generic.Instruction;
import com.sun.org.apache.bcel.internal.generic.InstructionList;
+import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE;
import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL;
+import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
import com.sun.org.apache.bcel.internal.generic.LocalVariableGen;
import com.sun.org.apache.bcel.internal.generic.NEW;
import com.sun.org.apache.bcel.internal.generic.PUSH;
@@ -36,6 +35,7 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeSetType;
+import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
import com.sun.org.apache.xml.internal.utils.XML11Char;
@@ -49,21 +49,18 @@ import com.sun.org.apache.xml.internal.utils.XML11Char;
*/
class VariableBase extends TopLevelElement {
- protected QName _name; // The name of the variable.
- protected String _escapedName; // The escaped qname of the variable.
- protected Type _type; // The type of this variable.
- protected boolean _isLocal; // True if the variable is local.
- protected LocalVariableGen _local; // Reference to JVM variable
- protected Instruction _loadInstruction; // Instruction to load JVM variable
+ protected QName _name; // The name of the variable.
+ protected String _escapedName; // The escaped qname of the variable.
+ protected Type _type; // The type of this variable.
+ protected boolean _isLocal; // True if the variable is local.
+ protected LocalVariableGen _local; // Reference to JVM variable
+ protected Instruction _loadInstruction; // Instruction to load JVM variable
protected Instruction _storeInstruction; // Instruction to load JVM variable
- protected Expression _select; // Reference to variable expression
- protected String select; // Textual repr. of variable expr.
+ protected Expression _select; // Reference to variable expression
+ protected String select; // Textual repr. of variable expr.
// References to this variable (when local)
- protected Vector _refs = new Vector(2);
-
- // Dependencies to other variables/parameters (for globals only)
- protected Vector _dependencies = null;
+ protected Vector<VariableRefBase> _refs = new Vector<>(2);
// Used to make sure parameter field is not added twice
protected boolean _ignore = false;
@@ -92,7 +89,7 @@ class VariableBase extends TopLevelElement {
public void copyReferences(VariableBase var) {
final int size = _refs.size();
for (int i = 0; i < size; i++) {
- var.addReference((VariableRefBase) _refs.get(i));
+ var.addReference(_refs.get(i));
}
}
@@ -112,8 +109,24 @@ class VariableBase extends TopLevelElement {
* Remove the mapping of this variable to a register.
* Called when we leave the AST scope of the variable's declaration
*/
- public void unmapRegister(MethodGenerator methodGen) {
+ public void unmapRegister(ClassGenerator classGen, MethodGenerator methodGen) {
if (_local != null) {
+ if (_type instanceof ResultTreeType) {
+ final ConstantPoolGen cpg = classGen.getConstantPool();
+ final InstructionList il = methodGen.getInstructionList();
+ if (classGen.getStylesheet().callsNodeset() && classGen.getDOMClass().equals(MULTI_DOM_CLASS)) {
+ final int removeDA = cpg.addMethodref(MULTI_DOM_CLASS, "removeDOMAdapter", "(" + DOM_ADAPTER_SIG + ")V");
+ il.append(methodGen.loadDOM());
+ il.append(new CHECKCAST(cpg.addClass(MULTI_DOM_CLASS)));
+ il.append(loadInstruction());
+ il.append(new CHECKCAST(cpg.addClass(DOM_ADAPTER_CLASS)));
+ il.append(new INVOKEVIRTUAL(removeDA));
+ }
+ final int release = cpg.addInterfaceMethodref(DOM_IMPL_CLASS, "release", "()V");
+ il.append(loadInstruction());
+ il.append(new INVOKEINTERFACE(release, 1));
+ }
+
_local.setEnd(methodGen.getInstructionList().getEnd());
methodGen.removeLocalVariable(_local);
_refs = null;
@@ -126,7 +139,6 @@ class VariableBase extends TopLevelElement {
* the JVM stack.
*/
public Instruction loadInstruction() {
- final Instruction instr = _loadInstruction;
if (_loadInstruction == null) {
_loadInstruction = _type.LOAD(_local.getIndex());
}
@@ -138,7 +150,6 @@ class VariableBase extends TopLevelElement {
* into this variable.
*/
public Instruction storeInstruction() {
- final Instruction instr = _storeInstruction;
if (_storeInstruction == null) {
_storeInstruction = _type.STORE(_local.getIndex());
}
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/WithParam.java b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/WithParam.java
index 3a87d59..fc2b202 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/compiler/WithParam.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/compiler/WithParam.java
@@ -1,6 +1,5 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Copyright 2001-2004 The Apache Software Foundation.
@@ -17,15 +16,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * $Id: WithParam.java,v 1.2.4.1 2005/09/12 11:38:01 pvedula Exp $
- */
package com.sun.org.apache.xalan.internal.xsltc.compiler;
+import com.sun.org.apache.bcel.internal.generic.ALOAD;
+import com.sun.org.apache.bcel.internal.generic.ASTORE;
+import com.sun.org.apache.bcel.internal.generic.CHECKCAST;
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
+import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE;
import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
import com.sun.org.apache.bcel.internal.generic.InstructionList;
+import com.sun.org.apache.bcel.internal.generic.LocalVariableGen;
import com.sun.org.apache.bcel.internal.generic.PUSH;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
@@ -60,6 +61,11 @@ final class WithParam extends Instruction {
private Expression _select;
/**
+ * Reference to JVM variable holding temporary result tree.
+ */
+ private LocalVariableGen _domAdapter;
+
+ /**
* %OPT% This is set to true when the WithParam is used in a CallTemplate
* for a simple named template. If this is true, the parameters are
* passed to the named template through method arguments rather than
@@ -164,8 +170,13 @@ final class WithParam extends Instruction {
_select.startIterator(classGen, methodGen);
}
// If not, compile result tree from parameter body if present.
+ // Store result tree into local variable for releasing it later
else if (hasContents()) {
+ final InstructionList il = methodGen.getInstructionList();
compileResultTree(classGen, methodGen);
+ _domAdapter = methodGen.addLocalVariable2("@" + _escapedName, Type.ResultTree.toJCType(), il.getEnd());
+ il.append(DUP);
+ il.append(new ASTORE(_domAdapter.getIndex()));
}
// If neither are present then store empty string in parameter slot
else {
@@ -208,4 +219,26 @@ final class WithParam extends Instruction {
ADD_PARAMETER_SIG)));
il.append(POP); // cleanup stack
}
+
+ /**
+ * Release the compiled result tree.
+ */
+ public void releaseResultTree(ClassGenerator classGen, MethodGenerator methodGen) {
+ if (_domAdapter != null) {
+ final ConstantPoolGen cpg = classGen.getConstantPool();
+ final InstructionList il = methodGen.getInstructionList();
+ if (classGen.getStylesheet().callsNodeset() && classGen.getDOMClass().equals(MULTI_DOM_CLASS)) {
+ final int removeDA = cpg.addMethodref(MULTI_DOM_CLASS, "removeDOMAdapter", "(" + DOM_ADAPTER_SIG + ")V");
+ il.append(methodGen.loadDOM());
+ il.append(new CHECKCAST(cpg.addClass(MULTI_DOM_CLASS)));
+ il.append(new ALOAD(_domAdapter.getIndex()));
+ il.append(new CHECKCAST(cpg.addClass(DOM_ADAPTER_CLASS)));
+ il.append(new INVOKEVIRTUAL(removeDA));
+ }
+ final int release = cpg.addInterfaceMethodref(DOM_IMPL_CLASS, "release", "()V");
+ il.append(new ALOAD(_domAdapter.getIndex()));
+ il.append(new INVOKEINTERFACE(release, 1));
+ _domAdapter = null;
+ }
+ }
}
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/dom/AdaptiveResultTreeImpl.java b/src/com/sun/org/apache/xalan/internal/xsltc/dom/AdaptiveResultTreeImpl.java
index fc1b1d9..cb50cf5 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/dom/AdaptiveResultTreeImpl.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/dom/AdaptiveResultTreeImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,9 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * $Id: AdaptiveResultTreeImpl.java,v 1.2.4.1 2005/09/06 05:52:18 pvedula Exp $
- */
+
package com.sun.org.apache.xalan.internal.xsltc.dom;
import com.sun.org.apache.xalan.internal.xsltc.DOM;
@@ -1338,4 +1336,11 @@ public class AdaptiveResultTreeImpl extends SimpleResultTreeImpl
}
}
+ public void release() {
+ if (_dom != null) {
+ _dom.release();
+ _dom = null;
+ }
+ super.release();
+ }
}
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/dom/DOMAdapter.java b/src/com/sun/org/apache/xalan/internal/xsltc/dom/DOMAdapter.java
index a12d9e4..4f44ae1 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/dom/DOMAdapter.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/dom/DOMAdapter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,9 +17,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * $Id: DOMAdapter.java,v 1.2.4.1 2005/09/06 06:07:28 pvedula Exp $
- */
package com.sun.org.apache.xalan.internal.xsltc.dom;
@@ -56,8 +53,6 @@ public final class DOMAdapter implements DOM {
private short[] _NSmapping = null;
private short[] _NSreverse = null;
- private StripFilter _filter = null;
-
private int _multiDOMMask;
public DOMAdapter(DOM dom,
@@ -165,9 +160,7 @@ public final class DOMAdapter implements DOM {
}
}
- public void setFilter(StripFilter filter) {
- _filter = filter;
- }
+ public void setFilter(StripFilter filter) {}
public DTMAxisIterator getTypedChildren(final int type) {
final int[] reverse = getReverse();
@@ -464,4 +457,8 @@ public final class DOMAdapter implements DOM {
public Map<String, Integer> getElementsWithIDs() {
return _dom.getElementsWithIDs();
}
+
+ public void release() {
+ _dom.release();
+ }
}
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/dom/MultiDOM.java b/src/com/sun/org/apache/xalan/internal/xsltc/dom/MultiDOM.java
index 66dfdc4..92eca91 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/dom/MultiDOM.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/dom/MultiDOM.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -670,4 +670,51 @@ public final class MultiDOM implements DOM {
public Map<String, Integer> getElementsWithIDs() {
return _main.getElementsWithIDs();
}
+
+ public void release() {
+ _main.release();
+ }
+
+ private boolean isMatchingAdapterEntry(DOM entry, DOMAdapter adapter) {
+ DOM dom = adapter.getDOMImpl();
+
+ return (entry == adapter) || (
+ /*
+ * Method addDOMAdapter overwrites for AdaptiveResultTreeImpl
+ * objects the usual entry with an adapter to the nested
+ * DOM, so we must check this here. See last 'if' statement
+ * of addDOMAdapter.
+ */
+ (dom instanceof AdaptiveResultTreeImpl) &&
+ (entry instanceof DOMAdapter) &&
+ (((AdaptiveResultTreeImpl)dom).getNestedDOM() == ((DOMAdapter)entry).getDOMImpl())
+ );
+ }
+
+ public void removeDOMAdapter(DOMAdapter adapter) {
+ _documents.remove(adapter.getDocumentURI(0));
+ DOM dom = adapter.getDOMImpl();
+
+ if (dom instanceof DTMDefaultBase) {
+ SuballocatedIntVector ids = ((DTMDefaultBase) dom).getDTMIDs();
+ int idsSize = ids.size();
+ for (int i = 0; i < idsSize; i++) {
+ _adapters[ids.elementAt(i) >>> DTMManager.IDENT_DTM_NODE_BITS] = null;
+ }
+ } else {
+ int id = dom.getDocument() >>> DTMManager.IDENT_DTM_NODE_BITS;
+ if ((id > 0) && (id < _adapters.length) && isMatchingAdapterEntry(_adapters[id], adapter)) {
+ _adapters[id] = null;
+ } else {
+ boolean found = false;
+ for (int i = 0; i < _adapters.length; i++) {
+ if (isMatchingAdapterEntry(_adapters[id], adapter)) {
+ _adapters[i] = null;
+ found = true;
+ break;
+ }
+ }
+ }
+ }
+ }
}
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/dom/SAXImpl.java b/src/com/sun/org/apache/xalan/internal/xsltc/dom/SAXImpl.java
index 77c56e5..2919b9b 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/dom/SAXImpl.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/dom/SAXImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,9 +17,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * $Id: SAXImpl.java,v 1.5 2005/09/28 13:48:37 pvedula Exp $
- */
package com.sun.org.apache.xalan.internal.xsltc.dom;
@@ -82,7 +79,7 @@ public final class SAXImpl extends SAX2DTM2
// Namespace prefix-to-uri mapping stuff
private int _uriCount = 0;
- private int _prefixCount = 0;
+ // private int _prefixCount = 0;
// Stack used to keep track of what whitespace text nodes are protected
// by xml:space="preserve" attributes and which nodes that are not.
@@ -90,11 +87,11 @@ public final class SAXImpl extends SAX2DTM2
private int _idx = 1;
private boolean _preserve = false;
- private static final String XML_STRING = "xml:";
+ // private static final String XML_STRING = "xml:";
private static final String XML_PREFIX = "xml";
private static final String XMLSPACE_STRING = "xml:space";
private static final String PRESERVE_STRING = "preserve";
- private static final String XMLNS_PREFIX = "xmlns";
+ // private static final String XMLNS_PREFIX = "xmlns";
private static final String XML_URI = "http://www.w3.org/XML/1998/namespace";
private boolean _escaping = true;
@@ -123,7 +120,7 @@ public final class SAXImpl extends SAX2DTM2
private BitArray _dontEscape = null;
// The URI to this document
- private String _documentURI = null;
+ // private String _documentURI = null;
static private int _documentURIIndex = 0;
// The owner Document when the input source is DOMSource.
@@ -143,8 +140,7 @@ public final class SAXImpl extends SAX2DTM2
// Support for access/navigation through org.w3c.dom API
private Node[] _nodes;
private NodeList[] _nodeLists;
- private final static String XML_LANG_ATTRIBUTE =
- "http://www.w3.org/XML/1998/namespace:@lang";
+ // private final static String XML_LANG_ATTRIBUTE = "http://www.w3.org/XML/1998/namespace:@lang";
/**
* Define the origin of the document from which the tree was built
@@ -491,6 +487,7 @@ public final class SAXImpl extends SAX2DTM2
/**
* Sets up a translet-to-dom type mapping table
*/
+ /*
private int[] setupMapping(String[] names, String[] uris, int[] types, int nNames) {
// Padding with number of names, because they
// may need to be added, i.e for RTFs. See copy03
@@ -502,6 +499,7 @@ public final class SAXImpl extends SAX2DTM2
}
return result;
}
+ */
/**
* Returns the internal type associated with an expanded QName
@@ -1230,9 +1228,6 @@ public final class SAXImpl extends SAX2DTM2
*/
public DTMAxisIterator getNamespaceAxisIterator(int axis, int ns)
{
-
- DTMAxisIterator iterator = null;
-
if (ns == NO_TYPE) {
return EMPTYITERATOR;
}
@@ -1546,7 +1541,6 @@ public final class SAXImpl extends SAX2DTM2
*/
public DTMAxisIterator getNthDescendant(int type, int n, boolean includeself)
{
- DTMAxisIterator source = (DTMAxisIterator) new TypedDescendantIterator(type);
return new NthDescendantIterator(n);
}
@@ -1882,4 +1876,7 @@ public final class SAXImpl extends SAX2DTM2
}
}
+ public void release() {
+ _dtmManager.release(this, true);
+ }
}
diff --git a/src/com/sun/org/apache/xalan/internal/xsltc/dom/SimpleResultTreeImpl.java b/src/com/sun/org/apache/xalan/internal/xsltc/dom/SimpleResultTreeImpl.java
index 9d5d07b..3d71c6d 100644
--- a/src/com/sun/org/apache/xalan/internal/xsltc/dom/SimpleResultTreeImpl.java
+++ b/src/com/sun/org/apache/xalan/internal/xsltc/dom/SimpleResultTreeImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -1013,4 +1013,12 @@ public class SimpleResultTreeImpl extends EmptySerializer implements DOM, DTM
public void migrateTo(DTMManager manager)
{
}
+
+ public void release()
+ {
+ if (_documentID != 0) {
+ _dtmManager.release(this, true);
+ _documentID = 0;
+ }
+ }
}