Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^6: XS: EXTEND/mPUSHi

by ikegami (Pope)
on Sep 27, 2011 at 01:33 UTC ( #927995=note: print w/ replies, xml ) Need Help??


in reply to Re^5: XS: EXTEND/mPUSHi
in thread XS: EXTEND/mPUSHi

xsubpp currently generates SP -= items;.

That change to the stack pointer is lost, since it's done in the real XS function (the wrapper), which doesn't doesn't "publish" the change using PUTBACK before calling the wrapped function.

I'd make Inline::C call PUTBACK before calling the wrapper function and make Inline_Stack_Reset a no-op.

In two places:

PPCODE: + PUTBACK; temp = PL_markstack_ptr++;

Update: I thought there would be backwards compatibility issues, but there aren't. ST(0) and such will still get the args. Adjusted.


Comment on Re^6: XS: EXTEND/mPUSHi
Select or Download Code
Re^7: XS: EXTEND/mPUSHi
by syphilis (Canon) on Sep 27, 2011 at 04:16 UTC
    I'd make Inline::C call PUTBACK before calling the wrapper function and make Inline_Stack_Reset a no-op

    Thanks - something to think about.
    Of course, while there's not actually anything that's broken, I'm inclined to leave things as they are.

    Cheers,
    Rob

      Hm. If you consider this "not broken", then I guess it isn't. Hm. If you consider this "not broken", then I guess it isn't.

      But if some of that seems unnecessary, then ... :)


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        The doing it twice is not a problem. Compilers will just get rid of the dead code. There's unreachable code every time you end an XS function using XSRETURN and the likes. That can't be that rare (especially XSRETURN_YES to return true), and it's got nothing to do with Inline::C.

        If you had look at the .xs instead of the .c, you can't even tell there's duplication.

        The problem is that Inline::C differs from XS. In XS, one doesn't call PUTBACK. In Inline::C, one must. In XS, the args are poped for you. In Inline::C, one must do so. Is this documented? Don't know. But even if it is, it's confusing and error prone.

        But if some of that seems unnecessary, then ... :)

        Ike obviously recognised the duplication to which you alluded ... but not me, alas.
        Could you elaborate ?

        Update: Also, ikegami mentioned making Inline_Stack_Reset a no-op. That just means amending Inline.h to do something like:
        #define Inline_Stack_Reset {}
        Right ?

        Cheers,
        Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://927995]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2014-08-02 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (55 votes), past polls