Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Eliminate a Perl 6 dynop in favor of an NQP one.
They did pretty much the same thing, just ended up with both for
historical reasons.
  • Loading branch information
jnthn committed Apr 9, 2013
1 parent df6a910 commit e088624
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 45 deletions.
24 changes: 11 additions & 13 deletions src/Perl6/Metamodel/BOOTSTRAP.pm
Expand Up @@ -499,12 +499,11 @@ BEGIN {

# Need clone in here, plus generics instantiation.
Code.HOW.add_method(Code, 'clone', static(sub ($self) {
my $dcself := nqp::decont($self);
my $cloned := nqp::clone($dcself);
nqp::bindattr($cloned, Code, '$!do',
pir::perl6_associate_sub_code_object__0PP(
nqp::clone(nqp::getattr($dcself, Code, '$!do')),
$cloned));
my $dcself := nqp::decont($self);
my $cloned := nqp::clone($dcself);
my $do_cloned := nqp::clone(nqp::getattr($dcself, Code, '$!do'));
nqp::bindattr($cloned, Code, '$!do', $do_cloned);
nqp::setcodeobj($do_cloned, $cloned);
Q:PIR {
$P0 = find_lex '$dcself'
$P1 = find_lex 'Code'
Expand Down Expand Up @@ -561,12 +560,11 @@ BEGIN {
Block.HOW.add_attribute(Block, BOOTSTRAPATTR.new(:name<$!state_vars>, :type(Mu), :package(Block)));
Block.HOW.add_attribute(Block, BOOTSTRAPATTR.new(:name<$!phasers>, :type(Mu), :package(Block)));
Block.HOW.add_method(Block, 'clone', static(sub ($self) {
my $dcself := nqp::decont($self);
my $cloned := nqp::clone($dcself);
nqp::bindattr($cloned, Code, '$!do',
pir::perl6_associate_sub_code_object__0PP(
nqp::clone(nqp::getattr($dcself, Code, '$!do')),
$cloned));
my $dcself := nqp::decont($self);
my $cloned := nqp::clone($dcself);
my $do_cloned := nqp::clone(nqp::getattr($dcself, Code, '$!do'));
nqp::bindattr($cloned, Code, '$!do', $do_cloned);
nqp::setcodeobj($do_cloned, $cloned);
Q:PIR {
$P0 = find_lex '$dcself'
$P1 = find_lex 'Code'
Expand Down Expand Up @@ -1817,7 +1815,7 @@ Perl6::Metamodel::ParametricRoleGroupHOW.set_selector_creator({
nqp::getcodeobj(nqp::curcode()).find_best_dispatchee(nqp::usecapture()),
nqp::usecapture())
};
pir::perl6_associate_sub_code_object__vPP($onlystar, $sel);
nqp::setcodeobj($onlystar, $sel);
nqp::bindattr($sel, Code, '$!do', $onlystar);
nqp::bindattr($sel, Routine, '$!dispatchees', []);
$sel
Expand Down
1 change: 0 additions & 1 deletion src/Perl6/Ops.pm
Expand Up @@ -32,7 +32,6 @@ $ops.add_hll_pirop_mapping('perl6', 'p6setfirstflag', 'perl6_set_block_first_fla
$ops.add_hll_pirop_mapping('perl6', 'p6takefirstflag', 'perl6_take_block_first_flag', 'I');
$ops.add_hll_pirop_mapping('perl6', 'p6return', 'perl6_returncc', '0P');
$ops.add_hll_pirop_mapping('perl6', 'p6routinereturn', 'perl6_return_from_routine', '0P');
$ops.add_hll_pirop_mapping('perl6', 'p6assoccode', 'perl6_associate_sub_code_object', 'vPP');
$ops.add_hll_pirop_mapping('perl6', 'p6getouterctx', 'perl6_get_outer_ctx', 'PP');
$ops.add_hll_pirop_mapping('perl6', 'tclc', 'titlecase', 'Ss', :inlinable(1));
$ops.add_hll_op('perl6', 'p6getcallsig', -> $qastcomp, $op {
Expand Down
13 changes: 6 additions & 7 deletions src/Perl6/World.pm
Expand Up @@ -963,8 +963,8 @@ class Perl6::World is HLL::World {
unless self.is_precompilation_mode() {
$fixups.push(QAST::Stmts.new(
self.set_attribute($code, $code_type, '$!do', QAST::BVal.new( :value($code_past) )),
QAST::VM.new(
:pirop('perl6_associate_sub_code_object vPP'),
QAST::Op.new(
:op('setcodeobj'),
QAST::BVal.new( :value($code_past) ),
QAST::WVal.new( :value($code) )
)));
Expand All @@ -983,7 +983,7 @@ class Perl6::World is HLL::World {
self.set_attribute($clone, $code_type, '$!do',
QAST::Var.new( :name($tmp), :scope('local') )),
QAST::Op.new(
:op('p6assoccode'),
:op('setcodeobj'),
QAST::Var.new( :name($tmp), :scope('local') ),
QAST::WVal.new( :value($clone) )
)));
Expand Down Expand Up @@ -1011,8 +1011,8 @@ class Perl6::World is HLL::World {

# Deserialization also needs to give the Parrot sub its backlink.
if self.is_precompilation_mode() {
$des.push(QAST::VM.new(
:pirop('perl6_associate_sub_code_object vPP'),
$des.push(QAST::Op.new(
:op('setcodeobj'),
QAST::BVal.new( :value($code_past) ),
QAST::WVal.new( :value($code) )));
}
Expand Down Expand Up @@ -1244,8 +1244,7 @@ class Perl6::World is HLL::World {
while $i < $num_subs {
my $subid := $precomp[$i].get_subid();
if nqp::existskey(%!sub_id_to_code_object, $subid) {
pir::perl6_associate_sub_code_object__vPP($precomp[$i],
%!sub_id_to_code_object{$subid});
nqp::setcodeobj($precomp[$i], %!sub_id_to_code_object{$subid});
nqp::bindattr(%!sub_id_to_code_object{$subid}, $code_type, '$!do', $precomp[$i]);
}
if nqp::existskey(%!sub_id_to_static_lexpad, $subid) {
Expand Down
23 changes: 0 additions & 23 deletions src/ops/perl6.ops
Expand Up @@ -1052,29 +1052,6 @@ inline op find_method_null_ok(out PMC, in PMC, in STR) :base_core {
}


/*

=item perl6_associate_sub_code_object()

Takes a Parrot Sub in $1 and a code object in $2 and associates the two.
Actually, it uses a field in the Parrot Sub PMC that Rakudo never makes
use of. Evil, but saves a prophash for every single code object.

=cut

*/
inline op perl6_associate_sub_code_object(in PMC, in PMC) :base_core {
if ($1->vtable->base_type == enum_class_Sub
|| $1->vtable->base_type == enum_class_Coroutine) {
SETATTR_Sub_multi_signature(interp, $1, $2);
PARROT_GC_WRITE_BARRIER(interp, $1);
}
else {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Can only use perl6_associate_sub_code_object if first operand is a Sub.");
}
}


/*

Expand Down
2 changes: 1 addition & 1 deletion tools/build/NQP_REVISION
@@ -1 +1 @@
2013.03-6-g0e3f03c
2013.03-7-g18f5d04

0 comments on commit e088624

Please sign in to comment.