PERL_NO_GET_CONTEXT makes your XS code more efficient on threaded perls, but you then have to write your XS code in such a way as to work with it.

On threaded (or more accurately, MULTIPLICITY) perls, all the interpreter state is collected into a single structure which is accessed via the my_perl local var; so for example you have

#define PL_stack_sp my_perl->Istack_sp
Under MULTIPLICITY, most perl API functions take an extra initial my_perl argument, which you have to provide. Within perl core itself, this is handled by the pTHX and aTHX macros, which declare the extra arg, and pass that arg down to lower-level functions.

However, if your caller didn't provide my_perl, you have to retrieve it yourself, e.g. from thread-local storage (which may be relatively slow). In the absence of PERL_NO_GET_CONTEXT, every API function call is defined in such a way that it does the (slow) retrieve of my_perl before calling that function. So it takes care of the details for you, but slowly.

See Background and PERL_IMPLICIT_CONTEXT for more info.

Dave.


In reply to Re: Significance of #define PERL_GET_NO_CONTEXT in XS by dave_the_m
in thread Significance of #define PERL_NO_GET_CONTEXT in XS by halfcountplus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.