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