001    /*
002     *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003     *
004     *  This file is licensed to You under the Eclipse Public License (EPL);
005     *  You may not use this file except in compliance with the License. You
006     *  may obtain a copy of the License at
007     *
008     *      http://www.opensource.org/licenses/eclipse-1.0.php
009     *
010     *  See the COPYRIGHT.txt file distributed with this work for information
011     *  regarding copyright ownership.
012     */
013    package org.jikesrvm;
014    
015    import org.vmmagic.pragma.*;
016    
017    /**
018     * Class to handle command-line arguments and options meant
019     * for the core runtime system of the VM.
020     * <p>
021     * Note: This file is mechanically generated from Options.template.
022     * <p>
023     * Note: Boolean options are defined in /home/dgrove/rvm-trunk/rvm/src-generated/options/BooleanOptions.vm.dat
024     *       All other options are defined in /home/dgrove/rvm-trunk/rvm/src-generated/options/ValueOptions.vm.dat
025     *       (value, enumeration)
026     * <p>
027     * NOTE: This class does not support all of the types of
028     *       options found in the other Jikes RVM options
029     *       files.  This is intentional and is done to enable
030     *       -X:vm options to be processed very early in the
031     *       booting process.
032     *
033     **/
034    @Uninterruptible public class Options extends Configuration {
035    
036       // Begin template-specified options
037       public static boolean MeasureCompilation            = false; // Time all compilations and report on exit
038       public static boolean MeasureCompilationPhases      = false; // Time all compilation sub-phases and report on exit
039       public static boolean stackTraceFull                = false; // Stack traces to consist of VM and application frames
040       public static boolean stackTraceAtExit              = false; // Dump a stack trace (via VM.syswrite) upon exit
041       public static boolean TraceClassLoading             = false; // More detailed tracing then -verbose:class
042       public static boolean ErrorsFatal                   = false; // Exit when non-fatal errors are detected; used for regression testing
043       public static boolean traceJNI                      = false; // Trace when calls into JNI happen
044       public static boolean countThreadTransitions        = false; // Count, and report, the number of thread state transitions.  This works better on IA32 than on PPC at the moment.
045       public static int maxSystemTroubleRecursionDepth    = 3; // If we get deeper than this in one of the System Trouble functions, try to die.
046       public static int interruptQuantum                  = 4; // Timer interrupt scheduling quantum in ms
047       public static int schedulingMultiplier              = 1; // Scheduling quantum = interruptQuantum * schedulingMultiplier
048       public static int TraceThreadScheduling             = 0; // Trace actions taken by thread scheduling
049       public static int VerboseStackTracePeriod           = 0; // Trace every nth time a stack trace is created
050       public static String EdgeCounterFile                = null; // Input file of edge counter profile data
051       public static int CBSCallSamplesPerTick             = 8; // How many CBS call samples (Prologue/Epilogue) should we take per time tick
052       public static int CBSCallSampleStride               = 2; // Stride between each CBS call sample (Prologue/Epilogue) within a sampling window
053       public static int CBSMethodSamplesPerTick           = 0; // How many CBS method samples (any yieldpoint) should we take per time tick
054       public static int CBSMethodSampleStride             = 3; // Stride between each CBS method sample (any yieldpoint) within a sampling window
055       public static String TuningForkTraceFile            = null; // Filename to use for TuningFork trace generation
056       public static int forceOneCPU                       = -1; // Force all threads to run on one CPU.  The argument specifies which CPU (starting from 0).
057       // End template-specified options
058    
059       // Begin generated support for "Enumeration" options
060       // End generated support for "Enumeration" options
061    
062      /**
063       * Take a string (most likely a command-line argument) and try to proccess it
064       * as an option command.  Return true if the string was understood, false
065       * otherwise.
066       *
067       * @param arg a String to try to process as an option command
068       * @return true if successful, false otherwise
069       */
070      @Interruptible
071      @NoOptCompile
072      public static boolean process(String arg) {
073    
074        // First handle the "option commands"
075        if (arg.equals("help")) {
076           printHelp();
077           return true;
078        }
079        if (arg.equals("printOptions")) {
080           printOptions();
081           return true;
082        }
083        if (arg.length() == 0) {
084          printHelp();
085          return true;
086        }
087    
088        // Required format of arg is 'name=value'
089        // Split into 'name' and 'value' strings
090        int split = arg.indexOf('=');
091        if (split == -1) {
092          VM.sysWrite("  Illegal option specification!\n  \""+arg+
093                      "\" must be specified as a name-value pair in the form of option=value\n");
094          return false;
095        }
096        String name = arg.substring(0,split);
097        String value = arg.substring(split+1);
098    
099        // Begin generated command-line processing
100        if (name.equals("measureCompilation")) {
101          if (value.equals("true")) {
102            MeasureCompilation = true;
103            return true;
104          } else if (value.equals("false")) {
105              MeasureCompilation = false;
106            return true;
107          } else
108            return false;
109        }
110        if (name.equals("measureCompilationPhases")) {
111          if (value.equals("true")) {
112            MeasureCompilationPhases = true;
113            return true;
114          } else if (value.equals("false")) {
115              MeasureCompilationPhases = false;
116            return true;
117          } else
118            return false;
119        }
120        if (name.equals("stackTraceFull")) {
121          if (value.equals("true")) {
122            stackTraceFull = true;
123            return true;
124          } else if (value.equals("false")) {
125              stackTraceFull = false;
126            return true;
127          } else
128            return false;
129        }
130        if (name.equals("stackTraceAtExit")) {
131          if (value.equals("true")) {
132            stackTraceAtExit = true;
133            return true;
134          } else if (value.equals("false")) {
135              stackTraceAtExit = false;
136            return true;
137          } else
138            return false;
139        }
140        if (name.equals("verboseTraceClassLoading")) {
141          if (value.equals("true")) {
142            TraceClassLoading = true;
143            return true;
144          } else if (value.equals("false")) {
145              TraceClassLoading = false;
146            return true;
147          } else
148            return false;
149        }
150        if (name.equals("errorsFatal")) {
151          if (value.equals("true")) {
152            ErrorsFatal = true;
153            return true;
154          } else if (value.equals("false")) {
155              ErrorsFatal = false;
156            return true;
157          } else
158            return false;
159        }
160        if (name.equals("traceJNI")) {
161          if (value.equals("true")) {
162            traceJNI = true;
163            return true;
164          } else if (value.equals("false")) {
165              traceJNI = false;
166            return true;
167          } else
168            return false;
169        }
170        if (name.equals("countThreadTransitions")) {
171          if (value.equals("true")) {
172            countThreadTransitions = true;
173            return true;
174          } else if (value.equals("false")) {
175              countThreadTransitions = false;
176            return true;
177          } else
178            return false;
179        }
180        if (name.equals("maxSystemTroubleRecursionDepth")) {
181           maxSystemTroubleRecursionDepth = CommandLineArgs.primitiveParseInt(value);
182           return true;
183         }
184        if (name.equals("interruptQuantum")) {
185           interruptQuantum = CommandLineArgs.primitiveParseInt(value);
186           return true;
187         }
188        if (name.equals("schedulingMultiplier")) {
189           schedulingMultiplier = CommandLineArgs.primitiveParseInt(value);
190           return true;
191         }
192        if (name.equals("traceThreadScheduling")) {
193           TraceThreadScheduling = CommandLineArgs.primitiveParseInt(value);
194           return true;
195         }
196        if (name.equals("verboseStackTrace")) {
197           VerboseStackTracePeriod = CommandLineArgs.primitiveParseInt(value);
198           return true;
199         }
200        if (name.equals("edgeCounterFile")) {
201           EdgeCounterFile = value;
202           return true;
203         }
204        if (name.equals("CBSCallSamplesPerTick")) {
205           CBSCallSamplesPerTick = CommandLineArgs.primitiveParseInt(value);
206           return true;
207         }
208        if (name.equals("CBSCallSampleStride")) {
209           CBSCallSampleStride = CommandLineArgs.primitiveParseInt(value);
210           return true;
211         }
212        if (name.equals("CBSMethodSamplesPerTick")) {
213           CBSMethodSamplesPerTick = CommandLineArgs.primitiveParseInt(value);
214           return true;
215         }
216        if (name.equals("CBSMethodSampleStride")) {
217           CBSMethodSampleStride = CommandLineArgs.primitiveParseInt(value);
218           return true;
219         }
220        if (name.equals("tfTraceFile")) {
221           TuningForkTraceFile = value;
222           return true;
223         }
224        if (name.equals("forceOneCPU")) {
225           forceOneCPU = CommandLineArgs.primitiveParseInt(value);
226           return true;
227         }
228           //End generated command-line processing
229    
230        // None of the above tests matched, so this wasn't an option
231        return false;
232      }
233    
234      // Print a short description of every option
235      @Interruptible
236      public static void printHelp() {
237    
238        VM.sysWrite("Commands\n");
239        VM.sysWrite("-X:vm[:help]\t\t\tPrint brief description of the core VM's command-line arguments\n");
240        VM.sysWrite("-X:vm:printOptions\t\tPrint the current values of the core VM's options\n");
241        VM.sysWrite("\n");
242    
243        //Begin generated help messages
244        VM.sysWrite("Boolean Options (-X:vm:<option>=true or -X:vm:<option>=false)\n");
245        VM.sysWrite("Option                                 Description\n");
246        VM.sysWrite("measureCompilation             Time all compilations and report on exit\n");
247        VM.sysWrite("measureCompilationPhases       Time all compilation sub-phases and report on exit\n");
248        VM.sysWrite("stackTraceFull                 Stack traces to consist of VM and application frames\n");
249        VM.sysWrite("stackTraceAtExit               Dump a stack trace (via VM.syswrite) upon exit\n");
250        VM.sysWrite("verboseTraceClassLoading       More detailed tracing then -verbose:class\n");
251        VM.sysWrite("errorsFatal                    Exit when non-fatal errors are detected; used for regression testing\n");
252        VM.sysWrite("traceJNI                       Trace when calls into JNI happen\n");
253        VM.sysWrite("countThreadTransitions         Count, and report, the number of thread state transitions.  This works better on IA32 than on PPC at the moment.\n");
254        VM.sysWrite("\nValue Options (-X:vm:<option>=<value>)\n");
255        VM.sysWrite("Option                         Type    Description\n");
256        VM.sysWrite("maxSystemTroubleRecursionDepth int     If we get deeper than this in one of the System Trouble functions, try to die.\n");
257        VM.sysWrite("interruptQuantum               int     Timer interrupt scheduling quantum in ms\n");
258        VM.sysWrite("schedulingMultiplier           int     Scheduling quantum = interruptQuantum * schedulingMultiplier\n");
259        VM.sysWrite("traceThreadScheduling          int     Trace actions taken by thread scheduling\n");
260        VM.sysWrite("verboseStackTrace              int     Trace every nth time a stack trace is created\n");
261        VM.sysWrite("edgeCounterFile                String  Input file of edge counter profile data\n");
262        VM.sysWrite("CBSCallSamplesPerTick          int     How many CBS call samples (Prologue/Epilogue) should we take per time tick\n");
263        VM.sysWrite("CBSCallSampleStride            int     Stride between each CBS call sample (Prologue/Epilogue) within a sampling window\n");
264        VM.sysWrite("CBSMethodSamplesPerTick        int     How many CBS method samples (any yieldpoint) should we take per time tick\n");
265        VM.sysWrite("CBSMethodSampleStride          int     Stride between each CBS method sample (any yieldpoint) within a sampling window\n");
266        VM.sysWrite("tfTraceFile                    String  Filename to use for TuningFork trace generation\n");
267        VM.sysWrite("forceOneCPU                    int     Force all threads to run on one CPU.  The argument specifies which CPU (starting from 0).\n");
268        VM.sysWrite("\nSelection Options (set option to one of an enumeration of possible values)\n");
269    
270        VM.sysExit(VM.EXIT_STATUS_PRINTED_HELP_MESSAGE);
271      }
272    
273      // print the options values
274      @Interruptible
275      public static void printOptions() {
276        VM.sysWrite("Current value of VM options:\n");
277        //Begin generated option value printing
278        VM.sysWriteln("\tmeasureCompilation             = ",MeasureCompilation);
279        VM.sysWriteln("\tmeasureCompilationPhases       = ",MeasureCompilationPhases);
280        VM.sysWriteln("\tstackTraceFull                 = ",stackTraceFull);
281        VM.sysWriteln("\tstackTraceAtExit               = ",stackTraceAtExit);
282        VM.sysWriteln("\tverboseTraceClassLoading       = ",TraceClassLoading);
283        VM.sysWriteln("\terrorsFatal                    = ",ErrorsFatal);
284        VM.sysWriteln("\ttraceJNI                       = ",traceJNI);
285        VM.sysWriteln("\tcountThreadTransitions         = ",countThreadTransitions);
286        VM.sysWriteln("\tmaxSystemTroubleRecursionDepth = ",maxSystemTroubleRecursionDepth);
287        VM.sysWriteln("\tinterruptQuantum               = ",interruptQuantum);
288        VM.sysWriteln("\tschedulingMultiplier           = ",schedulingMultiplier);
289        VM.sysWriteln("\ttraceThreadScheduling          = ",TraceThreadScheduling);
290        VM.sysWriteln("\tverboseStackTrace              = ",VerboseStackTracePeriod);
291        VM.sysWriteln("\tedgeCounterFile                = ",EdgeCounterFile);
292        VM.sysWriteln("\tCBSCallSamplesPerTick          = ",CBSCallSamplesPerTick);
293        VM.sysWriteln("\tCBSCallSampleStride            = ",CBSCallSampleStride);
294        VM.sysWriteln("\tCBSMethodSamplesPerTick        = ",CBSMethodSamplesPerTick);
295        VM.sysWriteln("\tCBSMethodSampleStride          = ",CBSMethodSampleStride);
296        VM.sysWriteln("\ttfTraceFile                    = ",TuningForkTraceFile);
297        VM.sysWriteln("\tforceOneCPU                    = ",forceOneCPU);
298        //End generated option value printing
299      }
300    }