Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.options/src/jdk/vm/ci/options/OptionValue.java @ 22672:1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Thu, 08 Oct 2015 17:28:41 -0700 |
parents | jvmci/jdk.internal.jvmci.options/src/jdk/internal/jvmci/options/OptionValue.java@ec96f33a101d |
children |
rev | line source |
---|---|
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22569
diff
changeset
|
23 package jdk.vm.ci.options; |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22469
diff
changeset
|
25 import java.io.PrintStream; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22469
diff
changeset
|
26 import java.util.ArrayList; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22469
diff
changeset
|
27 import java.util.Collection; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22469
diff
changeset
|
28 import java.util.Collections; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22469
diff
changeset
|
29 import java.util.Comparator; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22469
diff
changeset
|
30 import java.util.HashMap; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22469
diff
changeset
|
31 import java.util.Map; |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
32 import java.util.Map.Entry; |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22469
diff
changeset
|
33 import java.util.Objects; |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
34 |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 /** |
9919
af909f4b80a9
options are grouped per top level class/interface when accessed via the service mechanism
Doug Simon <doug.simon@oracle.com>
parents:
9914
diff
changeset
|
36 * An option value. |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 */ |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 public class OptionValue<T> { |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 /** |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
40 * Temporarily changes the value for an option. The {@linkplain OptionValue#getValue() value} of |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
41 * {@code option} is set to {@code value} until {@link OverrideScope#close()} is called on the |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
42 * object returned by this method. |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
43 * <p> |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
44 * Since the returned object is {@link AutoCloseable} the try-with-resource construct can be |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
45 * used: |
14763 | 46 * |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
47 * <pre> |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
48 * try (OverrideScope s = OptionValue.override(myOption, myValue) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
49 * // code that depends on myOption == myValue |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
50 * } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
51 * </pre> |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
52 */ |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
53 public static OverrideScope override(OptionValue<?> option, Object value) { |
18935
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18685
diff
changeset
|
54 OverrideScope current = getOverrideScope(); |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
55 if (current == null) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
56 if (!value.equals(option.getValue())) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
57 return new SingleOverrideScope(option, value); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
58 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
59 Map<OptionValue<?>, Object> overrides = Collections.emptyMap(); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
60 return new MultipleOverridesScope(current, overrides); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
61 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
62 return new MultipleOverridesScope(current, option, value); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
63 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
64 |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
65 /** |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
66 * Temporarily changes the values for a set of options. The {@linkplain OptionValue#getValue() |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
67 * value} of each {@code option} in {@code overrides} is set to the corresponding {@code value} |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
68 * in {@code overrides} until {@link OverrideScope#close()} is called on the object returned by |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
69 * this method. |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
70 * <p> |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
71 * Since the returned object is {@link AutoCloseable} the try-with-resource construct can be |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
72 * used: |
14763 | 73 * |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
74 * <pre> |
14906 | 75 * Map<OptionValue, Object> overrides = new HashMap<>(); |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
76 * overrides.put(myOption1, myValue1); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
77 * overrides.put(myOption2, myValue2); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
78 * try (OverrideScope s = OptionValue.override(overrides) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
79 * // code that depends on myOption == myValue |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
80 * } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
81 * </pre> |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
82 */ |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
83 public static OverrideScope override(Map<OptionValue<?>, Object> overrides) { |
18935
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18685
diff
changeset
|
84 OverrideScope current = getOverrideScope(); |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
85 if (current == null && overrides.size() == 1) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
86 Entry<OptionValue<?>, Object> single = overrides.entrySet().iterator().next(); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
87 OptionValue<?> option = single.getKey(); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
88 Object overrideValue = single.getValue(); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
89 if (!overrideValue.equals(option.getValue())) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
90 return new SingleOverrideScope(option, overrideValue); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
91 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
92 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
93 return new MultipleOverridesScope(current, overrides); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
94 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
95 |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
96 /** |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
97 * Temporarily changes the values for a set of options. The {@linkplain OptionValue#getValue() |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
98 * value} of each {@code option} in {@code overrides} is set to the corresponding {@code value} |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
99 * in {@code overrides} until {@link OverrideScope#close()} is called on the object returned by |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
100 * this method. |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
101 * <p> |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
102 * Since the returned object is {@link AutoCloseable} the try-with-resource construct can be |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
103 * used: |
14763 | 104 * |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
105 * <pre> |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
106 * try (OverrideScope s = OptionValue.override(myOption1, myValue1, myOption2, myValue2) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
107 * // code that depends on myOption == myValue |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
108 * } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
109 * </pre> |
14763 | 110 * |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
111 * @param overrides overrides in the form {@code [option1, override1, option2, override2, ...]} |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
112 */ |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
113 public static OverrideScope override(Object... overrides) { |
18935
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18685
diff
changeset
|
114 OverrideScope current = getOverrideScope(); |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
115 if (current == null && overrides.length == 2) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
116 OptionValue<?> option = (OptionValue<?>) overrides[0]; |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
117 Object overrideValue = overrides[1]; |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
118 if (!overrideValue.equals(option.getValue())) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
119 return new SingleOverrideScope(option, overrideValue); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
120 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
121 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
122 Map<OptionValue<?>, Object> map = Collections.emptyMap(); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
123 for (int i = 0; i < overrides.length; i += 2) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
124 OptionValue<?> option = (OptionValue<?>) overrides[i]; |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
125 Object overrideValue = overrides[i + 1]; |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
126 if (!overrideValue.equals(option.getValue())) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
127 if (map.isEmpty()) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
128 map = new HashMap<>(); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
129 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
130 map.put(option, overrideValue); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
131 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
132 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
133 return new MultipleOverridesScope(current, map); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
134 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
135 |
18935
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18685
diff
changeset
|
136 private static final ThreadLocal<OverrideScope> overrideScopeTL = new ThreadLocal<>(); |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18685
diff
changeset
|
137 |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18685
diff
changeset
|
138 protected static OverrideScope getOverrideScope() { |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18685
diff
changeset
|
139 return overrideScopeTL.get(); |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18685
diff
changeset
|
140 } |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18685
diff
changeset
|
141 |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18685
diff
changeset
|
142 protected static void setOverrideScope(OverrideScope overrideScope) { |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18685
diff
changeset
|
143 overrideScopeTL.set(overrideScope); |
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18685
diff
changeset
|
144 } |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
145 |
21519
cecb4e39521c
Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18935
diff
changeset
|
146 private T defaultValue; |
18683
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
147 |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
148 /** |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
149 * The raw option value. |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
150 */ |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
151 protected T value; |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
152 |
12671
582b3d24c6ad
record an OptionDescriptor in an OptionValue so that it can be queried for a name
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
153 private OptionDescriptor descriptor; |
582b3d24c6ad
record an OptionDescriptor in an OptionValue so that it can be queried for a name
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
154 |
12682
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
155 private long reads; |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
156 private OptionValue<?> next; |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14906
diff
changeset
|
157 private static OptionValue<?> head; |
12682
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
158 |
21558
d563baeca9df
changed uses of Graal terminology to JVMCI (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21554
diff
changeset
|
159 private static final boolean ShowReadsHistogram = Boolean.getBoolean("jvmci.showOptionValueReadsHistogram"); |
12682
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
160 |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
161 private static void addToHistogram(OptionValue<?> option) { |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
162 if (ShowReadsHistogram) { |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
163 synchronized (OptionValue.class) { |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
164 option.next = head; |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
165 head = option; |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
166 } |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
167 } |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
168 } |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
169 |
18683
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
170 @SuppressWarnings("unchecked") |
9914
84890660eefb
cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents:
9912
diff
changeset
|
171 public OptionValue(T value) { |
21519
cecb4e39521c
Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18935
diff
changeset
|
172 this.defaultValue = value; |
cecb4e39521c
Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18935
diff
changeset
|
173 this.value = (T) DEFAULT; |
12682
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
174 addToHistogram(this); |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
175 } |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
176 |
21519
cecb4e39521c
Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18935
diff
changeset
|
177 private static final Object DEFAULT = "DEFAULT"; |
9863
b2141bc6e98e
option values are either initialized upon creation or they must provide a lazily initialized value
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
178 private static final Object UNINITIALIZED = "UNINITIALIZED"; |
b2141bc6e98e
option values are either initialized upon creation or they must provide a lazily initialized value
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
179 |
b2141bc6e98e
option values are either initialized upon creation or they must provide a lazily initialized value
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
180 /** |
b2141bc6e98e
option values are either initialized upon creation or they must provide a lazily initialized value
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
181 * Creates an uninitialized option value for a subclass that initializes itself |
21519
cecb4e39521c
Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18935
diff
changeset
|
182 * {@link #defaultValue() lazily}. |
9863
b2141bc6e98e
option values are either initialized upon creation or they must provide a lazily initialized value
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
183 */ |
b2141bc6e98e
option values are either initialized upon creation or they must provide a lazily initialized value
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
184 @SuppressWarnings("unchecked") |
9914
84890660eefb
cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents:
9912
diff
changeset
|
185 protected OptionValue() { |
21519
cecb4e39521c
Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18935
diff
changeset
|
186 this.defaultValue = (T) UNINITIALIZED; |
cecb4e39521c
Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18935
diff
changeset
|
187 this.value = (T) DEFAULT; |
12682
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
188 addToHistogram(this); |
9863
b2141bc6e98e
option values are either initialized upon creation or they must provide a lazily initialized value
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
189 } |
b2141bc6e98e
option values are either initialized upon creation or they must provide a lazily initialized value
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
190 |
b2141bc6e98e
option values are either initialized upon creation or they must provide a lazily initialized value
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
191 /** |
21519
cecb4e39521c
Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18935
diff
changeset
|
192 * Lazy initialization of default value. |
9863
b2141bc6e98e
option values are either initialized upon creation or they must provide a lazily initialized value
Doug Simon <doug.simon@oracle.com>
parents:
9849
diff
changeset
|
193 */ |
21519
cecb4e39521c
Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18935
diff
changeset
|
194 protected T defaultValue() { |
cecb4e39521c
Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18935
diff
changeset
|
195 throw new InternalError("Option without a default value value must override defaultValue()"); |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
196 } |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
197 |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
198 /** |
12671
582b3d24c6ad
record an OptionDescriptor in an OptionValue so that it can be queried for a name
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
199 * Sets the descriptor for this option. |
582b3d24c6ad
record an OptionDescriptor in an OptionValue so that it can be queried for a name
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
200 */ |
582b3d24c6ad
record an OptionDescriptor in an OptionValue so that it can be queried for a name
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
201 public void setDescriptor(OptionDescriptor descriptor) { |
22469
a6adaf9c330d
Ensure only one OptionDescriptor is created per option; allow custom lists of options passed to OptionParser
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22054
diff
changeset
|
202 assert this.descriptor == null : "Overwriting existing descriptor"; |
12671
582b3d24c6ad
record an OptionDescriptor in an OptionValue so that it can be queried for a name
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
203 this.descriptor = descriptor; |
582b3d24c6ad
record an OptionDescriptor in an OptionValue so that it can be queried for a name
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
204 } |
582b3d24c6ad
record an OptionDescriptor in an OptionValue so that it can be queried for a name
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
205 |
582b3d24c6ad
record an OptionDescriptor in an OptionValue so that it can be queried for a name
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
206 /** |
18683
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
207 * Returns the descriptor for this option, if it has been set by |
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
208 * {@link #setDescriptor(OptionDescriptor)}. |
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
209 */ |
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
210 public OptionDescriptor getDescriptor() { |
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
211 return descriptor; |
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
212 } |
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
213 |
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
214 /** |
12671
582b3d24c6ad
record an OptionDescriptor in an OptionValue so that it can be queried for a name
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
215 * Gets the name of this option. The name for an option value with a null |
12682
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
216 * {@linkplain #setDescriptor(OptionDescriptor) descriptor} is the value of |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
217 * {@link Object#toString()}. |
12671
582b3d24c6ad
record an OptionDescriptor in an OptionValue so that it can be queried for a name
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
218 */ |
582b3d24c6ad
record an OptionDescriptor in an OptionValue so that it can be queried for a name
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
219 public String getName() { |
12682
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
220 return descriptor == null ? super.toString() : (descriptor.getDeclaringClass().getName() + "." + descriptor.getName()); |
12671
582b3d24c6ad
record an OptionDescriptor in an OptionValue so that it can be queried for a name
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
221 } |
582b3d24c6ad
record an OptionDescriptor in an OptionValue so that it can be queried for a name
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
222 |
582b3d24c6ad
record an OptionDescriptor in an OptionValue so that it can be queried for a name
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
223 @Override |
582b3d24c6ad
record an OptionDescriptor in an OptionValue so that it can be queried for a name
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
224 public String toString() { |
12735
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
225 return getName() + "=" + getValue(); |
12671
582b3d24c6ad
record an OptionDescriptor in an OptionValue so that it can be queried for a name
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
226 } |
582b3d24c6ad
record an OptionDescriptor in an OptionValue so that it can be queried for a name
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
227 |
582b3d24c6ad
record an OptionDescriptor in an OptionValue so that it can be queried for a name
Doug Simon <doug.simon@oracle.com>
parents:
9919
diff
changeset
|
228 /** |
18683
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
229 * The initial value specified in source code. The returned value is not affected by calls to |
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
230 * {@link #setValue(Object)} or registering {@link OverrideScope}s. Therefore, it is also not |
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
231 * affected by options set on the command line. |
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
232 */ |
21519
cecb4e39521c
Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18935
diff
changeset
|
233 public T getDefaultValue() { |
cecb4e39521c
Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18935
diff
changeset
|
234 if (defaultValue == UNINITIALIZED) { |
cecb4e39521c
Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18935
diff
changeset
|
235 defaultValue = defaultValue(); |
18683
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
236 } |
21519
cecb4e39521c
Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18935
diff
changeset
|
237 return defaultValue; |
18683
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
238 } |
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
239 |
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
240 /** |
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
241 * Returns true if the option has the same value that was set in the source code. |
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
242 */ |
21519
cecb4e39521c
Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18935
diff
changeset
|
243 public boolean hasDefaultValue() { |
22469
a6adaf9c330d
Ensure only one OptionDescriptor is created per option; allow custom lists of options passed to OptionParser
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22054
diff
changeset
|
244 if (!(this instanceof StableOptionValue)) { |
a6adaf9c330d
Ensure only one OptionDescriptor is created per option; allow custom lists of options passed to OptionParser
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22054
diff
changeset
|
245 getValue(); // ensure initialized |
a6adaf9c330d
Ensure only one OptionDescriptor is created per option; allow custom lists of options passed to OptionParser
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22054
diff
changeset
|
246 } |
21519
cecb4e39521c
Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18935
diff
changeset
|
247 return value == DEFAULT || Objects.equals(value, getDefaultValue()); |
18683
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
248 } |
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
249 |
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
250 /** |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
251 * Gets the value of this option. |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
252 */ |
9914
84890660eefb
cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents:
9912
diff
changeset
|
253 public T getValue() { |
12682
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
254 if (ShowReadsHistogram) { |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
255 reads++; |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
256 } |
12674
ecd519b39f10
don't try and get override for StableOptionValues
Doug Simon <doug.simon@oracle.com>
parents:
12672
diff
changeset
|
257 if (!(this instanceof StableOptionValue)) { |
18935
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18685
diff
changeset
|
258 OverrideScope overrideScope = getOverrideScope(); |
12674
ecd519b39f10
don't try and get override for StableOptionValues
Doug Simon <doug.simon@oracle.com>
parents:
12672
diff
changeset
|
259 if (overrideScope != null) { |
ecd519b39f10
don't try and get override for StableOptionValues
Doug Simon <doug.simon@oracle.com>
parents:
12672
diff
changeset
|
260 T override = overrideScope.getOverride(this); |
ecd519b39f10
don't try and get override for StableOptionValues
Doug Simon <doug.simon@oracle.com>
parents:
12672
diff
changeset
|
261 if (override != null) { |
ecd519b39f10
don't try and get override for StableOptionValues
Doug Simon <doug.simon@oracle.com>
parents:
12672
diff
changeset
|
262 return override; |
ecd519b39f10
don't try and get override for StableOptionValues
Doug Simon <doug.simon@oracle.com>
parents:
12672
diff
changeset
|
263 } |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
264 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
265 } |
21519
cecb4e39521c
Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18935
diff
changeset
|
266 if (value != DEFAULT) { |
18683
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
267 return value; |
823f499a247c
Store initial value (the value set in source code) of an option
Christian Wimmer <christian.wimmer@oracle.com>
parents:
16871
diff
changeset
|
268 } else { |
21519
cecb4e39521c
Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18935
diff
changeset
|
269 return getDefaultValue(); |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
270 } |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
271 } |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
272 |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
273 /** |
12735
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
274 * Gets the values of this option including overridden values. |
14763 | 275 * |
12735
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
276 * @param c the collection to which the values are added. If null, one is allocated. |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
277 * @return the collection to which the values were added in order from most overridden to |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
278 * current value |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
279 */ |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
280 @SuppressWarnings("unchecked") |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
281 public Collection<T> getValues(Collection<T> c) { |
14763 | 282 Collection<T> values = c == null ? new ArrayList<>() : c; |
12735
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
283 if (!(this instanceof StableOptionValue)) { |
18935
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18685
diff
changeset
|
284 OverrideScope overrideScope = getOverrideScope(); |
12735
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
285 if (overrideScope != null) { |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
286 overrideScope.getOverrides(this, (Collection<Object>) values); |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
287 } |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
288 } |
21519
cecb4e39521c
Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18935
diff
changeset
|
289 if (value != DEFAULT) { |
18685
18d0f83cd290
Add code missing in initial value handling for options
Christian Wimmer <christian.wimmer@oracle.com>
parents:
18683
diff
changeset
|
290 values.add(value); |
18d0f83cd290
Add code missing in initial value handling for options
Christian Wimmer <christian.wimmer@oracle.com>
parents:
18683
diff
changeset
|
291 } else { |
21519
cecb4e39521c
Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
18935
diff
changeset
|
292 values.add(getDefaultValue()); |
18685
18d0f83cd290
Add code missing in initial value handling for options
Christian Wimmer <christian.wimmer@oracle.com>
parents:
18683
diff
changeset
|
293 } |
12735
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
294 return values; |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
295 } |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
296 |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
297 /** |
9914
84890660eefb
cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents:
9912
diff
changeset
|
298 * Sets the value of this option. |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
299 */ |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
300 @SuppressWarnings("unchecked") |
9914
84890660eefb
cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents:
9912
diff
changeset
|
301 public void setValue(Object v) { |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
302 this.value = (T) v; |
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
303 } |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
304 |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
305 /** |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
306 * An object whose {@link #close()} method reverts the option value overriding initiated by |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
307 * {@link OptionValue#override(OptionValue, Object)} or {@link OptionValue#override(Map)}. |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
308 */ |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
309 public abstract static class OverrideScope implements AutoCloseable { |
16871
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
15040
diff
changeset
|
310 |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
15040
diff
changeset
|
311 private Map<DerivedOptionValue<?>, Object> derivedCache = null; |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
15040
diff
changeset
|
312 |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
15040
diff
changeset
|
313 public <T> T getDerived(DerivedOptionValue<T> key) { |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
15040
diff
changeset
|
314 if (derivedCache == null) { |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
15040
diff
changeset
|
315 derivedCache = new HashMap<>(); |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
15040
diff
changeset
|
316 } |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
15040
diff
changeset
|
317 @SuppressWarnings("unchecked") |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
15040
diff
changeset
|
318 T ret = (T) derivedCache.get(key); |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
15040
diff
changeset
|
319 if (ret == null) { |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
15040
diff
changeset
|
320 ret = key.createValue(); |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
15040
diff
changeset
|
321 derivedCache.put(key, ret); |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
15040
diff
changeset
|
322 } |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
15040
diff
changeset
|
323 return ret; |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
15040
diff
changeset
|
324 } |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
15040
diff
changeset
|
325 |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14906
diff
changeset
|
326 abstract void addToInherited(Map<OptionValue<?>, Object> inherited); |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
327 |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
328 abstract <T> T getOverride(OptionValue<T> option); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
329 |
12735
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
330 abstract void getOverrides(OptionValue<?> option, Collection<Object> c); |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
331 |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
332 public abstract void close(); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
333 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
334 |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
335 static class SingleOverrideScope extends OverrideScope { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
336 |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
337 private final OptionValue<?> option; |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
338 private final Object value; |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
339 |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
340 public SingleOverrideScope(OptionValue<?> option, Object value) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
341 if (option instanceof StableOptionValue) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
342 throw new IllegalArgumentException("Cannot override stable option " + option); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
343 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
344 this.option = option; |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
345 this.value = value; |
18935
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18685
diff
changeset
|
346 setOverrideScope(this); |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
347 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
348 |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
349 @Override |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14906
diff
changeset
|
350 void addToInherited(Map<OptionValue<?>, Object> inherited) { |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
351 inherited.put(option, value); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
352 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
353 |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
354 @SuppressWarnings("unchecked") |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
355 @Override |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
356 <T> T getOverride(OptionValue<T> key) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
357 if (key == this.option) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
358 return (T) value; |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
359 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
360 return null; |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
361 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
362 |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
363 @Override |
12735
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
364 void getOverrides(OptionValue<?> key, Collection<Object> c) { |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
365 if (key == this.option) { |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
366 c.add(value); |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
367 } |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
368 } |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
369 |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
370 @Override |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
371 public void close() { |
18935
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18685
diff
changeset
|
372 setOverrideScope(null); |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
373 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
374 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
375 |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
376 static class MultipleOverridesScope extends OverrideScope { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
377 final OverrideScope parent; |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14906
diff
changeset
|
378 final Map<OptionValue<?>, Object> overrides; |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
379 |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
380 public MultipleOverridesScope(OverrideScope parent, OptionValue<?> option, Object value) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
381 this.parent = parent; |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
382 this.overrides = new HashMap<>(); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
383 if (parent != null) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
384 parent.addToInherited(overrides); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
385 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
386 if (option instanceof StableOptionValue) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
387 throw new IllegalArgumentException("Cannot override stable option " + option); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
388 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
389 if (!value.equals(option.getValue())) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
390 this.overrides.put(option, value); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
391 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
392 if (!overrides.isEmpty()) { |
18935
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18685
diff
changeset
|
393 setOverrideScope(this); |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
394 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
395 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
396 |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
397 MultipleOverridesScope(OverrideScope parent, Map<OptionValue<?>, Object> overrides) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
398 this.parent = parent; |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
399 if (overrides.isEmpty() && parent == null) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
400 this.overrides = Collections.emptyMap(); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
401 return; |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
402 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
403 this.overrides = new HashMap<>(); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
404 if (parent != null) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
405 parent.addToInherited(this.overrides); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
406 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
407 for (Map.Entry<OptionValue<?>, Object> e : overrides.entrySet()) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
408 OptionValue<?> option = e.getKey(); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
409 if (option instanceof StableOptionValue) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
410 throw new IllegalArgumentException("Cannot override stable option " + option); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
411 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
412 if (!e.getValue().equals(option.getValue())) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
413 this.overrides.put(option, e.getValue()); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
414 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
415 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
416 if (!this.overrides.isEmpty()) { |
18935
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18685
diff
changeset
|
417 setOverrideScope(this); |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
418 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
419 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
420 |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
421 @Override |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14906
diff
changeset
|
422 void addToInherited(Map<OptionValue<?>, Object> inherited) { |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
423 if (parent != null) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
424 parent.addToInherited(inherited); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
425 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
426 inherited.putAll(overrides); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
427 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
428 |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
429 @SuppressWarnings("unchecked") |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
430 @Override |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
431 <T> T getOverride(OptionValue<T> option) { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
432 return (T) overrides.get(option); |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
433 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
434 |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
435 @Override |
12735
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
436 void getOverrides(OptionValue<?> option, Collection<Object> c) { |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
437 Object v = overrides.get(option); |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
438 if (v != null) { |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
439 c.add(v); |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
440 } |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
441 if (parent != null) { |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
442 parent.getOverrides(option, c); |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
443 } |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
444 } |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
445 |
bb85b81258a0
modified OptionValue.toString() to use the current, possibly overriding value; added OptionValue.getValues()
Doug Simon <doug.simon@oracle.com>
parents:
12682
diff
changeset
|
446 @Override |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
447 public void close() { |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
448 if (!overrides.isEmpty()) { |
18935
07f2a49f0bfb
Various adjustments to simplify future merges
Paul Woegerer <paul.woegerer@oracle.com>
parents:
18685
diff
changeset
|
449 setOverrideScope(parent); |
12672
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
450 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
451 } |
38bf986ce231
added support for scoped overriding of OptionValues (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
12671
diff
changeset
|
452 } |
12682
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
453 |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
454 static { |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
455 if (ShowReadsHistogram) { |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
456 Runtime.getRuntime().addShutdownHook(new Thread() { |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
457 @Override |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
458 public void run() { |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
459 ArrayList<OptionValue<?>> options = new ArrayList<>(); |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
460 for (OptionValue<?> option = head; option != null; option = option.next) { |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
461 options.add(option); |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
462 } |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
463 Collections.sort(options, new Comparator<OptionValue<?>>() { |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
464 |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
465 public int compare(OptionValue<?> o1, OptionValue<?> o2) { |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
466 if (o1.reads < o2.reads) { |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
467 return -1; |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
468 } else if (o1.reads > o2.reads) { |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
469 return 1; |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
470 } else { |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
471 return o1.getName().compareTo(o2.getName()); |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
472 } |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
473 } |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
474 }); |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
475 PrintStream out = System.out; |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
476 out.println("=== OptionValue reads histogram ==="); |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
477 for (OptionValue<?> option : options) { |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
478 out.println(option.reads + "\t" + option); |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
479 } |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
480 } |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
481 }); |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
482 } |
5dbfb4d5eaba
added a histogram to OptionValue (enabled by -Dgraal.showOptionValueReadsHistogram=true) to see which options are most frequently read
Doug Simon <doug.simon@oracle.com>
parents:
12674
diff
changeset
|
483 } |
9849
e876c2a6954f
extensible option system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
484 } |