Skip to content

Commit e3384dc

Browse files
syberFather Chrysostomos
syber
authored and
Father Chrysostomos
committed
op_class_sv removed for threaded perls op_class_targ removed for non-threaded perls
1 parent b55b14d commit e3384dc

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

op.c

+18-8
Original file line numberDiff line numberDiff line change
@@ -863,12 +863,14 @@ Perl_op_clear(pTHX_ OP *o)
863863
}
864864
#endif
865865
case OP_METHOD:
866-
SvREFCNT_dec(cMETHOPx(o)->op_class_sv);
867866
#ifdef USE_ITHREADS
868867
if (cMETHOPx(o)->op_class_targ) {
869868
pad_swipe(cMETHOPx(o)->op_class_targ, 1);
870869
cMETHOPx(o)->op_class_targ = 0;
871870
}
871+
#else
872+
SvREFCNT_dec(cMETHOPx(o)->op_class_sv);
873+
cMETHOPx(o)->op_class_sv = NULL;
872874
#endif
873875
break;
874876
case OP_CONST:
@@ -2238,9 +2240,6 @@ S_finalize_op(pTHX_ OP* o)
22382240
/* Relocate all the METHOP's SVs to the pad for thread safety. */
22392241
case OP_METHOD_NAMED:
22402242
op_relocate_sv(&cMETHOPx(o)->op_u.op_meth_sv, &o->op_targ);
2241-
case OP_METHOD:
2242-
if (cMETHOPx(o)->op_class_sv)
2243-
op_relocate_sv(&cMETHOPx(o)->op_class_sv, &cMETHOPx(o)->op_class_targ);
22442243
break;
22452244
#endif
22462245

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

4696-
methop->op_class_sv = NULL;
4695+
#ifdef USE_ITHREADS
46974696
methop->op_class_targ = 0;
4697+
#else
4698+
methop->op_class_sv = NULL;
4699+
#endif
46984700
CHANGE_TYPE(methop, type);
46994701
methop = (METHOP*) CHECKOP(type, methop);
47004702

@@ -11627,10 +11629,18 @@ Perl_ck_subr(pTHX_ OP *o)
1162711629
/* cache const class' name to speedup class method calls */
1162811630
if (const_class) {
1162911631
STRLEN len;
11632+
SV* shared;
1163011633
const char* str = SvPV(const_class, len);
11631-
if (len) cMETHOPx(cvop)->op_class_sv = newSVpvn_share(
11632-
str, SvUTF8(const_class) ? -len : len, 0
11633-
);
11634+
if (len) {
11635+
shared = newSVpvn_share(
11636+
str, SvUTF8(const_class) ? -len : len, 0
11637+
);
11638+
#ifdef USE_ITHREADS
11639+
op_relocate_sv(&shared, &cMETHOPx(cvop)->op_class_targ);
11640+
#else
11641+
cMETHOPx(cvop)->op_class_sv = shared;
11642+
#endif
11643+
}
1163411644
}
1163511645
break;
1163611646
}

op.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,11 @@ struct methop {
202202
OP* op_first; /* optree for method name */
203203
SV* op_meth_sv; /* static method name */
204204
} op_u;
205-
SV* op_class_sv; /* static class name */
205+
#ifdef USE_ITHREADS
206206
PADOFFSET op_class_targ; /* pad index for class name if threaded */
207+
#else
208+
SV* op_class_sv; /* static class name */
209+
#endif
207210
};
208211

209212
struct pmop {
@@ -444,7 +447,7 @@ struct loop {
444447
# define cSVOPx_svp(v) (cSVOPx(v)->op_sv \
445448
? &cSVOPx(v)->op_sv : &PAD_SVl((v)->op_targ))
446449
# define cMETHOPx_class(v) (cMETHOPx(v)->op_class_targ ? \
447-
PAD_SVl(cMETHOPx(v)->op_class_targ) : cMETHOPx(v)->op_class_sv)
450+
PAD_SVl(cMETHOPx(v)->op_class_targ) : NULL)
448451
#else
449452
# define cGVOPx_gv(o) ((GV*)cSVOPx(o)->op_sv)
450453
# ifndef PERL_CORE

0 commit comments

Comments
 (0)