Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java @ 13371:4db09b7304da
read DontCompileHugeMethods and HugeMethodLimit from VM
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 17 Dec 2013 22:37:03 +0100 |
parents | 1480cfe97462 |
children | 8275a0d0c90a |
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 /** |
13371
4db09b7304da
read DontCompileHugeMethods and HugeMethodLimit from VM
Doug Simon <doug.simon@oracle.com>
parents:
13366
diff
changeset
|
93 * 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
|
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 |
13365
bfc5acea3c12
consolidated mechanism for overriding options in CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
13362
diff
changeset
|
113 * {@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
|
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) { |
13365
bfc5acea3c12
consolidated mechanism for overriding options in CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
13362
diff
changeset
|
116 if (options != null) { |
bfc5acea3c12
consolidated mechanism for overriding options in CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
13362
diff
changeset
|
117 for (String option : options.split("\\s+")) { |
bfc5acea3c12
consolidated mechanism for overriding options in CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
13362
diff
changeset
|
118 if (!HotSpotOptions.parseOption(option, this)) { |
bfc5acea3c12
consolidated mechanism for overriding options in CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
13362
diff
changeset
|
119 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
|
120 } |
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
|
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 |
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 * 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
|
127 * {@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
|
128 */ |
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 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
|
130 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
|
131 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
|
132 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
|
133 } |
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 |
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 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
|
136 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
|
137 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
|
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 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
|
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 } |
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 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
|
144 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
|
145 } |
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
|
146 } |
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
|
147 |
9108 | 148 // Some runtime instances we need. |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
149 private final HotSpotGraalRuntime runtime = runtime(); |
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
150 private final VMToCompilerImpl vmToCompiler = (VMToCompilerImpl) runtime.getVMToCompiler(); |
9108 | 151 |
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
|
152 /** List of Zip/Jar files to compile (see {@link #CompileTheWorldClasspath}. */ |
9108 | 153 private final String files; |
154 | |
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
|
155 /** Class index to start compilation at (see {@link #CompileTheWorldStartAt}. */ |
9108 | 156 private final int startAt; |
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 /** Class index to stop compilation at (see {@link #CompileTheWorldStopAt}. */ |
9108 | 159 private final int stopAt; |
160 | |
161 // Counters | |
162 private int classFileCounter = 0; | |
163 private int compiledMethodsCounter = 0; | |
164 private long compileTime = 0; | |
165 | |
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
|
166 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
|
167 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
|
168 |
9108 | 169 /** |
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
|
170 * Creates a compile-the-world instance. |
9108 | 171 * |
172 * @param files {@link File#pathSeparator} separated list of Zip/Jar files to compile | |
173 * @param startAt index of the class file to start compilation at | |
174 * @param stopAt index of the class file to stop compilation at | |
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 public CompileTheWorld(String files, Config config, int startAt, int stopAt, boolean verbose) { |
9108 | 177 this.files = files; |
178 this.startAt = startAt; | |
179 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
|
180 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
|
181 this.config = config; |
9108 | 182 |
13113 | 183 // 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
|
184 config.put(ExitVMOnException, false); |
13113 | 185 |
186 // ...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
|
187 config.put(PrintBailout, true); |
bfc5acea3c12
consolidated mechanism for overriding options in CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
13362
diff
changeset
|
188 config.put(PrintStackTraceOnException, true); |
9108 | 189 } |
190 | |
191 /** | |
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
|
192 * 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
|
193 * {@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
|
194 * 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
|
195 * class path. |
9108 | 196 */ |
197 public void compile() throws Throwable { | |
198 if (SUN_BOOT_CLASS_PATH.equals(files)) { | |
199 final String[] entries = System.getProperty(SUN_BOOT_CLASS_PATH).split(File.pathSeparator); | |
200 String bcpFiles = ""; | |
201 for (int i = 0; i < entries.length; i++) { | |
202 final String entry = entries[i]; | |
203 | |
204 // We stop at rt.jar, unless it is the first boot class path entry. | |
205 if (entry.endsWith("rt.jar") && (i > 0)) { | |
206 break; | |
207 } | |
208 if (i > 0) { | |
209 bcpFiles += File.pathSeparator; | |
210 } | |
211 bcpFiles += entry; | |
212 } | |
213 compile(bcpFiles); | |
214 } else { | |
215 compile(files); | |
216 } | |
217 } | |
218 | |
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
|
219 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
|
220 println(""); |
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
221 } |
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
222 |
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
|
223 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
|
224 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
|
225 } |
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
226 |
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
|
227 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
|
228 if (verbose) { |
13199
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
229 TTY.println(s); |
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
230 } |
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 |
9108 | 233 /** |
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
|
234 * Compiles all methods in all classes in the Zip/Jar files passed. |
9108 | 235 * |
236 * @param fileList {@link File#pathSeparator} separated list of Zip/Jar files to compile | |
237 * @throws Throwable | |
238 */ | |
239 private void compile(String fileList) throws Throwable { | |
240 final String[] entries = fileList.split(File.pathSeparator); | |
241 | |
242 for (int i = 0; i < entries.length; i++) { | |
243 final String entry = entries[i]; | |
244 | |
245 // For now we only compile all methods in all classes in zip/jar files. | |
246 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
|
247 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
|
248 println(); |
9108 | 249 continue; |
250 } | |
251 | |
13199
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
252 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
|
253 println(); |
9108 | 254 |
255 URL url = new URL("jar", "", "file:" + entry + "!/"); | |
256 ClassLoader loader = new URLClassLoader(new URL[]{url}); | |
257 | |
258 JarFile jarFile = new JarFile(entry); | |
259 Enumeration<JarEntry> e = jarFile.entries(); | |
260 | |
261 while (e.hasMoreElements()) { | |
262 JarEntry je = e.nextElement(); | |
263 if (je.isDirectory() || !je.getName().endsWith(".class")) { | |
264 continue; | |
265 } | |
266 | |
267 // Are we done? | |
268 if (classFileCounter >= stopAt) { | |
269 break; | |
270 } | |
271 | |
272 String className = je.getName().substring(0, je.getName().length() - ".class".length()); | |
273 classFileCounter++; | |
274 | |
13371
4db09b7304da
read DontCompileHugeMethods and HugeMethodLimit from VM
Doug Simon <doug.simon@oracle.com>
parents:
13366
diff
changeset
|
275 try (AutoCloseable s = config.apply()) { |
9108 | 276 // 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
|
277 Class<?> javaClass = Class.forName(className.replace('/', '.'), true, loader); |
9108 | 278 |
279 // Pre-load all classes in the constant pool. | |
280 try { | |
281 HotSpotResolvedObjectType objectType = (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromClass(javaClass); | |
282 ConstantPool constantPool = objectType.constantPool(); | |
283 for (int cpi = 1; cpi < constantPool.length(); cpi++) { | |
284 constantPool.loadReferencedType(cpi, Bytecodes.LDC); | |
285 } | |
286 } catch (Throwable t) { | |
287 // 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
|
288 println("Preloading failed for (%d) %s", classFileCounter, className); |
9108 | 289 } |
290 | |
291 // 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
|
292 HotSpotMetaAccessProvider metaAccess = runtime.getHostProviders().getMetaAccess(); |
9108 | 293 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
|
294 println("CompileTheWorld (%d) : %s", classFileCounter, className); |
9108 | 295 |
296 // Enqueue each constructor/method in the class for compilation. | |
297 for (Constructor<?> constructor : javaClass.getDeclaredConstructors()) { | |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
10672
diff
changeset
|
298 HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaConstructor(constructor); |
9108 | 299 if (canBeCompiled(javaMethod, constructor.getModifiers())) { |
300 compileMethod(javaMethod); | |
301 } | |
302 } | |
303 for (Method method : javaClass.getDeclaredMethods()) { | |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
10672
diff
changeset
|
304 HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaMethod(method); |
9108 | 305 if (canBeCompiled(javaMethod, method.getModifiers())) { |
306 compileMethod(javaMethod); | |
307 } | |
308 } | |
309 } | |
310 } 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
|
311 println("CompileTheWorld (%d) : Skipping %s", classFileCounter, className); |
9108 | 312 } |
313 } | |
314 jarFile.close(); | |
315 } | |
316 | |
13199
bae0869c829a
put CompileTheWorldTest logging behind the graal.compileTheWorldTest.log system property
Doug Simon <doug.simon@oracle.com>
parents:
13113
diff
changeset
|
317 println(); |
13365
bfc5acea3c12
consolidated mechanism for overriding options in CompileTheWorld
Doug Simon <doug.simon@oracle.com>
parents:
13362
diff
changeset
|
318 TTY.println("CompileTheWorld : Done (%d classes, %d methods, %d ms)", classFileCounter, compiledMethodsCounter, compileTime); |
9108 | 319 } |
320 | |
321 /** | |
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
|
322 * 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
|
323 * 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
|
324 * 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
|
325 */ |
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
|
326 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
|
327 |
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 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
|
329 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
|
330 } |
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 @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
|
333 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
|
334 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
|
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 |
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 /** |
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 * Compiles a method and gathers some statistics. |
9108 | 340 */ |
341 private void compileMethod(HotSpotResolvedJavaMethod method) { | |
342 try { | |
343 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
|
344 |
13362
9fd85def8368
made CompileTheWorld ignore profiling info
Doug Simon <doug.simon@oracle.com>
parents:
13361
diff
changeset
|
345 // Be optimistic and return false for exceptionSeen. |
9fd85def8368
made CompileTheWorld ignore profiling info
Doug Simon <doug.simon@oracle.com>
parents:
13361
diff
changeset
|
346 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
|
347 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
|
348 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
|
349 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
|
350 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
|
351 CompilationTask task = new CTWCompilationTask(backend, phasePlan, optimisticOpts, profilingInfo, method, INVOCATION_ENTRY_BCI, id); |
13366
1480cfe97462
CTWCompilationTask should not be removed from compilation queue
Doug Simon <doug.simon@oracle.com>
parents:
13365
diff
changeset
|
352 task.runCompilation(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 |
9108 | 354 compileTime += (System.currentTimeMillis() - start); |
355 compiledMethodsCounter++; | |
356 method.reprofile(); // makes the method also not-entrant | |
357 } catch (Throwable t) { | |
358 // Catch everything and print a message | |
13371
4db09b7304da
read DontCompileHugeMethods and HugeMethodLimit from VM
Doug Simon <doug.simon@oracle.com>
parents:
13366
diff
changeset
|
359 println("CompileTheWorld (%d) : Error compiling method: %s", classFileCounter, MetaUtil.format("%H.%n(%p):%r", method)); |
9108 | 360 t.printStackTrace(TTY.cachedOut); |
361 } | |
362 } | |
363 | |
364 /** | |
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 * Determines if a method should be compiled (Cf. CompilationPolicy::can_be_compiled). |
9108 | 366 * |
367 * @return true if it can be compiled, false otherwise | |
368 */ | |
13371
4db09b7304da
read DontCompileHugeMethods and HugeMethodLimit from VM
Doug Simon <doug.simon@oracle.com>
parents:
13366
diff
changeset
|
369 private boolean canBeCompiled(HotSpotResolvedJavaMethod javaMethod, int modifiers) { |
9108 | 370 if (Modifier.isAbstract(modifiers) || Modifier.isNative(modifiers)) { |
371 return false; | |
372 } | |
13371
4db09b7304da
read DontCompileHugeMethods and HugeMethodLimit from VM
Doug Simon <doug.simon@oracle.com>
parents:
13366
diff
changeset
|
373 HotSpotVMConfig c = runtime.getConfig(); |
4db09b7304da
read DontCompileHugeMethods and HugeMethodLimit from VM
Doug Simon <doug.simon@oracle.com>
parents:
13366
diff
changeset
|
374 if (c.dontCompileHugeMethods && javaMethod.getCodeSize() > c.hugeMethodLimit) { |
9108 | 375 return false; |
376 } | |
377 // Skip @Snippets for now | |
378 if (javaMethod.getAnnotation(Snippet.class) != null) { | |
379 return false; | |
380 } | |
381 return true; | |
382 } | |
383 | |
384 } |