Skip to content

Commit

Permalink
examples: prepare winxed pirs
Browse files Browse the repository at this point in the history
 document internal src/pmc/resizablepmcarray.pmc functions
  • Loading branch information
Reini Urban committed Mar 19, 2014
1 parent e5565eb commit b983c96
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
6 changes: 3 additions & 3 deletions examples/benchmarks/dispatch.winxed
Expand Up @@ -13,13 +13,13 @@ http://whiteknight.github.io/2011/05/10/timings_vtable_overrides.html

Starting no dispatch (base line)
Total time: 0.189244s

Starting vtable calls
Total time: 0.257013s

Starting method calls
Total time: 4.172381s

Starting vtable_override calls
Total time: 8.376169s

Expand Down
4 changes: 4 additions & 0 deletions examples/benchmarks/run.sh
@@ -1,4 +1,8 @@
#!/bin/sh
for e in examples/benchmarks/*.winxed
do
./winxed -c --noan $e
done
for e in examples/benchmarks/*.pir examples/benchmarks/*.pasm
do
./parrot -O2 $e
Expand Down
32 changes: 31 additions & 1 deletion src/pmc/resizablepmcarray.pmc
Expand Up @@ -10,7 +10,7 @@ src/pmc/resizablepmcarray.pmc - resizable array for PMCs only
This class, ResizablePMCArray, implements an resizable array which stores PMCs.
It puts things into Integer, Float, or String PMCs as appropriate.

=head2 Vtable Functions
=head2 Internal Functions

=over 4

Expand Down Expand Up @@ -57,6 +57,16 @@ static void throw_shift_empty(PARROT_INTERP)
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: static */

/*

=item C<inline static void do_shift(ARGIN(PMC *arr))>

Removes and returns an item from the start of the array.
Moves the whole rest of the array around.

=cut

*/
PARROT_INLINE
static void
do_shift(ARGIN(PMC *arr))
Expand All @@ -70,6 +80,16 @@ do_shift(ARGIN(PMC *arr))
item[size] = PMCNULL;
}

/*

=item C<inline static void do_unshift(ARGIN(PMC *arr))>

Adds an item at the start of the array.
Moves the whole rest of the array around.

=cut

*/
PARROT_INLINE
static void
do_unshift(PARROT_INTERP, ARGIN(PMC *arr), ARGIN(PMC *val))
Expand All @@ -83,7 +103,17 @@ do_unshift(PARROT_INTERP, ARGIN(PMC *arr), ARGIN(PMC *val))
memmove(item + 1, item, size * sizeof (PMC *));
item[0] = val;
}
/*

=back

=head1 Vtable Functions

=over

=cut

*/

pmclass ResizablePMCArray extends FixedPMCArray auto_attrs provides array {
ATTR INTVAL resize_threshold; /* max size before array needs resizing */
Expand Down

0 comments on commit b983c96

Please sign in to comment.