comparison graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotOptions.java @ 21563:4f63449b4422

revived post option parsing handler notification
author Doug Simon <doug.simon@oracle.com>
date Fri, 29 May 2015 00:06:22 +0200
parents 47bebae7454f
children 93f282187d90
comparison
equal deleted inserted replaced
21562:47bebae7454f 21563:4f63449b4422
20 * or visit www.oracle.com if you need additional information or have any 20 * or visit www.oracle.com if you need additional information or have any
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 java.util.*;
26 26
27 import com.oracle.jvmci.debug.*;
28 import com.oracle.jvmci.options.*; 27 import com.oracle.jvmci.options.*;
29 import com.oracle.jvmci.runtime.*; 28 import com.oracle.jvmci.runtime.*;
30 29
31 //JaCoCo Exclude 30 //JaCoCo Exclude
32 31
36 */ 35 */
37 public class HotSpotOptions { 36 public class HotSpotOptions {
38 37
39 private static final String JVMCI_OPTION_PREFIX = "-G:"; 38 private static final String JVMCI_OPTION_PREFIX = "-G:";
40 39
41 static { 40 /**
42 // Debug should not be initialized until all options that may affect 41 * Called from VM.
43 // its initialization have been processed. 42 */
44 assert !Debug.Initialization.isDebugInitialized() : "The class " + Debug.class.getName() + " must not be initialized before the JVMCI runtime has been initialized. " + 43 static void printFlags() {
45 "This can be fixed by placing a call to " + JVMCI.class.getName() + ".getRuntime() on the path that triggers initialization of " + Debug.class.getName(); 44 SortedMap<String, OptionDescriptor> options = new TreeMap<>();
45 for (Options opts : Services.load(Options.class)) {
46 for (OptionDescriptor desc : opts) {
47 if (isHotSpotOption(desc)) {
48 String name = desc.getName();
49 OptionDescriptor existing = options.put(name, desc);
50 assert existing == null : "Option named \"" + name + "\" has multiple definitions: " + existing.getLocation() + " and " + desc.getLocation();
51 }
52 }
53 }
46 54
47 for (OptionsParsed handler : Services.load(OptionsParsed.class)) { 55 OptionUtils.printFlags(options, JVMCI_OPTION_PREFIX);
48 handler.apply();
49 }
50 } 56 }
51 57
52 /** 58 /**
53 * Ensures {@link HotSpotOptions} is initialized. 59 * Determines if a given option is a HotSpot command line option.
54 */ 60 */
55 public static void initialize() { 61 private static boolean isHotSpotOption(OptionDescriptor desc) {
62 return desc.getDeclaringClass().getName().startsWith("com.oracle.graal");
56 } 63 }
57
58 static void printFlags() {
59 OptionUtils.printFlags(options, JVMCI_OPTION_PREFIX);
60 }
61
62 public native Object getOptionValue(String optionName);
63 } 64 }