Skip to content

Commit

Permalink
op_class_sv removed for threaded perls op_class_targ removed for non-…
Browse files Browse the repository at this point in the history
…threaded perls
  • Loading branch information
syber authored and Father Chrysostomos committed Nov 24, 2014
1 parent b55b14d commit e3384dc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
26 changes: 18 additions & 8 deletions op.c
Original file line number Diff line number Diff line change
Expand Up @@ -863,12 +863,14 @@ Perl_op_clear(pTHX_ OP *o)
}
#endif
case OP_METHOD:
SvREFCNT_dec(cMETHOPx(o)->op_class_sv);
#ifdef USE_ITHREADS
if (cMETHOPx(o)->op_class_targ) {
pad_swipe(cMETHOPx(o)->op_class_targ, 1);
cMETHOPx(o)->op_class_targ = 0;
}
#else
SvREFCNT_dec(cMETHOPx(o)->op_class_sv);
cMETHOPx(o)->op_class_sv = NULL;
#endif
break;
case OP_CONST:
Expand Down Expand Up @@ -2238,9 +2240,6 @@ S_finalize_op(pTHX_ OP* o)
/* Relocate all the METHOP's SVs to the pad for thread safety. */
case OP_METHOD_NAMED:
op_relocate_sv(&cMETHOPx(o)->op_u.op_meth_sv, &o->op_targ);
case OP_METHOD:
if (cMETHOPx(o)->op_class_sv)
op_relocate_sv(&cMETHOPx(o)->op_class_sv, &cMETHOPx(o)->op_class_targ);
break;
#endif

Expand Down Expand Up @@ -4693,8 +4692,11 @@ S_newMETHOP_internal(pTHX_ I32 type, I32 flags, OP* dynamic_meth, SV* const_meth
methop->op_next = (OP*)methop;
}

methop->op_class_sv = NULL;
#ifdef USE_ITHREADS
methop->op_class_targ = 0;
#else
methop->op_class_sv = NULL;
#endif
CHANGE_TYPE(methop, type);
methop = (METHOP*) CHECKOP(type, methop);

Expand Down Expand Up @@ -11627,10 +11629,18 @@ Perl_ck_subr(pTHX_ OP *o)
/* cache const class' name to speedup class method calls */
if (const_class) {
STRLEN len;
SV* shared;
const char* str = SvPV(const_class, len);
if (len) cMETHOPx(cvop)->op_class_sv = newSVpvn_share(
str, SvUTF8(const_class) ? -len : len, 0
);
if (len) {
shared = newSVpvn_share(
str, SvUTF8(const_class) ? -len : len, 0
);
#ifdef USE_ITHREADS
op_relocate_sv(&shared, &cMETHOPx(cvop)->op_class_targ);
#else
cMETHOPx(cvop)->op_class_sv = shared;
#endif
}
}
break;
}
Expand Down
7 changes: 5 additions & 2 deletions op.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,11 @@ struct methop {
OP* op_first; /* optree for method name */
SV* op_meth_sv; /* static method name */
} op_u;
SV* op_class_sv; /* static class name */
#ifdef USE_ITHREADS
PADOFFSET op_class_targ; /* pad index for class name if threaded */
#else
SV* op_class_sv; /* static class name */
#endif
};

struct pmop {
Expand Down Expand Up @@ -444,7 +447,7 @@ struct loop {
# define cSVOPx_svp(v) (cSVOPx(v)->op_sv \
? &cSVOPx(v)->op_sv : &PAD_SVl((v)->op_targ))
# define cMETHOPx_class(v) (cMETHOPx(v)->op_class_targ ? \
PAD_SVl(cMETHOPx(v)->op_class_targ) : cMETHOPx(v)->op_class_sv)
PAD_SVl(cMETHOPx(v)->op_class_targ) : NULL)
#else
# define cGVOPx_gv(o) ((GV*)cSVOPx(o)->op_sv)
# ifndef PERL_CORE
Expand Down

0 comments on commit e3384dc

Please sign in to comment.