- cv = PL_compcv;
-
- if (!cv) {
- /* If for some reason the pragma is operational at run-time, try to discover
- * the current cv in use. */
- const PERL_SI *si;
-
- 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;
-
- switch (CxTYPE(cx)) {
- case CXt_SUB:
- case CXt_FORMAT:
- /* The propagation workaround is only needed up to 5.10.0 and at that
- * time format and sub contexts were still identical. And even later the
- * cv members offsets should have been kept the same. */
- cv = cx->blk_sub.cv;
- goto get_enclosing_cv;
- case CXt_EVAL:
- cv = cx->blk_eval.cv;
- goto get_enclosing_cv;
- default:
- break;
- }
- }
- }
-
- cv = PL_main_cv;
- }
-
-get_enclosing_cv:
- for (outside = CvOUTSIDE(cv); outside; outside = CvOUTSIDE(cv))
- cv = outside;
-
- return PTR2IV(cv);
-}
-
-#endif /* LT_WORKAROUND_REQUIRE_PROPAGATION */
-
-STATIC SV *lt_tag(pTHX_ SV *value) {
-#define lt_tag(V) lt_tag(aTHX_ (V))
- lt_hint_t *h;
- SV *code = NULL;
-
- if (SvROK(value)) {
- value = SvRV(value);
- if (SvTYPE(value) >= SVt_PVCV) {
- code = value;
- SvREFCNT_inc_simple_NN(code);
- }
- }
-
-#if LT_HINT_STRUCT
- h = PerlMemShared_malloc(sizeof *h);
- h->code = code;
-# if LT_WORKAROUND_REQUIRE_PROPAGATION
- h->require_tag = lt_require_tag();
-# endif /* LT_WORKAROUND_REQUIRE_PROPAGATION */
-#else /* LT_HINT_STRUCT */
- h = code;
-#endif /* !LT_HINT_STRUCT */
-
-#if LT_THREADSAFE
- {
- dMY_CXT;
- /* 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 /* LT_THREADSAFE */
-
- return newSViv(PTR2IV(h));
-}
-
-STATIC SV *lt_detag(pTHX_ const SV *hint) {
-#define lt_detag(H) lt_detag(aTHX_ (H))
- lt_hint_t *h;
-#if LT_THREADSAFE
- dMY_CXT;
-#endif
-
- if (!(hint && SvIOK(hint)))
- return NULL;
-
- h = INT2PTR(lt_hint_t *, SvIVX(hint));
-#if LT_THREADSAFE
- h = ptable_fetch(MY_CXT.tbl, h);
-#endif /* LT_THREADSAFE */
-#if LT_WORKAROUND_REQUIRE_PROPAGATION
- if (lt_require_tag() != h->require_tag)
- return NULL;
-#endif /* LT_WORKAROUND_REQUIRE_PROPAGATION */
-
- return LT_HINT_CODE(h);
-}
-
-STATIC U32 lt_hash = 0;
-
-STATIC SV *lt_hint(pTHX) {
-#define lt_hint() lt_hint(aTHX)
- SV *hint;
-#ifdef cop_hints_fetch_pvn
- hint = cop_hints_fetch_pvn(PL_curcop, __PACKAGE__, __PACKAGE_LEN__, lt_hash,0);
-#elif LT_HAS_PERL(5, 9, 5)
- hint = Perl_refcounted_he_fetch(aTHX_ PL_curcop->cop_hints_hash,
- NULL,
- __PACKAGE__, __PACKAGE_LEN__,
- 0,
- lt_hash);
-#else
- SV **val = hv_fetch(GvHV(PL_hintgv), __PACKAGE__, __PACKAGE_LEN__, lt_hash);
- if (!val)
- return 0;
- hint = *val;
-#endif
- return lt_detag(hint);
-}