author | chegar |
Fri, 07 Jan 2011 21:02:58 +0000 | |
changeset 7969 | 1a6282ab0d2a |
parent 5547 | f4b087cbb361 |
child 22892 | 1709e0e0b87c |
permissions | -rw-r--r-- |
5411
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
1 |
/* |
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5411
diff
changeset
|
2 |
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. |
5411
11ca5b0fb0f2
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. |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
4 |
* |
11ca5b0fb0f2
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 |
11ca5b0fb0f2
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 |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
8 |
* |
11ca5b0fb0f2
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 |
11ca5b0fb0f2
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 |
11ca5b0fb0f2
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 |
11ca5b0fb0f2
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 |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
13 |
* accompanied this code). |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
14 |
* |
11ca5b0fb0f2
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 |
11ca5b0fb0f2
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, |
11ca5b0fb0f2
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. |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
18 |
* |
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5411
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5411
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5411
diff
changeset
|
21 |
* questions. |
5411
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
22 |
* |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
23 |
*/ |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
24 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
25 |
import java.io.ByteArrayOutputStream; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
26 |
import java.io.IOException; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
27 |
import java.io.OutputStream; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
28 |
import java.io.PrintWriter; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
29 |
import java.io.StringWriter; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
30 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
31 |
import java.lang.reflect.Method; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
32 |
import java.net.URI; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
33 |
import java.util.Arrays; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
34 |
import java.util.Vector; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
35 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
36 |
import javax.tools.Diagnostic; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
37 |
import javax.tools.DiagnosticCollector; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
38 |
import javax.tools.FileObject; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
39 |
import javax.tools.ForwardingJavaFileManager; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
40 |
import javax.tools.JavaCompiler; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
41 |
import javax.tools.JavaCompiler.CompilationTask; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
42 |
import javax.tools.JavaFileManager; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
43 |
import javax.tools.JavaFileObject; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
44 |
import javax.tools.JavaFileObject.Kind; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
45 |
import javax.tools.SimpleJavaFileObject; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
46 |
import javax.tools.StandardJavaFileManager; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
47 |
import javax.tools.ToolProvider; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
48 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
49 |
/* |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
50 |
* @test SortMethodsTest |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
51 |
* @bug 6925573 |
11ca5b0fb0f2
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 |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
53 |
methods. |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
54 |
* @run main SortMethodsTest |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
55 |
* @author volker.simonis@gmail.com |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
56 |
*/ |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
57 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
58 |
public class SortMethodsTest { |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
59 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
60 |
static String createClass(String name, int nrOfMethods) { |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
61 |
StringWriter sw = new StringWriter(); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
62 |
PrintWriter pw = new PrintWriter(sw); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
63 |
pw.println("public class " + name + "{"); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
64 |
for (int i = 0; i < nrOfMethods; i++) { |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
65 |
pw.println(" public void m" + i + "() {}"); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
66 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
67 |
pw.println(" public static String sayHello() {"); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
68 |
pw.println(" return \"Hello from class \" + " + name + |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
69 |
".class.getName() + \" with \" + " + name + |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
70 |
".class.getDeclaredMethods().length + \" methods\";"); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
71 |
pw.println(" }"); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
72 |
pw.println("}"); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
73 |
pw.close(); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
74 |
return sw.toString(); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
75 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
76 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
77 |
public static void main(String args[]) { |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
78 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
79 |
JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
80 |
DiagnosticCollector<JavaFileObject> diags = new DiagnosticCollector<JavaFileObject>(); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
81 |
final String cName = new String("ManyMethodsClass"); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
82 |
Vector<Long> results = new Vector<Long>(); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
83 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
84 |
for (int i = 6; i < 600000; i*=10) { |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
85 |
String klass = createClass(cName, i); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
86 |
JavaMemoryFileObject file = new JavaMemoryFileObject(cName, klass); |
11ca5b0fb0f2
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); |
11ca5b0fb0f2
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)); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
89 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
90 |
if (task.call()) { |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
91 |
try { |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
92 |
MemoryClassLoader mcl = new MemoryClassLoader(file); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
93 |
long start = System.nanoTime(); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
94 |
Class<? extends Object> c = Class.forName(cName, true, mcl); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
95 |
long end = System.nanoTime(); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
96 |
results.add(end - start); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
97 |
Method m = c.getDeclaredMethod("sayHello", new Class[0]); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
98 |
String ret = (String)m.invoke(null, new Object[0]); |
11ca5b0fb0f2
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)"); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
100 |
} catch (Exception e) { |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
101 |
System.err.println(e); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
102 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
103 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
104 |
else { |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
105 |
System.out.println(klass); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
106 |
System.out.println(); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
107 |
for (Diagnostic diag : diags.getDiagnostics()) { |
11ca5b0fb0f2
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()); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
109 |
System.out.println(diag.getSource() + "\n" + diag.getMessage(null)); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
110 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
111 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
112 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
113 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
114 |
long lastRatio = 0; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
115 |
for (int i = 2; i < results.size(); i++) { |
11ca5b0fb0f2
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); |
11ca5b0fb0f2
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); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
118 |
long ratio = normalized2/normalized1; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
119 |
lastRatio = ratio; |
11ca5b0fb0f2
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"); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
121 |
} |
11ca5b0fb0f2
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 |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
123 |
if (lastRatio > 80) { |
11ca5b0fb0f2
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!!!"); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
125 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
126 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
127 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
128 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
129 |
class JavaMemoryFileObject extends SimpleJavaFileObject { |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
130 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
131 |
private final String code; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
132 |
private ByteArrayOutputStream byteCode; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
133 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
134 |
JavaMemoryFileObject(String name, String code) { |
11ca5b0fb0f2
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); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
136 |
this.code = code; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
137 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
138 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
139 |
@Override |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
140 |
public CharSequence getCharContent(boolean ignoreEncodingErrors) { |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
141 |
return code; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
142 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
143 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
144 |
@Override |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
145 |
public OutputStream openOutputStream() { |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
146 |
byteCode = new ByteArrayOutputStream(); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
147 |
return byteCode; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
148 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
149 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
150 |
byte[] getByteCode() { |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
151 |
return byteCode.toByteArray(); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
152 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
153 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
154 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
155 |
class MemoryClassLoader extends ClassLoader { |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
156 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
157 |
private final JavaMemoryFileObject jfo; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
158 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
159 |
public MemoryClassLoader(JavaMemoryFileObject jfo) { |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
160 |
this.jfo = jfo; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
161 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
162 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
163 |
public Class findClass(String name) { |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
164 |
byte[] b = jfo.getByteCode(); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
165 |
return defineClass(name, b, 0, b.length); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
166 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
167 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
168 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
169 |
class MemoryFileManager extends ForwardingJavaFileManager<JavaFileManager> { |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
170 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
171 |
private final JavaFileObject jfo; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
172 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
173 |
public MemoryFileManager(StandardJavaFileManager jfm, JavaFileObject jfo) { |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
174 |
super(jfm); |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
175 |
this.jfo = jfo; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
176 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
177 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
178 |
@Override |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
179 |
public FileObject getFileForInput(Location location, String packageName, |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
180 |
String relativeName) throws IOException { |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
181 |
return jfo; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
182 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
183 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
184 |
@Override |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
185 |
public JavaFileObject getJavaFileForOutput(Location location, String qualifiedName, |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
186 |
Kind kind, FileObject outputFile) throws IOException { |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
187 |
return jfo; |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
188 |
} |
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
189 |
|
11ca5b0fb0f2
6935118: UseCompressedOops modification in methodOopDesc::sort_methods() causes JCK timeout
coleenp
parents:
diff
changeset
|
190 |
} |