Browse files

Merge in from master, fixing a few conflicts in imcc

  • Loading branch information...
2 parents 00bd560 + 361e440 commit a5fc5642a560bd299803c9d8d3e685833ea155a5 @Whiteknight Whiteknight committed Aug 13, 2011
Showing with 839 additions and 288 deletions.
  1. +7 −0 CREDITS
  2. +2 −0 MANIFEST
  3. +2 −0 NEWS
  4. +3 −3 compilers/imcc/imcc.y
  5. +3 −3 compilers/imcc/imcparser.c
  6. +15 −1 compilers/pct/src/PAST/Compiler.pir
  7. +3 −1 config/gen/config_pm/
  8. +8 −8 config/gen/makefiles/
  9. +10 −1 docs/book/pct/ch04_pge.pod
  10. +73 −26 docs/dev/profiling.pod
  11. +3 −41 docs/glossary.pod
  12. +4 −1 docs/index/pct_tutorial.json
  13. +4 −1 docs/index/pdds.json
  14. +7 −8 docs/pct/gettingstarted.pod
  15. +15 −1 docs/project/git_workflow.pod
  16. +1 −1 docs/project/release_manager_guide.pod
  17. BIN examples/languages/squaak/doc/pct-stages.png
  18. +257 −0 examples/languages/squaak/doc/pct-stages.svg
  19. +1 −1 examples/languages/squaak/doc/tutorial_episode_1.pod
  20. +13 −18 examples/languages/squaak/doc/tutorial_episode_2.pod
  21. +5 −1 examples/languages/squaak/doc/tutorial_episode_4.pod
  22. +13 −0 lib/Parrot/Docs/
  23. +1 −1 lib/Parrot/Pmc2c/
  24. +1 −1 lib/Parrot/Pmc2c/
  25. +6 −56 runtime/parrot/library/distutils.pir
  26. +32 −0 src/nci_test.c
  27. +7 −0 src/pmc/exception.pmc
  28. +27 −76 src/pmc/multisub.pmc
  29. +38 −1 src/pmc/ptr.pmc
  30. +37 −1 src/pmc/unmanagedstruct.pmc
  31. +52 −2 t/pmc/nci.t
  32. +3 −1 t/src/atomic.t
  33. +4 −1 t/src/basic.t
  34. +3 −1 t/src/embed.t
  35. +4 −1 t/src/embed/api.t
  36. +4 −1 t/src/exit.t
  37. +3 −1 t/src/extend.t
  38. +5 −1 t/src/extend_vtable.t
  39. +4 −1 t/src/misc.t
  40. +3 −1 t/src/pointer_array.t
  41. +4 −1 t/src/warnings.t
  42. +6 −5 t/tools/dev/headerizer/02_methods.t
  43. +146 −19 tools/docs/
@@ -18,6 +18,13 @@
PPPS: To turn this file into a author map for git-svn, see tools/dev/
+N: Aaron Faanes
+D: make_html_docs revisions
+U: dafrito
+S: Richardson, TX
N: Aaron Sherman
U: ajs
@@ -541,6 +541,8 @@ examples/languages/abc/t/abc_special_variables [examples]
examples/languages/abc/t/abc_statement [examples]
examples/languages/squaak/MAINTAINER [examples]
examples/languages/squaak/README [examples]
+examples/languages/squaak/doc/pct-stages.png [examples]
+examples/languages/squaak/doc/pct-stages.svg [examples]
examples/languages/squaak/doc/tutorial_episode_1.pod [examples]
examples/languages/squaak/doc/tutorial_episode_2.pod [examples]
examples/languages/squaak/doc/tutorial_episode_3.pod [examples]
@@ -1,5 +1,7 @@
New in 3.7.0
- Core
+ + Added mem_sys_strndup function.
+ + Added new load_bytecode_p_s opcode as an eventual replacement for load_bytecode_s
- Languages
- Documentation
+ The Archive::Tar and Archive::Zip libraries now have POD docs
@@ -1443,10 +1443,10 @@ multi_type:
SymReg *r;
- if (strcmp($1, "_") != 0)
- r = mk_const(imcc, $1, 'S');
- else {
+ if (strcmp($1, "\"_\"") == 0 || strcmp($1, "'_'") == 0)
r = mk_const(imcc, "PMC", 'S');
+ else {
+ r = mk_const(imcc, $1, 'S');
$$ = r;
@@ -3751,10 +3751,10 @@ YYSTYPE yylval;
#line 1444 "compilers/imcc/imcc.y"
SymReg *r;
- if (strcmp((yyvsp[(1) - (1)].s), "_") != 0)
- r = mk_const(imcc, (yyvsp[(1) - (1)].s), 'S');
- else {
+ if (strcmp((yyvsp[(1) - (1)].s), "\"_\"") == 0 || strcmp((yyvsp[(1) - (1)].s), "'_'") == 0)
r = mk_const(imcc, "PMC", 'S');
+ else {
+ r = mk_const(imcc, (yyvsp[(1) - (1)].s), 'S');
mem_sys_free((yyvsp[(1) - (1)].s));
( = r;
@@ -1066,7 +1066,7 @@ Return the POST representation of a C<PAST::Block>.
$I0 = defined symtable['']
if $I0 goto have_symtable
## merge the Block's symtable with outersym
- symtable = clone symtable
+ symtable = 'shallow_clone_hash'(symtable)
.local pmc it
it = iter outersym
@@ -1226,6 +1226,20 @@ Return the POST representation of a C<PAST::Block>.
.return (bpost)
+.sub 'shallow_clone_hash'
+ .param pmc to_clone
+ $P0 = new ['Hash']
+ $P1 = iter to_clone
+ it_loop:
+ unless $P1 goto it_loop_end
+ $S0 = shift $P1
+ $P2 = to_clone[$S0]
+ $P0[$S0] = $P2
+ goto it_loop
+ it_loop_end:
+ .return ($P0)
@@ -42,6 +42,7 @@ undefined values) is undefined, and may be rather funky.
.sub _config
.local string prefix, conf_file
+ .local pmc ex
prefix = interpinfo .INTERPINFO_RUNTIME_PREFIX
$S0 = concat prefix, "/runtime"
@@ -58,6 +59,8 @@ undefined values) is undefined, and may be rather funky.
goto L1
+ .get_results (ex)
+ finalize ex
# Treat it as installed parrot.
conf_file = "@libdir@@versiondir@/include/config.fpmc"
goto L2
@@ -85,7 +88,6 @@ undefined values) is undefined, and may be rather funky.
.return( conf_hash )
- .local pmc ex
.get_results (ex)
$S0 = "Can't read '"
$S0 .= conf_file
@@ -530,7 +530,7 @@ PBC_TO_EXE = .@slash@pbc_to_exe$(EXE)
PARROT_CONFIG = .@slash@parrot_config$(EXE)
NQP_RX = .@slash@parrot-nqp$(EXE)
NCI_THUNK_GEN = .@slash@parrot_nci_thunk_gen$(EXE)
-PROVE = .@slash@parrot-prove$(EXE)
+PARROT_PROVE = .@slash@parrot-prove$(EXE)
OPS2C = .@slash@ops2c$(EXE)
WINXED = .@slash@winxed$(EXE)
@@ -543,8 +543,8 @@ INSTALLABLEPBCTOEXE = .@slash@installable_pbc_to_exe$(EXE)
INSTALLABLEPDB = .@slash@installable_parrot_debugger$(EXE)
INSTALLABLECONFIG = .@slash@installable_parrot_config$(EXE)
INSTALLABLENQP = .@slash@installable_parrot-nqp$(EXE)
-INSTALLABLENCITHUNKGEN = .@slash@installable_parrot_nci_thunk_gen$(EXE)
-INSTALLABLEPROVE = .@slash@installable_parrot-prove$(EXE)
+INSTALLABLENCITHUNKGEN = .@slash@installable_parrot_nci_thunk_gen$(EXE)
+INSTALLABLEPARROT_PROVE = .@slash@installable_parrot-prove$(EXE)
INSTALLABLEOPS2C = .@slash@installable_ops2c$(EXE)
INSTALLABLEWINXED = .@slash@installable_winxed$(EXE)
@@ -838,9 +838,9 @@ help :
world : parrot_utils
-parrot_utils : all $(PDUMP) $(DIS) $(PDB) $(PBC_MERGE) $(PBC_TO_EXE) $(PARROT_CONFIG) src/install_config$(O) $(PROVE) $(OPS2C)
+parrot_utils : all $(PDUMP) $(DIS) $(PDB) $(PBC_MERGE) $(PBC_TO_EXE) $(PARROT_CONFIG) src/install_config$(O) $(PARROT_PROVE) $(OPS2C)
bootstrap-ops : $(OPS2C)
$(OPS2C) --core --quiet
@@ -885,7 +885,7 @@ $(NCI_THUNK_GEN) : parrot_nci_thunk_gen.pbc $(PBC_TO_EXE)
parrot-prove.pbc : runtime/parrot/bin/prove.pir $(PARROT)
$(PARROT) -o parrot-prove.pbc runtime/parrot/bin/prove.pir
-$(PROVE) : parrot-prove.pbc $(PARROT) $(PBC_TO_EXE)
+$(PARROT_PROVE) : parrot-prove.pbc $(PARROT) $(PBC_TO_EXE)
$(PBC_TO_EXE) parrot-prove.pbc
$(PARROT_CONFIG) : $(DEV_TOOLS_DIR)/parrot-config.pir $(PARROT) $(PBC_TO_EXE)
@@ -1044,7 +1044,7 @@ $(INSTALLABLEPBCTOEXE) : $(PBC_TO_EXE) src/install_config$(O)
$(INSTALLABLENCITHUNKGEN) : parrot_nci_thunk_gen.pbc $(PBC_TO_EXE) src/install_config$(O)
$(PBC_TO_EXE) parrot_nci_thunk_gen.pbc --install
-$(INSTALLABLEPROVE) : parrot-prove.pbc $(PBC_TO_EXE) src/install_config$(O)
+$(INSTALLABLEPARROT_PROVE) : parrot-prove.pbc $(PBC_TO_EXE) src/install_config$(O)
$(PBC_TO_EXE) parrot-prove.pbc --install
@@ -2303,7 +2303,7 @@ prog-clean :
pbc_to_exe.pbc pbc_to_exe.c pbc_to_exe$(O) pbc_to_exe$(EXE) \
$(NCI_THUNK_GEN) parrot_nci_thunk_gen.c parrot_nci_thunk_gen$(O) parrot_nci_thunk_gen.pbc \
@@ -65,7 +65,16 @@ X<token>
There are two different kinds of rules: C<rule>, which we saw above, and
C<token>. A C<rule> performs smart whitespace matching between the various
pieces of the pattern. The C<record> rule given previously would match
-"6355 John" or "6355 John" but not "6355John".
+ 6355 John
+ 6355 John
+but not
+ 6355John
A C<token> matches whitespace only if you specifically request it. To get the
same effect with a token, add the C<\s> (match a space character) and C<+>
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2005, Parrot Foundation.
+# Copyright (C) 2001-2011, Parrot Foundation.
=head1 NAME
@@ -10,74 +10,121 @@ This file documents the use of Parrot's profiling runcore.
=head2 Summary
-The profiling runcore is built as part of Parrot and is designed to allow
-discovery of bottlenecks in PIR code. It is also being instrumented to support
-HLL profiling, but this support is currently limited. Code can be run under
-the profiling runcore by passing C<-Rprofiling> or C<--runcore profiling> to
-the C<parrot> binary. The location and format of the output file are
-determined by environment variables as documented below. If the profiling
-runcore does not detect any relevant environment variables, it will use the
-defaults described below.
+This file provides an introduction on how to profile code written in a
+Parrot-hosted language. Parrot includes profiling as a built-in runcore which
+outputs a textual line-based format. This file will generally need to be
+post-processed, either by a custom script or by C<tools/dev/>, which
+is installed under C<lib/3.6.0-devel/tools/dev/> in a standard
+The profiling runcore can record any annotations added by HLL compilers, though
+annotations are ignored by C<> and are not recorded by default.
+This and various other aspects of profiling can be controlled through
+environment variables, as described below.
=head2 Running Code Under the Profiler
-<add something here>
+In Parrot, profiling capability is provided in the form of a built-in runcore
+and is available with any installed version of Parrot. The only condition is
+that you be able to run your code as a series of arguments passed directly to
+the parrot executable, rather than a "fakecutable" (a native executable that
+runs built-in hard-coded Parrot bytecode). If you usually run your code via a
+fakecutable such as C<perl6>, you'll need to run C<perl6.pbc> directly instead.
+For example, if you run C<./perl6 foo.p6>, instead run C<parrot perl6.pbc foo.p6>.
+If your code can run normally when passed to the C<parrot> executable
+directly, you can easily profile it.
+To profile, add C<-Rprofiling> to the command-line invocation of C<parrot>
+before any C<.pbc> files are added, e.g. C<./parrot -Rprofiling perl6.pbc foo.p6>.
+Your program will run more slowly and will end with a message such as
+ PROFILING RUNCORE: wrote profile to parrot.pprof.4251
+Use F<tools/dev/> to generate Callgrind-compatible output from this file.
+You now have a raw profile of your code.
=head2 Profile Post-processing Tools
-<add something here>
+The profiling runcore spits out a line-oriented plain-text file which contains
+the timing information for each executed instruction and a description of each
+context change. This data should be sufficient to determine any information
+about the timing of instructions and subs. The format is intended to be
+straightforward and amenable to processing by external tools.
+F<tools/dev/> is included with Parrot and attempts to read a profile
+generated by the profiling runcore and produce a profile which
+callgrind-compatible tools (e.g. F<kcachegrind>) can understand.
=head3 Interpreting Post-processed Output
-<add something here>
+note to self about what to cover:
+ Use callgrind_annotate (include some known-good and useful invocations, plus examples)
+ Use kcachegrind (results are likely to be buggy)
+ Don't use wincachegrind (lovely tool, uses xdebug-flavored version of callgrind's format)
=head2 Bugs and Surprises
-<add something here>
+In theory the output of F<> should be compatible with F<kcachegrind>. In
+practice, it isn't. If you have a use case that reliably produces non-sensical
+results, talk to cotto on #parrot or file a ticket.
-=head2 Manually Post-processing
+=head2 Environment Variables
-<add something here>
+=head3 Generally Useful Variables
-=head2 Environment Variables
+This section includes environment variables which are likely to be of interest
+to developers wishing to profile HLL code.
=over 4
This determines the full name of the file where the output will be written, if
any. Parrot does not check if the filename exists before opening it for
-writing and will happily overwrite any existing files, including previous profiles.
+writing and will happily truncate and overwrite any existing files, including
+previous profiles.
-If no value is specified, Parrot will write to a file named C<parrot.pprof.X>,
+If no value is specified, Parrot will write to a file named F<parrot.pprof.X>,
where X is the PID of the Parrot process. When the profiling runcore exits, it
will print a message announcing where the profile was written.
This variable can also have the special values C<stdout> and C<stderr>. When
either of these values are detected (case-insensitively), Parrot will print its
-profiling output the stdout or stderr.
+profiling output to STDOUT or STDERR.
+This determines whether PIR annotations will be recorded as part of the
+profile. Annotations are necessary when profiling HLL code, but will cause the
+profiling runcore to run more slowly. By default, they are disabled. Set this
+value to enable them.
This determines the type of output which will contain the profile. Current
options are C<pprof> and C<none>. C<pprof> is the default and is a ascii-based
human-readable format. It can be post-processed into a Callgrind-compatible
-format by tools/dev/ C<none> writes nothing to the output file.
+format by C<tools/dev/>. C<none> writes nothing to the output file.
It is most useful for testing and optimizing the profiling runcore itself. It
is expected to be of little interest to users wishing to profile PIR and HLL
-This determines whether PIR annotations will be recorded as part of the
-profile. Annotations are necessary when profiling HLL code, but will cause the
-profiling runcore to run more slowly. By default, they are disabled. Set this
-value to enable them.
+=head3 Debugging-Related Variables
+These variables are intended primarly for testing of the profiling code itself.
+You can play with them if you want, but they probably won't help you get any
+useful work done.
+=over 4
When this is set, the profiling runcore will record all addresses as a single
-constant value and all times as 1. This options is useful primarily for
+constant value and all times as C<1>. This option is useful primarily for
testing, where it's helpful to have a way to ensure that a given chunk of code
will always produce exactly the same profile. If you want this feature
enabled, you also probably want to pass a fixed hash seed to Parrot via
Oops, something went wrong.

0 comments on commit a5fc564

Please sign in to comment.