< prev index next >
src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Sort.java
Print this page
rev 886 : 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
*** 1,8 ****
/*
! * reserved comment block
! * DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
--- 1,7 ----
/*
! * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
*** 15,50 ****
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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;
import com.sun.org.apache.bcel.internal.generic.NEW;
import com.sun.org.apache.bcel.internal.generic.NOP;
--- 14,39 ----
*** 74,90 ****
private Expression _select;
private AttributeValue _order;
private AttributeValue _caseOrder;
private AttributeValue _dataType;
! private String _lang; // bug! see 26869
!
! private String _data = null;
!
private String _className = null;
! private ArrayList _closureVars = null;
private boolean _needsSortRecordFactory = false;
// -- Begin Closure interface --------------------
/**
--- 63,76 ----
private Expression _select;
private AttributeValue _order;
private AttributeValue _caseOrder;
private AttributeValue _dataType;
! private String _lang; // bug! see 26869
private String _className = null;
! private ArrayList<VariableRefBase> _closureVars = null;
private boolean _needsSortRecordFactory = false;
// -- Begin Closure interface --------------------
/**
*** 113,123 ****
/**
* Add new variable to the closure.
*/
public void addVariable(VariableRefBase variableRef) {
if (_closureVars == null) {
! _closureVars = new ArrayList();
}
// Only one reference per variable
if (!_closureVars.contains(variableRef)) {
_closureVars.add(variableRef);
--- 99,109 ----
/**
* Add new variable to the closure.
*/
public void addVariable(VariableRefBase variableRef) {
if (_closureVars == null) {
! _closureVars = new ArrayList<>();
}
// Only one reference per variable
if (!_closureVars.contains(variableRef)) {
_closureVars.add(variableRef);
*** 244,254 ****
* and a node sort record producing objects as its parameters.
*/
public static void translateSortIterator(ClassGenerator classGen,
MethodGenerator methodGen,
Expression nodeSet,
! Vector sortObjects)
{
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
// SortingIterator.SortingIterator(NodeIterator,NodeSortRecordFactory);
--- 230,240 ----
* and a node sort record producing objects as its parameters.
*/
public static void translateSortIterator(ClassGenerator classGen,
MethodGenerator methodGen,
Expression nodeSet,
! Vector<Sort> sortObjects)
{
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
// SortingIterator.SortingIterator(NodeIterator,NodeSortRecordFactory);
*** 310,329 ****
/**
* Compiles code that instantiates a NodeSortRecordFactory object which
* will produce NodeSortRecord objects of a specific type.
*/
! public static void compileSortRecordFactory(Vector sortObjects,
ClassGenerator classGen, MethodGenerator methodGen)
{
String sortRecordClass =
compileSortRecord(sortObjects, classGen, methodGen);
boolean needsSortRecordFactory = false;
final int nsorts = sortObjects.size();
for (int i = 0; i < nsorts; i++) {
! final Sort sort = (Sort) sortObjects.elementAt(i);
needsSortRecordFactory |= sort._needsSortRecordFactory;
}
String sortRecordFactoryClass = NODE_SORT_FACTORY;
if (needsSortRecordFactory) {
--- 296,315 ----
/**
* Compiles code that instantiates a NodeSortRecordFactory object which
* will produce NodeSortRecord objects of a specific type.
*/
! public static void compileSortRecordFactory(Vector<Sort> sortObjects,
ClassGenerator classGen, MethodGenerator methodGen)
{
String sortRecordClass =
compileSortRecord(sortObjects, classGen, methodGen);
boolean needsSortRecordFactory = false;
final int nsorts = sortObjects.size();
for (int i = 0; i < nsorts; i++) {
! final Sort sort = sortObjects.elementAt(i);
needsSortRecordFactory |= sort._needsSortRecordFactory;
}
String sortRecordFactoryClass = NODE_SORT_FACTORY;
if (needsSortRecordFactory) {
*** 427,445 ****
+ "[" + STRING_SIG
+ "[" + STRING_SIG
+ "[" + STRING_SIG + ")V")));
// Initialize closure variables in sortRecordFactory
! final ArrayList dups = new ArrayList();
for (int j = 0; j < nsorts; j++) {
final Sort sort = (Sort) sortObjects.get(j);
final int length = (sort._closureVars == null) ? 0 :
sort._closureVars.size();
for (int i = 0; i < length; i++) {
! VariableRefBase varRef = (VariableRefBase) sort._closureVars.get(i);
// Discard duplicate variable references
if (dups.contains(varRef)) continue;
final VariableBase var = varRef.getVariable();
--- 413,431 ----
+ "[" + STRING_SIG
+ "[" + STRING_SIG
+ "[" + STRING_SIG + ")V")));
// Initialize closure variables in sortRecordFactory
! final ArrayList<VariableRefBase> dups = new ArrayList<>();
for (int j = 0; j < nsorts; j++) {
final Sort sort = (Sort) sortObjects.get(j);
final int length = (sort._closureVars == null) ? 0 :
sort._closureVars.size();
for (int i = 0; i < length; i++) {
! VariableRefBase varRef = sort._closureVars.get(i);
// Discard duplicate variable references
if (dups.contains(varRef)) continue;
final VariableBase var = varRef.getVariable();
*** 453,467 ****
dups.add(varRef);
}
}
}
! public static String compileSortRecordFactory(Vector sortObjects,
ClassGenerator classGen, MethodGenerator methodGen,
String sortRecordClass)
{
! final XSLTC xsltc = ((Sort)sortObjects.firstElement()).getXSLTC();
final String className = xsltc.getHelperClassName();
final NodeSortRecordFactGenerator sortRecordFactory =
new NodeSortRecordFactGenerator(className,
NODE_SORT_FACTORY,
--- 439,453 ----
dups.add(varRef);
}
}
}
! public static String compileSortRecordFactory(Vector<Sort> sortObjects,
ClassGenerator classGen, MethodGenerator methodGen,
String sortRecordClass)
{
! final XSLTC xsltc = (sortObjects.firstElement()).getXSLTC();
final String className = xsltc.getHelperClassName();
final NodeSortRecordFactGenerator sortRecordFactory =
new NodeSortRecordFactGenerator(className,
NODE_SORT_FACTORY,
*** 472,490 ****
ConstantPoolGen cpg = sortRecordFactory.getConstantPool();
// Add a new instance variable for each var in closure
final int nsorts = sortObjects.size();
! final ArrayList dups = new ArrayList();
for (int j = 0; j < nsorts; j++) {
! final Sort 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);
// Discard duplicate variable references
if (dups.contains(varRef)) continue;
final VariableBase var = varRef.getVariable();
--- 458,476 ----
ConstantPoolGen cpg = sortRecordFactory.getConstantPool();
// Add a new instance variable for each var in closure
final int nsorts = sortObjects.size();
! final ArrayList<VariableRefBase> dups = new ArrayList<>();
for (int j = 0; j < nsorts; 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 = sort._closureVars.get(i);
// Discard duplicate variable references
if (dups.contains(varRef)) continue;
final VariableBase var = varRef.getVariable();
*** 598,611 ****
}
/**
* Create a new auxillary class extending NodeSortRecord.
*/
! private static String compileSortRecord(Vector sortObjects,
ClassGenerator classGen,
MethodGenerator methodGen) {
! final XSLTC xsltc = ((Sort)sortObjects.firstElement()).getXSLTC();
final String className = xsltc.getHelperClassName();
// This generates a new class for handling this specific sort
final NodeSortRecordGenerator sortRecord =
new NodeSortRecordGenerator(className,
--- 584,597 ----
}
/**
* Create a new auxillary class extending NodeSortRecord.
*/
! private static String compileSortRecord(Vector<Sort> sortObjects,
ClassGenerator classGen,
MethodGenerator methodGen) {
! final XSLTC xsltc = sortObjects.firstElement().getXSLTC();
final String className = xsltc.getHelperClassName();
// This generates a new class for handling this specific sort
final NodeSortRecordGenerator sortRecord =
new NodeSortRecordGenerator(className,
*** 617,630 ****
final ConstantPoolGen cpg = sortRecord.getConstantPool();
// Add a new instance variable for each var in closure
final int nsorts = sortObjects.size();
! final ArrayList dups = new ArrayList();
for (int j = 0; j < nsorts; j++) {
! final Sort sort = (Sort) sortObjects.get(j);
// Set the name of the inner class in this sort object
sort.setInnerClassName(className);
final int length = (sort._closureVars == null) ? 0 :
--- 603,616 ----
final ConstantPoolGen cpg = sortRecord.getConstantPool();
// Add a new instance variable for each var in closure
final int nsorts = sortObjects.size();
! final ArrayList<VariableRefBase> dups = new ArrayList<>();
for (int j = 0; j < nsorts; j++) {
! final Sort sort = sortObjects.get(j);
// Set the name of the inner class in this sort object
sort.setInnerClassName(className);
final int length = (sort._closureVars == null) ? 0 :
*** 642,653 ****
null, cpg.getConstantPool()));
dups.add(varRef);
}
}
! MethodGenerator init = compileInit(sortObjects, sortRecord,
! cpg, className);
MethodGenerator extract = compileExtract(sortObjects, sortRecord,
cpg, className);
sortRecord.addMethod(init);
sortRecord.addMethod(extract);
--- 628,638 ----
null, cpg.getConstantPool()));
dups.add(varRef);
}
}
! MethodGenerator init = compileInit(sortRecord, cpg, className);
MethodGenerator extract = compileExtract(sortObjects, sortRecord,
cpg, className);
sortRecord.addMethod(init);
sortRecord.addMethod(extract);
*** 658,669 ****
/**
* Create a constructor for the new class. Updates the reference to the
* collator in the super calls only when the stylesheet specifies a new
* language in xsl:sort.
*/
! private static MethodGenerator compileInit(Vector sortObjects,
! NodeSortRecordGenerator sortRecord,
ConstantPoolGen cpg,
String className)
{
final InstructionList il = new InstructionList();
final MethodGenerator init =
--- 643,653 ----
/**
* Create a constructor for the new class. Updates the reference to the
* collator in the super calls only when the stylesheet specifies a new
* language in xsl:sort.
*/
! private static MethodGenerator compileInit(NodeSortRecordGenerator sortRecord,
ConstantPoolGen cpg,
String className)
{
final InstructionList il = new InstructionList();
final MethodGenerator init =
*** 686,696 ****
/**
* Compiles a method that overloads NodeSortRecord.extractValueFromDOM()
*/
! private static MethodGenerator compileExtract(Vector sortObjects,
NodeSortRecordGenerator sortRecord,
ConstantPoolGen cpg,
String className) {
final InstructionList il = new InstructionList();
--- 670,680 ----
/**
* Compiles a method that overloads NodeSortRecord.extractValueFromDOM()
*/
! private static MethodGenerator compileExtract(Vector<Sort> sortObjects,
NodeSortRecordGenerator sortRecord,
ConstantPoolGen cpg,
String className) {
final InstructionList il = new InstructionList();
*** 728,738 ****
}
// 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);
target[level] = il.append(NOP);
sort.translateSelect(sortRecord, extractMethod);
il.append(ARETURN);
}
--- 712,722 ----
}
// Append all the cases for the switch statment
for (int level = 0; level < levels; level++) {
match[level] = level;
! final Sort sort = sortObjects.elementAt(level);
target[level] = il.append(NOP);
sort.translateSelect(sortRecord, extractMethod);
il.append(ARETURN);
}
< prev index next >