1 /* This file is part of the indirect Perl module.
2 * See http://search.cpan.org/dist/indirect/ */
4 #define PERL_NO_GET_CONTEXT
9 #define __PACKAGE__ "indirect"
10 #define __PACKAGE_LEN__ (sizeof(__PACKAGE__)-1)
12 /* --- Compatibility wrappers ---------------------------------------------- */
23 # define Newx(v, n, c) New(0, v, n, c)
27 # define SvPV_const SvPV
30 #ifndef SvPV_nolen_const
31 # define SvPV_nolen_const SvPV_nolen
35 # define SvPVX_const SvPVX
38 #ifndef SvREFCNT_inc_simple_void_NN
39 # ifdef SvREFCNT_inc_simple_NN
40 # define SvREFCNT_inc_simple_void_NN SvREFCNT_inc_simple_NN
42 # define SvREFCNT_inc_simple_void_NN SvREFCNT_inc
46 #ifndef sv_catpvn_nomg
47 # define sv_catpvn_nomg sv_catpvn
51 # define mPUSHp(P, L) PUSHs(sv_2mortal(newSVpvn((P), (L))))
55 # define mPUSHu(U) PUSHs(sv_2mortal(newSVuv(U)))
59 # define HvNAME_get(H) HvNAME(H)
63 # define HvNAMELEN_get(H) strlen(HvNAME_get(H))
66 #define I_HAS_PERL(R, V, S) (PERL_REVISION > (R) || (PERL_REVISION == (R) && (PERL_VERSION > (V) || (PERL_VERSION == (V) && (PERL_SUBVERSION >= (S))))))
68 #if I_HAS_PERL(5, 10, 0) || defined(PL_parser)
70 # define PL_linestr PL_parser->linestr
73 # define PL_bufptr PL_parser->bufptr
76 # define PL_oldbufptr PL_parser->oldbufptr
80 # define PL_linestr PL_Ilinestr
83 # define PL_bufptr PL_Ibufptr
86 # define PL_oldbufptr PL_Ioldbufptr
90 #ifndef I_WORKAROUND_REQUIRE_PROPAGATION
91 # define I_WORKAROUND_REQUIRE_PROPAGATION !I_HAS_PERL(5, 10, 1)
94 /* ... Thread safety and multiplicity ...................................... */
96 /* Safe unless stated otherwise in Makefile.PL */
101 #ifndef I_MULTIPLICITY
102 # if defined(MULTIPLICITY) || defined(PERL_IMPLICIT_CONTEXT)
103 # define I_MULTIPLICITY 1
105 # define I_MULTIPLICITY 0
108 #if I_MULTIPLICITY && !defined(tTHX)
109 # define tTHX PerlInterpreter*
112 #if I_MULTIPLICITY && defined(USE_ITHREADS) && defined(dMY_CXT) && defined(MY_CXT) && defined(START_MY_CXT) && defined(MY_CXT_INIT) && (defined(MY_CXT_CLONE) || defined(dMY_CXT_SV))
113 # define I_THREADSAFE 1
114 # ifndef MY_CXT_CLONE
115 # define MY_CXT_CLONE \
117 my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1)); \
118 Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t); \
119 sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
122 # define I_THREADSAFE 0
124 # define dMY_CXT dNOOP
126 # define MY_CXT indirect_globaldata
128 # define START_MY_CXT STATIC my_cxt_t MY_CXT;
130 # define MY_CXT_INIT NOOP
132 # define MY_CXT_CLONE NOOP
135 #if defined(OP_CHECK_MUTEX_LOCK) && defined(OP_CHECK_MUTEX_UNLOCK)
136 # define I_CHECK_MUTEX_LOCK OP_CHECK_MUTEX_LOCK
137 # define I_CHECK_MUTEX_UNLOCK OP_CHECK_MUTEX_UNLOCK
139 # define I_CHECK_MUTEX_LOCK OP_REFCNT_LOCK
140 # define I_CHECK_MUTEX_UNLOCK OP_REFCNT_UNLOCK
143 typedef OP *(*indirect_ck_t)(pTHX_ OP *);
145 #ifdef wrap_op_checker
147 # define indirect_ck_replace(T, NC, OCP) wrap_op_checker((T), (NC), (OCP))
151 STATIC void indirect_ck_replace(pTHX_ OPCODE type, indirect_ck_t new_ck, indirect_ck_t *old_ck_p) {
152 #define indirect_ck_replace(T, NC, OCP) indirect_ck_replace(aTHX_ (T), (NC), (OCP))
155 *old_ck_p = PL_check[type];
156 PL_check[type] = new_ck;
158 I_CHECK_MUTEX_UNLOCK;
163 STATIC void indirect_ck_restore(pTHX_ OPCODE type, indirect_ck_t *old_ck_p) {
164 #define indirect_ck_restore(T, OCP) indirect_ck_restore(aTHX_ (T), (OCP))
167 PL_check[type] = *old_ck_p;
170 I_CHECK_MUTEX_UNLOCK;
173 /* --- Helpers ------------------------------------------------------------- */
175 /* ... Thread-safe hints ................................................... */
177 #if I_WORKAROUND_REQUIRE_PROPAGATION
184 #define I_HINT_STRUCT 1
186 #define I_HINT_CODE(H) ((H)->code)
188 #define I_HINT_FREE(H) { \
189 indirect_hint_t *h = (H); \
190 SvREFCNT_dec(h->code); \
191 PerlMemShared_free(h); \
194 #else /* I_WORKAROUND_REQUIRE_PROPAGATION */
196 typedef SV indirect_hint_t;
198 #define I_HINT_STRUCT 0
200 #define I_HINT_CODE(H) (H)
202 #define I_HINT_FREE(H) SvREFCNT_dec(H);
204 #endif /* !I_WORKAROUND_REQUIRE_PROPAGATION */
208 #define PTABLE_NAME ptable_hints
209 #define PTABLE_VAL_FREE(V) I_HINT_FREE(V)
218 #define ptable_hints_store(T, K, V) ptable_hints_store(aTHX_ (T), (K), (V))
219 #define ptable_hints_free(T) ptable_hints_free(aTHX_ (T))
221 #endif /* I_THREADSAFE */
223 /* Define the op->str ptable here because we need to be able to clean it during
232 } indirect_op_info_t;
234 #define PTABLE_NAME ptable
235 #define PTABLE_VAL_FREE(V) if (V) { Safefree(((indirect_op_info_t *) (V))->buf); Safefree(V); }
244 #define ptable_store(T, K, V) ptable_store(aTHX_ (T), (K), (V))
245 #define ptable_delete(T, K) ptable_delete(aTHX_ (T), (K))
246 #define ptable_clear(T) ptable_clear(aTHX_ (T))
247 #define ptable_free(T) ptable_free(aTHX_ (T))
249 #define MY_CXT_KEY __PACKAGE__ "::_guts" XS_VERSION
253 ptable *tbl; /* It really is a ptable_hints */
264 STATIC SV *indirect_clone(pTHX_ SV *sv, tTHX owner) {
265 #define indirect_clone(S, O) indirect_clone(aTHX_ (S), (O))
273 if (SvTYPE(sv) == SVt_PVHV && HvNAME_get(sv))
276 param.stashes = stashes;
278 param.proto_perl = owner;
280 dupsv = sv_dup(sv, ¶m);
284 SvREFCNT_dec(stashes);
287 return SvREFCNT_inc(dupsv);
290 STATIC void indirect_ptable_clone(pTHX_ ptable_ent *ent, void *ud_) {
292 indirect_hint_t *h1 = ent->val;
295 if (ud->owner == aTHX)
300 h2 = PerlMemShared_malloc(sizeof *h2);
301 h2->code = indirect_clone(h1->code, ud->owner);
302 #if I_WORKAROUND_REQUIRE_PROPAGATION
303 h2->require_tag = PTR2IV(indirect_clone(INT2PTR(SV *, h1->require_tag),
307 #else /* I_HINT_STRUCT */
309 h2 = indirect_clone(h1, ud->owner);
311 #endif /* !I_HINT_STRUCT */
313 ptable_hints_store(ud->tbl, ent->key, h2);
318 STATIC void indirect_thread_cleanup(pTHX_ void *ud) {
321 SvREFCNT_dec(MY_CXT.global_code);
322 ptable_free(MY_CXT.map);
323 ptable_hints_free(MY_CXT.tbl);
326 #endif /* I_THREADSAFE */
328 #if I_WORKAROUND_REQUIRE_PROPAGATION
329 STATIC IV indirect_require_tag(pTHX) {
330 #define indirect_require_tag() indirect_require_tag(aTHX)
331 const CV *cv, *outside;
336 /* If for some reason the pragma is operational at run-time, try to discover
337 * the current cv in use. */
340 for (si = PL_curstackinfo; si; si = si->si_prev) {
343 for (cxix = si->si_cxix; cxix >= 0; --cxix) {
344 const PERL_CONTEXT *cx = si->si_cxstack + cxix;
346 switch (CxTYPE(cx)) {
349 /* The propagation workaround is only needed up to 5.10.0 and at that
350 * time format and sub contexts were still identical. And even later the
351 * cv members offsets should have been kept the same. */
353 goto get_enclosing_cv;
355 cv = cx->blk_eval.cv;
356 goto get_enclosing_cv;
367 for (outside = CvOUTSIDE(cv); outside; outside = CvOUTSIDE(cv))
372 #endif /* I_WORKAROUND_REQUIRE_PROPAGATION */
374 STATIC SV *indirect_tag(pTHX_ SV *value) {
375 #define indirect_tag(V) indirect_tag(aTHX_ (V))
381 if (SvTYPE(value) >= SVt_PVCV) {
383 SvREFCNT_inc_simple_void_NN(code);
388 h = PerlMemShared_malloc(sizeof *h);
390 # if I_WORKAROUND_REQUIRE_PROPAGATION
391 h->require_tag = indirect_require_tag();
392 # endif /* I_WORKAROUND_REQUIRE_PROPAGATION */
393 #else /* I_HINT_STRUCT */
395 #endif /* !I_HINT_STRUCT */
400 /* We only need for the key to be an unique tag for looking up the value later
401 * Allocated memory provides convenient unique identifiers, so that's why we
402 * use the hint as the key itself. */
403 ptable_hints_store(MY_CXT.tbl, h, h);
405 #endif /* I_THREADSAFE */
407 return newSViv(PTR2IV(h));
410 STATIC SV *indirect_detag(pTHX_ const SV *hint) {
411 #define indirect_detag(H) indirect_detag(aTHX_ (H))
413 #if I_THREADSAFE || I_WORKAROUND_REQUIRE_PROPAGATION
417 h = INT2PTR(indirect_hint_t *, SvIVX(hint));
419 h = ptable_fetch(MY_CXT.tbl, h);
420 #endif /* I_THREADSAFE */
422 #if I_WORKAROUND_REQUIRE_PROPAGATION
423 if (indirect_require_tag() != h->require_tag)
424 return MY_CXT.global_code;
425 #endif /* I_WORKAROUND_REQUIRE_PROPAGATION */
427 return I_HINT_CODE(h);
430 STATIC U32 indirect_hash = 0;
432 STATIC SV *indirect_hint(pTHX) {
433 #define indirect_hint() indirect_hint(aTHX)
439 #if I_HAS_PERL(5, 10, 0) || defined(PL_parser)
444 #ifdef cop_hints_fetch_pvn
445 hint = cop_hints_fetch_pvn(PL_curcop, __PACKAGE__, __PACKAGE_LEN__,
447 #elif I_HAS_PERL(5, 9, 5)
448 hint = Perl_refcounted_he_fetch(aTHX_ PL_curcop->cop_hints_hash,
450 __PACKAGE__, __PACKAGE_LEN__,
455 SV **val = hv_fetch(GvHV(PL_hintgv), __PACKAGE__, __PACKAGE_LEN__, 0);
461 if (hint && SvIOK(hint))
462 return indirect_detag(hint);
465 return MY_CXT.global_code;
469 /* ... op -> source position ............................................... */
471 STATIC void indirect_map_store(pTHX_ const OP *o, STRLEN pos, SV *sv, line_t line) {
472 #define indirect_map_store(O, P, N, L) indirect_map_store(aTHX_ (O), (P), (N), (L))
473 indirect_op_info_t *oi;
478 if (!(oi = ptable_fetch(MY_CXT.map, o))) {
479 Newx(oi, 1, indirect_op_info_t);
480 ptable_store(MY_CXT.map, o, oi);
486 s = SvPV_const(sv, len);
492 if (len > oi->size) {
494 Newx(oi->buf, len, char);
497 Copy(s, oi->buf, len, char);
504 STATIC const indirect_op_info_t *indirect_map_fetch(pTHX_ const OP *o) {
505 #define indirect_map_fetch(O) indirect_map_fetch(aTHX_ (O))
508 return ptable_fetch(MY_CXT.map, o);
511 STATIC void indirect_map_delete(pTHX_ const OP *o) {
512 #define indirect_map_delete(O) indirect_map_delete(aTHX_ (O))
515 ptable_delete(MY_CXT.map, o);
518 /* --- Check functions ----------------------------------------------------- */
520 STATIC STRLEN indirect_nextline(const char *s, STRLEN len) {
523 for (i = 0; i < len; ++i) {
526 while (i < len && s[i] == '\r')
535 STATIC int indirect_find(pTHX_ SV *name_sv, const char *line_bufptr, STRLEN *name_pos) {
536 #define indirect_find(NSV, LBP, NP) indirect_find(aTHX_ (NSV), (LBP), (NP))
537 STRLEN name_len, line_len;
538 const char *name, *name_end;
539 const char *line, *line_end;
540 const char *p, *t, *u;
542 line = SvPV_const(PL_linestr, line_len);
543 line_end = line + line_len;
545 name = SvPV_const(name_sv, name_len);
546 if (name_len >= 1 && *name == '$') {
549 while (line_bufptr < line_end && *line_bufptr != '$')
551 if (line_bufptr >= line_end)
554 name_end = name + name_len;
558 p = ninstr(p, line_end, name, name_end);
561 if (!isALNUM(p[name_len]))
563 /* p points to a word that has name as prefix, skip the rest of the word */
572 STRLEN i = indirect_nextline(t, line_len);
584 /* ... ck_const ............................................................ */
586 STATIC OP *(*indirect_old_ck_const)(pTHX_ OP *) = 0;
588 STATIC OP *indirect_ck_const(pTHX_ OP *o) {
589 o = indirect_old_ck_const(aTHX_ o);
591 if (indirect_hint()) {
594 if (SvPOK(sv) && (SvTYPE(sv) >= SVt_PV)) {
597 if (indirect_find(sv, PL_oldbufptr, &pos)) {
598 indirect_map_store(o, pos, sv, CopLINE(&PL_compiling));
604 indirect_map_delete(o);
608 /* ... ck_rv2sv ............................................................ */
610 STATIC OP *(*indirect_old_ck_rv2sv)(pTHX_ OP *) = 0;
612 STATIC OP *indirect_ck_rv2sv(pTHX_ OP *o) {
613 if (indirect_hint()) {
614 OP *op = cUNOPo->op_first;
616 const char *name = NULL;
618 OPCODE type = (OPCODE) op->op_type;
623 GV *gv = cGVOPx_gv(op);
629 if ((PL_opargs[type] & OA_CLASS_MASK) == OA_SVOP) {
630 SV *nsv = cSVOPx_sv(op);
631 if (SvPOK(nsv) && (SvTYPE(nsv) >= SVt_PV))
632 name = SvPV_const(nsv, len);
638 sv = sv_2mortal(newSVpvn("$", 1));
639 sv_catpvn_nomg(sv, name, len);
640 if (!indirect_find(sv, PL_oldbufptr, &pos)) {
641 /* If it failed, retry without the current stash */
642 const char *stash = HvNAME_get(PL_curstash);
643 STRLEN stashlen = HvNAMELEN_get(PL_curstash);
645 if ((len < stashlen + 2) || strnNE(name, stash, stashlen)
646 || name[stashlen] != ':' || name[stashlen+1] != ':') {
647 /* Failed again ? Try to remove main */
650 if ((len < stashlen + 2) || strnNE(name, stash, stashlen)
651 || name[stashlen] != ':' || name[stashlen+1] != ':')
655 sv_setpvn(sv, "$", 1);
657 sv_catpvn_nomg(sv, name + stashlen, len - stashlen);
658 if (!indirect_find(sv, PL_oldbufptr, &pos))
662 o = indirect_old_ck_rv2sv(aTHX_ o);
664 indirect_map_store(o, pos, sv, CopLINE(&PL_compiling));
669 o = indirect_old_ck_rv2sv(aTHX_ o);
671 indirect_map_delete(o);
675 /* ... ck_padany ........................................................... */
677 STATIC OP *(*indirect_old_ck_padany)(pTHX_ OP *) = 0;
679 STATIC OP *indirect_ck_padany(pTHX_ OP *o) {
680 o = indirect_old_ck_padany(aTHX_ o);
682 if (indirect_hint()) {
684 const char *s = PL_oldbufptr, *t = PL_bufptr - 1;
686 while (s < t && isSPACE(*s)) ++s;
687 if (*s == '$' && ++s <= t) {
688 while (s < t && isSPACE(*s)) ++s;
689 while (s < t && isSPACE(*t)) --t;
690 sv = sv_2mortal(newSVpvn("$", 1));
691 sv_catpvn_nomg(sv, s, t - s + 1);
692 indirect_map_store(o, s - SvPVX_const(PL_linestr),
693 sv, CopLINE(&PL_compiling));
698 indirect_map_delete(o);
702 /* ... ck_scope ............................................................ */
704 STATIC OP *(*indirect_old_ck_scope) (pTHX_ OP *) = 0;
705 STATIC OP *(*indirect_old_ck_lineseq)(pTHX_ OP *) = 0;
707 STATIC OP *indirect_ck_scope(pTHX_ OP *o) {
708 OP *(*old_ck)(pTHX_ OP *) = 0;
710 switch (o->op_type) {
711 case OP_SCOPE: old_ck = indirect_old_ck_scope; break;
712 case OP_LINESEQ: old_ck = indirect_old_ck_lineseq; break;
716 if (indirect_hint()) {
717 indirect_map_store(o, PL_oldbufptr - SvPVX_const(PL_linestr),
718 NULL, CopLINE(&PL_compiling));
722 indirect_map_delete(o);
726 /* We don't need to clean the map entries for leave ops because they can only
727 * be created by mutating from a lineseq. */
729 /* ... ck_method ........................................................... */
731 STATIC OP *(*indirect_old_ck_method)(pTHX_ OP *) = 0;
733 STATIC OP *indirect_ck_method(pTHX_ OP *o) {
734 if (indirect_hint()) {
735 OP *op = cUNOPo->op_first;
737 /* Indirect method call is only possible when the method is a bareword, so
738 * don't trip up on $obj->$meth. */
739 if (op && op->op_type == OP_CONST) {
740 const indirect_op_info_t *oi = indirect_map_fetch(op);
748 sv = sv_2mortal(newSVpvn(oi->buf, oi->len));
750 /* Keep the old line so that we really point to the first line of the
754 o = indirect_old_ck_method(aTHX_ o);
755 /* o may now be a method_named */
757 indirect_map_store(o, pos, sv, line);
763 o = indirect_old_ck_method(aTHX_ o);
765 indirect_map_delete(o);
769 /* ... ck_method_named ..................................................... */
771 /* "use foo/no foo" compiles its call to import/unimport directly to a
772 * method_named op. */
774 STATIC OP *(*indirect_old_ck_method_named)(pTHX_ OP *) = 0;
776 STATIC OP *indirect_ck_method_named(pTHX_ OP *o) {
777 if (indirect_hint()) {
783 if (!SvPOK(sv) || (SvTYPE(sv) < SVt_PV))
785 sv = sv_mortalcopy(sv);
787 if (!indirect_find(sv, PL_oldbufptr, &pos))
789 line = CopLINE(&PL_compiling);
791 o = indirect_old_ck_method_named(aTHX_ o);
793 indirect_map_store(o, pos, sv, line);
798 o = indirect_old_ck_method_named(aTHX_ o);
800 indirect_map_delete(o);
804 /* ... ck_entersub ......................................................... */
806 STATIC OP *(*indirect_old_ck_entersub)(pTHX_ OP *) = 0;
808 STATIC OP *indirect_ck_entersub(pTHX_ OP *o) {
809 SV *code = indirect_hint();
811 o = indirect_old_ck_entersub(aTHX_ o);
814 const indirect_op_info_t *moi, *ooi;
820 lop = (LISTOP *) oop;
821 if (!(lop->op_flags & OPf_KIDS))
824 } while (oop->op_type != OP_PUSHMARK);
825 oop = oop->op_sibling;
831 switch (oop->op_type) {
842 if (mop->op_type == OP_METHOD)
843 mop = cUNOPx(mop)->op_first;
844 else if (mop->op_type != OP_METHOD_NAMED)
847 moi = indirect_map_fetch(mop);
851 ooi = indirect_map_fetch(oop);
855 /* When positions are identical, the method and the object must have the
856 * same name. But it also means that it is an indirect call, as "foo->foo"
857 * results in different positions. */
858 if ( moi->line < ooi->line
859 || (moi->line == ooi->line && moi->pos <= ooi->pos)) {
867 file = sv_2mortal(newSVpv(CopFILE(&PL_compiling), 0));
869 file = sv_mortalcopy(CopFILESV(&PL_compiling));
874 mPUSHp(ooi->buf, ooi->len);
875 mPUSHp(moi->buf, moi->len);
880 call_sv(code, G_VOID);
893 STATIC U32 indirect_initialized = 0;
895 STATIC void indirect_teardown(pTHX_ void *root) {
896 if (!indirect_initialized)
906 ptable_free(MY_CXT.map);
908 ptable_hints_free(MY_CXT.tbl);
912 indirect_ck_restore(OP_CONST, &indirect_old_ck_const);
913 indirect_ck_restore(OP_RV2SV, &indirect_old_ck_rv2sv);
914 indirect_ck_restore(OP_PADANY, &indirect_old_ck_padany);
915 indirect_ck_restore(OP_SCOPE, &indirect_old_ck_scope);
916 indirect_ck_restore(OP_LINESEQ, &indirect_old_ck_lineseq);
918 indirect_ck_restore(OP_METHOD, &indirect_old_ck_method);
919 indirect_ck_restore(OP_METHOD_NAMED, &indirect_old_ck_method_named);
920 indirect_ck_restore(OP_ENTERSUB, &indirect_old_ck_entersub);
922 indirect_initialized = 0;
925 STATIC void indirect_setup(pTHX) {
926 #define indirect_setup() indirect_setup(aTHX)
927 if (indirect_initialized)
933 MY_CXT.tbl = ptable_new();
936 MY_CXT.map = ptable_new();
937 MY_CXT.global_code = NULL;
940 indirect_ck_replace(OP_CONST, indirect_ck_const, &indirect_old_ck_const);
941 indirect_ck_replace(OP_RV2SV, indirect_ck_rv2sv, &indirect_old_ck_rv2sv);
942 indirect_ck_replace(OP_PADANY, indirect_ck_padany, &indirect_old_ck_padany);
943 indirect_ck_replace(OP_SCOPE, indirect_ck_scope, &indirect_old_ck_scope);
944 indirect_ck_replace(OP_LINESEQ, indirect_ck_scope, &indirect_old_ck_lineseq);
946 indirect_ck_replace(OP_METHOD, indirect_ck_method,
947 &indirect_old_ck_method);
948 indirect_ck_replace(OP_METHOD_NAMED, indirect_ck_method_named,
949 &indirect_old_ck_method_named);
950 indirect_ck_replace(OP_ENTERSUB, indirect_ck_entersub,
951 &indirect_old_ck_entersub);
954 call_atexit(indirect_teardown, aTHX);
956 call_atexit(indirect_teardown, NULL);
959 indirect_initialized = 1;
962 STATIC U32 indirect_booted = 0;
964 /* --- XS ------------------------------------------------------------------ */
966 MODULE = indirect PACKAGE = indirect
972 if (!indirect_booted++) {
975 PERL_HASH(indirect_hash, __PACKAGE__, __PACKAGE_LEN__);
977 stash = gv_stashpvn(__PACKAGE__, __PACKAGE_LEN__, 1);
978 newCONSTSUB(stash, "I_THREADSAFE", newSVuv(I_THREADSAFE));
979 newCONSTSUB(stash, "I_FORKSAFE", newSVuv(I_FORKSAFE));
997 ud.tbl = t = ptable_new();
998 ud.owner = MY_CXT.owner;
999 ptable_walk(MY_CXT.tbl, indirect_ptable_clone, &ud);
1000 global_code_dup = indirect_clone(MY_CXT.global_code, MY_CXT.owner);
1004 MY_CXT.map = ptable_new();
1006 MY_CXT.owner = aTHX;
1007 MY_CXT.global_code = global_code_dup;
1009 reap(3, indirect_thread_cleanup, NULL);
1018 RETVAL = indirect_tag(value);
1028 else if (SvROK(code))
1032 SvREFCNT_dec(MY_CXT.global_code);
1033 MY_CXT.global_code = SvREFCNT_inc(code);