blob: dbb9ce72bfb5e33646b7ce97b4ef53a97e40a863 [file] [log] [blame]
Steve Blocka7e24c12009-10-30 11:49:00 +00001// 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
Steve Block3ce2e202009-11-05 08:53:23 +000099// assembler-ia32.cc / assembler-arm.cc / assembler-x64.cc
Steve Blocka7e24c12009-10-30 11:49:00 +0000100DEFINE_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")
Steve Block3ce2e202009-11-05 08:53:23 +0000107DEFINE_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)")
Steve Blockd0582a62009-12-15 09:54:21 +0000117DEFINE_bool(enable_vfp3, true,
118 "enable use of VFP3 instructions if available (ARM only)")
Andrei Popescu31002712010-02-23 13:46:05 +0000119DEFINE_bool(enable_armv7, true,
120 "enable use of ARMv7 instructions if available (ARM only)")
Steve Blocka7e24c12009-10-30 11:49:00 +0000121
122// bootstrapper.cc
123DEFINE_string(expose_natives_as, NULL, "expose natives in global object")
124DEFINE_string(expose_debug_as, NULL, "expose debug in global object")
Steve Blocka7e24c12009-10-30 11:49:00 +0000125DEFINE_bool(expose_gc, false, "expose gc extension")
126DEFINE_int(stack_trace_limit, 10, "number of stack frames to capture")
127
128// builtins-ia32.cc
129DEFINE_bool(inline_new, true, "use fast inline allocation")
130
131// checks.cc
132DEFINE_bool(stack_trace_on_abort, true,
133 "print a stack trace if an assertion failure occurs")
134
135// codegen-ia32.cc / codegen-arm.cc
136DEFINE_bool(trace, false, "trace function calls")
137DEFINE_bool(defer_negation, true, "defer negation operation")
Steve Blocka7e24c12009-10-30 11:49:00 +0000138
139// codegen.cc
140DEFINE_bool(lazy, true, "use lazy compilation")
141DEFINE_bool(debug_info, true, "add debug information to compiled functions")
142
143// compiler.cc
144DEFINE_bool(strict, false, "strict error checking")
145DEFINE_int(min_preparse_length, 1024,
Steve Block3ce2e202009-11-05 08:53:23 +0000146 "minimum length for automatic enable preparsing")
Leon Clarked91b9f72010-01-27 17:25:45 +0000147DEFINE_bool(full_compiler, true, "enable dedicated backend for run-once code")
148DEFINE_bool(fast_compiler, false, "enable speculative optimizing backend")
149DEFINE_bool(always_full_compiler, false,
150 "try to use the dedicated run-once backend for all code")
Steve Blockd0582a62009-12-15 09:54:21 +0000151DEFINE_bool(always_fast_compiler, false,
Leon Clarked91b9f72010-01-27 17:25:45 +0000152 "try to use the speculative optimizing backend for all code")
153DEFINE_bool(trace_bailout, false,
154 "print reasons for falling back to using the classic V8 backend")
Steve Blocka7e24c12009-10-30 11:49:00 +0000155
156// compilation-cache.cc
157DEFINE_bool(compilation_cache, true, "enable compilation cache")
158
159// debug.cc
160DEFINE_bool(remote_debugging, false, "enable remote debugging")
161DEFINE_bool(trace_debug_json, false, "trace debugging JSON request/response")
Steve Blockd0582a62009-12-15 09:54:21 +0000162DEFINE_bool(debugger_auto_break, true,
Steve Blocka7e24c12009-10-30 11:49:00 +0000163 "automatically set the debug break flag when debugger commands are "
Steve Blockd0582a62009-12-15 09:54:21 +0000164 "in the queue")
Steve Blocka7e24c12009-10-30 11:49:00 +0000165
166// frames.cc
167DEFINE_int(max_stack_trace_source_length, 300,
168 "maximum length of function source code printed in a stack trace.")
169
170// heap.cc
Steve Block3ce2e202009-11-05 08:53:23 +0000171DEFINE_int(max_new_space_size, 0, "max size of the new generation")
172DEFINE_int(max_old_space_size, 0, "max size of the old generation")
Steve Blocka7e24c12009-10-30 11:49:00 +0000173DEFINE_bool(gc_global, false, "always perform global GCs")
174DEFINE_int(gc_interval, -1, "garbage collect after <n> allocations")
175DEFINE_bool(trace_gc, false,
176 "print one trace line following each garbage collection")
177DEFINE_bool(trace_gc_verbose, false,
178 "print more details following each garbage collection")
179DEFINE_bool(collect_maps, true,
180 "garbage collect maps from which no objects can be reached")
181
182// v8.cc
183DEFINE_bool(use_idle_notification, true,
184 "Use idle notification to reduce memory footprint.")
185// ic.cc
186DEFINE_bool(use_ic, true, "use inline caching")
187
188// macro-assembler-ia32.cc
189DEFINE_bool(native_code_counters, false,
190 "generate extra code for manipulating stats counters")
191
192// mark-compact.cc
193DEFINE_bool(always_compact, false, "Perform compaction on every full GC")
194DEFINE_bool(never_compact, false,
195 "Never perform compaction on full GC - testing only")
196DEFINE_bool(cleanup_ics_at_gc, true,
197 "Flush inline caches prior to mark compact collection.")
198DEFINE_bool(cleanup_caches_in_maps_at_gc, true,
199 "Flush code caches in maps during mark compact cycle.")
200
201DEFINE_bool(canonicalize_object_literal_maps, true,
202 "Canonicalize maps for object literals.")
203
Leon Clarkee46be812010-01-19 14:06:41 +0000204DEFINE_bool(use_big_map_space, true,
205 "Use big map space, but don't compact if it grew too big.")
206
Leon Clarked91b9f72010-01-27 17:25:45 +0000207DEFINE_int(max_map_space_pages, MapSpace::kMaxMapPageIndex - 1,
208 "Maximum number of pages in map space which still allows to encode "
209 "forwarding pointers. That's actually a constant, but it's useful "
210 "to control it with a flag for better testing.")
211
Steve Blocka7e24c12009-10-30 11:49:00 +0000212// mksnapshot.cc
213DEFINE_bool(h, false, "print this message")
Steve Blockd0582a62009-12-15 09:54:21 +0000214DEFINE_bool(new_snapshot, true, "use new snapshot implementation")
Steve Blocka7e24c12009-10-30 11:49:00 +0000215
216// parser.cc
217DEFINE_bool(allow_natives_syntax, false, "allow natives syntax")
218
219// rewriter.cc
220DEFINE_bool(optimize_ast, true, "optimize the ast")
221
Andrei Popescu31002712010-02-23 13:46:05 +0000222// simulator-arm.cc and simulator-mips.cc
Steve Blocka7e24c12009-10-30 11:49:00 +0000223DEFINE_bool(trace_sim, false, "trace simulator execution")
224DEFINE_int(stop_sim_at, 0, "Simulator stop after x number of instructions")
225
226// top.cc
227DEFINE_bool(trace_exception, false,
228 "print stack trace when throwing exceptions")
229DEFINE_bool(preallocate_message_memory, false,
230 "preallocate some memory to build stack traces.")
231
232// usage-analyzer.cc
233DEFINE_bool(usage_computation, true, "compute variable usage counts")
234
235// v8.cc
236DEFINE_bool(preemption, false,
237 "activate a 100ms timer that switches between V8 threads")
238
239// Regexp
240DEFINE_bool(trace_regexps, false, "trace regexp execution")
241DEFINE_bool(regexp_optimization, true, "generate optimized regexp code")
Leon Clarkee46be812010-01-19 14:06:41 +0000242DEFINE_bool(regexp_entry_native, true, "use native code to enter regexp")
Steve Blocka7e24c12009-10-30 11:49:00 +0000243
244// Testing flags test/cctest/test-{flags,api,serialization}.cc
245DEFINE_bool(testing_bool_flag, true, "testing_bool_flag")
246DEFINE_int(testing_int_flag, 13, "testing_int_flag")
247DEFINE_float(testing_float_flag, 2.5, "float-flag")
248DEFINE_string(testing_string_flag, "Hello, world!", "string-flag")
249DEFINE_int(testing_prng_seed, 42, "Seed used for threading test randomness")
250#ifdef WIN32
251DEFINE_string(testing_serialization_file, "C:\\Windows\\Temp\\serdes",
252 "file in which to testing_serialize heap")
253#else
254DEFINE_string(testing_serialization_file, "/tmp/serdes",
255 "file in which to serialize heap")
256#endif
257
258//
259// Dev shell flags
260//
261
262DEFINE_bool(help, false, "Print usage message, including flags, on console")
263DEFINE_bool(dump_counters, false, "Dump counters on exit")
264DEFINE_bool(debugger, true, "Enable JavaScript debugger")
265DEFINE_bool(remote_debugger, false, "Connect JavaScript debugger to the "
266 "debugger agent in another process")
267DEFINE_bool(debugger_agent, false, "Enable debugger agent")
268DEFINE_int(debugger_port, 5858, "Port to use for remote debugging")
269DEFINE_string(map_counters, false, "Map counters to a file")
270DEFINE_args(js_arguments, JSArguments(),
271 "Pass all remaining arguments to the script. Alias for \"--\".")
272
273//
274// Debug only flags
275//
276#undef FLAG
277#ifdef DEBUG
278#define FLAG FLAG_FULL
279#else
280#define FLAG FLAG_READONLY
281#endif
282
283// checks.cc
284DEFINE_bool(enable_slow_asserts, false,
285 "enable asserts that are slow to execute")
286
287// codegen-ia32.cc / codegen-arm.cc
288DEFINE_bool(trace_codegen, false,
289 "print name of functions for which code is generated")
290DEFINE_bool(print_source, false, "pretty print source code")
291DEFINE_bool(print_builtin_source, false,
292 "pretty print source code for builtins")
293DEFINE_bool(print_ast, false, "print source AST")
294DEFINE_bool(print_builtin_ast, false, "print source AST for builtins")
Steve Block3ce2e202009-11-05 08:53:23 +0000295DEFINE_bool(print_json_ast, false, "print source AST as JSON")
296DEFINE_bool(print_builtin_json_ast, false,
297 "print source AST for builtins as JSON")
Steve Blocka7e24c12009-10-30 11:49:00 +0000298DEFINE_bool(trace_calls, false, "trace calls")
299DEFINE_bool(trace_builtin_calls, false, "trace builtins calls")
300DEFINE_string(stop_at, "", "function name where to insert a breakpoint")
301
302// compiler.cc
303DEFINE_bool(print_builtin_scopes, false, "print scopes for builtins")
304DEFINE_bool(print_scopes, false, "print scopes")
Leon Clarke4515c472010-02-03 11:58:03 +0000305DEFINE_bool(print_ir, false, "print the AST as seen by the backend")
Steve Blocka7e24c12009-10-30 11:49:00 +0000306
307// contexts.cc
308DEFINE_bool(trace_contexts, false, "trace contexts operations")
309
310// heap.cc
311DEFINE_bool(gc_greedy, false, "perform GC prior to some allocations")
312DEFINE_bool(gc_verbose, false, "print stuff during garbage collection")
313DEFINE_bool(heap_stats, false, "report heap statistics before and after GC")
314DEFINE_bool(code_stats, false, "report code statistics after GC")
315DEFINE_bool(verify_heap, false, "verify heap pointers before and after GC")
316DEFINE_bool(print_handles, false, "report handles after GC")
317DEFINE_bool(print_global_handles, false, "report global handles after GC")
318DEFINE_bool(print_rset, false, "print remembered sets before GC")
319
320// ic.cc
321DEFINE_bool(trace_ic, false, "trace inline cache state transitions")
322
323// objects.cc
324DEFINE_bool(trace_normalization,
325 false,
326 "prints when objects are turned into dictionaries.")
327
328// runtime.cc
329DEFINE_bool(trace_lazy, false, "trace lazy compilation")
330
331// serialize.cc
332DEFINE_bool(debug_serialization, false,
333 "write debug information into the snapshot.")
334
335// spaces.cc
336DEFINE_bool(collect_heap_spill_statistics, false,
337 "report heap spill statistics along with heap_stats "
338 "(requires heap_stats)")
339
340// Regexp
Leon Clarkee46be812010-01-19 14:06:41 +0000341DEFINE_bool(regexp_possessive_quantifier,
342 false,
343 "enable possessive quantifier syntax for testing")
Steve Blocka7e24c12009-10-30 11:49:00 +0000344DEFINE_bool(trace_regexp_bytecodes, false, "trace regexp bytecode execution")
345DEFINE_bool(trace_regexp_assembler,
346 false,
347 "trace regexp macro assembler calls.")
348
349//
350// Logging and profiling only flags
351//
352#undef FLAG
353#ifdef ENABLE_LOGGING_AND_PROFILING
354#define FLAG FLAG_FULL
355#else
356#define FLAG FLAG_READONLY
357#endif
358
359// log.cc
360DEFINE_bool(log, false,
361 "Minimal logging (no API, code, GC, suspect, or handles samples).")
362DEFINE_bool(log_all, false, "Log all events to the log file.")
363DEFINE_bool(log_runtime, false, "Activate runtime system %Log call.")
364DEFINE_bool(log_api, false, "Log API events to the log file.")
365DEFINE_bool(log_code, false,
366 "Log code events to the log file without profiling.")
367DEFINE_bool(log_gc, false,
368 "Log heap samples on garbage collection for the hp2ps tool.")
369DEFINE_bool(log_handles, false, "Log global handle events.")
Leon Clarkee46be812010-01-19 14:06:41 +0000370DEFINE_bool(log_snapshot_positions, false,
371 "log positions of (de)serialized objects in the snapshot.")
Steve Blocka7e24c12009-10-30 11:49:00 +0000372DEFINE_bool(log_state_changes, false, "Log state changes.")
373DEFINE_bool(log_suspect, false, "Log suspect operations.")
Steve Block3ce2e202009-11-05 08:53:23 +0000374DEFINE_bool(log_producers, false, "Log stack traces of JS objects allocations.")
Steve Blocka7e24c12009-10-30 11:49:00 +0000375DEFINE_bool(compress_log, false,
376 "Compress log to save space (makes log less human-readable).")
377DEFINE_bool(prof, false,
378 "Log statistical profiling information (implies --log-code).")
379DEFINE_bool(prof_auto, true,
380 "Used with --prof, starts profiling automatically")
381DEFINE_bool(prof_lazy, false,
382 "Used with --prof, only does sampling and logging"
383 " when profiler is active (implies --noprof_auto).")
384DEFINE_bool(log_regexp, false, "Log regular expression execution.")
385DEFINE_bool(sliding_state_window, false,
386 "Update sliding state window counters.")
Andrei Popescu402d9372010-02-26 13:31:12 +0000387DEFINE_string(logfile, "v8.log", "Specify the name of the log file.")
Steve Blocka7e24c12009-10-30 11:49:00 +0000388DEFINE_bool(oprofile, false, "Enable JIT agent for OProfile.")
389
390//
391// Heap protection flags
392// Using heap protection requires ENABLE_LOGGING_AND_PROFILING as well.
393//
394#ifdef ENABLE_HEAP_PROTECTION
395#undef FLAG
396#define FLAG FLAG_FULL
397
398DEFINE_bool(protect_heap, false,
399 "Protect/unprotect V8's heap when leaving/entring the VM.")
400
401#endif
402
403//
404// Disassembler only flags
405//
406#undef FLAG
407#ifdef ENABLE_DISASSEMBLER
408#define FLAG FLAG_FULL
409#else
410#define FLAG FLAG_READONLY
411#endif
412
413// code-stubs.cc
414DEFINE_bool(print_code_stubs, false, "print code stubs")
415
416// codegen-ia32.cc / codegen-arm.cc
417DEFINE_bool(print_code, false, "print generated code")
418DEFINE_bool(print_builtin_code, false, "print generated code for builtins")
419
420// Cleanup...
421#undef FLAG_FULL
422#undef FLAG_READONLY
423#undef FLAG
424
425#undef DEFINE_bool
426#undef DEFINE_int
427#undef DEFINE_string
428
429#undef FLAG_MODE_DECLARE
430#undef FLAG_MODE_DEFINE
431#undef FLAG_MODE_DEFINE_DEFAULTS
432#undef FLAG_MODE_META