Skip to content

Commit

Permalink
[gsoc_pdd09] update to trunk from r30310
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.parrot.org/parrot/branches/gsoc_pdd09@30354 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
Whiteknight authored and Whiteknight committed Aug 19, 2008
1 parent cd4daac commit 6450bbf
Show file tree
Hide file tree
Showing 23 changed files with 418 additions and 196 deletions.
16 changes: 14 additions & 2 deletions NEWS
Expand Up @@ -9,23 +9,32 @@ New in 0.7.0 [r29473 through r30270]
+ PDD27: add multisub lookup
- Languages
+ Cardinal (Ruby):
- Class variables
- Parsing improvements
- Minor additions to class builtins
- Add support for block parameters to functions
+ Lua:
- various language fixes
- refactor all libraries (namespace, method registration)
- add a OpenGL binding (still incomplete)
- lost user back trace (see ppd25 & pushaction)
+ Pipp (PHP):
- Add support for while- and for-loops
- Add support for increment and decrement
- Designate PHP 5.3 as the reference implementation
- Designate PHP 5.3 as the reference implementation
- Improve support for string literals
+ Pugs (Perl 6):
- removed due to bit rot
+ Rakudo (Perl 6):
- now over 2200 passing spectests
- updated the Rakudo roadmap
- Perl 6 multi dispatch
- dispatch with slurpies
- class attributes ("my $.x")
- now up to 2196 passing tests
- anonymous classes
- OO and metaclass improvements (.WHAT, .WHICH, .WHENCE)
- additional builtin methods and subs
- improved make test targets and harness
+ Tcl:
- implement [lreverse], [lsort -command]
- allow [incr] to autovivify
Expand All @@ -35,6 +44,9 @@ New in 0.7.0 [r29473 through r30270]
- Compilers
+ PCT:
- :scope('register') for PAST::Var nodes
- allow invocant specification in attribute scope PAST::Var nodes
- correct ordering of sub generation from POST
- add 'loadinit' attribute to PAST::Block for block initialization
+ PIRC:
- PIR registers now use the vanilla register allocator
- all PASM output now uses PASM registers
Expand Down
6 changes: 3 additions & 3 deletions PLATFORMS
Expand Up @@ -35,8 +35,8 @@ linux-x86_64-gcc4.1.0 8 Y - - Y Y Y Y ? 20070116
linux-x86_64-gcc4.1.0 4 Y - - Y Y Y Y/2 ? 20060807
linux-x86_64-gcc4.1.2 8 Y - - Y Y Y Y ? 20080220
openbsd-zaurus-gcc3.3.5 Y - - Y Y Y ? ? 20070309
sol8-sparc-cc B - - - - - - Y/1 ? 20080401
sol8-sparc-gcc_4.1.0 B - - - - - - Y/77 ? 20080401
sol8-sparc-cc B - - - - - - Y/85 ? 20080818
sol8-sparc-gcc_4.1.0 B - - - - - - Y/87 ? 20080818
sol10-sparc-cc_5.8 B Y - - Y Y Y Y/9 ? 20060807
sol10-sparc-cc_5.9 B4*4 Y - - Y Y Y Y ? 20080510
sol10-sparc-cc_5.9 B8 Y - - Y Y Y Y/2 ? 20080518
Expand All @@ -48,7 +48,7 @@ opensolaris-x86-gcc_4.0.3 4 Y Y ? ? ? Y Y/2 ? 20080325
tru64-alpha-compaq_c6.5 8 ? ? ? Y ? Y Y/2 ? 20060203
cygwin1.5.24-x86-gcc3.4.4 4 Y Y - - - Y Y/6*1 ? 20071016
cygwin1.5.25-x86-gcc3.4.4 4 Y Y - - - Y Y/6*1 ? 20080513
win32-x86-mingw_gcc3.4.5 Y Y - - - Y Y/2 Y 20080617
win32-x86-mingw_gcc3.4.5 Y Y - - - Y Y/1 Y 20080819
win32-x86-mingw_gcc4.2.1 Y Y - - - Y Y/11 ? 20080520
win32-x86-msvc_6.0 - Y - Y - Y Y/5 ? 20080520
win32-x86-msvc_7.1 - Y - Y - Y Y/11 ? 20080520
Expand Down
25 changes: 17 additions & 8 deletions compilers/pct/src/PAST/Compiler.pir
Expand Up @@ -518,21 +518,27 @@ Return the POST representation of a C<PAST::Block>.
blockpast = get_global '@?BLOCK'
unshift blockpast, node

.local string name
.local string name, pirflags, blocktype
.local pmc ns
name = node.'name'()
pirflags = node.'pirflags'()
blocktype = node.'blocktype'()
ns = node.'namespace'()

## handle anonymous blocks
if name goto have_name
name = self.'unique'('_block')
if ns goto have_name
pirflags = concat pirflags, ' :anon'
have_name:

## create a POST::Sub node for this block
.local string blocktype
blocktype = node.'blocktype'()
.local pmc ns, pirflags
ns = node.'namespace'()
pirflags = node.'pirflags'()
.local pmc bpost
$P0 = get_hll_global ['POST'], 'Sub'
bpost = $P0.'new'('node'=>node, 'name'=>name, 'blocktype'=>blocktype, 'namespace'=>ns, 'pirflags'=>pirflags)
bpost = $P0.'new'('node'=>node, 'name'=>name, 'blocktype'=>blocktype, 'namespace'=>ns)
unless pirflags goto pirflags_done
bpost.'pirflags'(pirflags)
pirflags_done:

## determine the outer POST::Sub for the new one
.local pmc outerpost
Expand Down Expand Up @@ -672,7 +678,10 @@ Return the POST representation of a C<PAST::Block>.
$P0 = get_hll_global ['POST'], 'Ops'
bpost = $P0.'new'(bpost, 'node'=>node, 'result'=>result)
if ns goto block_decl_ns
bpost.'push_pirop'('get_global', result, name)
concat $S0, '.const .Sub ', result
concat $S0, ' = '
concat $S0, name
bpost.'push_pirop'($S0)
goto block_done
block_decl_ns:
bpost.'push_pirop'('get_hll_global', result, ns, name)
Expand Down
85 changes: 52 additions & 33 deletions docs/pdds/pdd09_gc.pod
Expand Up @@ -377,7 +377,7 @@ the GC in the Arenas->gc_private field.
Trigger or perform a GC run. With an incremental GC core, this may only
start/continue a partial mark phase or sweep phase, rather than performing an
entire run from start to finish. It may take several calls to C<do_gc_mark> in
order to complete an entire incremental run.
order to complete an entire run of an incremental collector.

For a concurrent collector, calls to this function may activate a concurrent
collection thread or, if such a thread is already running, do nothing at all.
Expand Down Expand Up @@ -432,17 +432,20 @@ proper operation.
=item C<void (*finalize_gc_system) (Interp *)>

Called during interpreter destruction. Free used resources and memory pools.
All PMCs must be swept, and PMCs with custom destroy VTABLE methods must have
those called.

=item C<void (*init_pool) (Interp *, Small_Object_Pool *)>

Initialize the given pool. This function should set the following function
pointers for use with the pool.
Initialize the given pool. Populates the C<Small_Object_Pool> structure with
initial values, and sets a series of function pointers for working with the
pool. The function pointers used with the pool are discussed next.

=back

=head3 Small_Object_Pool function pointers

Each GC core defines 4 function pointers stored in the Small_Object_Pool
Each GC core defines 4 function pointers stored in the C<Small_Object_Pool>
structures. These function pointers are used throughout Parrot to implement
basic behaviors for the pool.

Expand All @@ -458,7 +461,10 @@ is zeroed.

=item C<void (*add_free_object) (Interp *, Small_Object_Pool *, PObj *);>

Add a freed object to the pool's free list.
Add a freed object to the pool's free list. This function is most often called
internally to the GC itself to add items to the free list after a sweep, or
when a new arena is created to add the new items to the free list. It does
not need to be used in this way, however.

=item C<void (*alloc_objects) (Interp *, Small_Object_Pool *);>

Expand All @@ -471,93 +477,104 @@ factor which increases the size of each new allocated arena.
Reallocation for additional objects. It has the same signature as
C<alloc_objects>, and in some GC cores the same function pointer is used for
both. In some GC cores, C<more_objects> may do a GC run in an attempt to free
existing objects without having to allocate new ones.
existing objects without having to allocate new ones. This function may also
call C<pool->alloc_objects> internally, to allocate objects if a GC run fails
to free any old objects.

=back

=head3 Write Barrier

Each GC core has to provide these (possibly empty) macros:
Each GC core has to provide the following macros. All of these might be
defined empty, for GC cores which do not use them.

=over 4

=item C<GC_WRITE_BARRIER(Interp *, PMC *agg, PMC *old, PMC *new)>

This macro is invoked when in aggregate C<agg> the element C<old> is getting
overritten by C<new>. Both C<old> and C<new> may be NULL.
overwritten by C<new>. Either C<old>, C<new>, or both may be NULL.

=item C<GC_WRITE_BARRIER_KEY(Interp *, PMC *agg, PMC *old, PObj
*old_key, PMC *new, PObj *new_key)>

Like above. Invoked when a hash key is inserted, possibly replacing an old
key.
Similar to C<GC_WRITE_BARRIER>. Invoked when a hash key C<new_key> is
inserted into hash C<agg> with value C<new>, possibly replacing a key/value
pair C<old_key> and C<old>, respectively. Any of C<old>, C<old_key>, C<new>
or C<new_key> might be C<NULL>.

=back

=head2 Blocking GC

Being able to block GC is important, so newly allocated Buffers or PMCs won't
be collected before they're attached to the live tree. The following
routines control GC:
be collected before they're attached to the live tree. Parrot provides locking
mechanisms to prevent the GC from taking certain actions, such as marking
or sweeping. GC block functions are nesting, and multiple calls to a lock
function requires the same number of calls to the corresponding unlock
function in order to operate the GC normally again. The following functions
are used to block the GC from performing certain actions:

=over 4

=item Parrot_block_GC_mark(Interp *interpreter)

Block the GC mark phase for the passed interpreter. (But not the sweep phase)
Block the GC mark phase for the passed interpreter, but do not block the sweep
phase. In a stop-the-world collector, this will prevent the entire collection
run, but in an incremental collector this will only block if the GC is in the
trace state.

=item Parrot_block_GC_sweep(Interp *interpreter)

Block the GC sweep phase for the passed interpreter. (But not the mark phase)
Block the GC sweep phase for the passed interpreter, but do not block the
trace phase.

=item Parrot_unblock_GC_mark(Interp *interpreter)

Unblock the GC mark phase for the passed interpreter. (But not the sweep
phase)
Unblock the GC mark phase for the passed interpreter, but do not unblock a
blocked sweep phase, if it is blocked using C<Parrot_block_GC_sweep>.

=item Parrot_unblock_GC_sweep(Interp *interpreter)

Unblock the GC sweep phase for the passed interpreter. (But not the mark
phase)
Unblock the GC sweep phase for the passed interpreter, but do not unblock the
mark phase if it has been blocked by C<Parrot_block_GC_mark>.

=item Parrot_is_blocked_GC_mark(Interp *interpreter)

Test whether the mark phase has been blocked.
Test whether the mark phase has been blocked. Notice that the sweep phase can
be locked independently and cannot be determined using this function.

=item Parrot_is_blocked_GC_sweep(Interp *interpreter)

Test whether the sweep phase has been blocked.
Test whether the sweep phase has been blocked. Notice that the mark phase can
be locked independently and cannot be determined using this function.

=back

Note that the blocking is recursive--if you call Parrot_block_GC_sweep() three
times in succession, you need to call Parrot_unblock_GC_sweep() three times to
re-enable the GC sweep phase.

=head2 PMC/Buffer API

=head3 Flags

For PMCs and Buffers to be collected properly, you must set the appropriate
flags on them.

Directly manipulating these flags is not recommended. Always use the macros
defined in F<include/parrot/pobj.h>.
flags on them. Directly manipulating these flags is not recommended because
the exact values can be changed over time. A series of macros have been created
in F<include/parrot/pobject.h> that set and check for these flags. Always use
these provided macros when you need to test or set these flags.

=over 4

=item PObj_active_destroy_FLAG

The PMC has some sort of active destructor, and will have that destructor
called when the PMC is destroyed.
called when the PMC is destroyed. The destructor is typically called from
within C<src/gc/dod.c:Parrot_dod_free_pmc>.

=item PObj_custom_mark_FLAG

The C<mark> vtable slot will be called during the GC mark phase. The mark
function must call C<pobject_lives> for all non-NULL objects (Buffers and
PMCs) that PMC refers to.

Please note that C<pobject_lives> may be a macro.
PMCs) that PMC refers to. This flag is typically tested and the custom mark
VTABLE method called from C<src/gc/dod.c:mark_special>.

=item PObj_data_is_PMC_array_FLAG

Expand Down Expand Up @@ -587,7 +604,9 @@ The following flags can be used by the GC subsystem:

=item PObj_live_FLAG

The system considers the object to be alive for collection purposes.
The system considers the object to be alive for collection purposes. Objects
with this flag set should never be collected, freed, destroyed, or put on the
free list.

=item PObj_on_free_list_FLAG

Expand Down
9 changes: 7 additions & 2 deletions languages/lua/src/lua51.pir
Expand Up @@ -198,15 +198,20 @@ used in F<languages/lua/src/POSTGrammar.tg>
.sub 'pir' :method :multi(_, ['Lua::POST::Chunk'])
.param pmc node
.local pmc subcode
subcode = get_global '@!subcode'
$P0 = new 'CodeString'
push subcode, $P0
.local pmc code
code = self.'pir_children'(node)
$S0 = node.'prologue'()
if $S0 == '' goto L1
new code, 'CodeString'
code.'emit'($S0)
$P0 = self.'code'()
$P0 = pop subcode
code .= $P0
self.'code'(code)
$P0 = subcode[-1]
$P0 .= code
L1:
.return (code)
.end
Expand Down
1 change: 1 addition & 0 deletions languages/perl6/docs/spectest-progress.csv
Expand Up @@ -88,3 +88,4 @@
"2008-08-16 00:00",30256,121,3268,2220,0,134,914,6138
"2008-08-17 00:00",30275,121,3268,2220,0,134,914,6170
"2008-08-18 00:00",30292,121,3268,2220,0,134,914,6170
"2008-08-19 00:00",30322,121,3268,2220,0,134,914,6242
18 changes: 18 additions & 0 deletions languages/perl6/src/parser/actions.pm
Expand Up @@ -29,6 +29,23 @@ method TOP($/) {
# Make sure we have the interpinfo constants.
$past.unshift( PAST::Op.new( :inline('.include "interpinfo.pasm"') ) );

# convert the last operation of the block into a .return op
# so that :load block below isn't used as return value
$past.push( PAST::Op.new( $past.pop(), :pirop('return') ) );
# automatically invoke mainline on :load (but not :init)
$past.push(
PAST::Block.new(
PAST::Op.new(
:inline(
'$P0 = interpinfo .INTERPINFO_CURRENT_SUB',
'$P0 = $P0."get_outer"()',
'$P0()'
)
),
:pirflags(':load')
)
);

make $past;
}

Expand Down Expand Up @@ -1332,6 +1349,7 @@ method noun($/, $key) {
$past.unshift(PAST::Var.new(
:name('$_'),
:scope('lexical'),
:viviself('Failure'),
:node($/)
));
}
Expand Down
2 changes: 2 additions & 0 deletions languages/perl6/t/spectest_regression.data
Expand Up @@ -7,10 +7,12 @@ S02-builtin_data_types/array_extending.t
S02-builtin_data_types/array.t
S02-builtin_data_types/flattening.t
S02-builtin_data_types/hash.t
S02-builtin_data_types/hash_ref.t
S02-builtin_data_types/nested_arrays.t
S02-builtin_data_types/nested_pairs.t
S02-builtin_data_types/num.t
S02-builtin_data_types/range.t
S02-builtin_data_types/subscripts_and_context.t
S02-builtin_data_types/type.t
S02-literals/autoref.t
S02-literals/hex_chars.t
Expand Down

0 comments on commit 6450bbf

Please sign in to comment.