Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java @ 13362:9fd85def8368
made CompileTheWorld ignore profiling info
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 17 Dec 2013 16:42:29 +0100 |
parents | 5a6c617a66ac |
children | bfc5acea3c12 |
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 | |
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
|
25 import static com.oracle.graal.hotspot.CompileTheWorld.Options.*; |
9289
261a43921c5e
rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents:
9108
diff
changeset
|
26 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
|
27 import static com.oracle.graal.nodes.StructuredGraph.*; |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
28 import static com.oracle.graal.phases.GraalOptions.*; |
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.*; |
9108 | 39 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
|
40 import com.oracle.graal.graph.*; |
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.bridge.*; |
43 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
|
44 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
|
45 import com.oracle.graal.options.OptionValue.OverrideScope; |
9108 | 46 import com.oracle.graal.phases.*; |
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
|
47 import com.oracle.graal.phases.tiers.*; |
9108 | 48 import com.oracle.graal.replacements.*; |
49 | |
50 /** | |
51 * This class implements compile-the-world functionality in Graal. | |
52 */ | |
53 public final class CompileTheWorld { | |
54 | |
13361
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
55 /** |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
56 * 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
|
57 */ |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
58 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
|
59 |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
60 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
|
61 // @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
|
62 @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
|
63 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
|
64 @Option(help = "Verbose CompileTheWorld operation") |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
65 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
|
66 @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
|
67 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
|
68 @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
|
69 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
|
70 @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
|
71 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
|
72 @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
|
73 "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
|
74 "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
|
75 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
|
76 // @formatter:on |
13361
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
77 |
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 * 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
|
80 * {@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
|
81 */ |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
82 static void overrideWithNativeOptions(HotSpotVMConfig c) { |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
83 if (c.compileTheWorldStartAt != 1) { |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
84 CompileTheWorldStartAt.setValue(c.compileTheWorldStartAt); |
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 if (c.compileTheWorldStopAt != Integer.MAX_VALUE) { |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
87 CompileTheWorldStopAt.setValue(c.compileTheWorldStopAt); |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
88 } |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
89 } |
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
|
90 } |
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 |
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 /** |
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
|
93 * A mechanism for overriding Graal options that effect compilation. A {@link Config} 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
|
94 * 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
|
95 * properly. 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
|
96 * |
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 * <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
|
98 * 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
|
99 * 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
|
100 * // 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
|
101 * } |
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
|
102 * </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
|
103 */ |
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 @SuppressWarnings("serial") |
13361
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
105 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
|
106 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
|
107 |
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 /** |
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 * Creates a {@link Config} object by parsing a set of space separated override 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
|
110 * |
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 * @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
|
112 * a format compatible with |
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
|
113 * {@link HotSpotOptions#parseOption(String, OptionConsumer)} |
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
|
114 */ |
13361
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
115 public Config(String 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
|
116 for (String option : options.split("\\s+")) { |
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
|
117 if (!HotSpotOptions.parseOption(option, 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
|
118 throw new GraalInternalError("Invalid option specified: %s", option); |
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 /** |
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 * 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
|
125 * {@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
|
126 */ |
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 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
|
128 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
|
129 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
|
130 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
|
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 |
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 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
|
134 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
|
135 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
|
136 |
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 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
|
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 |
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 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
|
142 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
|
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 |
13361
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
145 public static Config parse(String input) { |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
146 if (input == null) { |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
147 return null; |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
148 } else { |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
149 return new Config(input); |
5a6c617a66ac
added -G:+CompileTheWorldVerbose and -G:CompileTheWorldIterations options
Doug Simon <doug.simon@oracle.com>
parents:
13353
diff
changeset
|
150 } |
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
|
151 } |
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
|
152 } |
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
|
153 |
9108 | 154 // Some runtime instances we need. |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
155 private final HotSpotGraalRuntime runtime = runtime(); |
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
156 private final VMToCompilerImpl vmToCompiler = (VMToCompilerImpl) runtime.getVMToCompiler(); |
9108 | 157 |
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
|
158 /** List of Zip/Jar files to compile (see {@link #CompileTheWorldClasspath}. */ |
9108 | 159 private final String files; |
160 | |
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
|
161 /** Class index to start compilation at (see {@link #CompileTheWorldStartAt}. */ |
9108 | 162 private final int startAt; |
163 | |
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 /** Class index to stop compilation at (see {@link #CompileTheWorldStopAt}. */ |
9108 | 165 private final int stopAt; |
166 | |
167 // Counters | |
168 private int classFileCounter = 0; | |
169 private int compiledMethodsCounter = 0; | |
170 private long compileTime = 0; | |
171 | |
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
|
172 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
|
173 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
|
174 |
9108 | 175 /** |
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
|
176 * Creates a compile-the-world instance. |
9108 | 177 * |
178 * @param files {@link File#pathSeparator} separated list of Zip/Jar files to compile | |
179 * @param startAt index of the class file to start compilation at | |
180 * @param stopAt index of the class file to stop compilation at | |
181 */ | |
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
|
182 public CompileTheWorld(String files, Config config, int startAt, int stopAt, boolean verbose) { |
9108 | 183 this.files = files; |
184 this.startAt = startAt; | |
185 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
|
186 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
|
187 this.config = config; |
9108 | 188 |
13113 | 189 // We don't want the VM to exit when a method fails to compile... |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9289
diff
changeset
|
190 ExitVMOnException.setValue(false); |
13113 | 191 |
192 // ...but we want to see exceptions. | |
193 PrintBailout.setValue(true); | |
194 PrintStackTraceOnException.setValue(true); | |
9108 | 195 } |
196 | |
197 /** | |
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
|
198 * Compiles all methods in all classes in the Zip/Jar archive files 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
|
199 * {@link #CompileTheWorldClasspath}. If {@link #CompileTheWorldClasspath} contains the magic |
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
|
200 * token {@link #SUN_BOOT_CLASS_PATH} passed up from HotSpot we take the files from the boot |
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
|
201 * class path. |
9108 | 202 */ |
203 public void compile() throws Throwable { | |
204 if (SUN_BOOT_CLASS_PATH.equals(files)) { | |
205 final String[] entries = System.getProperty(SUN_BOOT_CLASS_PATH).split(File.pathSeparator); | |
206 String bcpFiles = ""; | |
207 for (int i = 0; i < entries.length; i++) { | |
208 final String entry = entries[i]; | |
209 | |
210 // We stop at rt.jar, unless it is the first boot class path entry. | |
211 if (entry.endsWith("rt.jar") && (i > 0)) { | |
212 break; | |
213 } | |
214 if (i > 0) { | |
215 bcpFiles += File.pathSeparator; | |
216 } | |
217 bcpFiles += entry; | |
218 } | |
219 compile(bcpFiles); | |
220 } else { | |
221 compile(files); | |
222 } | |
223 } | |
224 | |
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
|
225 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
|
226 println(""); |
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 |
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
|
229 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
|
230 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
|
231 } |
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
232 |
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
|
233 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
|
234 if (verbose) { |
13199
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
235 TTY.println(s); |
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
236 } |
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
237 } |
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
238 |
9108 | 239 /** |
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
|
240 * Compiles all methods in all classes in the Zip/Jar files passed. |
9108 | 241 * |
242 * @param fileList {@link File#pathSeparator} separated list of Zip/Jar files to compile | |
243 * @throws Throwable | |
244 */ | |
245 private void compile(String fileList) throws Throwable { | |
246 final String[] entries = fileList.split(File.pathSeparator); | |
247 | |
248 for (int i = 0; i < entries.length; i++) { | |
249 final String entry = entries[i]; | |
250 | |
251 // For now we only compile all methods in all classes in zip/jar files. | |
252 if (!entry.endsWith(".zip") && !entry.endsWith(".jar")) { | |
13199
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
253 println("CompileTheWorld : Skipped classes in " + entry); |
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
254 println(); |
9108 | 255 continue; |
256 } | |
257 | |
13199
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
258 println("CompileTheWorld : Compiling all classes in " + entry); |
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
259 println(); |
9108 | 260 |
261 URL url = new URL("jar", "", "file:" + entry + "!/"); | |
262 ClassLoader loader = new URLClassLoader(new URL[]{url}); | |
263 | |
264 JarFile jarFile = new JarFile(entry); | |
265 Enumeration<JarEntry> e = jarFile.entries(); | |
266 | |
267 while (e.hasMoreElements()) { | |
268 JarEntry je = e.nextElement(); | |
269 if (je.isDirectory() || !je.getName().endsWith(".class")) { | |
270 continue; | |
271 } | |
272 | |
273 // Are we done? | |
274 if (classFileCounter >= stopAt) { | |
275 break; | |
276 } | |
277 | |
278 String className = je.getName().substring(0, je.getName().length() - ".class".length()); | |
279 classFileCounter++; | |
280 | |
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
|
281 try (AutoCloseable s = config == null ? null : config.apply()) { |
9108 | 282 // Load and initialize class |
10543
97caf20971ed
CTW: adapt output messages, so that they match with the output of hotspot
Bernhard Urban <bernhard.urban@jku.at>
parents:
10461
diff
changeset
|
283 Class<?> javaClass = Class.forName(className.replace('/', '.'), true, loader); |
9108 | 284 |
285 // Pre-load all classes in the constant pool. | |
286 try { | |
287 HotSpotResolvedObjectType objectType = (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromClass(javaClass); | |
288 ConstantPool constantPool = objectType.constantPool(); | |
289 for (int cpi = 1; cpi < constantPool.length(); cpi++) { | |
290 constantPool.loadReferencedType(cpi, Bytecodes.LDC); | |
291 } | |
292 } catch (Throwable t) { | |
293 // If something went wrong during pre-loading we just ignore it. | |
13199
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
294 println("Preloading failed for (%d) %s", classFileCounter, className); |
9108 | 295 } |
296 | |
297 // Are we compiling this class? | |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
298 HotSpotMetaAccessProvider metaAccess = runtime.getHostProviders().getMetaAccess(); |
9108 | 299 if (classFileCounter >= startAt) { |
13199
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
300 println("CompileTheWorld (%d) : %s", classFileCounter, className); |
9108 | 301 |
302 // Enqueue each constructor/method in the class for compilation. | |
303 for (Constructor<?> constructor : javaClass.getDeclaredConstructors()) { | |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
10672
diff
changeset
|
304 HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaConstructor(constructor); |
9108 | 305 if (canBeCompiled(javaMethod, constructor.getModifiers())) { |
306 compileMethod(javaMethod); | |
307 } | |
308 } | |
309 for (Method method : javaClass.getDeclaredMethods()) { | |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
10672
diff
changeset
|
310 HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaMethod(method); |
9108 | 311 if (canBeCompiled(javaMethod, method.getModifiers())) { |
312 compileMethod(javaMethod); | |
313 } | |
314 } | |
315 } | |
316 } catch (Throwable t) { | |
13199
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
317 println("CompileTheWorld (%d) : Skipping %s", classFileCounter, className); |
9108 | 318 } |
319 } | |
320 jarFile.close(); | |
321 } | |
322 | |
13199
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
323 println(); |
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
324 println("CompileTheWorld : Done (%d classes, %d methods, %d ms)", classFileCounter, compiledMethodsCounter, compileTime); |
9108 | 325 } |
326 | |
327 /** | |
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
|
328 * A compilation task that creates a fresh compilation suite for its compilation. This is |
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
|
329 * required so that a CTW compilation can be {@linkplain Config configured} differently from a |
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
|
330 * VM triggered 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
|
331 */ |
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
|
332 static class CTWCompilationTask extends CompilationTask { |
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
|
333 |
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 CTWCompilationTask(HotSpotBackend backend, PhasePlan plan, OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo, HotSpotResolvedJavaMethod method, int entryBCI, int id) { |
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 super(backend, plan, optimisticOpts, profilingInfo, method, entryBCI, id); |
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 |
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
|
338 @Override |
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
|
339 protected Suites getSuites(HotSpotProviders providers) { |
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
|
340 return providers.getSuites().createSuites(); |
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
|
341 } |
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
|
342 } |
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 /** |
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
|
345 * Compiles a method and gathers some statistics. |
9108 | 346 */ |
347 private void compileMethod(HotSpotResolvedJavaMethod method) { | |
348 try { | |
349 long start = System.currentTimeMillis(); | |
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
|
350 |
13362
9fd85def8368
made CompileTheWorld ignore profiling info
Doug Simon <doug.simon@oracle.com>
parents:
13361
diff
changeset
|
351 // Be optimistic and return false for exceptionSeen. |
9fd85def8368
made CompileTheWorld ignore profiling info
Doug Simon <doug.simon@oracle.com>
parents:
13361
diff
changeset
|
352 final ProfilingInfo profilingInfo = DefaultProfilingInfo.get(TriState.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
|
353 final OptimisticOptimizations optimisticOpts = new OptimisticOptimizations(profilingInfo); |
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
|
354 int id = vmToCompiler.allocateCompileTaskId(); |
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
|
355 HotSpotBackend backend = runtime.getHostBackend(); |
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
|
356 PhasePlan phasePlan = vmToCompiler.createPhasePlan(backend.getProviders(), optimisticOpts, false); |
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
|
357 CompilationTask task = new CTWCompilationTask(backend, phasePlan, optimisticOpts, profilingInfo, method, INVOCATION_ENTRY_BCI, id); |
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
|
358 task.runCompilation(); |
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 |
9108 | 360 compileTime += (System.currentTimeMillis() - start); |
361 compiledMethodsCounter++; | |
362 method.reprofile(); // makes the method also not-entrant | |
363 } catch (Throwable t) { | |
364 // Catch everything and print a message | |
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
|
365 println("CompileTheWorldClasspath (%d) : Error compiling method: %s", classFileCounter, MetaUtil.format("%H.%n(%p):%r", method)); |
9108 | 366 t.printStackTrace(TTY.cachedOut); |
367 } | |
368 } | |
369 | |
370 /** | |
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
|
371 * Determines if a method should be compiled (Cf. CompilationPolicy::can_be_compiled). |
9108 | 372 * |
373 * @return true if it can be compiled, false otherwise | |
374 */ | |
375 private static boolean canBeCompiled(HotSpotResolvedJavaMethod javaMethod, int modifiers) { | |
376 if (Modifier.isAbstract(modifiers) || Modifier.isNative(modifiers)) { | |
377 return false; | |
378 } | |
379 // This number is from HotSpot: | |
380 final int hugeMethodLimit = 8000; | |
381 if (javaMethod.getCodeSize() > hugeMethodLimit) { | |
382 return false; | |
383 } | |
384 // Skip @Snippets for now | |
385 if (javaMethod.getAnnotation(Snippet.class) != null) { | |
386 return false; | |
387 } | |
388 return true; | |
389 } | |
390 | |
391 } |