Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java @ 18223:17c98fad6980
converted HotSpotResolvedObjectType to an interface
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 03 Nov 2014 17:03:19 +0100 |
parents | 2bf5ea10eea7 |
children | 0f41072d8bbc |
rev | line source |
---|---|
9108 | 1 /* |
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.graal.hotspot; | |
24 | |
15259
d90e5c22ba55
Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15193
diff
changeset
|
25 import static com.oracle.graal.compiler.common.GraalOptions.*; |
16722
46eaf7cd8275
added memory usage analysis to CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
16480
diff
changeset
|
26 import static com.oracle.graal.debug.internal.MemUseTrackerImpl.*; |
9289
261a43921c5e
rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents:
9108
diff
changeset
|
27 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
28 import static com.oracle.graal.nodes.StructuredGraph.*; |
9289
261a43921c5e
rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents:
9108
diff
changeset
|
29 |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
10672
diff
changeset
|
30 import java.io.*; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
10672
diff
changeset
|
31 import java.lang.reflect.*; |
9108 | 32 import java.net.*; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
10672
diff
changeset
|
33 import java.util.*; |
9108 | 34 import java.util.jar.*; |
35 | |
36 import com.oracle.graal.api.meta.*; | |
13362
9fd85def8368
made CompileTheWorld ignore profiling info
Doug Simon <doug.simon@oracle.com>
parents:
13361
diff
changeset
|
37 import com.oracle.graal.api.meta.ProfilingInfo.TriState; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
10672
diff
changeset
|
38 import com.oracle.graal.bytecode.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15077
diff
changeset
|
39 import com.oracle.graal.compiler.common.*; |
9108 | 40 import com.oracle.graal.debug.*; |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
41 import com.oracle.graal.hotspot.HotSpotOptions.OptionConsumer; |
9108 | 42 import com.oracle.graal.hotspot.meta.*; |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
43 import com.oracle.graal.options.*; |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
44 import com.oracle.graal.options.OptionValue.OverrideScope; |
9108 | 45 import com.oracle.graal.replacements.*; |
46 | |
47 /** | |
48 * This class implements compile-the-world functionality in Graal. | |
49 */ | |
50 public final class CompileTheWorld { | |
51 | |
13361
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
52 /** |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
53 * Magic token to trigger reading files from the boot class path. |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
54 */ |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
55 public static final String SUN_BOOT_CLASS_PATH = "sun.boot.class.path"; |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
56 |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
57 public static class Options { |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
58 // @formatter:off |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
59 @Option(help = "Compile all methods in all classes on given class path") |
13361
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
60 public static final OptionValue<String> CompileTheWorldClasspath = new OptionValue<>(SUN_BOOT_CLASS_PATH); |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
61 @Option(help = "Verbose CompileTheWorld operation") |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
62 public static final OptionValue<Boolean> CompileTheWorldVerbose = new OptionValue<>(true); |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
63 @Option(help = "The number of CompileTheWorld iterations to perform") |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
64 public static final OptionValue<Integer> CompileTheWorldIterations = new OptionValue<>(1); |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
65 @Option(help = "First class to consider when using -XX:+CompileTheWorld") |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
66 public static final OptionValue<Integer> CompileTheWorldStartAt = new OptionValue<>(1); |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
67 @Option(help = "Last class to consider when using -XX:+CompileTheWorld") |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
68 public static final OptionValue<Integer> CompileTheWorldStopAt = new OptionValue<>(Integer.MAX_VALUE); |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
69 @Option(help = "Option value overrides to use during compile the world. For example, " + |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
70 "to disable inlining and partial escape analysis specify '-PartialEscapeAnalysis -Inline'. " + |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
71 "The format for each option is the same as on the command line just without the '-G:' prefix.") |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
72 public static final OptionValue<String> CompileTheWorldConfig = new OptionValue<>(null); |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
73 // @formatter:on |
13361
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
74 |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
75 /** |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
76 * Overrides {@link #CompileTheWorldStartAt} and {@link #CompileTheWorldStopAt} from |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
77 * {@code -XX} HotSpot options of the same name if the latter have non-default values. |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
78 */ |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
79 static void overrideWithNativeOptions(HotSpotVMConfig c) { |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
80 if (c.compileTheWorldStartAt != 1) { |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
81 CompileTheWorldStartAt.setValue(c.compileTheWorldStartAt); |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
82 } |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
83 if (c.compileTheWorldStopAt != Integer.MAX_VALUE) { |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
84 CompileTheWorldStopAt.setValue(c.compileTheWorldStopAt); |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
85 } |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
86 } |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
87 } |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
88 |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
89 /** |
13371
4db09b7304da
read DontCompileHugeMethods and HugeMethodLimit from VM
Doug Simon <doug.simon@oracle.com>
parents:
13366
diff
changeset
|
90 * A mechanism for overriding Graal options that affect compilation. A {@link Config} object |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
91 * should be used in a try-with-resources statement to ensure overriding of options is scoped |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
92 * properly. For example: |
14906 | 93 * |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
94 * <pre> |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
95 * Config config = ...; |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
96 * try (AutoCloseable s = config == null ? null : config.apply()) { |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
97 * // perform a Graal compilation |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
98 * } |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
99 * </pre> |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
100 */ |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
101 @SuppressWarnings("serial") |
13361
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
102 public static class Config extends HashMap<OptionValue<?>, Object> implements AutoCloseable, OptionConsumer { |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
103 OverrideScope scope; |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
104 |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
105 /** |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
106 * Creates a {@link Config} object by parsing a set of space separated override options. |
14906 | 107 * |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
108 * @param options a space separated set of option value settings with each option setting in |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
109 * a format compatible with |
13365
bfc5acea3c12
consolidated mechanism for overriding options in CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
13362
diff
changeset
|
110 * {@link HotSpotOptions#parseOption(String, OptionConsumer)}. Ignored if null. |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
111 */ |
13361
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
112 public Config(String options) { |
13365
bfc5acea3c12
consolidated mechanism for overriding options in CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
13362
diff
changeset
|
113 if (options != null) { |
bfc5acea3c12
consolidated mechanism for overriding options in CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
13362
diff
changeset
|
114 for (String option : options.split("\\s+")) { |
bfc5acea3c12
consolidated mechanism for overriding options in CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
13362
diff
changeset
|
115 if (!HotSpotOptions.parseOption(option, this)) { |
bfc5acea3c12
consolidated mechanism for overriding options in CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
13362
diff
changeset
|
116 throw new GraalInternalError("Invalid option specified: %s", option); |
bfc5acea3c12
consolidated mechanism for overriding options in CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
13362
diff
changeset
|
117 } |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
118 } |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
119 } |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
120 } |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
121 |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
122 /** |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
123 * Applies the overrides represented by this object. The overrides are in effect until |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
124 * {@link #close()} is called on this object. |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
125 */ |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
126 Config apply() { |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
127 assert scope == null; |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
128 scope = OptionValue.override(this); |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
129 return this; |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
130 } |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
131 |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
132 public void close() { |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
133 assert scope != null; |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
134 scope.close(); |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
135 |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
136 scope = null; |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
137 |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
138 } |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
139 |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
140 public void set(OptionDescriptor desc, Object value) { |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
141 put(desc.getOptionValue(), value); |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
142 } |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
143 } |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
144 |
9108 | 145 // Some runtime instances we need. |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
146 private final HotSpotGraalRuntime runtime = runtime(); |
9108 | 147 |
14906 | 148 /** List of Zip/Jar files to compile (see {@link Options#CompileTheWorldClasspath}). */ |
9108 | 149 private final String files; |
150 | |
14906 | 151 /** Class index to start compilation at (see {@link Options#CompileTheWorldStartAt}). */ |
9108 | 152 private final int startAt; |
153 | |
14906 | 154 /** Class index to stop compilation at (see {@link Options#CompileTheWorldStopAt}). */ |
9108 | 155 private final int stopAt; |
156 | |
157 // Counters | |
158 private int classFileCounter = 0; | |
159 private int compiledMethodsCounter = 0; | |
160 private long compileTime = 0; | |
16722
46eaf7cd8275
added memory usage analysis to CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
16480
diff
changeset
|
161 private long memoryUsed = 0; |
9108 | 162 |
13200
ebdc13d9845d
replaced use of graal.compileTheWorldTest.log system property with a field to control CTW verbosity which is true by default but is set to false by CTW unit test
Doug Simon <doug.simon@oracle.com>
parents:
13199
diff
changeset
|
163 private boolean verbose; |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
164 private final Config config; |
13200
ebdc13d9845d
replaced use of graal.compileTheWorldTest.log system property with a field to control CTW verbosity which is true by default but is set to false by CTW unit test
Doug Simon <doug.simon@oracle.com>
parents:
13199
diff
changeset
|
165 |
9108 | 166 /** |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
167 * Creates a compile-the-world instance. |
14906 | 168 * |
9108 | 169 * @param files {@link File#pathSeparator} separated list of Zip/Jar files to compile |
170 * @param startAt index of the class file to start compilation at | |
171 * @param stopAt index of the class file to stop compilation at | |
172 */ | |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
173 public CompileTheWorld(String files, Config config, int startAt, int stopAt, boolean verbose) { |
9108 | 174 this.files = files; |
175 this.startAt = startAt; | |
176 this.stopAt = stopAt; | |
13200
ebdc13d9845d
replaced use of graal.compileTheWorldTest.log system property with a field to control CTW verbosity which is true by default but is set to false by CTW unit test
Doug Simon <doug.simon@oracle.com>
parents:
13199
diff
changeset
|
177 this.verbose = verbose; |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
178 this.config = config; |
9108 | 179 |
13113 | 180 // We don't want the VM to exit when a method fails to compile... |
13365
bfc5acea3c12
consolidated mechanism for overriding options in CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
13362
diff
changeset
|
181 config.put(ExitVMOnException, false); |
13113 | 182 |
183 // ...but we want to see exceptions. | |
13365
bfc5acea3c12
consolidated mechanism for overriding options in CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
13362
diff
changeset
|
184 config.put(PrintBailout, true); |
bfc5acea3c12
consolidated mechanism for overriding options in CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
13362
diff
changeset
|
185 config.put(PrintStackTraceOnException, true); |
9108 | 186 } |
187 | |
188 /** | |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
189 * Compiles all methods in all classes in the Zip/Jar archive files in |
14906 | 190 * {@link Options#CompileTheWorldClasspath}. If {@link Options#CompileTheWorldClasspath} |
191 * contains the magic token {@link #SUN_BOOT_CLASS_PATH} passed up from HotSpot we take the | |
192 * files from the boot class path. | |
9108 | 193 */ |
194 public void compile() throws Throwable { | |
195 if (SUN_BOOT_CLASS_PATH.equals(files)) { | |
196 final String[] entries = System.getProperty(SUN_BOOT_CLASS_PATH).split(File.pathSeparator); | |
197 String bcpFiles = ""; | |
198 for (int i = 0; i < entries.length; i++) { | |
199 final String entry = entries[i]; | |
200 | |
201 // We stop at rt.jar, unless it is the first boot class path entry. | |
202 if (entry.endsWith("rt.jar") && (i > 0)) { | |
203 break; | |
204 } | |
205 if (i > 0) { | |
206 bcpFiles += File.pathSeparator; | |
207 } | |
208 bcpFiles += entry; | |
209 } | |
210 compile(bcpFiles); | |
211 } else { | |
212 compile(files); | |
213 } | |
214 } | |
215 | |
13200
ebdc13d9845d
replaced use of graal.compileTheWorldTest.log system property with a field to control CTW verbosity which is true by default but is set to false by CTW unit test
Doug Simon <doug.simon@oracle.com>
parents:
13199
diff
changeset
|
216 public void println() { |
13199
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
217 println(""); |
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
218 } |
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
219 |
13200
ebdc13d9845d
replaced use of graal.compileTheWorldTest.log system property with a field to control CTW verbosity which is true by default but is set to false by CTW unit test
Doug Simon <doug.simon@oracle.com>
parents:
13199
diff
changeset
|
220 public void println(String format, Object... args) { |
13199
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
221 println(String.format(format, args)); |
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
222 } |
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
223 |
13200
ebdc13d9845d
replaced use of graal.compileTheWorldTest.log system property with a field to control CTW verbosity which is true by default but is set to false by CTW unit test
Doug Simon <doug.simon@oracle.com>
parents:
13199
diff
changeset
|
224 public void println(String s) { |
ebdc13d9845d
replaced use of graal.compileTheWorldTest.log system property with a field to control CTW verbosity which is true by default but is set to false by CTW unit test
Doug Simon <doug.simon@oracle.com>
parents:
13199
diff
changeset
|
225 if (verbose) { |
13199
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
226 TTY.println(s); |
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
227 } |
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
228 } |
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
229 |
9108 | 230 /** |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
231 * Compiles all methods in all classes in the Zip/Jar files passed. |
14906 | 232 * |
9108 | 233 * @param fileList {@link File#pathSeparator} separated list of Zip/Jar files to compile |
234 * @throws Throwable | |
235 */ | |
236 private void compile(String fileList) throws Throwable { | |
237 final String[] entries = fileList.split(File.pathSeparator); | |
238 | |
16872
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
239 try (AutoCloseable s = config.apply()) { |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
240 for (int i = 0; i < entries.length; i++) { |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
241 final String entry = entries[i]; |
9108 | 242 |
16872
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
243 // For now we only compile all methods in all classes in zip/jar files. |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
244 if (!entry.endsWith(".zip") && !entry.endsWith(".jar")) { |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
245 println("CompileTheWorld : Skipped classes in " + entry); |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
246 println(); |
9108 | 247 continue; |
248 } | |
249 | |
16872
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
250 println("CompileTheWorld : Compiling all classes in " + entry); |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
251 println(); |
9108 | 252 |
16872
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
253 URL url = new URL("jar", "", "file:" + entry + "!/"); |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
254 ClassLoader loader = new URLClassLoader(new URL[]{url}); |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
255 |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
256 JarFile jarFile = new JarFile(entry); |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
257 Enumeration<JarEntry> e = jarFile.entries(); |
9108 | 258 |
16872
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
259 while (e.hasMoreElements()) { |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
260 JarEntry je = e.nextElement(); |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
261 if (je.isDirectory() || !je.getName().endsWith(".class")) { |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
262 continue; |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
263 } |
9108 | 264 |
16872
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
265 // Are we done? |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
266 if (classFileCounter >= stopAt) { |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
267 break; |
9108 | 268 } |
269 | |
16872
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
270 String className = je.getName().substring(0, je.getName().length() - ".class".length()); |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
271 classFileCounter++; |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
272 |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
273 try { |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
274 // Load and initialize class |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
275 Class<?> javaClass = Class.forName(className.replace('/', '.'), true, loader); |
9108 | 276 |
16872
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
277 // Pre-load all classes in the constant pool. |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
278 try { |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18167
diff
changeset
|
279 HotSpotResolvedObjectType objectType = HotSpotResolvedObjectTypeImpl.fromObjectClass(javaClass); |
16872
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
280 ConstantPool constantPool = objectType.constantPool(); |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
281 for (int cpi = 1; cpi < constantPool.length(); cpi++) { |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
282 constantPool.loadReferencedType(cpi, Bytecodes.LDC); |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
283 } |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
284 } catch (Throwable t) { |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
285 // If something went wrong during pre-loading we just ignore it. |
17395
c8bd29658465
be more verbose about class resolution during CTW
Doug Simon <doug.simon@oracle.com>
parents:
17377
diff
changeset
|
286 println("Preloading failed for (%d) %s: %s", classFileCounter, className, t); |
16872
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
287 } |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
288 |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
289 // Are we compiling this class? |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
290 HotSpotMetaAccessProvider metaAccess = runtime.getHostProviders().getMetaAccess(); |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
291 if (classFileCounter >= startAt) { |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
292 println("CompileTheWorld (%d) : %s", classFileCounter, className); |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
293 |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
294 // Compile each constructor/method in the class. |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
295 for (Constructor<?> constructor : javaClass.getDeclaredConstructors()) { |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
296 HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaConstructor(constructor); |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
297 if (canBeCompiled(javaMethod, constructor.getModifiers())) { |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
298 compileMethod(javaMethod); |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
299 } |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
300 } |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
301 for (Method method : javaClass.getDeclaredMethods()) { |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
302 HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaMethod(method); |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
303 if (canBeCompiled(javaMethod, method.getModifiers())) { |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
304 compileMethod(javaMethod); |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
305 } |
9108 | 306 } |
307 } | |
16872
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
308 } catch (Throwable t) { |
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
309 println("CompileTheWorld (%d) : Skipping %s", classFileCounter, className); |
9108 | 310 } |
311 } | |
16872
ce8ac92efb14
Don't recreate suites on every CTW compile.
Roland Schatz <roland.schatz@oracle.com>
parents:
16831
diff
changeset
|
312 jarFile.close(); |
9108 | 313 } |
314 } | |
315 | |
13199
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
316 println(); |
16722
46eaf7cd8275
added memory usage analysis to CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
16480
diff
changeset
|
317 println("CompileTheWorld : Done (%d classes, %d methods, %d ms, %d bytes of memory used)", classFileCounter, compiledMethodsCounter, compileTime, memoryUsed); |
9108 | 318 } |
319 | |
13452
8275a0d0c90a
create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents:
13371
diff
changeset
|
320 class CTWCompilationTask extends CompilationTask { |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
321 |
13859
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
322 CTWCompilationTask(HotSpotBackend backend, HotSpotResolvedJavaMethod method) { |
17377
58f45b63b802
CompileTheWorld compilations are no longer installed as default nmethods
Doug Simon <doug.simon@oracle.com>
parents:
16872
diff
changeset
|
323 super(backend, method, INVOCATION_ENTRY_BCI, 0L, method.allocateCompileId(INVOCATION_ENTRY_BCI), false); |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
324 } |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
325 |
13452
8275a0d0c90a
create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents:
13371
diff
changeset
|
326 /** |
8275a0d0c90a
create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents:
13371
diff
changeset
|
327 * Returns empty profiling info to be as close to the CTW behavior of C1 and C2 as possible. |
8275a0d0c90a
create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents:
13371
diff
changeset
|
328 */ |
8275a0d0c90a
create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents:
13371
diff
changeset
|
329 @Override |
8275a0d0c90a
create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents:
13371
diff
changeset
|
330 protected ProfilingInfo getProfilingInfo() { |
8275a0d0c90a
create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents:
13371
diff
changeset
|
331 // Be optimistic and return false for exceptionSeen. |
8275a0d0c90a
create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents:
13371
diff
changeset
|
332 return DefaultProfilingInfo.get(TriState.FALSE); |
8275a0d0c90a
create profiling info, phase plan and optimistic opts when running a CompilationTask, not when creating it (GRAAL-640)
Doug Simon <doug.simon@oracle.com>
parents:
13371
diff
changeset
|
333 } |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
334 } |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
335 |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
336 /** |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
337 * Compiles a method and gathers some statistics. |
9108 | 338 */ |
339 private void compileMethod(HotSpotResolvedJavaMethod method) { | |
340 try { | |
341 long start = System.currentTimeMillis(); | |
16722
46eaf7cd8275
added memory usage analysis to CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
16480
diff
changeset
|
342 long allocatedAtStart = getCurrentThreadAllocatedBytes(); |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
343 |
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
344 HotSpotBackend backend = runtime.getHostBackend(); |
13859
1e01e2644a5d
Make blocking compiles safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13630
diff
changeset
|
345 CompilationTask task = new CTWCompilationTask(backend, method); |
15695
128359d7cddc
once the Graal compilation queue has been shutdown, don't process any pending compilations and be more defensive about preventing future compilations to be queued
Doug Simon <doug.simon@oracle.com>
parents:
15463
diff
changeset
|
346 task.runCompilation(); |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
347 |
16722
46eaf7cd8275
added memory usage analysis to CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
16480
diff
changeset
|
348 memoryUsed += getCurrentThreadAllocatedBytes() - allocatedAtStart; |
9108 | 349 compileTime += (System.currentTimeMillis() - start); |
350 compiledMethodsCounter++; | |
351 } catch (Throwable t) { | |
352 // Catch everything and print a message | |
16480
10c12d09a8d2
moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
16399
diff
changeset
|
353 println("CompileTheWorld (%d) : Error compiling method: %s", classFileCounter, method.format("%H.%n(%p):%r")); |
9108 | 354 t.printStackTrace(TTY.cachedOut); |
355 } | |
356 } | |
357 | |
358 /** | |
13353
0e5c4f9fa9a5
enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents:
13200
diff
changeset
|
359 * Determines if a method should be compiled (Cf. CompilationPolicy::can_be_compiled). |
14906 | 360 * |
9108 | 361 * @return true if it can be compiled, false otherwise |
362 */ | |
13371
4db09b7304da
read DontCompileHugeMethods and HugeMethodLimit from VM
Doug Simon <doug.simon@oracle.com>
parents:
13366
diff
changeset
|
363 private boolean canBeCompiled(HotSpotResolvedJavaMethod javaMethod, int modifiers) { |
9108 | 364 if (Modifier.isAbstract(modifiers) || Modifier.isNative(modifiers)) { |
365 return false; | |
366 } | |
13371
4db09b7304da
read DontCompileHugeMethods and HugeMethodLimit from VM
Doug Simon <doug.simon@oracle.com>
parents:
13366
diff
changeset
|
367 HotSpotVMConfig c = runtime.getConfig(); |
4db09b7304da
read DontCompileHugeMethods and HugeMethodLimit from VM
Doug Simon <doug.simon@oracle.com>
parents:
13366
diff
changeset
|
368 if (c.dontCompileHugeMethods && javaMethod.getCodeSize() > c.hugeMethodLimit) { |
9108 | 369 return false; |
370 } | |
16831
217eee2ddead
support use of -XX:CompileCommand=dontinline to exclude problematic methods from CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
16722
diff
changeset
|
371 // Allow use of -XX:CompileCommand=dontinline to exclude problematic methods |
217eee2ddead
support use of -XX:CompileCommand=dontinline to exclude problematic methods from CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
16722
diff
changeset
|
372 if (!javaMethod.canBeInlined()) { |
217eee2ddead
support use of -XX:CompileCommand=dontinline to exclude problematic methods from CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
16722
diff
changeset
|
373 return false; |
217eee2ddead
support use of -XX:CompileCommand=dontinline to exclude problematic methods from CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
16722
diff
changeset
|
374 } |
9108 | 375 // Skip @Snippets for now |
376 if (javaMethod.getAnnotation(Snippet.class) != null) { | |
377 return false; | |
378 } | |
379 return true; | |
380 } | |
381 | |
382 } |