Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotOptions.java @ 21562:47bebae7454f
Merge.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 28 May 2015 21:58:33 +0200 |
parents | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java@28cbfacd0518 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java@d563baeca9df |
children | 4f63449b4422 |
comparison
equal
deleted
inserted
replaced
21561:ce2113326bc8 | 21562:47bebae7454f |
---|---|
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 package com.oracle.jvmci.hotspot; | 23 package com.oracle.jvmci.hotspot; |
24 | 24 |
25 import static com.oracle.jvmci.hotspot.HotSpotOptionsLoader.*; | 25 import static com.oracle.jvmci.hotspot.HotSpotOptionsLoader.*; |
26 import static java.lang.Double.*; | |
27 | 26 |
28 import com.oracle.jvmci.debug.*; | 27 import com.oracle.jvmci.debug.*; |
29 import com.oracle.jvmci.options.*; | 28 import com.oracle.jvmci.options.*; |
30 import com.oracle.jvmci.options.OptionUtils.OptionConsumer; | |
31 import com.oracle.jvmci.runtime.*; | 29 import com.oracle.jvmci.runtime.*; |
32 | 30 |
33 //JaCoCo Exclude | 31 //JaCoCo Exclude |
34 | 32 |
35 /** | 33 /** |
38 */ | 36 */ |
39 public class HotSpotOptions { | 37 public class HotSpotOptions { |
40 | 38 |
41 private static final String JVMCI_OPTION_PREFIX = "-G:"; | 39 private static final String JVMCI_OPTION_PREFIX = "-G:"; |
42 | 40 |
43 /** | |
44 * Parses the JVMCI specific options specified to HotSpot (e.g., on the command line). | |
45 * | |
46 * @param optionsParsedClass the {@link Class} for {@link OptionsParsed} | |
47 * @return the implementations of {@link OptionsParsed} available | |
48 */ | |
49 private static native OptionsParsed[] parseVMOptions(Class<?> optionsParsedClass); | |
50 | |
51 static { | 41 static { |
52 // Debug should not be initialized until all options that may affect | 42 // Debug should not be initialized until all options that may affect |
53 // its initialization have been processed. | 43 // its initialization have been processed. |
54 assert !Debug.Initialization.isDebugInitialized() : "The class " + Debug.class.getName() + " must not be initialized before the JVMCI runtime has been initialized. " + | 44 assert !Debug.Initialization.isDebugInitialized() : "The class " + Debug.class.getName() + " must not be initialized before the JVMCI runtime has been initialized. " + |
55 "This can be fixed by placing a call to " + JVMCI.class.getName() + ".getRuntime() on the path that triggers initialization of " + Debug.class.getName(); | 45 "This can be fixed by placing a call to " + JVMCI.class.getName() + ".getRuntime() on the path that triggers initialization of " + Debug.class.getName(); |
56 | 46 |
57 for (OptionsParsed handler : parseVMOptions(OptionsParsed.class)) { | 47 for (OptionsParsed handler : Services.load(OptionsParsed.class)) { |
58 handler.apply(); | 48 handler.apply(); |
59 } | 49 } |
60 } | 50 } |
61 | 51 |
62 /** | 52 /** |
63 * Ensures {@link HotSpotOptions} is initialized. | 53 * Ensures {@link HotSpotOptions} is initialized. |
64 */ | 54 */ |
65 public static void initialize() { | 55 public static void initialize() { |
66 } | 56 } |
67 | 57 |
68 /** | 58 static void printFlags() { |
69 * Helper for the VM code called by {@link #parseVMOptions}. | 59 OptionUtils.printFlags(options, JVMCI_OPTION_PREFIX); |
70 * | |
71 * @param name the name of a parsed option | |
72 * @param option the object encapsulating the option | |
73 * @param spec specification of boolean option value, type of option value or action to take | |
74 */ | |
75 static void setOption(String name, OptionValue<?> option, char spec, String stringValue, long primitiveValue) { | |
76 switch (spec) { | |
77 case '+': | |
78 option.setValue(Boolean.TRUE); | |
79 break; | |
80 case '-': | |
81 option.setValue(Boolean.FALSE); | |
82 break; | |
83 case '?': | |
84 OptionUtils.printFlags(options, JVMCI_OPTION_PREFIX); | |
85 break; | |
86 case ' ': | |
87 OptionUtils.printNoMatchMessage(options, name, JVMCI_OPTION_PREFIX); | |
88 break; | |
89 case 'i': | |
90 option.setValue((int) primitiveValue); | |
91 break; | |
92 case 'f': | |
93 option.setValue((float) longBitsToDouble(primitiveValue)); | |
94 break; | |
95 case 'd': | |
96 option.setValue(longBitsToDouble(primitiveValue)); | |
97 break; | |
98 case 's': | |
99 option.setValue(stringValue); | |
100 break; | |
101 } | |
102 } | 60 } |
103 | 61 |
104 /** | 62 public native Object getOptionValue(String optionName); |
105 * Parses a given option value specification. | |
106 * | |
107 * @param option the specification of an option and its value | |
108 * @param setter the object to notify of the parsed option and value. If null, the | |
109 * {@link OptionValue#setValue(Object)} method of the specified option is called | |
110 * instead. | |
111 */ | |
112 public static boolean parseOption(String option, OptionConsumer setter) { | |
113 return OptionUtils.parseOption(options, option, JVMCI_OPTION_PREFIX, setter); | |
114 } | |
115 } | 63 } |