annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java @ 13353:0e5c4f9fa9a5

enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
author Doug Simon <doug.simon@oracle.com>
date Mon, 16 Dec 2013 23:33:40 +0100
parents bdc836ef885e
children 2236d18302e0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
23
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
24 package com.oracle.graal.hotspot;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25
11561
e1309fc4d17f ensure Debug.enable() is called before any DebugTimer or DebugMetric objects are requested
Doug Simon <doug.simon@oracle.com>
parents: 11365
diff changeset
26 import static com.oracle.graal.compiler.GraalDebugConfig.*;
9935
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
27 import static java.nio.file.Files.*;
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
28
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
29 import java.io.*;
12777
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
30 import java.lang.reflect.*;
9935
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
31 import java.nio.charset.*;
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
32 import java.nio.file.*;
5156
482265e41a1a added -G:+PrintFlags flag for printing the Graal flags; tightened format checking of Graal options to be consistent with HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 5149
diff changeset
33 import java.util.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34
11561
e1309fc4d17f ensure Debug.enable() is called before any DebugTimer or DebugMetric objects are requested
Doug Simon <doug.simon@oracle.com>
parents: 11365
diff changeset
35 import com.oracle.graal.debug.*;
12777
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
36 import com.oracle.graal.graph.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
37 import com.oracle.graal.hotspot.logging.*;
9849
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
38 import com.oracle.graal.options.*;
12777
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
39 import com.oracle.graal.phases.common.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40
9935
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
41 /**
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
42 * Called from {@code graalCompiler.cpp} to parse any Graal specific options. Such options are
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
43 * (currently) distinguished by a {@code "-G:"} prefix.
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
44 */
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
45 public class HotSpotOptions {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
46
9919
af909f4b80a9 options are grouped per top level class/interface when accessed via the service mechanism
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
47 private static final Map<String, OptionDescriptor> options = new HashMap<>();
9849
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
48
9935
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
49 /**
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
50 * Initializes {@link #options} from {@link Options} services.
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
51 */
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
52 private static void initializeOptions() {
9919
af909f4b80a9 options are grouped per top level class/interface when accessed via the service mechanism
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
53 ServiceLoader<Options> sl = ServiceLoader.loadInstalled(Options.class);
af909f4b80a9 options are grouped per top level class/interface when accessed via the service mechanism
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
54 for (Options opts : sl) {
af909f4b80a9 options are grouped per top level class/interface when accessed via the service mechanism
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
55 for (OptionDescriptor desc : opts) {
9986
4f542ceb5fed added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents: 9935
diff changeset
56 if (isHotSpotOption(desc)) {
9919
af909f4b80a9 options are grouped per top level class/interface when accessed via the service mechanism
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
57 String name = desc.getName();
af909f4b80a9 options are grouped per top level class/interface when accessed via the service mechanism
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
58 OptionDescriptor existing = options.put(name, desc);
af909f4b80a9 options are grouped per top level class/interface when accessed via the service mechanism
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
59 assert existing == null : "Option named \"" + name + "\" has multiple definitions: " + existing.getLocation() + " and " + desc.getLocation();
af909f4b80a9 options are grouped per top level class/interface when accessed via the service mechanism
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
60 }
9853
e45c7720b46b use package of generated OptionProvider to filter Graal options that are parsed from the HotSpot command line (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9849
diff changeset
61 }
9849
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
62 }
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
63 }
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
64
9935
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
65 /**
9986
4f542ceb5fed added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents: 9935
diff changeset
66 * Determines if a given option is a HotSpot command line option.
4f542ceb5fed added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents: 9935
diff changeset
67 */
4f542ceb5fed added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents: 9935
diff changeset
68 public static boolean isHotSpotOption(OptionDescriptor desc) {
4f542ceb5fed added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents: 9935
diff changeset
69 return desc.getClass().getName().startsWith("com.oracle.graal");
4f542ceb5fed added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents: 9935
diff changeset
70 }
4f542ceb5fed added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents: 9935
diff changeset
71
4f542ceb5fed added VerifyHotSpotOptionsPhase to ensure that global state is not initialized from options prior to command line parsing
Doug Simon <doug.simon@oracle.com>
parents: 9935
diff changeset
72 /**
9935
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
73 * Loads default option value overrides from a {@code graal.options} file if it exists. Each
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
74 * line in this file starts with {@code "#"} and is ignored or must have the format of a Graal
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
75 * command line option without the leading {@code "-G:"} prefix. These option value are set
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
76 * prior to processing of any Graal options present on the command line.
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
77 */
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
78 private static void loadOptionOverrides() throws InternalError {
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
79 String javaHome = System.getProperty("java.home");
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
80 Path graalDotOptions = Paths.get(javaHome, "lib", "graal.options");
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
81 if (!exists(graalDotOptions)) {
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
82 graalDotOptions = Paths.get(javaHome, "jre", "lib", "graal.options");
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
83 }
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
84 if (exists(graalDotOptions)) {
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
85 try {
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
86 for (String line : Files.readAllLines(graalDotOptions, Charset.defaultCharset())) {
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
87 if (!line.startsWith("#")) {
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
88 if (!setOption(line)) {
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
89 throw new InternalError("Invalid option \"" + line + "\" specified in " + graalDotOptions);
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
90 }
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
91 }
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
92 }
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
93 } catch (IOException e) {
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
94 throw (InternalError) new InternalError().initCause(e);
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
95 }
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
96 }
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
97 }
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
98
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
99 static {
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
100 initializeOptions();
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
101 loadOptionOverrides();
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
102 }
2a091d2987bd added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents: 9919
diff changeset
103
5156
482265e41a1a added -G:+PrintFlags flag for printing the Graal flags; tightened format checking of Graal options to be consistent with HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 5149
diff changeset
104 // Called from VM code
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
105 public static boolean setOption(String option) {
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: 13106
diff changeset
106 return parseOption(option, 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: 13106
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: 13106
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: 13106
diff changeset
109 interface 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: 13106
diff changeset
110 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: 13106
diff changeset
111 }
0e5c4f9fa9a5 enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents: 13106
diff changeset
112
0e5c4f9fa9a5 enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents: 13106
diff changeset
113 /**
0e5c4f9fa9a5 enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents: 13106
diff changeset
114 * Parses a given option value specification.
0e5c4f9fa9a5 enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents: 13106
diff changeset
115 *
0e5c4f9fa9a5 enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents: 13106
diff changeset
116 * @param option the specification of an option and its 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: 13106
diff changeset
117 * @param setter the object to notify of the parsed option and value. If null, the
0e5c4f9fa9a5 enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents: 13106
diff changeset
118 * {@link OptionValue#setValue(Object)} method of the specified option is called
0e5c4f9fa9a5 enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents: 13106
diff changeset
119 * instead.
0e5c4f9fa9a5 enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents: 13106
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: 13106
diff changeset
121 public static boolean parseOption(String option, OptionConsumer setter) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122 if (option.length() == 0) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
123 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
124 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
125
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
126 Object value = null;
9912
fbad7372eccd added support for stable options
Doug Simon <doug.simon@oracle.com>
parents: 9903
diff changeset
127 String optionName = null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
128 String valueString = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129
7294
49bbf004fbb8 restored support for -G:+PrintFlags option
Doug Simon <doug.simon@oracle.com>
parents: 6525
diff changeset
130 if (option.equals("+PrintFlags")) {
49bbf004fbb8 restored support for -G:+PrintFlags option
Doug Simon <doug.simon@oracle.com>
parents: 6525
diff changeset
131 printFlags();
49bbf004fbb8 restored support for -G:+PrintFlags option
Doug Simon <doug.simon@oracle.com>
parents: 6525
diff changeset
132 return true;
49bbf004fbb8 restored support for -G:+PrintFlags option
Doug Simon <doug.simon@oracle.com>
parents: 6525
diff changeset
133 }
49bbf004fbb8 restored support for -G:+PrintFlags option
Doug Simon <doug.simon@oracle.com>
parents: 6525
diff changeset
134
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
135 char first = option.charAt(0);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
136 if (first == '+' || first == '-') {
9912
fbad7372eccd added support for stable options
Doug Simon <doug.simon@oracle.com>
parents: 9903
diff changeset
137 optionName = option.substring(1);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138 value = (first == '+');
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
139 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
140 int index = option.indexOf('=');
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
141 if (index == -1) {
9912
fbad7372eccd added support for stable options
Doug Simon <doug.simon@oracle.com>
parents: 9903
diff changeset
142 optionName = option;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
143 valueString = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
144 } else {
9912
fbad7372eccd added support for stable options
Doug Simon <doug.simon@oracle.com>
parents: 9903
diff changeset
145 optionName = option.substring(0, index);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
146 valueString = option.substring(index + 1);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
147 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
148 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
149
9919
af909f4b80a9 options are grouped per top level class/interface when accessed via the service mechanism
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
150 OptionDescriptor desc = options.get(optionName);
af909f4b80a9 options are grouped per top level class/interface when accessed via the service mechanism
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
151 if (desc == null) {
9912
fbad7372eccd added support for stable options
Doug Simon <doug.simon@oracle.com>
parents: 9903
diff changeset
152 Logger.info("Could not find option " + optionName + " (use -G:+PrintFlags to see Graal options)");
11935
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
153 List<OptionDescriptor> matches = fuzzyMatch(optionName);
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
154 if (!matches.isEmpty()) {
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
155 Logger.info("Did you mean one of the following?");
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
156 for (OptionDescriptor match : matches) {
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
157 boolean isBoolean = match.getType() == boolean.class;
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
158 Logger.info(String.format(" %s%s%s", isBoolean ? "(+/-)" : "", match.getName(), isBoolean ? "" : "=<value>"));
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
159 }
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
160 }
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9853
diff changeset
161 return false;
9849
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
162 }
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
163
9919
af909f4b80a9 options are grouped per top level class/interface when accessed via the service mechanism
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
164 Class<?> optionType = desc.getType();
9849
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
165
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
166 if (value == null) {
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
167 if (optionType == Boolean.TYPE || optionType == Boolean.class) {
9912
fbad7372eccd added support for stable options
Doug Simon <doug.simon@oracle.com>
parents: 9903
diff changeset
168 Logger.info("Value for boolean option '" + optionName + "' must use '-G:+" + optionName + "' or '-G:-" + optionName + "' format");
9849
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
169 return false;
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
170 }
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
171
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
172 if (valueString == null) {
9912
fbad7372eccd added support for stable options
Doug Simon <doug.simon@oracle.com>
parents: 9903
diff changeset
173 Logger.info("Value for option '" + optionName + "' must use '-G:" + optionName + "=<value>' format");
9849
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
174 return false;
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
175 }
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
176
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
177 if (optionType == Float.class) {
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
178 value = Float.parseFloat(valueString);
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
179 } else if (optionType == Double.class) {
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
180 value = Double.parseDouble(valueString);
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
181 } else if (optionType == Integer.class) {
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
182 value = Integer.parseInt(valueString);
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
183 } else if (optionType == String.class) {
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
184 value = valueString;
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
185 }
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
186 } else {
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
187 if (optionType != Boolean.class) {
9912
fbad7372eccd added support for stable options
Doug Simon <doug.simon@oracle.com>
parents: 9903
diff changeset
188 Logger.info("Value for option '" + optionName + "' must use '-G:" + optionName + "=<value>' format");
9849
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
189 return false;
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
190 }
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
191 }
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
192
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
193 if (value != 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: 13106
diff changeset
194 if (setter != 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: 13106
diff changeset
195 setter.set(desc, 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: 13106
diff changeset
196 } else {
0e5c4f9fa9a5 enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents: 13106
diff changeset
197 OptionValue<?> optionValue = desc.getOptionValue();
0e5c4f9fa9a5 enabled non-hosted CompileTheWorld execution with complete bootstrapping and the ability to override compilation options separately for CTW compilations
Doug Simon <doug.simon@oracle.com>
parents: 13106
diff changeset
198 optionValue.setValue(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: 13106
diff changeset
199 // Logger.info("Set option " + desc.getName() + " to " + 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: 13106
diff changeset
200 }
9849
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
201 } else {
9912
fbad7372eccd added support for stable options
Doug Simon <doug.simon@oracle.com>
parents: 9903
diff changeset
202 Logger.info("Wrong value \"" + valueString + "\" for option " + optionName);
9849
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
203 return false;
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
204 }
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
205
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
206 return true;
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
207 }
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
208
11365
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
209 /**
12777
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
210 * Sets the relevant system property such that a {@link DebugTimer} or {@link DebugMetric}
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
211 * associated with a field in a class will be unconditionally enabled when it is created.
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
212 * <p>
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
213 * This method verifies that the named field exists and is of an expected type. However, it does
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
214 * not verify that the timer or metric created has the same name of the field.
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
215 *
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
216 * @param c the class in which the field is declared
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
217 * @param name the name of the field
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
218 */
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
219 private static void unconditionallyEnableTimerOrMetric(Class c, String name) {
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
220 try {
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
221 Field field = c.getDeclaredField(name);
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
222 String propertyName;
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
223 if (DebugTimer.class.isAssignableFrom(field.getType())) {
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
224 propertyName = Debug.ENABLE_TIMER_PROPERTY_NAME_PREFIX + name;
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
225 } else {
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
226 assert DebugMetric.class.isAssignableFrom(field.getType());
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
227 propertyName = Debug.ENABLE_METRIC_PROPERTY_NAME_PREFIX + name;
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
228 }
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
229 String previous = System.setProperty(propertyName, "true");
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
230 if (previous != null) {
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
231 Logger.info("Overrode value \"" + previous + "\" of system property \"" + propertyName + "\" with \"true\"");
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
232 }
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
233 } catch (Exception e) {
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
234 throw new GraalInternalError(e);
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
235 }
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
236 }
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
237
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
238 /**
11561
e1309fc4d17f ensure Debug.enable() is called before any DebugTimer or DebugMetric objects are requested
Doug Simon <doug.simon@oracle.com>
parents: 11365
diff changeset
239 * Called from VM code once all Graal command line options have been processed by
e1309fc4d17f ensure Debug.enable() is called before any DebugTimer or DebugMetric objects are requested
Doug Simon <doug.simon@oracle.com>
parents: 11365
diff changeset
240 * {@link #setOption(String)}.
11585
516b93ccf7c9 pass the value of the -XX:+CITime VM option explicitly to HotSpotOptions.finalize()
Doug Simon <doug.simon@oracle.com>
parents: 11563
diff changeset
241 *
13106
bdc836ef885e made CITimeEach work for Graal even if CITime is not enabled
Doug Simon <doug.simon@oracle.com>
parents: 13103
diff changeset
242 * @param timeCompilations true if the CITime or CITimeEach HotSpot VM options are set
11561
e1309fc4d17f ensure Debug.enable() is called before any DebugTimer or DebugMetric objects are requested
Doug Simon <doug.simon@oracle.com>
parents: 11365
diff changeset
243 */
13106
bdc836ef885e made CITimeEach work for Graal even if CITime is not enabled
Doug Simon <doug.simon@oracle.com>
parents: 13103
diff changeset
244 public static void finalizeOptions(boolean timeCompilations) {
bdc836ef885e made CITimeEach work for Graal even if CITime is not enabled
Doug Simon <doug.simon@oracle.com>
parents: 13103
diff changeset
245 if (timeCompilations) {
12777
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
246 unconditionallyEnableTimerOrMetric(InliningUtil.class, "InlinedBytecodes");
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
247 unconditionallyEnableTimerOrMetric(CompilationTask.class, "CompilationTime");
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
248 }
516ad7baa080 made the BytecodesParsed and InlinedBytecodes metrics and CompilationTime timer be unconditionally enabled if -XX:+CITime
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
249 if (areDebugScopePatternsEnabled()) {
11612
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
250 assert !Debug.Initialization.isDebugInitialized();
54dff87002e0 check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents: 11611
diff changeset
251 System.setProperty(Debug.Initialization.INITIALIZER_PROPERTY_NAME, "true");
11561
e1309fc4d17f ensure Debug.enable() is called before any DebugTimer or DebugMetric objects are requested
Doug Simon <doug.simon@oracle.com>
parents: 11365
diff changeset
252 }
e1309fc4d17f ensure Debug.enable() is called before any DebugTimer or DebugMetric objects are requested
Doug Simon <doug.simon@oracle.com>
parents: 11365
diff changeset
253 }
e1309fc4d17f ensure Debug.enable() is called before any DebugTimer or DebugMetric objects are requested
Doug Simon <doug.simon@oracle.com>
parents: 11365
diff changeset
254
e1309fc4d17f ensure Debug.enable() is called before any DebugTimer or DebugMetric objects are requested
Doug Simon <doug.simon@oracle.com>
parents: 11365
diff changeset
255 /**
11365
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
256 * Wraps some given text to one or more lines of a given maximum width.
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
257 *
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
258 * @param text text to wrap
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
259 * @param width maximum width of an output line, exception for words in {@code text} longer than
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
260 * this value
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
261 * @return {@code text} broken into lines
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
262 */
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
263 private static List<String> wrap(String text, int width) {
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
264 List<String> lines = Collections.singletonList(text);
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
265 if (text.length() > width) {
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
266 String[] chunks = text.split("\\s+");
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
267 lines = new ArrayList<>();
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
268 StringBuilder line = new StringBuilder();
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
269 for (String chunk : chunks) {
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
270 if (line.length() + chunk.length() > width) {
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
271 lines.add(line.toString());
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
272 line.setLength(0);
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
273 }
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
274 if (line.length() != 0) {
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
275 line.append(' ');
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
276 }
11889
b168635707b5 fix line wrapping issue when printing help for options
Doug Simon <doug.simon@oracle.com>
parents: 11612
diff changeset
277 String[] embeddedLines = chunk.split("%n", -2);
11365
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
278 if (embeddedLines.length == 1) {
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
279 line.append(chunk);
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
280 } else {
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
281 for (int i = 0; i < embeddedLines.length; i++) {
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
282 line.append(embeddedLines[i]);
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
283 if (i < embeddedLines.length - 1) {
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
284 lines.add(line.toString());
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
285 line.setLength(0);
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
286 }
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
287 }
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
288 }
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
289 }
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
290 if (line.length() != 0) {
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
291 lines.add(line.toString());
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
292 }
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
293 }
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
294 return lines;
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
295 }
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
296
5156
482265e41a1a added -G:+PrintFlags flag for printing the Graal flags; tightened format checking of Graal options to be consistent with HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 5149
diff changeset
297 private static void printFlags() {
482265e41a1a added -G:+PrintFlags flag for printing the Graal flags; tightened format checking of Graal options to be consistent with HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 5149
diff changeset
298 Logger.info("[Graal flags]");
9919
af909f4b80a9 options are grouped per top level class/interface when accessed via the service mechanism
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
299 SortedMap<String, OptionDescriptor> sortedOptions = new TreeMap<>(options);
af909f4b80a9 options are grouped per top level class/interface when accessed via the service mechanism
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
300 for (Map.Entry<String, OptionDescriptor> e : sortedOptions.entrySet()) {
9849
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
301 e.getKey();
9919
af909f4b80a9 options are grouped per top level class/interface when accessed via the service mechanism
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
302 OptionDescriptor desc = e.getValue();
af909f4b80a9 options are grouped per top level class/interface when accessed via the service mechanism
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
303 Object value = desc.getOptionValue().getValue();
11365
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
304 List<String> helpLines = wrap(desc.getHelp(), 70);
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
305 Logger.info(String.format("%9s %-40s = %-14s %s", desc.getType().getSimpleName(), e.getKey(), value, helpLines.get(0)));
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
306 for (int i = 1; i < helpLines.size(); i++) {
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
307 Logger.info(String.format("%67s %s", " ", helpLines.get(i)));
5a7644d5fe20 added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents: 9986
diff changeset
308 }
9849
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
309 }
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
310
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
311 System.exit(0);
e876c2a6954f extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 7739
diff changeset
312 }
11935
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
313
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
314 /**
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
315 * Compute string similarity based on Dice's coefficient.
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
316 *
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
317 * Ported from str_similar() in globals.cpp.
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
318 */
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
319 static float stringSimiliarity(String str1, String str2) {
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
320 int hit = 0;
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
321 for (int i = 0; i < str1.length() - 1; ++i) {
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
322 for (int j = 0; j < str2.length() - 1; ++j) {
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
323 if ((str1.charAt(i) == str2.charAt(j)) && (str1.charAt(i + 1) == str2.charAt(j + 1))) {
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
324 ++hit;
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
325 break;
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
326 }
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
327 }
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
328 }
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
329 return 2.0f * hit / (str1.length() + str2.length());
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
330 }
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
331
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
332 private static final float FUZZY_MATCH_THRESHOLD = 0.7F;
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
333
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
334 /**
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
335 * Returns the set of options that fuzzy match a given option name.
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
336 */
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
337 private static List<OptionDescriptor> fuzzyMatch(String optionName) {
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
338 List<OptionDescriptor> matches = new ArrayList<>();
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
339 for (Map.Entry<String, OptionDescriptor> e : options.entrySet()) {
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
340 float score = stringSimiliarity(e.getKey(), optionName);
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
341 if (score >= FUZZY_MATCH_THRESHOLD) {
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
342 matches.add(e.getValue());
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
343 }
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
344 }
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
345 return matches;
12e9d529fd1d suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents: 11889
diff changeset
346 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
347 }