From: Vincent Pit Date: Tue, 24 Feb 2009 13:33:19 +0000 (+0100) Subject: Fix the B stashes cache cloning, and really use it for blessing op objects X-Git-Tag: v0.32~11 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=93e1c8fccc5fcbedbf35207f01c6336202bca06f;p=perl%2Fmodules%2FVariable-Magic.git Fix the B stashes cache cloning, and really use it for blessing op objects --- diff --git a/Magic.xs b/Magic.xs index 25d1d1c..9772cd7 100644 --- a/Magic.xs +++ b/Magic.xs @@ -646,7 +646,7 @@ STATIC SV *vmg_op_info(pTHX_ unsigned int opinfo) { case VMG_OP_INFO_OBJECT: { dMY_CXT; return sv_bless(sv_2mortal(newRV_noinc(newSViv(PTR2IV(PL_op)))), - gv_stashpv(vmg_opclassnames[vmg_opclass(PL_op)], 1)); + MY_CXT.b__op_stashes[vmg_opclass(PL_op)]); } default: break; @@ -1247,7 +1247,7 @@ CODE: MY_CXT.wizards = hv; for (c = 0; c < OPc_MAX; ++c) { MY_CXT.b__op_stashes[c] = (had_b__op_stash & (((U32) 1) << c)) - ? gv_stashpv("B::OP", 1) : NULL; + ? gv_stashpv(vmg_opclassnames[c], 1) : NULL; } } diff --git a/t/40-threads.t b/t/40-threads.t index 6fb1d36..0b16c6a 100644 --- a/t/40-threads.t +++ b/t/40-threads.t @@ -41,9 +41,14 @@ sub try { sig => $sig, get => sub { ++$c; 0 }, set => sub { - my $name = $_[-1]; - $name = $name->name if $op_info == VMG_OP_INFO_OBJECT; - is $name, 'sassign', "opname for op_info $op_info in thread $tid is correct"; + my $op = $_[-1]; + if ($op_info == VMG_OP_INFO_OBJECT) { + is_deeply { class => ref($op), name => $op->name }, + { class => 'B::BINOP', name => 'sassign' }, + "op object in thread $tid is correct"; + } else { + is $op, 'sassign', "op name in thread $tid is correct"; + } 0 }, free => sub { ++$destroyed; 0 }, diff --git a/t/41-clone.t b/t/41-clone.t index 90f15e0..e410f88 100644 --- a/t/41-clone.t +++ b/t/41-clone.t @@ -40,10 +40,15 @@ sub spawn_wiz { wizard data => sub { $_[1] + threads->tid() }, get => sub { ++$c; 0 }, set => sub { - my $name = $_[-1]; - $name = $name->name if $op_info == VMG_OP_INFO_OBJECT; + my $op = $_[-1]; my $tid = threads->tid(); - is $name, 'sassign', "opname for op_info $op_info in thread $tid is correct"; + if ($op_info == VMG_OP_INFO_OBJECT) { + is_deeply { class => ref($op), name => $op->name }, + { class => 'B::BINOP', name => 'sassign' }, + "op object in thread $tid is correct"; + } else { + is $op, 'sassign', "op name in thread $tid is correct"; + } 0 }, free => sub { ++$destroyed; 0 },