I don't know the semantics of PL_markstack_ptr, but I would guess that it's an internal detail that might be subject to change in the future.
It's documented in perlguts, though reading that documentation has not helped me any.
I think that makes it public - at least public enough that any alteration to its usage will be outlined in perlguts. And it has been in Inline::C and Inline::CPP for a very long time, without ever causing problems.
For me, it's more about removing arcane clutter that is deployed only by Inline::C/CPP, rather than looking for improved running performance.
Many of the "truly void" functions (eg those that don't invoke dXSARGS) don't even need to increment the ptr - so, for them:
void
foo (x)
SV * x
PREINIT:
I32* temp;
PPCODE:
temp = PL_markstack_ptr++;
foo(x);
if (PL_markstack_ptr != temp) {
/* truly void, because dXSARGS not invoked */
PL_markstack_ptr = temp;
XSRETURN_EMPTY; /* return empty stack */
}
/* must have used dXSARGS; list context implied */
return; /* assume stack size is correct */
can be rewritten as:
void
foo (x)
SV * x
CODE:
foo(x);
XSRETURN_EMPTY;
which is much more readily comprehensible, and much more concise.
See
https://github.com/Perl/perl5/issues/21523 where the issue was first reported. And also see
https://github.com/ingydotnet/inline-c-pm/issues/104 for a bit of a discussion, and for Tony Cook's solution that suppresses the warnings shown in the former link.
I've actually started using a hacked Inline::C that eliminates the need for relying on "the PL_markstack_ptr dance". (It's based on the idea mentioned in that bug report - though it required some additional refining not mentioned there ... and it's probably not
everyone's preferred approach.)
Cheers,
Rob
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.