[Jifty-commit] r5593 - in Runops-Trace/trunk: .
Jifty commits
jifty-commit at lists.jifty.org
Sat Jul 26 15:57:50 EDT 2008
Author: nothingmuch
Date: Sat Jul 26 15:57:47 2008
New Revision: 5593
Modified:
Runops-Trace/trunk/Changes
Runops-Trace/trunk/Makefile.PL
Runops-Trace/trunk/Trace.xs
Runops-Trace/trunk/bench.pl
Runops-Trace/trunk/lib/Runops/Trace.pm
Log:
HORRAY
Modified: Runops-Trace/trunk/Changes
==============================================================================
--- Runops-Trace/trunk/Changes (original)
+++ Runops-Trace/trunk/Changes Sat Jul 26 15:57:47 2008
@@ -46,3 +46,5 @@
0.11 - Sat Jul 26 2008
opmask is now a bitfield instead of a bool array (hoping this also takes
care of compilation problems), and other minor tweaks.
+
+ opcode arity detection that caused a segfault fixed
Modified: Runops-Trace/trunk/Makefile.PL
==============================================================================
--- Runops-Trace/trunk/Makefile.PL (original)
+++ Runops-Trace/trunk/Makefile.PL Sat Jul 26 15:57:47 2008
@@ -5,6 +5,6 @@
use ExtUtils::MakeMaker;
WriteMakefile(
- NAME => 'Runops::Trace',
- VERSION_FROM => 'lib/Runops/Trace.pm',
+ NAME => 'Runops::Trace',
+ VERSION_FROM => 'lib/Runops/Trace.pm',
);
Modified: Runops-Trace/trunk/Trace.xs
==============================================================================
--- Runops-Trace/trunk/Trace.xs (original)
+++ Runops-Trace/trunk/Trace.xs Sat Jul 26 15:57:47 2008
@@ -10,6 +10,7 @@
#include "ppport.h"
#define XPUSHREF(x) XPUSHs(sv_2mortal(newRV_inc(x)))
+#define PUSHREF(x) PUSHs(sv_2mortal(newRV_inc(x)))
int (*Runops_Trace_old_runops ) ( pTHX );
@@ -79,7 +80,6 @@
STATIC SV *
Runops_Trace_op_to_BOP (pTHX_ OP *op) {
dSP;
- /* this assumes Runops_Trace_load_B() has already been called */
/* we fake B::UNOP object (fakeop_sv) that points to our static fakeop.
* then we set first_op to the op we want to make an object out of, and
@@ -94,7 +94,8 @@
XPUSHs(Runops_Trace_fakeop_sv);
PUTBACK;
- call_pv("B::UNOP::first", G_SCALAR);
+ /* call_pv("B::UNOP::first", G_SCALAR); */
+ XS_B__UNOP_first(aTHX);
SPAGAIN;
@@ -114,6 +115,7 @@
case OP_REFGEN:
return ARITY_LIST;
+ case OP_LEAVELOOP: /* FIXME BASEOP_OR_UNOP */
case OP_ENTERITER:
case OP_ENTERLOOP:
return ARITY_NULL;
@@ -129,7 +131,9 @@
return ARITY_NULL;
case OA_BASEOP_OR_UNOP:
- return (o->op_flags & OPf_KIDS) ? ARITY_UNARY : ARITY_NULL;
+ /* FIXME gotta check gimme from context block */
+ /* return (o->op_flags & OPf_KIDS ) ? ARITY_gimme : ARITY_NULL; */
+ return ARITY_NULL;
case OA_LOGOP:
case OA_UNOP:
@@ -169,8 +173,8 @@
Runops_Trace_perl (pTHX) {
dSP;
- register SV **orig_sp = SP;
- register SV **list_mark;
+ SV **orig_sp = SP;
+ SV **list_mark;
SV *sv_ret;
SV *PL_op_object;
@@ -186,13 +190,18 @@
* times get hooked, the idea is that this can be used for
* trace caching */
+ /* in the future this might change to a dynamically decayed bloom filter */
+
if ( !Runops_Trace_op_counters )
Runops_Trace_op_counters = newHV();
/* unfortunately we need to keep the counters in a hash */
count = hv_fetch(Runops_Trace_op_counters, (char *)PL_op, sizeof(PL_op), 1);
- c = SvTRUE(*count) ? SvUV(*count) + 1 : 1;
- sv_setuv(*count, c);
+ if ( SvTRUE(*count) ) {
+ SvUVX(*count)++;
+ } else {
+ *count = newSVuv(1);
+ }
/* if we haven't reached the threshold yet, then return */
if (c < Runops_Trace_threshold)
@@ -211,32 +220,36 @@
PL_op_object = Runops_Trace_op_to_BOP(aTHX_ PL_op);
arity = Runops_Trace_op_arity(aTHX_ PL_op);
-
+ /* arguments for the sub start at this mark */
PUSHMARK(SP);
- /* XPUSHs(Runops_Trace_perl_hook); */
- XPUSHs(PL_op_object);
- XPUSHs(sv_2mortal(newSViv(arity)));
+
+ EXTEND(SP, 4); /* op obj, arity flag, unary and binary ops. ARITY_LIST will call extend for nary args */
+
+ PUSHs(PL_op_object);
+ PUSHs(sv_2mortal(newSViv(arity)));
switch (arity) {
+
case ARITY_LIST_UNARY:
/* ENTERSUB's unary arg (the cv) is the last thing on the stack, but it has args too */
- XPUSHREF(*orig_sp--);
+ PUSHREF(*orig_sp--);
+ /* fall through */
case ARITY_LIST:
+ list_mark = PL_stack_base + *(PL_markstack_ptr-1) + 1;
/* repeat stack from the op's mark to SP just before we started pushing */
- for (list_mark = PL_stack_base + *(PL_markstack_ptr-1) + 1; list_mark <= orig_sp; list_mark++) {
- XPUSHREF(*list_mark);
+ EXTEND(SP, orig_sp - list_mark);
+ while ( list_mark <= orig_sp ) {
+ XPUSHREF(*list_mark++);
}
break;
-
case ARITY_BINARY:
XPUSHREF(*(orig_sp-1));
case ARITY_UNARY:
XPUSHREF(*orig_sp);
break;
-
case ARITY_LIST_BINARY:
{
SV **mark = SP; dORIGMARK;
@@ -254,7 +267,6 @@
XPUSHREF(lav);
XPUSHREF(rav);
}
-
break;
case ARITY_NULL:
@@ -262,11 +274,10 @@
default:
- warn("Unknown arity for %s (%p)", PL_op_name[PL_op->op_type], PL_op);
+ /* warn("Unknown arity for %s (%p)", PL_op_name[PL_op->op_type], PL_op); */
break;
}
-
PUTBACK;
call_sv(Runops_Trace_perl_hook, (Runops_Trace_perl_ignore_ret ? G_DISCARD : G_SCALAR));
@@ -283,7 +294,6 @@
ret = 0;
}
-
PUTBACK;
FREETMPS;
LEAVE;
@@ -315,7 +325,6 @@
Runops_Trace_load_B (pTHX) {
if (!Runops_Trace_loaded_B) {
load_module( PERL_LOADMOD_NOIMPORT, newSVpv("B", 0), (SV *)NULL );
- Runops_Trace_fakeop_sv = sv_bless(newRV_noinc(newSVuv((UV)&Runops_Trace_fakeop)), gv_stashpv("B::UNOP", 0));
Runops_Trace_loaded_B = 1;
}
}
@@ -329,8 +338,6 @@
Runops_Trace_clear_perl_hook(aTHX);
- Runops_Trace_load_B(aTHX);
-
/* Initialize/set the tracing function */
SvSetSV( Runops_Trace_perl_hook, tracer_rv );
@@ -387,6 +394,8 @@
STATIC void
Runops_Trace_mask_set_op_type (I32 op_type, bool bit) {
+ if ( !Runops_Trace_mask )
+ Runops_Trace_mask_autocreate();
if ( op_type < MAXO_PLUS && op_type >= 0 ) {
const int offset = op_type >> 3;
const int bit = op_type & 0x07;
@@ -421,6 +430,7 @@
PROTOTYPES: ENABLE
BOOT:
+ Runops_Trace_fakeop_sv = sv_bless(newRV_noinc(newSVuv((UV)&Runops_Trace_fakeop)), gv_stashpv("B::UNOP", 0));
Runops_Trace_clear_hook();
Runops_Trace_old_runops = PL_runops;
PL_runops = runops_trace;
Modified: Runops-Trace/trunk/bench.pl
==============================================================================
--- Runops-Trace/trunk/bench.pl (original)
+++ Runops-Trace/trunk/bench.pl Sat Jul 26 15:57:47 2008
@@ -52,7 +52,6 @@
Runops::Trace::enable_tracing();
},
mask_and_threshold => sub {
- next;
require Runops::Trace;
Runops::Trace::set_trace_threshold(5);
Runops::Trace::mask_all();
@@ -61,7 +60,6 @@
Runops::Trace::enable_tracing();
},
perl_hook => sub {
- next;
require Runops::Trace;
Runops::Trace::clear_mask();
Runops::Trace::mask_op(qw(enteriter enterloop));
@@ -76,18 +74,18 @@
waste_time();
foreach my $test qw(normal disabled null_c_cb mask threshold mask_and_threshold perl_hook) {
- $setup{$test}->();
- our $j = undef;
+ $setup{$test}->();
+ our $j = undef;
- eval {
- my $res = countit(1, \&waste_time);
- $res{$test} = $res;
- print "$test: " . timestr($res), "\n";
- };
+ eval {
+ my $res = countit(2, \&waste_time);
+ $res{$test} = $res;
+ print "$test: " . timestr($res), "\n";
+ };
- warn "test $test failed: $@" if $@;
+ warn "test $test failed: $@" if $@;
- $setup{disabled}->();
+ $setup{disabled}->();
}
cmpthese(\%res);
Modified: Runops-Trace/trunk/lib/Runops/Trace.pm
==============================================================================
--- Runops-Trace/trunk/lib/Runops/Trace.pm (original)
+++ Runops-Trace/trunk/lib/Runops/Trace.pm Sat Jul 26 15:57:47 2008
@@ -10,6 +10,9 @@
our $VERSION = '0.11';
+# load XS_B__UNOP_first
+BEGIN { require B };
+
use DynaLoader ();
our @ISA = qw( DynaLoader Exporter );
Runops::Trace->bootstrap($VERSION);
More information about the Jifty-commit
mailing list