author | hannesw |
Tue, 22 Mar 2016 14:23:16 +0100 | |
changeset 36690 | 06b714373aa4 |
parent 32547 | dea8ac70d849 |
child 36526 | 3b41f1c69604 |
permissions | -rw-r--r-- |
32454
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
1 |
/* |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
4 |
* |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
8 |
* |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
13 |
* accompanied this code). |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
14 |
* |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
18 |
* |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
21 |
* questions. |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
22 |
*/ |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
23 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
24 |
package combo; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
25 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
26 |
import com.sun.source.tree.ClassTree; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
27 |
import com.sun.source.tree.CompilationUnitTree; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
28 |
import com.sun.source.util.JavacTask; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
29 |
import com.sun.source.util.TaskEvent; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
30 |
import com.sun.source.util.TaskEvent.Kind; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
31 |
import com.sun.source.util.TaskListener; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
32 |
import com.sun.source.util.TreeScanner; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
33 |
import com.sun.tools.javac.api.MultiTaskListener; |
32547
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
34 |
import com.sun.tools.javac.code.Kinds; |
32454
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
35 |
import com.sun.tools.javac.code.Symbol; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
36 |
import com.sun.tools.javac.code.Symtab; |
32547
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
37 |
import com.sun.tools.javac.code.Type; |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
38 |
import com.sun.tools.javac.code.Type.ClassType; |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
39 |
import com.sun.tools.javac.code.TypeTag; |
32454
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
40 |
import com.sun.tools.javac.code.Types; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
41 |
import com.sun.tools.javac.comp.Check; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
42 |
import com.sun.tools.javac.comp.CompileStates; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
43 |
import com.sun.tools.javac.comp.Enter; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
44 |
import com.sun.tools.javac.main.Arguments; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
45 |
import com.sun.tools.javac.main.JavaCompiler; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
46 |
import com.sun.tools.javac.tree.JCTree.JCClassDecl; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
47 |
import com.sun.tools.javac.util.Context; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
48 |
import com.sun.tools.javac.util.Log; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
49 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
50 |
import javax.tools.Diagnostic; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
51 |
import javax.tools.DiagnosticListener; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
52 |
import javax.tools.JavaFileManager; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
53 |
import javax.tools.JavaFileObject; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
54 |
import java.util.HashSet; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
55 |
import java.util.Set; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
56 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
57 |
/** |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
58 |
* A reusable context is a context that can be used safely across multiple compilation rounds |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
59 |
* arising from execution of a combo test. It achieves reuse by replacing some components |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
60 |
* (most notably JavaCompiler and Log) with reusable counterparts, and by exposing a method |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
61 |
* to cleanup leftovers from previous compilation. |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
62 |
* <p> |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
63 |
* There are, however, situations in which reusing the context is not safe: (i) when different |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
64 |
* compilations are using different sets of compiler options (as most option values are cached |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
65 |
* inside components themselves) and (ii) when the compilation unit happens to redefine classes |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
66 |
* in the java.* packages. |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
67 |
*/ |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
68 |
class ReusableContext extends Context implements TaskListener { |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
69 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
70 |
Set<CompilationUnitTree> roots = new HashSet<>(); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
71 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
72 |
String opts; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
73 |
boolean polluted = false; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
74 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
75 |
ReusableContext() { |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
76 |
super(); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
77 |
put(Log.logKey, ReusableLog.factory); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
78 |
put(JavaCompiler.compilerKey, ReusableJavaCompiler.factory); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
79 |
} |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
80 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
81 |
void clear() { |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
82 |
drop(Arguments.argsKey); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
83 |
drop(DiagnosticListener.class); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
84 |
drop(Log.outKey); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
85 |
drop(JavaFileManager.class); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
86 |
drop(JavacTask.class); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
87 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
88 |
if (ht.get(Log.logKey) instanceof ReusableLog) { |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
89 |
//log already inited - not first round |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
90 |
((ReusableLog)Log.instance(this)).clear(); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
91 |
Enter.instance(this).newRound(); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
92 |
((ReusableJavaCompiler)ReusableJavaCompiler.instance(this)).clear(); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
93 |
Types.instance(this).newRound(); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
94 |
Check.instance(this).newRound(); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
95 |
CompileStates.instance(this).clear(); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
96 |
MultiTaskListener.instance(this).clear(); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
97 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
98 |
//find if any of the roots have redefined java.* classes |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
99 |
Symtab syms = Symtab.instance(this); |
32547
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
100 |
pollutionScanner.scan(roots, syms); |
32454
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
101 |
roots.clear(); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
102 |
} |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
103 |
} |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
104 |
|
32547
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
105 |
/** |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
106 |
* This scanner detects as to whether the shared context has been polluted. This happens |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
107 |
* whenever a compiled program redefines a core class (in 'java.*' package) or when |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
108 |
* (typically because of cyclic inheritance) the symbol kind of a core class has been touched. |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
109 |
*/ |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
110 |
TreeScanner<Void, Symtab> pollutionScanner = new TreeScanner<Void, Symtab>() { |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
111 |
@Override |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
112 |
public Void visitClass(ClassTree node, Symtab syms) { |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
113 |
Symbol sym = ((JCClassDecl)node).sym; |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
114 |
if (sym != null) { |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
115 |
syms.classes.remove(sym.flatName()); |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
116 |
Type sup = supertype(sym); |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
117 |
if (isCoreClass(sym) || |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
118 |
(sup != null && isCoreClass(sup.tsym) && sup.tsym.kind != Kinds.Kind.TYP)) { |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
119 |
polluted = true; |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
120 |
} |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
121 |
} |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
122 |
return super.visitClass(node, syms); |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
123 |
} |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
124 |
|
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
125 |
private boolean isCoreClass(Symbol s) { |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
126 |
return s.flatName().toString().startsWith("java."); |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
127 |
} |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
128 |
|
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
129 |
private Type supertype(Symbol s) { |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
130 |
if (s.type == null || |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
131 |
!s.type.hasTag(TypeTag.CLASS)) { |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
132 |
return null; |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
133 |
} else { |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
134 |
ClassType ct = (ClassType)s.type; |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
135 |
return ct.supertype_field; |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
136 |
} |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
137 |
} |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
138 |
}; |
dea8ac70d849
8135246: CheckAttributedTree silently generates spurious compiler error
mcimadamore
parents:
32454
diff
changeset
|
139 |
|
32454
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
140 |
@Override |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
141 |
public void finished(TaskEvent e) { |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
142 |
if (e.getKind() == Kind.PARSE) { |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
143 |
roots.add(e.getCompilationUnit()); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
144 |
} |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
145 |
} |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
146 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
147 |
@Override |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
148 |
public void started(TaskEvent e) { |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
149 |
//do nothing |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
150 |
} |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
151 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
152 |
<T> void drop(Key<T> k) { |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
153 |
ht.remove(k); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
154 |
} |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
155 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
156 |
<T> void drop(Class<T> c) { |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
157 |
ht.remove(key(c)); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
158 |
} |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
159 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
160 |
/** |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
161 |
* Reusable JavaCompiler; exposes a method to clean up the component from leftovers associated with |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
162 |
* previous compilations. |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
163 |
*/ |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
164 |
static class ReusableJavaCompiler extends JavaCompiler { |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
165 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
166 |
static Factory<JavaCompiler> factory = ReusableJavaCompiler::new; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
167 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
168 |
ReusableJavaCompiler(Context context) { |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
169 |
super(context); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
170 |
} |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
171 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
172 |
@Override |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
173 |
public void close() { |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
174 |
//do nothing |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
175 |
} |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
176 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
177 |
void clear() { |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
178 |
newRound(); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
179 |
} |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
180 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
181 |
@Override |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
182 |
protected void checkReusable() { |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
183 |
//do nothing - it's ok to reuse the compiler |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
184 |
} |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
185 |
} |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
186 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
187 |
/** |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
188 |
* Reusable Log; exposes a method to clean up the component from leftovers associated with |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
189 |
* previous compilations. |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
190 |
*/ |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
191 |
static class ReusableLog extends Log { |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
192 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
193 |
static Factory<Log> factory = ReusableLog::new; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
194 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
195 |
Context context; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
196 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
197 |
ReusableLog(Context context) { |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
198 |
super(context); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
199 |
this.context = context; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
200 |
} |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
201 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
202 |
void clear() { |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
203 |
recorded.clear(); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
204 |
sourceMap.clear(); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
205 |
nerrors = 0; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
206 |
nwarnings = 0; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
207 |
//Set a fake listener that will lazily lookup the context for the 'real' listener. Since |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
208 |
//this field is never updated when a new task is created, we cannot simply reset the field |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
209 |
//or keep old value. This is a hack to workaround the limitations in the current infrastructure. |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
210 |
diagListener = new DiagnosticListener<JavaFileObject>() { |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
211 |
DiagnosticListener<JavaFileObject> cachedListener; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
212 |
|
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
213 |
@Override |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
214 |
@SuppressWarnings("unchecked") |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
215 |
public void report(Diagnostic<? extends JavaFileObject> diagnostic) { |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
216 |
if (cachedListener == null) { |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
217 |
cachedListener = context.get(DiagnosticListener.class); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
218 |
} |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
219 |
cachedListener.report(diagnostic); |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
220 |
} |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
221 |
}; |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
222 |
} |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
223 |
} |
b0ac04e0fefe
8129962: Investigate performance improvements in langtools combo tests
mcimadamore
parents:
diff
changeset
|
224 |
} |