-
-#else /* I_HINT_STRUCT */
-
- h2 = indirect_clone(h1, ud->owner);
- SvREFCNT_inc(h2);
-
-#endif /* !I_HINT_STRUCT */
-
- ptable_hints_store(ud->tbl, ent->key, h2);
-}
-
-STATIC void indirect_thread_cleanup(pTHX_ void *);
-
-STATIC void indirect_thread_cleanup(pTHX_ void *ud) {
- int *level = ud;
-
- if (*level) {
- *level = 0;
- LEAVE;
- SAVEDESTRUCTOR_X(indirect_thread_cleanup, level);
- ENTER;
- } else {
- dMY_CXT;
- PerlMemShared_free(level);
- ptable_free(MY_CXT.map);
- ptable_hints_free(MY_CXT.tbl);
- }
-}
-
-#endif /* I_THREADSAFE */
-
-STATIC SV *indirect_tag(pTHX_ SV *value) {
-#define indirect_tag(V) indirect_tag(aTHX_ (V))
- indirect_hint_t *h;
- SV *code = NULL;
- dMY_CXT;
-
- if (SvROK(value)) {
- value = SvRV(value);
- if (SvTYPE(value) >= SVt_PVCV) {
- code = value;
- SvREFCNT_inc_simple_NN(code);
- }
- }
-
-#if I_HINT_STRUCT
- h = PerlMemShared_malloc(sizeof *h);
- h->code = code;
-
-#if I_WORKAROUND_REQUIRE_PROPAGATION
- {
- const PERL_SI *si;
- I32 requires = 0;
-
- for (si = PL_curstackinfo; si; si = si->si_prev) {
- I32 cxix;
-
- for (cxix = si->si_cxix; cxix >= 0; --cxix) {
- const PERL_CONTEXT *cx = si->si_cxstack + cxix;
-
- if (CxTYPE(cx) == CXt_EVAL && cx->blk_eval.old_op_type == OP_REQUIRE)
- ++requires;
- }
- }
-
- h->requires = requires;
- }
-#endif /* I_WORKAROUND_REQUIRE_PROPAGATION */
-
-#else /* I_HINT_STRUCT */
- h = code;
-#endif /* !I_HINT_STRUCT */
-
-#if I_THREADSAFE
- /* We only need for the key to be an unique tag for looking up the value later.
- * Allocated memory provides convenient unique identifiers, so that's why we
- * use the hint as the key itself. */
- ptable_hints_store(MY_CXT.tbl, h, h);
-#endif /* I_THREADSAFE */
-
- return newSViv(PTR2IV(h));
-}
-
-STATIC SV *indirect_detag(pTHX_ const SV *hint) {
-#define indirect_detag(H) indirect_detag(aTHX_ (H))
- indirect_hint_t *h;
- dMY_CXT;
-
- if (!(hint && SvIOK(hint)))
- return NULL;
-
- h = INT2PTR(indirect_hint_t *, SvIVX(hint));
-#if I_THREADSAFE
- h = ptable_fetch(MY_CXT.tbl, h);
-#endif /* I_THREADSAFE */
-
-#if I_WORKAROUND_REQUIRE_PROPAGATION
- {
- const PERL_SI *si;
- I32 requires = 0;
-
- for (si = PL_curstackinfo; si; si = si->si_prev) {
- I32 cxix;
-
- for (cxix = si->si_cxix; cxix >= 0; --cxix) {
- const PERL_CONTEXT *cx = si->si_cxstack + cxix;
-
- if (CxTYPE(cx) == CXt_EVAL && cx->blk_eval.old_op_type == OP_REQUIRE
- && ++requires > h->requires)
- return NULL;