[perl #41549] [PATCH] fixes :vtable pragma for .pbc files

3 views
Skip to first unread message

Alek Storm

unread,
Feb 19, 2007, 11:02:23 PM2/19/07
to bugs-bi...@rt.perl.org
# New Ticket Created by "Alek Storm"
# Please include the string: [perl #41549]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=41549 >


This patch resolves the problem mentioned in Patrick's replies to
#40626 and #41364 that bytecode does not store the :vtable pragma.

This always works:
% cat test.pir
.sub main :main
$P0 = subclass "Hash", "Test"
$P1 = new "Test"
$S0 = $P1
print "done\n"
.end

.namespace [ "Test" ]
.sub get_string :method :vtable
print "get_string\n"
.end
% parrot test.pir
get_string
done

Before the patch:
% parrot -o test.pbc test.pir
% parrot test.pbc
done

After the patch:
% parrot -o test.pbc test.pir
% parrot test.pbc
get_string
done

Subclassing from a core class is just there to show that it doesn't
re-break #40626. The freezing problem is fixed by adding an INTVAL
vtable_index member (index into Parrot_vtable_slot_names[] in
include/parrot/vtable.h) to the Parrot_sub struct in
include/parrot/sub.h, which is then frozen with the Sub PMC. This
hopefully means that we can deprecate the double-underscore method of
overriding vtable methods - if so, I'll happily submit a patch.
In the process, this patch also reworks how Parrot stores :vtable subs
by replacing the storing of duplicate methods in a VTABLE
sub-namespace with a lookup by their vtable_index.

Files changed:
src/objects.c
src/pmc/delegate.pmc
src/pmc/parrotobject.pmc
src/pmc/sub.pmc
lib/Parrot/Pmc2c/delegate.pm
include/parrot/sub.h
include/parrot/objects.h
compilers/imcc/pbc.c

Note: Since this patch affects all .pbc files, you'll have to run
`make clean` to regenerate them during the build process, or you'll
get weird errors. Also, part of this patch updates my last patch,
#41364, so if you get an error patching parrotobject.pmc, it's not
broken - the rest will work fine.

Thanks,
Alek Storm

vtable_bytecode.patch

Jonathan Worthington

unread,
Feb 22, 2007, 6:33:15 AM2/22/07
to perl6-i...@perl.org
Alek Storm (via RT) wrote:
> This patch resolves the problem mentioned in Patrick's replies to
> #40626 and #41364 that bytecode does not store the :vtable pragma.
>
> ...
>
I've looked over this patch and it looks pretty good to me. There's
release stuff ongoing at the moment, so unless anyone else objects I'll
put this in once the release is done.

Thanks!

Jonathan


Reply all
Reply to author
Forward
0 new messages