Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java @ 12570:af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 24 Oct 2013 14:57:57 +0200 |
parents | 12e9d529fd1d |
children | 516ad7baa080 |
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.*; |
2a091d2987bd
added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
30 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
|
31 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
|
32 import java.util.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 |
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
|
34 import com.oracle.graal.debug.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
35 import com.oracle.graal.hotspot.logging.*; |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
36 import com.oracle.graal.options.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 |
9935
2a091d2987bd
added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
38 /** |
2a091d2987bd
added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
39 * 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
|
40 * (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
|
41 */ |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 public class HotSpotOptions { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 |
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
|
44 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
|
45 |
9935
2a091d2987bd
added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
46 /** |
2a091d2987bd
added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
47 * 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
|
48 */ |
2a091d2987bd
added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 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
|
57 } |
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
|
58 } |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
59 } |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
60 } |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
61 |
9935
2a091d2987bd
added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
62 /** |
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
|
63 * 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
|
64 */ |
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
|
65 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
|
66 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
|
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 |
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 /** |
9935
2a091d2987bd
added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
70 * 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
|
71 * 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
|
72 * 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
|
73 * 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
|
74 */ |
2a091d2987bd
added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
75 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
|
76 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
|
77 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
|
78 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
|
79 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
|
80 } |
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 try { |
2a091d2987bd
added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
83 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
|
84 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
|
85 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
|
86 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
|
87 } |
2a091d2987bd
added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
88 } |
2a091d2987bd
added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
89 } |
2a091d2987bd
added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
90 } 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
|
91 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
|
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 } |
2a091d2987bd
added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
94 } |
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 static { |
2a091d2987bd
added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
97 initializeOptions(); |
2a091d2987bd
added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
98 loadOptionOverrides(); |
2a091d2987bd
added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
99 } |
2a091d2987bd
added graal.options mechanism for being able to override default option values
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
100 |
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
|
101 // Called from VM code |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
102 public static boolean setOption(String option) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 if (option.length() == 0) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
105 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
106 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
107 Object value = null; |
9912
fbad7372eccd
added support for stable options
Doug Simon <doug.simon@oracle.com>
parents:
9903
diff
changeset
|
108 String optionName = null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
109 String valueString = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
110 |
7294
49bbf004fbb8
restored support for -G:+PrintFlags option
Doug Simon <doug.simon@oracle.com>
parents:
6525
diff
changeset
|
111 if (option.equals("+PrintFlags")) { |
49bbf004fbb8
restored support for -G:+PrintFlags option
Doug Simon <doug.simon@oracle.com>
parents:
6525
diff
changeset
|
112 printFlags(); |
49bbf004fbb8
restored support for -G:+PrintFlags option
Doug Simon <doug.simon@oracle.com>
parents:
6525
diff
changeset
|
113 return true; |
49bbf004fbb8
restored support for -G:+PrintFlags option
Doug Simon <doug.simon@oracle.com>
parents:
6525
diff
changeset
|
114 } |
49bbf004fbb8
restored support for -G:+PrintFlags option
Doug Simon <doug.simon@oracle.com>
parents:
6525
diff
changeset
|
115 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
116 char first = option.charAt(0); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 if (first == '+' || first == '-') { |
9912
fbad7372eccd
added support for stable options
Doug Simon <doug.simon@oracle.com>
parents:
9903
diff
changeset
|
118 optionName = option.substring(1); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
119 value = (first == '+'); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
120 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
121 int index = option.indexOf('='); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
122 if (index == -1) { |
9912
fbad7372eccd
added support for stable options
Doug Simon <doug.simon@oracle.com>
parents:
9903
diff
changeset
|
123 optionName = option; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
124 valueString = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
125 } else { |
9912
fbad7372eccd
added support for stable options
Doug Simon <doug.simon@oracle.com>
parents:
9903
diff
changeset
|
126 optionName = option.substring(0, index); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 valueString = option.substring(index + 1); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
128 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
129 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
130 |
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
|
131 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
|
132 if (desc == null) { |
9912
fbad7372eccd
added support for stable options
Doug Simon <doug.simon@oracle.com>
parents:
9903
diff
changeset
|
133 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
|
134 List<OptionDescriptor> matches = fuzzyMatch(optionName); |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
135 if (!matches.isEmpty()) { |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
136 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
|
137 for (OptionDescriptor match : matches) { |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
138 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
|
139 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
|
140 } |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
141 } |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9853
diff
changeset
|
142 return false; |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
143 } |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
144 |
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
|
145 Class<?> optionType = desc.getType(); |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
146 |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
147 if (value == null) { |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
148 if (optionType == Boolean.TYPE || optionType == Boolean.class) { |
9912
fbad7372eccd
added support for stable options
Doug Simon <doug.simon@oracle.com>
parents:
9903
diff
changeset
|
149 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
|
150 return false; |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
151 } |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
152 |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
153 if (valueString == null) { |
9912
fbad7372eccd
added support for stable options
Doug Simon <doug.simon@oracle.com>
parents:
9903
diff
changeset
|
154 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
|
155 return false; |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
156 } |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
157 |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
158 if (optionType == Float.class) { |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
159 value = Float.parseFloat(valueString); |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
160 } else if (optionType == Double.class) { |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
161 value = Double.parseDouble(valueString); |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
162 } else if (optionType == Integer.class) { |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
163 value = Integer.parseInt(valueString); |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
164 } else if (optionType == String.class) { |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
165 value = valueString; |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
166 } |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
167 } else { |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
168 if (optionType != Boolean.class) { |
9912
fbad7372eccd
added support for stable options
Doug Simon <doug.simon@oracle.com>
parents:
9903
diff
changeset
|
169 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
|
170 return false; |
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 } |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
173 |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
174 if (value != null) { |
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
|
175 OptionValue<?> optionValue = desc.getOptionValue(); |
9912
fbad7372eccd
added support for stable options
Doug Simon <doug.simon@oracle.com>
parents:
9903
diff
changeset
|
176 optionValue.setValue(value); |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11935
diff
changeset
|
177 // Logger.info("Set option " + desc.getName() + " to " + value); |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
178 } else { |
9912
fbad7372eccd
added support for stable options
Doug Simon <doug.simon@oracle.com>
parents:
9903
diff
changeset
|
179 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
|
180 return false; |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
181 } |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
182 |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
183 return true; |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
184 } |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
185 |
11365
5a7644d5fe20
added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents:
9986
diff
changeset
|
186 /** |
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
|
187 * 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
|
188 * {@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
|
189 * |
516b93ccf7c9
pass the value of the -XX:+CITime VM option explicitly to HotSpotOptions.finalize()
Doug Simon <doug.simon@oracle.com>
parents:
11563
diff
changeset
|
190 * @param ciTime the value of the CITime HotSpot VM option |
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
|
191 */ |
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
|
192 public static void finalizeOptions(boolean ciTime) { |
516b93ccf7c9
pass the value of the -XX:+CITime VM option explicitly to HotSpotOptions.finalize()
Doug Simon <doug.simon@oracle.com>
parents:
11563
diff
changeset
|
193 if (areDebugScopePatternsEnabled() || ciTime) { |
11612
54dff87002e0
check that Debug has not been initialized before HotSpotOptions.finalizeOptions() is called
Doug Simon <doug.simon@oracle.com>
parents:
11611
diff
changeset
|
194 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
|
195 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
|
196 } |
e1309fc4d17f
ensure Debug.enable() is called before any DebugTimer or DebugMetric objects are requested
Doug Simon <doug.simon@oracle.com>
parents:
11365
diff
changeset
|
197 } |
e1309fc4d17f
ensure Debug.enable() is called before any DebugTimer or DebugMetric objects are requested
Doug Simon <doug.simon@oracle.com>
parents:
11365
diff
changeset
|
198 |
e1309fc4d17f
ensure Debug.enable() is called before any DebugTimer or DebugMetric objects are requested
Doug Simon <doug.simon@oracle.com>
parents:
11365
diff
changeset
|
199 /** |
11365
5a7644d5fe20
added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents:
9986
diff
changeset
|
200 * 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
|
201 * |
5a7644d5fe20
added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents:
9986
diff
changeset
|
202 * @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
|
203 * @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
|
204 * this value |
5a7644d5fe20
added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents:
9986
diff
changeset
|
205 * @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
|
206 */ |
5a7644d5fe20
added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents:
9986
diff
changeset
|
207 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
|
208 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
|
209 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
|
210 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
|
211 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
|
212 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
|
213 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
|
214 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
|
215 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
|
216 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
|
217 } |
5a7644d5fe20
added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents:
9986
diff
changeset
|
218 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
|
219 line.append(' '); |
5a7644d5fe20
added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents:
9986
diff
changeset
|
220 } |
11889
b168635707b5
fix line wrapping issue when printing help for options
Doug Simon <doug.simon@oracle.com>
parents:
11612
diff
changeset
|
221 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
|
222 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
|
223 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
|
224 } else { |
5a7644d5fe20
added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents:
9986
diff
changeset
|
225 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
|
226 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
|
227 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
|
228 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
|
229 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
|
230 } |
5a7644d5fe20
added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents:
9986
diff
changeset
|
231 } |
5a7644d5fe20
added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents:
9986
diff
changeset
|
232 } |
5a7644d5fe20
added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents:
9986
diff
changeset
|
233 } |
5a7644d5fe20
added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents:
9986
diff
changeset
|
234 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
|
235 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
|
236 } |
5a7644d5fe20
added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents:
9986
diff
changeset
|
237 } |
5a7644d5fe20
added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents:
9986
diff
changeset
|
238 return lines; |
5a7644d5fe20
added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents:
9986
diff
changeset
|
239 } |
5a7644d5fe20
added capability for embedding new lines in lengthy option help messages
Doug Simon <doug.simon@oracle.com>
parents:
9986
diff
changeset
|
240 |
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
|
241 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
|
242 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
|
243 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
|
244 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
|
245 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
|
246 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
|
247 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
|
248 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
|
249 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
|
250 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
|
251 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
|
252 } |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
253 } |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
254 |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
255 System.exit(0); |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
7739
diff
changeset
|
256 } |
11935
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
257 |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
258 /** |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
259 * 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
|
260 * |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
261 * 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
|
262 */ |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
263 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
|
264 int hit = 0; |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
265 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
|
266 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
|
267 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
|
268 ++hit; |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
269 break; |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
270 } |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
271 } |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
272 } |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
273 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
|
274 } |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
275 |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
276 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
|
277 |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
278 /** |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
279 * 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
|
280 */ |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
281 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
|
282 List<OptionDescriptor> matches = new ArrayList<>(); |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
283 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
|
284 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
|
285 if (score >= FUZZY_MATCH_THRESHOLD) { |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
286 matches.add(e.getValue()); |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
287 } |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
288 } |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
289 return matches; |
12e9d529fd1d
suggest corrections for mistyped Graal options (GRAAL-521)
Doug Simon <doug.simon@oracle.com>
parents:
11889
diff
changeset
|
290 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
291 } |