Mercurial > hg > truffle
comparison graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotOptions.java @ 21551:5324104ac4f3
moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 26 May 2015 17:13:37 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
21550:f48a6cea31eb | 21551:5324104ac4f3 |
---|---|
1 /* | |
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.jvmci.hotspot; | |
24 | |
25 import static com.oracle.jvmci.hotspot.HotSpotOptionsLoader.*; | |
26 import static java.lang.Double.*; | |
27 | |
28 import com.oracle.graal.debug.*; | |
29 import com.oracle.graal.options.*; | |
30 import com.oracle.graal.options.OptionUtils.OptionConsumer; | |
31 import com.oracle.jvmci.runtime.*; | |
32 | |
33 //JaCoCo Exclude | |
34 | |
35 /** | |
36 * Sets Graal options from the HotSpot command line. Such options are distinguished by the | |
37 * {@link #GRAAL_OPTION_PREFIX} prefix. | |
38 */ | |
39 public class HotSpotOptions { | |
40 | |
41 private static final String GRAAL_OPTION_PREFIX = "-G:"; | |
42 | |
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 { | |
52 // Debug should not be initialized until all options that may affect | |
53 // 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. " + | |
55 "This can be fixed by placing a call to " + JVMCI.class.getName() + ".getRuntime() on the path that triggers initialization of " + Debug.class.getName(); | |
56 | |
57 for (OptionsParsed handler : parseVMOptions(OptionsParsed.class)) { | |
58 handler.apply(); | |
59 } | |
60 } | |
61 | |
62 /** | |
63 * Ensures {@link HotSpotOptions} is initialized. | |
64 */ | |
65 public static void initialize() { | |
66 } | |
67 | |
68 /** | |
69 * Helper for the VM code called by {@link #parseVMOptions}. | |
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, GRAAL_OPTION_PREFIX); | |
85 break; | |
86 case ' ': | |
87 OptionUtils.printNoMatchMessage(options, name, GRAAL_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 } | |
103 | |
104 /** | |
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, GRAAL_OPTION_PREFIX, setter); | |
114 } | |
115 } |