Mercurial > hg > truffle
annotate test/runtime/6925573/SortMethodsTest.java @ 18529:ab86fa952750
removed static access to HotSpotGraalRuntime from some SPARC HotSpot classes
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 26 Nov 2014 13:08:18 +0100 |
parents | 4ca6dc0799b6 |
children |
rev | line source |
---|---|
1498
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1498
diff
changeset
|
2 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. |
1498
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
4 * |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
8 * |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
13 * accompanied this code). |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
14 * |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
18 * |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1498
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1498
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1498
diff
changeset
|
21 * questions. |
1498
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
22 * |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
23 */ |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
24 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
25 import java.io.ByteArrayOutputStream; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
26 import java.io.IOException; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
27 import java.io.OutputStream; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
28 import java.io.PrintWriter; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
29 import java.io.StringWriter; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
30 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
31 import java.lang.reflect.Method; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
32 import java.net.URI; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
33 import java.util.Arrays; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
34 import java.util.Vector; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
35 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
36 import javax.tools.Diagnostic; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
37 import javax.tools.DiagnosticCollector; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
38 import javax.tools.FileObject; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
39 import javax.tools.ForwardingJavaFileManager; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
40 import javax.tools.JavaCompiler; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
41 import javax.tools.JavaCompiler.CompilationTask; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
42 import javax.tools.JavaFileManager; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
43 import javax.tools.JavaFileObject; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
44 import javax.tools.JavaFileObject.Kind; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
45 import javax.tools.SimpleJavaFileObject; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
46 import javax.tools.StandardJavaFileManager; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
47 import javax.tools.ToolProvider; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
48 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
49 /* |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
50 * @test SortMethodsTest |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
51 * @bug 6925573 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
52 * @summary verify that class loading does not need quadratic time with regard to the number of class |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
53 methods. |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
54 * @run main SortMethodsTest |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
55 * @author volker.simonis@gmail.com |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
56 */ |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
57 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
58 public class SortMethodsTest { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
59 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
60 static String createClass(String name, int nrOfMethods) { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
61 StringWriter sw = new StringWriter(); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
62 PrintWriter pw = new PrintWriter(sw); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
63 pw.println("public class " + name + "{"); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
64 for (int i = 0; i < nrOfMethods; i++) { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
65 pw.println(" public void m" + i + "() {}"); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
66 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
67 pw.println(" public static String sayHello() {"); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
68 pw.println(" return \"Hello from class \" + " + name + |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
69 ".class.getName() + \" with \" + " + name + |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
70 ".class.getDeclaredMethods().length + \" methods\";"); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
71 pw.println(" }"); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
72 pw.println("}"); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
73 pw.close(); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
74 return sw.toString(); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
75 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
76 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
77 public static void main(String args[]) { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
78 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
79 JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
80 DiagnosticCollector<JavaFileObject> diags = new DiagnosticCollector<JavaFileObject>(); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
81 final String cName = new String("ManyMethodsClass"); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
82 Vector<Long> results = new Vector<Long>(); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
83 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
84 for (int i = 6; i < 600000; i*=10) { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
85 String klass = createClass(cName, i); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
86 JavaMemoryFileObject file = new JavaMemoryFileObject(cName, klass); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
87 MemoryFileManager mfm = new MemoryFileManager(comp.getStandardFileManager(diags, null, null), file); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
88 CompilationTask task = comp.getTask(null, mfm, diags, null, null, Arrays.asList(file)); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
89 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
90 if (task.call()) { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
91 try { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
92 MemoryClassLoader mcl = new MemoryClassLoader(file); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
93 long start = System.nanoTime(); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
94 Class<? extends Object> c = Class.forName(cName, true, mcl); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
95 long end = System.nanoTime(); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
96 results.add(end - start); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
97 Method m = c.getDeclaredMethod("sayHello", new Class[0]); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
98 String ret = (String)m.invoke(null, new Object[0]); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
99 System.out.println(ret + " (loaded and resloved in " + (end - start) + "ns)"); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
100 } catch (Exception e) { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
101 System.err.println(e); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
102 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
103 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
104 else { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
105 System.out.println(klass); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
106 System.out.println(); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
107 for (Diagnostic diag : diags.getDiagnostics()) { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
108 System.out.println(diag.getCode() + "\n" + diag.getKind() + "\n" + diag.getPosition()); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
109 System.out.println(diag.getSource() + "\n" + diag.getMessage(null)); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
110 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
111 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
112 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
113 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
114 long lastRatio = 0; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
115 for (int i = 2; i < results.size(); i++) { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
116 long normalized1 = Math.max(results.get(i-1) - results.get(0), 1); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
117 long normalized2 = Math.max(results.get(i) - results.get(0), 1); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
118 long ratio = normalized2/normalized1; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
119 lastRatio = ratio; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
120 System.out.println("10 x more methods requires " + ratio + " x more time"); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
121 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
122 // The following is just vague estimation but seems to work on current x86_64 and sparcv9 machines |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
123 if (lastRatio > 80) { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
124 throw new RuntimeException("ATTENTION: it seems that class loading needs quadratic time with regard to the number of class methods!!!"); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
125 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
126 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
127 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
128 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
129 class JavaMemoryFileObject extends SimpleJavaFileObject { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
130 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
131 private final String code; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
132 private ByteArrayOutputStream byteCode; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
133 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
134 JavaMemoryFileObject(String name, String code) { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
135 super(URI.create("string:///" + name.replace('.','/') + Kind.SOURCE.extension), Kind.SOURCE); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
136 this.code = code; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
137 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
138 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
139 @Override |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
140 public CharSequence getCharContent(boolean ignoreEncodingErrors) { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
141 return code; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
142 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
143 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
144 @Override |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
145 public OutputStream openOutputStream() { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
146 byteCode = new ByteArrayOutputStream(); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
147 return byteCode; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
148 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
149 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
150 byte[] getByteCode() { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
151 return byteCode.toByteArray(); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
152 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
153 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
154 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
155 class MemoryClassLoader extends ClassLoader { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
156 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
157 private final JavaMemoryFileObject jfo; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
158 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
159 public MemoryClassLoader(JavaMemoryFileObject jfo) { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
160 this.jfo = jfo; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
161 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
162 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
163 public Class findClass(String name) { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
164 byte[] b = jfo.getByteCode(); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
165 return defineClass(name, b, 0, b.length); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
166 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
167 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
168 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
169 class MemoryFileManager extends ForwardingJavaFileManager<JavaFileManager> { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
170 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
171 private final JavaFileObject jfo; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
172 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
173 public MemoryFileManager(StandardJavaFileManager jfm, JavaFileObject jfo) { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
174 super(jfm); |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
175 this.jfo = jfo; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
176 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
177 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
178 @Override |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
179 public FileObject getFileForInput(Location location, String packageName, |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
180 String relativeName) throws IOException { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
181 return jfo; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
182 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
183 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
184 @Override |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
185 public JavaFileObject getJavaFileForOutput(Location location, String qualifiedName, |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
186 Kind kind, FileObject outputFile) throws IOException { |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
187 return jfo; |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
188 } |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
189 |
77261afdc5f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
190 } |