Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame^] | 1 | // Copyright 2008 the V8 project authors. All rights reserved. |
| 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | // This file defines all of the flags. It is separated into different section, |
| 29 | // for Debug, Release, Logging and Profiling, etc. To add a new flag, find the |
| 30 | // correct section, and use one of the DEFINE_ macros, without a trailing ';'. |
| 31 | // |
| 32 | // This include does not have a guard, because it is a template-style include, |
| 33 | // which can be included multiple times in different modes. It expects to have |
| 34 | // a mode defined before it's included. The modes are FLAG_MODE_... below: |
| 35 | |
| 36 | // We want to declare the names of the variables for the header file. Normally |
| 37 | // this will just be an extern declaration, but for a readonly flag we let the |
| 38 | // compiler make better optimizations by giving it the value. |
| 39 | #if defined(FLAG_MODE_DECLARE) |
| 40 | #define FLAG_FULL(ftype, ctype, nam, def, cmt) \ |
| 41 | extern ctype FLAG_##nam; |
| 42 | #define FLAG_READONLY(ftype, ctype, nam, def, cmt) \ |
| 43 | static ctype const FLAG_##nam = def; |
| 44 | |
| 45 | // We want to supply the actual storage and value for the flag variable in the |
| 46 | // .cc file. We only do this for writable flags. |
| 47 | #elif defined(FLAG_MODE_DEFINE) |
| 48 | #define FLAG_FULL(ftype, ctype, nam, def, cmt) \ |
| 49 | ctype FLAG_##nam = def; |
| 50 | #define FLAG_READONLY(ftype, ctype, nam, def, cmt) |
| 51 | |
| 52 | // We need to define all of our default values so that the Flag structure can |
| 53 | // access them by pointer. These are just used internally inside of one .cc, |
| 54 | // for MODE_META, so there is no impact on the flags interface. |
| 55 | #elif defined(FLAG_MODE_DEFINE_DEFAULTS) |
| 56 | #define FLAG_FULL(ftype, ctype, nam, def, cmt) \ |
| 57 | static ctype const FLAGDEFAULT_##nam = def; |
| 58 | #define FLAG_READONLY(ftype, ctype, nam, def, cmt) |
| 59 | |
| 60 | |
| 61 | // We want to write entries into our meta data table, for internal parsing and |
| 62 | // printing / etc in the flag parser code. We only do this for writable flags. |
| 63 | #elif defined(FLAG_MODE_META) |
| 64 | #define FLAG_FULL(ftype, ctype, nam, def, cmt) \ |
| 65 | { Flag::TYPE_##ftype, #nam, &FLAG_##nam, &FLAGDEFAULT_##nam, cmt, false }, |
| 66 | #define FLAG_READONLY(ftype, ctype, nam, def, cmt) |
| 67 | |
| 68 | #else |
| 69 | #error No mode supplied when including flags.defs |
| 70 | #endif |
| 71 | |
| 72 | #ifdef FLAG_MODE_DECLARE |
| 73 | // Structure used to hold a collection of arguments to the JavaScript code. |
| 74 | struct JSArguments { |
| 75 | public: |
| 76 | JSArguments(); |
| 77 | JSArguments(int argc, const char** argv); |
| 78 | int argc() const; |
| 79 | const char** argv(); |
| 80 | const char*& operator[](int idx); |
| 81 | JSArguments& operator=(JSArguments args); |
| 82 | private: |
| 83 | int argc_; |
| 84 | const char** argv_; |
| 85 | }; |
| 86 | #endif |
| 87 | |
| 88 | #define DEFINE_bool(nam, def, cmt) FLAG(BOOL, bool, nam, def, cmt) |
| 89 | #define DEFINE_int(nam, def, cmt) FLAG(INT, int, nam, def, cmt) |
| 90 | #define DEFINE_float(nam, def, cmt) FLAG(FLOAT, double, nam, def, cmt) |
| 91 | #define DEFINE_string(nam, def, cmt) FLAG(STRING, const char*, nam, def, cmt) |
| 92 | #define DEFINE_args(nam, def, cmt) FLAG(ARGS, JSArguments, nam, def, cmt) |
| 93 | |
| 94 | // |
| 95 | // Flags in all modes. |
| 96 | // |
| 97 | #define FLAG FLAG_FULL |
| 98 | |
| 99 | // assembler-ia32.cc / assembler-arm.cc |
| 100 | DEFINE_bool(debug_code, false, |
| 101 | "generate extra code (comments, assertions) for debugging") |
| 102 | DEFINE_bool(emit_branch_hints, false, "emit branch hints") |
| 103 | DEFINE_bool(push_pop_elimination, true, |
| 104 | "eliminate redundant push/pops in assembly code") |
| 105 | DEFINE_bool(print_push_pop_elimination, false, |
| 106 | "print elimination of redundant push/pops in assembly code") |
| 107 | |
| 108 | // bootstrapper.cc |
| 109 | DEFINE_string(expose_natives_as, NULL, "expose natives in global object") |
| 110 | DEFINE_string(expose_debug_as, NULL, "expose debug in global object") |
| 111 | DEFINE_string(natives_file, NULL, "alternative natives file") |
| 112 | DEFINE_bool(expose_gc, false, "expose gc extension") |
| 113 | DEFINE_int(stack_trace_limit, 10, "number of stack frames to capture") |
| 114 | |
| 115 | // builtins-ia32.cc |
| 116 | DEFINE_bool(inline_new, true, "use fast inline allocation") |
| 117 | |
| 118 | // checks.cc |
| 119 | DEFINE_bool(stack_trace_on_abort, true, |
| 120 | "print a stack trace if an assertion failure occurs") |
| 121 | |
| 122 | // codegen-ia32.cc / codegen-arm.cc |
| 123 | DEFINE_bool(trace, false, "trace function calls") |
| 124 | DEFINE_bool(defer_negation, true, "defer negation operation") |
| 125 | DEFINE_bool(check_stack, true, |
| 126 | "check stack for overflow, interrupt, breakpoint") |
| 127 | |
| 128 | // codegen.cc |
| 129 | DEFINE_bool(lazy, true, "use lazy compilation") |
| 130 | DEFINE_bool(debug_info, true, "add debug information to compiled functions") |
| 131 | |
| 132 | // compiler.cc |
| 133 | DEFINE_bool(strict, false, "strict error checking") |
| 134 | DEFINE_int(min_preparse_length, 1024, |
| 135 | "Minimum length for automatic enable preparsing") |
| 136 | |
| 137 | // compilation-cache.cc |
| 138 | DEFINE_bool(compilation_cache, true, "enable compilation cache") |
| 139 | |
| 140 | // debug.cc |
| 141 | DEFINE_bool(remote_debugging, false, "enable remote debugging") |
| 142 | DEFINE_bool(trace_debug_json, false, "trace debugging JSON request/response") |
| 143 | DEFINE_bool(debugger_auto_break, false, |
| 144 | "automatically set the debug break flag when debugger commands are " |
| 145 | "in the queue (experimental)") |
| 146 | |
| 147 | // frames.cc |
| 148 | DEFINE_int(max_stack_trace_source_length, 300, |
| 149 | "maximum length of function source code printed in a stack trace.") |
| 150 | |
| 151 | // heap.cc |
| 152 | DEFINE_int(new_space_size, 0, "size of (each semispace in) the new generation") |
| 153 | DEFINE_int(old_space_size, 0, "size of the old generation") |
| 154 | DEFINE_bool(gc_global, false, "always perform global GCs") |
| 155 | DEFINE_int(gc_interval, -1, "garbage collect after <n> allocations") |
| 156 | DEFINE_bool(trace_gc, false, |
| 157 | "print one trace line following each garbage collection") |
| 158 | DEFINE_bool(trace_gc_verbose, false, |
| 159 | "print more details following each garbage collection") |
| 160 | DEFINE_bool(collect_maps, true, |
| 161 | "garbage collect maps from which no objects can be reached") |
| 162 | |
| 163 | // v8.cc |
| 164 | DEFINE_bool(use_idle_notification, true, |
| 165 | "Use idle notification to reduce memory footprint.") |
| 166 | // ic.cc |
| 167 | DEFINE_bool(use_ic, true, "use inline caching") |
| 168 | |
| 169 | // macro-assembler-ia32.cc |
| 170 | DEFINE_bool(native_code_counters, false, |
| 171 | "generate extra code for manipulating stats counters") |
| 172 | |
| 173 | // mark-compact.cc |
| 174 | DEFINE_bool(always_compact, false, "Perform compaction on every full GC") |
| 175 | DEFINE_bool(never_compact, false, |
| 176 | "Never perform compaction on full GC - testing only") |
| 177 | DEFINE_bool(cleanup_ics_at_gc, true, |
| 178 | "Flush inline caches prior to mark compact collection.") |
| 179 | DEFINE_bool(cleanup_caches_in_maps_at_gc, true, |
| 180 | "Flush code caches in maps during mark compact cycle.") |
| 181 | |
| 182 | DEFINE_bool(canonicalize_object_literal_maps, true, |
| 183 | "Canonicalize maps for object literals.") |
| 184 | |
| 185 | // mksnapshot.cc |
| 186 | DEFINE_bool(h, false, "print this message") |
| 187 | |
| 188 | // parser.cc |
| 189 | DEFINE_bool(allow_natives_syntax, false, "allow natives syntax") |
| 190 | |
| 191 | // rewriter.cc |
| 192 | DEFINE_bool(optimize_ast, true, "optimize the ast") |
| 193 | |
| 194 | // simulator-arm.cc |
| 195 | DEFINE_bool(trace_sim, false, "trace simulator execution") |
| 196 | DEFINE_int(stop_sim_at, 0, "Simulator stop after x number of instructions") |
| 197 | |
| 198 | // top.cc |
| 199 | DEFINE_bool(trace_exception, false, |
| 200 | "print stack trace when throwing exceptions") |
| 201 | DEFINE_bool(preallocate_message_memory, false, |
| 202 | "preallocate some memory to build stack traces.") |
| 203 | |
| 204 | // usage-analyzer.cc |
| 205 | DEFINE_bool(usage_computation, true, "compute variable usage counts") |
| 206 | |
| 207 | // v8.cc |
| 208 | DEFINE_bool(preemption, false, |
| 209 | "activate a 100ms timer that switches between V8 threads") |
| 210 | |
| 211 | // Regexp |
| 212 | DEFINE_bool(trace_regexps, false, "trace regexp execution") |
| 213 | DEFINE_bool(regexp_optimization, true, "generate optimized regexp code") |
| 214 | |
| 215 | // Testing flags test/cctest/test-{flags,api,serialization}.cc |
| 216 | DEFINE_bool(testing_bool_flag, true, "testing_bool_flag") |
| 217 | DEFINE_int(testing_int_flag, 13, "testing_int_flag") |
| 218 | DEFINE_float(testing_float_flag, 2.5, "float-flag") |
| 219 | DEFINE_string(testing_string_flag, "Hello, world!", "string-flag") |
| 220 | DEFINE_int(testing_prng_seed, 42, "Seed used for threading test randomness") |
| 221 | #ifdef WIN32 |
| 222 | DEFINE_string(testing_serialization_file, "C:\\Windows\\Temp\\serdes", |
| 223 | "file in which to testing_serialize heap") |
| 224 | #else |
| 225 | DEFINE_string(testing_serialization_file, "/tmp/serdes", |
| 226 | "file in which to serialize heap") |
| 227 | #endif |
| 228 | |
| 229 | // |
| 230 | // Dev shell flags |
| 231 | // |
| 232 | |
| 233 | DEFINE_bool(help, false, "Print usage message, including flags, on console") |
| 234 | DEFINE_bool(dump_counters, false, "Dump counters on exit") |
| 235 | DEFINE_bool(debugger, true, "Enable JavaScript debugger") |
| 236 | DEFINE_bool(remote_debugger, false, "Connect JavaScript debugger to the " |
| 237 | "debugger agent in another process") |
| 238 | DEFINE_bool(debugger_agent, false, "Enable debugger agent") |
| 239 | DEFINE_int(debugger_port, 5858, "Port to use for remote debugging") |
| 240 | DEFINE_string(map_counters, false, "Map counters to a file") |
| 241 | DEFINE_args(js_arguments, JSArguments(), |
| 242 | "Pass all remaining arguments to the script. Alias for \"--\".") |
| 243 | |
| 244 | // |
| 245 | // Debug only flags |
| 246 | // |
| 247 | #undef FLAG |
| 248 | #ifdef DEBUG |
| 249 | #define FLAG FLAG_FULL |
| 250 | #else |
| 251 | #define FLAG FLAG_READONLY |
| 252 | #endif |
| 253 | |
| 254 | // checks.cc |
| 255 | DEFINE_bool(enable_slow_asserts, false, |
| 256 | "enable asserts that are slow to execute") |
| 257 | |
| 258 | // codegen-ia32.cc / codegen-arm.cc |
| 259 | DEFINE_bool(trace_codegen, false, |
| 260 | "print name of functions for which code is generated") |
| 261 | DEFINE_bool(print_source, false, "pretty print source code") |
| 262 | DEFINE_bool(print_builtin_source, false, |
| 263 | "pretty print source code for builtins") |
| 264 | DEFINE_bool(print_ast, false, "print source AST") |
| 265 | DEFINE_bool(print_builtin_ast, false, "print source AST for builtins") |
| 266 | DEFINE_bool(trace_calls, false, "trace calls") |
| 267 | DEFINE_bool(trace_builtin_calls, false, "trace builtins calls") |
| 268 | DEFINE_string(stop_at, "", "function name where to insert a breakpoint") |
| 269 | |
| 270 | // compiler.cc |
| 271 | DEFINE_bool(print_builtin_scopes, false, "print scopes for builtins") |
| 272 | DEFINE_bool(print_scopes, false, "print scopes") |
| 273 | |
| 274 | // contexts.cc |
| 275 | DEFINE_bool(trace_contexts, false, "trace contexts operations") |
| 276 | |
| 277 | // heap.cc |
| 278 | DEFINE_bool(gc_greedy, false, "perform GC prior to some allocations") |
| 279 | DEFINE_bool(gc_verbose, false, "print stuff during garbage collection") |
| 280 | DEFINE_bool(heap_stats, false, "report heap statistics before and after GC") |
| 281 | DEFINE_bool(code_stats, false, "report code statistics after GC") |
| 282 | DEFINE_bool(verify_heap, false, "verify heap pointers before and after GC") |
| 283 | DEFINE_bool(print_handles, false, "report handles after GC") |
| 284 | DEFINE_bool(print_global_handles, false, "report global handles after GC") |
| 285 | DEFINE_bool(print_rset, false, "print remembered sets before GC") |
| 286 | |
| 287 | // ic.cc |
| 288 | DEFINE_bool(trace_ic, false, "trace inline cache state transitions") |
| 289 | |
| 290 | // objects.cc |
| 291 | DEFINE_bool(trace_normalization, |
| 292 | false, |
| 293 | "prints when objects are turned into dictionaries.") |
| 294 | |
| 295 | // runtime.cc |
| 296 | DEFINE_bool(trace_lazy, false, "trace lazy compilation") |
| 297 | |
| 298 | // serialize.cc |
| 299 | DEFINE_bool(debug_serialization, false, |
| 300 | "write debug information into the snapshot.") |
| 301 | |
| 302 | // spaces.cc |
| 303 | DEFINE_bool(collect_heap_spill_statistics, false, |
| 304 | "report heap spill statistics along with heap_stats " |
| 305 | "(requires heap_stats)") |
| 306 | |
| 307 | // Regexp |
| 308 | DEFINE_bool(trace_regexp_bytecodes, false, "trace regexp bytecode execution") |
| 309 | DEFINE_bool(trace_regexp_assembler, |
| 310 | false, |
| 311 | "trace regexp macro assembler calls.") |
| 312 | |
| 313 | // |
| 314 | // Logging and profiling only flags |
| 315 | // |
| 316 | #undef FLAG |
| 317 | #ifdef ENABLE_LOGGING_AND_PROFILING |
| 318 | #define FLAG FLAG_FULL |
| 319 | #else |
| 320 | #define FLAG FLAG_READONLY |
| 321 | #endif |
| 322 | |
| 323 | // log.cc |
| 324 | DEFINE_bool(log, false, |
| 325 | "Minimal logging (no API, code, GC, suspect, or handles samples).") |
| 326 | DEFINE_bool(log_all, false, "Log all events to the log file.") |
| 327 | DEFINE_bool(log_runtime, false, "Activate runtime system %Log call.") |
| 328 | DEFINE_bool(log_api, false, "Log API events to the log file.") |
| 329 | DEFINE_bool(log_code, false, |
| 330 | "Log code events to the log file without profiling.") |
| 331 | DEFINE_bool(log_gc, false, |
| 332 | "Log heap samples on garbage collection for the hp2ps tool.") |
| 333 | DEFINE_bool(log_handles, false, "Log global handle events.") |
| 334 | DEFINE_bool(log_state_changes, false, "Log state changes.") |
| 335 | DEFINE_bool(log_suspect, false, "Log suspect operations.") |
| 336 | DEFINE_bool(compress_log, false, |
| 337 | "Compress log to save space (makes log less human-readable).") |
| 338 | DEFINE_bool(prof, false, |
| 339 | "Log statistical profiling information (implies --log-code).") |
| 340 | DEFINE_bool(prof_auto, true, |
| 341 | "Used with --prof, starts profiling automatically") |
| 342 | DEFINE_bool(prof_lazy, false, |
| 343 | "Used with --prof, only does sampling and logging" |
| 344 | " when profiler is active (implies --noprof_auto).") |
| 345 | DEFINE_bool(log_regexp, false, "Log regular expression execution.") |
| 346 | DEFINE_bool(sliding_state_window, false, |
| 347 | "Update sliding state window counters.") |
| 348 | DEFINE_string(logfile, "v8.log", "Specify the name of the log file.") |
| 349 | DEFINE_bool(oprofile, false, "Enable JIT agent for OProfile.") |
| 350 | |
| 351 | // |
| 352 | // Heap protection flags |
| 353 | // Using heap protection requires ENABLE_LOGGING_AND_PROFILING as well. |
| 354 | // |
| 355 | #ifdef ENABLE_HEAP_PROTECTION |
| 356 | #undef FLAG |
| 357 | #define FLAG FLAG_FULL |
| 358 | |
| 359 | DEFINE_bool(protect_heap, false, |
| 360 | "Protect/unprotect V8's heap when leaving/entring the VM.") |
| 361 | |
| 362 | #endif |
| 363 | |
| 364 | // |
| 365 | // Disassembler only flags |
| 366 | // |
| 367 | #undef FLAG |
| 368 | #ifdef ENABLE_DISASSEMBLER |
| 369 | #define FLAG FLAG_FULL |
| 370 | #else |
| 371 | #define FLAG FLAG_READONLY |
| 372 | #endif |
| 373 | |
| 374 | // code-stubs.cc |
| 375 | DEFINE_bool(print_code_stubs, false, "print code stubs") |
| 376 | |
| 377 | // codegen-ia32.cc / codegen-arm.cc |
| 378 | DEFINE_bool(print_code, false, "print generated code") |
| 379 | DEFINE_bool(print_builtin_code, false, "print generated code for builtins") |
| 380 | |
| 381 | // Cleanup... |
| 382 | #undef FLAG_FULL |
| 383 | #undef FLAG_READONLY |
| 384 | #undef FLAG |
| 385 | |
| 386 | #undef DEFINE_bool |
| 387 | #undef DEFINE_int |
| 388 | #undef DEFINE_string |
| 389 | |
| 390 | #undef FLAG_MODE_DECLARE |
| 391 | #undef FLAG_MODE_DEFINE |
| 392 | #undef FLAG_MODE_DEFINE_DEFAULTS |
| 393 | #undef FLAG_MODE_META |