Skip to content

Commit

Permalink
8273278: Support XSLT on GraalVM Native Image--deterministic bytecode…
Browse files Browse the repository at this point in the history
… generation in XSLT

Reviewed-by: joehw
  • Loading branch information
jovanstevanovic authored and JoeWang-Java committed Sep 10, 2021
1 parent 5e1df2c commit f690a01
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
Expand Down Expand Up @@ -33,6 +33,7 @@
import com.sun.org.apache.xml.internal.serializer.ToHTMLStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
Expand All @@ -42,7 +43,7 @@
* @author Jacek Ambroziak
* @author Santiago Pericas-Geertsen
* @author Morten Jorgensen
* @LastModified: Oct 2017
* @LastModified: Sep 2021
*/
final class LiteralElement extends Instruction {

Expand Down Expand Up @@ -202,7 +203,7 @@ public Type typeCheck(SymbolTable stable) throws TypeCheckError {
* to _ANY_ namespace URI. Used by literal result elements to determine
*/
public Set<Map.Entry<String, String>> getNamespaceScope(SyntaxTreeNode node) {
Map<String, String> all = new HashMap<>();
Map<String, String> all = new LinkedHashMap<>();

while (node != null) {
Map<String, String> mapping = node.getPrefixMapping();
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
Expand Down Expand Up @@ -48,6 +48,7 @@
import com.sun.org.apache.xml.internal.dtm.DTM;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand All @@ -62,7 +63,7 @@
* @author Morten Jorgensen
* @author Erwin Bolwidt <ejb@klomp.org>
* @author G. Todd Miller
* @LastModified: Nov 2017
* @LastModified: Sep 2021
*/
final class Mode implements Constants {

Expand Down Expand Up @@ -129,13 +130,15 @@ final class Mode implements Constants {

/**
* A mapping between templates and test sequences.
* {@link LinkedHashMap} is necessary to make traversal order consistent across runs.
*/
private Map<Template, Object> _neededTemplates = new HashMap<>();
private Map<Template, Object> _neededTemplates = new LinkedHashMap<>();

/**
* A mapping between named templates and Mode objects.
* {@link LinkedHashMap} is necessary to make traversal order consistent across runs.
*/
private Map<Template, Mode> _namedTemplates = new HashMap<>();
private Map<Template, Mode> _namedTemplates = new LinkedHashMap<>();

/**
* A mapping between templates and instruction handles.
Expand Down Expand Up @@ -198,7 +201,7 @@ public String functionName() {

public String functionName(int min, int max) {
if (_importLevels == null) {
_importLevels = new HashMap<>();
_importLevels = new LinkedHashMap<>();
}
_importLevels.put(max, min);
return _methodName + '_' + max;
Expand Down Expand Up @@ -1053,8 +1056,8 @@ public void compileApplyImports(ClassGenerator classGen, int min, int max) {
final List<String> names = xsltc.getNamesIndex();

// Clear some datastructures
_namedTemplates = new HashMap<>();
_neededTemplates = new HashMap<>();
_namedTemplates = new LinkedHashMap<>();
_neededTemplates = new LinkedHashMap<>();
_templateIHs = new HashMap<>();
_templateILs = new HashMap<>();
_patternGroups = (List<LocationPathPattern>[])new ArrayList[32];
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
Expand Down Expand Up @@ -53,7 +53,7 @@
/**
* @author Jacek Ambroziak
* @author Santiago Pericas-Geertsen
* @LastModified: Nov 2017
* @LastModified: Sep 2021
*/
final class Number extends Instruction implements Closure {
private static final int LEVEL_SINGLE = 0;
Expand Down Expand Up @@ -383,7 +383,7 @@ private void compilePatterns(ClassGenerator classGen,
_className = getXSLTC().getHelperClassName();
nodeCounterGen = new NodeCounterGenerator(_className,
ClassNames[_level],
toString(),
getClass().getName(), // Name of this node should be consistent across runs.
ACC_PUBLIC | ACC_SUPER,
null,
classGen.getStylesheet());
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
Expand Down Expand Up @@ -67,6 +67,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand All @@ -75,7 +76,7 @@
/**
* @author Jacek Ambroziak
* @author Santiago Pericas-Geertsen
* @LastModified: July 2019
* @LastModified: Sep 2021
*/
public class MethodGenerator extends MethodGen
implements com.sun.org.apache.xalan.internal.xsltc.compiler.Constants {
Expand Down Expand Up @@ -283,7 +284,7 @@ protected class LocalVariableRegistry {
/**
* Maps a name to a {@link LocalVariableGen}
*/
protected Map<String, Object> _nameToLVGMap = new HashMap<>();
protected Map<String, Object> _nameToLVGMap = new LinkedHashMap<>();

/**
* Registers a {@link org.apache.bcel.generic.LocalVariableGen}
Expand Down Expand Up @@ -1330,8 +1331,8 @@ public boolean isExternal() {
// to local variables in the outlined method.
HashMap<LocalVariableGen, LocalVariableGen> localVarMap = new HashMap<>();

HashMap<LocalVariableGen, InstructionHandle> revisedLocalVarStart = new HashMap<>();
HashMap<LocalVariableGen, InstructionHandle> revisedLocalVarEnd = new HashMap<>();
HashMap<LocalVariableGen, InstructionHandle> revisedLocalVarStart = new LinkedHashMap<>();
HashMap<LocalVariableGen, InstructionHandle> revisedLocalVarEnd = new LinkedHashMap<>();

// Pass 1: Make copies of all instructions, append them to the new list
// and associate old instruction references with the new ones, i.e.,
Expand Down

1 comment on commit f690a01

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.