1 # Copyright (C) 2001-2007, The Perl Foundation.
14 This document describes parrot's command line options.
18 parrot [-options] <file> [arguments ...]
26 If this environment variable is set, parrot will use this path as runtime
27 prefix instead of the compiled in path.
31 Turn on the I<--gc-debug> flag.
37 =head2 Assembler options
43 Assume PASM input on stdin.
47 Assume PBC file on stdin, run it.
49 =item -d, --imcc-debug [hexbits]
51 The B<-d> switch takes an optional argument which is considered to hold a hex
52 value of debug bits. Without a value, debug is set to 1.
54 The individual bits can be listed on the command line by use of the
55 B<--help-debug> switch.
57 To produce really huge output on F<stderr> run C<"parrot B<-d 0ffff> ...">.
58 Note: If the argument is separated by whitespace from the B<-d>
59 switch, it has to start with a number.
63 Print command line option summary.
67 Print debugging and tracing flag bits summary.
69 =item -o outputfile, --output=outputfile
71 Act like an assembler. Don't run code, unless B<-r> is given too. If the
72 outputfile ends with B<.pbc>, a PBC file is written. If it ends with B<.pasm>,
73 a PASM output is generated, even from PASM input. This can be handy to check
74 various optimizations, including B<-Op>.
78 Act like an assembler, but always output bytecode, even if the output file does
83 Only useful after B<-o> or B<--output-pbc>. Run the program from the compiled
84 in-memory image. If two B<-r> options are given, the B<.pbc> file is read from
85 disc and run. This is mainly needed for tests.
89 One B<-v> shows which files are worked on and prints a summary over register
90 usage and optimization stats per I<compilation unit>. With two B<-v> switches,
91 C<parrot> prints a line per individual processing step too.
95 Turn on yydebug in F<yacc>/F<bison>.
99 Print version information and exit.
105 -O0 no optimization (default)
106 -O1 optimizations without life info (e.g. branches)
108 -O2 optimizations with life info
109 -Op rewrite I and N PASM registers most used first
110 -Ot select fastest runcore (default with -O1 and -O2)
111 -Oc turns on the optional/experimental tail call optimizations
113 See F<docs/imcc/operation.pod> for more information on the optimizer. NB.
114 Optimization is currently experimental and these options are likely to change.
116 =item -E, --pre-process-only
118 Preprocess source file (i.e. expand macros) and print result to stdout. E.g.
120 $ parrot -E t/op/macro_10.pasm
121 $ parrot -E t/op/macro_10.pasm | parrot -- -
125 =head2 Runcore Options
127 These options select the runcore, which is useful for performance
128 tuning and debugging. See L<About runcores> below for details.
132 =item -R, --runcore CORE
134 Select the runcore. The following cores are available:
136 slow, bounds bounds checking core (default)
137 fast fast core (no bounds checking, profiling, or tracing)
139 cgp computed goto-predereferenced core
140 cgoto computed goto core
142 cgp-jit computed goto-predereferenced core with JIT
143 switch-jit switch core with JIT
144 exec exec core (uses JIT at compile time to generate native code)
145 trace bounds checking core w/ trace info (see 'parrot --help-debug')
146 gcdebug performs a full GC run before every op dispatch (good for
147 debugging GC problems)
149 =item -b, --bounds-checks, --slow-core
151 Select the bounds-checking slow core (default).
155 Select the CGP (CGoto Predereferenced) core (if available).
157 =item -f, --fast-core
159 Select the fast (or function) core.
161 =item -g, --computed-goto-core
163 Select the CGoto core (if available).
167 Run with the JIT subsystem (if available).
171 Run with the slow core and print an execution profile.
173 =item -S, --switched-core
175 TODO: This needs to be documented briefly here and also in glossary.pod.
179 Run with the slow core and print trace information to B<stderr>. See 'parrot
180 --help-debug' for available flag bits.
190 Turn on warnings. See 'parrot --help-debug' for available flag bits.
192 =item -D, --parrot-debug
194 Turn on interpreter debug flag. See 'parrot --help-debug' for available flag
199 Turn on GC (Garbage Collection) debugging. This imposes some stress on the GC
200 subsystem and can slow down execution considerably.
204 This turns off DOD (Dead Object Detection) and GC. This may be useful to find
205 GC related bugs. Don't use this option for longer running programs: as memory
206 is no longer recycled, it may quickly become exhausted.
208 =item --leak-test, --destroy-at-end
210 Free all memory of the last interpreter, so that leak checkers can be run.
214 Read a keystroke before starting.
216 =item --runtime-prefix
218 Print the runtime prefix path and exit.
224 If the file ends in B<.pbc> it will be interpreted immediately.
226 If the file ends in B<.pasm>, then it is parsed as PASM code. Otherwise, it is
227 parsed as PIR code. In both cases, it will then be run, unless the B<-o> flag
230 If the B<file> is a single dash, input from B<stdin> is read.
232 =head2 [arguments ...]
234 Optional arguments passed to the running program as ARGV. The program is
235 assumed to know what to do with these.
237 =head1 Generated files
239 If JIT debugging is enabled (e.g. via C<--parrot-debug 04>), the
240 following additional output files are generated:
242 file.stabs.s ... stabsfile for the program
243 file.o ... object file with debug information
244 EVAL_n ... source of B<compile> op number I<n>
245 EVAL_n.stabs.s ... stabsfile for this block
246 EVAL_n.o ... object file with debug information
248 See F<docs/jit.pod> for further information.
250 =head1 About runcores
252 The runcore (or runloop) tells Parrot how to find the C code that
253 implements each instruction. Parrot provides more than one way to do
254 this, partly because it is expected that no one runcore will perform
255 optimally on all architectures (or even for all problems on a given
256 architecture), and partly because some of the runcores are specialized
259 In the default "slow" runcore, each opcode is a separate C function.
260 That's pretty easy in pseudocode:
264 op = op_function( op )
267 The GC debugging runcore is similar:
269 gcdebug_runcore( op ):
271 perform_full_gc_run()
272 op = op_function( op )
275 Of course, this is much slower, but is extremely helpful for pinning
276 memory corruption problems that affect GC down to single-instruction
278 L<http://www.oreillynet.com/onlamp/blog/2007/10/debugging_gc_problems_in_parro.html>
279 for more information.
281 The trace and profile cores are also based on the "slow" core, doing
282 full bounds checking, and also printing runtime information to stderr.
284 The switched core eschews a bunch of tiny op functions in favor of
285 cases in a large switch statement:
287 switch_runcore( op ):
296 Depending on the C compiler implementation, this may be faster than
297 function calling. On older systems, it may fail to compile
300 The computed-goto ("cgoto") runcore avoids the overhead of function
301 calls by jumping directly to the address where each opcode's function
302 starts. The computed-goto-prederef ("CGP") core takes this one step
303 further by replacing opcode numbers in the bytecode with those opfunc
304 addresses. See "Predereferencing" in F<docs/glossary.pod> for a
307 Finally, the JIT runcore uses the "slow" core, but also creates and
308 jumps to JIT-compiled native code for supported opcodes. "cgp-jit"
309 and "switched-jit" are variations that use the CGP or switched core
310 but run JIT code when possible.
312 =head1 Operation table
314 Command line Action Output
315 ---------------------------------------------
319 -o x.pasm x.pir ass x.pasm
320 -o x.pasm y.pasm ass x.pasm
321 -o x.pbc x.pir ass x.pbc
322 -o x.pbc x.pasm ass x.pbc
323 -o x.pbc -r x.pasm ass/run pasm x.pbc
324 -o x.pbc -r -r x.pasm ass/run pbc x.pbc
329 run ... yes, run the program
330 ass ... assemble sourcefile
331 obj .. produce native (ELF) object file for the EXEC subsystem
343 Leopold Toetsch C<lt@toetsch.at>