flag-definitions.h revision 3ce2e2076e8e3e60cf1810eec160ea2d8557e9e7
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.
74struct JSArguments {
75public:
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);
82private:
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 / assembler-x64.cc
100DEFINE_bool(debug_code, false,
101            "generate extra code (comments, assertions) for debugging")
102DEFINE_bool(emit_branch_hints, false, "emit branch hints")
103DEFINE_bool(push_pop_elimination, true,
104            "eliminate redundant push/pops in assembly code")
105DEFINE_bool(print_push_pop_elimination, false,
106            "print elimination of redundant push/pops in assembly code")
107DEFINE_bool(enable_sse2, true,
108            "enable use of SSE2 instructions if available")
109DEFINE_bool(enable_sse3, true,
110            "enable use of SSE3 instructions if available")
111DEFINE_bool(enable_cmov, true,
112            "enable use of CMOV instruction if available")
113DEFINE_bool(enable_rdtsc, true,
114            "enable use of RDTSC instruction if available")
115DEFINE_bool(enable_sahf, true,
116            "enable use of SAHF instruction if available (X64 only)")
117
118// bootstrapper.cc
119DEFINE_string(expose_natives_as, NULL, "expose natives in global object")
120DEFINE_string(expose_debug_as, NULL, "expose debug in global object")
121DEFINE_string(natives_file, NULL, "alternative natives file")
122DEFINE_bool(expose_gc, false, "expose gc extension")
123DEFINE_int(stack_trace_limit, 10, "number of stack frames to capture")
124
125// builtins-ia32.cc
126DEFINE_bool(inline_new, true, "use fast inline allocation")
127
128// checks.cc
129DEFINE_bool(stack_trace_on_abort, true,
130            "print a stack trace if an assertion failure occurs")
131
132// codegen-ia32.cc / codegen-arm.cc
133DEFINE_bool(trace, false, "trace function calls")
134DEFINE_bool(defer_negation, true, "defer negation operation")
135DEFINE_bool(check_stack, true,
136            "check stack for overflow, interrupt, breakpoint")
137
138// codegen.cc
139DEFINE_bool(lazy, true, "use lazy compilation")
140DEFINE_bool(debug_info, true, "add debug information to compiled functions")
141
142// compiler.cc
143DEFINE_bool(strict, false, "strict error checking")
144DEFINE_int(min_preparse_length, 1024,
145           "minimum length for automatic enable preparsing")
146DEFINE_bool(fast_compiler, true,
147            "use the fast-mode compiler for some top-level code")
148DEFINE_bool(trace_bailout, false,
149            "print reasons for failing to use fast compilation")
150
151// compilation-cache.cc
152DEFINE_bool(compilation_cache, true, "enable compilation cache")
153
154// debug.cc
155DEFINE_bool(remote_debugging, false, "enable remote debugging")
156DEFINE_bool(trace_debug_json, false, "trace debugging JSON request/response")
157DEFINE_bool(debugger_auto_break, false,
158            "automatically set the debug break flag when debugger commands are "
159            "in the queue (experimental)")
160
161// frames.cc
162DEFINE_int(max_stack_trace_source_length, 300,
163           "maximum length of function source code printed in a stack trace.")
164
165// heap.cc
166DEFINE_int(max_new_space_size, 0, "max size of the new generation")
167DEFINE_int(max_old_space_size, 0, "max size of the old generation")
168DEFINE_bool(gc_global, false, "always perform global GCs")
169DEFINE_int(gc_interval, -1, "garbage collect after <n> allocations")
170DEFINE_bool(trace_gc, false,
171            "print one trace line following each garbage collection")
172DEFINE_bool(trace_gc_verbose, false,
173            "print more details following each garbage collection")
174DEFINE_bool(collect_maps, true,
175            "garbage collect maps from which no objects can be reached")
176
177// v8.cc
178DEFINE_bool(use_idle_notification, true,
179            "Use idle notification to reduce memory footprint.")
180// ic.cc
181DEFINE_bool(use_ic, true, "use inline caching")
182
183// macro-assembler-ia32.cc
184DEFINE_bool(native_code_counters, false,
185            "generate extra code for manipulating stats counters")
186
187// mark-compact.cc
188DEFINE_bool(always_compact, false, "Perform compaction on every full GC")
189DEFINE_bool(never_compact, false,
190            "Never perform compaction on full GC - testing only")
191DEFINE_bool(cleanup_ics_at_gc, true,
192            "Flush inline caches prior to mark compact collection.")
193DEFINE_bool(cleanup_caches_in_maps_at_gc, true,
194            "Flush code caches in maps during mark compact cycle.")
195
196DEFINE_bool(canonicalize_object_literal_maps, true,
197            "Canonicalize maps for object literals.")
198
199// mksnapshot.cc
200DEFINE_bool(h, false, "print this message")
201
202// parser.cc
203DEFINE_bool(allow_natives_syntax, false, "allow natives syntax")
204
205// rewriter.cc
206DEFINE_bool(optimize_ast, true, "optimize the ast")
207
208// simulator-arm.cc
209DEFINE_bool(trace_sim, false, "trace simulator execution")
210DEFINE_int(stop_sim_at, 0, "Simulator stop after x number of instructions")
211
212// top.cc
213DEFINE_bool(trace_exception, false,
214            "print stack trace when throwing exceptions")
215DEFINE_bool(preallocate_message_memory, false,
216            "preallocate some memory to build stack traces.")
217
218// usage-analyzer.cc
219DEFINE_bool(usage_computation, true, "compute variable usage counts")
220
221// v8.cc
222DEFINE_bool(preemption, false,
223            "activate a 100ms timer that switches between V8 threads")
224
225// Regexp
226DEFINE_bool(trace_regexps, false, "trace regexp execution")
227DEFINE_bool(regexp_optimization, true, "generate optimized regexp code")
228
229// Testing flags test/cctest/test-{flags,api,serialization}.cc
230DEFINE_bool(testing_bool_flag, true, "testing_bool_flag")
231DEFINE_int(testing_int_flag, 13, "testing_int_flag")
232DEFINE_float(testing_float_flag, 2.5, "float-flag")
233DEFINE_string(testing_string_flag, "Hello, world!", "string-flag")
234DEFINE_int(testing_prng_seed, 42, "Seed used for threading test randomness")
235#ifdef WIN32
236DEFINE_string(testing_serialization_file, "C:\\Windows\\Temp\\serdes",
237              "file in which to testing_serialize heap")
238#else
239DEFINE_string(testing_serialization_file, "/tmp/serdes",
240              "file in which to serialize heap")
241#endif
242
243//
244// Dev shell flags
245//
246
247DEFINE_bool(help, false, "Print usage message, including flags, on console")
248DEFINE_bool(dump_counters, false, "Dump counters on exit")
249DEFINE_bool(debugger, true, "Enable JavaScript debugger")
250DEFINE_bool(remote_debugger, false, "Connect JavaScript debugger to the "
251                                    "debugger agent in another process")
252DEFINE_bool(debugger_agent, false, "Enable debugger agent")
253DEFINE_int(debugger_port, 5858, "Port to use for remote debugging")
254DEFINE_string(map_counters, false, "Map counters to a file")
255DEFINE_args(js_arguments, JSArguments(),
256            "Pass all remaining arguments to the script. Alias for \"--\".")
257
258//
259// Debug only flags
260//
261#undef FLAG
262#ifdef DEBUG
263#define FLAG FLAG_FULL
264#else
265#define FLAG FLAG_READONLY
266#endif
267
268// checks.cc
269DEFINE_bool(enable_slow_asserts, false,
270            "enable asserts that are slow to execute")
271
272// codegen-ia32.cc / codegen-arm.cc
273DEFINE_bool(trace_codegen, false,
274            "print name of functions for which code is generated")
275DEFINE_bool(print_source, false, "pretty print source code")
276DEFINE_bool(print_builtin_source, false,
277            "pretty print source code for builtins")
278DEFINE_bool(print_ast, false, "print source AST")
279DEFINE_bool(print_builtin_ast, false, "print source AST for builtins")
280DEFINE_bool(print_json_ast, false, "print source AST as JSON")
281DEFINE_bool(print_builtin_json_ast, false,
282            "print source AST for builtins as JSON")
283DEFINE_bool(trace_calls, false, "trace calls")
284DEFINE_bool(trace_builtin_calls, false, "trace builtins calls")
285DEFINE_string(stop_at, "", "function name where to insert a breakpoint")
286
287// compiler.cc
288DEFINE_bool(print_builtin_scopes, false, "print scopes for builtins")
289DEFINE_bool(print_scopes, false, "print scopes")
290
291// contexts.cc
292DEFINE_bool(trace_contexts, false, "trace contexts operations")
293
294// heap.cc
295DEFINE_bool(gc_greedy, false, "perform GC prior to some allocations")
296DEFINE_bool(gc_verbose, false, "print stuff during garbage collection")
297DEFINE_bool(heap_stats, false, "report heap statistics before and after GC")
298DEFINE_bool(code_stats, false, "report code statistics after GC")
299DEFINE_bool(verify_heap, false, "verify heap pointers before and after GC")
300DEFINE_bool(print_handles, false, "report handles after GC")
301DEFINE_bool(print_global_handles, false, "report global handles after GC")
302DEFINE_bool(print_rset, false, "print remembered sets before GC")
303
304// ic.cc
305DEFINE_bool(trace_ic, false, "trace inline cache state transitions")
306
307// objects.cc
308DEFINE_bool(trace_normalization,
309            false,
310            "prints when objects are turned into dictionaries.")
311
312// runtime.cc
313DEFINE_bool(trace_lazy, false, "trace lazy compilation")
314
315// serialize.cc
316DEFINE_bool(debug_serialization, false,
317            "write debug information into the snapshot.")
318
319// spaces.cc
320DEFINE_bool(collect_heap_spill_statistics, false,
321            "report heap spill statistics along with heap_stats "
322            "(requires heap_stats)")
323
324// Regexp
325DEFINE_bool(trace_regexp_bytecodes, false, "trace regexp bytecode execution")
326DEFINE_bool(trace_regexp_assembler,
327            false,
328            "trace regexp macro assembler calls.")
329
330//
331// Logging and profiling only flags
332//
333#undef FLAG
334#ifdef ENABLE_LOGGING_AND_PROFILING
335#define FLAG FLAG_FULL
336#else
337#define FLAG FLAG_READONLY
338#endif
339
340// log.cc
341DEFINE_bool(log, false,
342            "Minimal logging (no API, code, GC, suspect, or handles samples).")
343DEFINE_bool(log_all, false, "Log all events to the log file.")
344DEFINE_bool(log_runtime, false, "Activate runtime system %Log call.")
345DEFINE_bool(log_api, false, "Log API events to the log file.")
346DEFINE_bool(log_code, false,
347            "Log code events to the log file without profiling.")
348DEFINE_bool(log_gc, false,
349            "Log heap samples on garbage collection for the hp2ps tool.")
350DEFINE_bool(log_handles, false, "Log global handle events.")
351DEFINE_bool(log_state_changes, false, "Log state changes.")
352DEFINE_bool(log_suspect, false, "Log suspect operations.")
353DEFINE_bool(log_producers, false, "Log stack traces of JS objects allocations.")
354DEFINE_bool(compress_log, false,
355            "Compress log to save space (makes log less human-readable).")
356DEFINE_bool(prof, false,
357            "Log statistical profiling information (implies --log-code).")
358DEFINE_bool(prof_auto, true,
359            "Used with --prof, starts profiling automatically")
360DEFINE_bool(prof_lazy, false,
361            "Used with --prof, only does sampling and logging"
362            " when profiler is active (implies --noprof_auto).")
363DEFINE_bool(log_regexp, false, "Log regular expression execution.")
364DEFINE_bool(sliding_state_window, false,
365            "Update sliding state window counters.")
366DEFINE_string(logfile, "v8.log", "Specify the name of the log file.")
367DEFINE_bool(oprofile, false, "Enable JIT agent for OProfile.")
368
369//
370// Heap protection flags
371// Using heap protection requires ENABLE_LOGGING_AND_PROFILING as well.
372//
373#ifdef ENABLE_HEAP_PROTECTION
374#undef FLAG
375#define FLAG FLAG_FULL
376
377DEFINE_bool(protect_heap, false,
378            "Protect/unprotect V8's heap when leaving/entring the VM.")
379
380#endif
381
382//
383// Disassembler only flags
384//
385#undef FLAG
386#ifdef ENABLE_DISASSEMBLER
387#define FLAG FLAG_FULL
388#else
389#define FLAG FLAG_READONLY
390#endif
391
392// code-stubs.cc
393DEFINE_bool(print_code_stubs, false, "print code stubs")
394
395// codegen-ia32.cc / codegen-arm.cc
396DEFINE_bool(print_code, false, "print generated code")
397DEFINE_bool(print_builtin_code, false, "print generated code for builtins")
398
399// Cleanup...
400#undef FLAG_FULL
401#undef FLAG_READONLY
402#undef FLAG
403
404#undef DEFINE_bool
405#undef DEFINE_int
406#undef DEFINE_string
407
408#undef FLAG_MODE_DECLARE
409#undef FLAG_MODE_DEFINE
410#undef FLAG_MODE_DEFINE_DEFAULTS
411#undef FLAG_MODE_META
412