Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^13: Perl 5 Optimizing Compiler, Part 4: LLVM Backend?

by BrowserUk (Pope)
on Aug 29, 2012 at 22:12 UTC ( #990582=note: print w/ replies, xml ) Need Help??


in reply to Re^12: Perl 5 Optimizing Compiler, Part 4: LLVM Backend?
in thread Perl 5 Optimizing Compiler, Part 4: LLVM Backend?

The perl context is passed around as pTHX and aTHX as a C param.

That's even worse.


Comment on Re^13: Perl 5 Optimizing Compiler, Part 4: LLVM Backend?
Re^14: Perl 5 Optimizing Compiler, Part 4: LLVM Backend?
by bulk88 (Priest) on Aug 29, 2012 at 22:57 UTC
      Why?
      1. Because all that should be needed (on windows) is
        #define PERL_GET_CONTEXT TlsGetValue(PL_thr_key) #define PERL_SET_CONTEXT(t) TlsSetValue(PL_thr_key, (t))

        Quite why those calls are bracketed to preserve information from a previous error is strange.

        What previous error have we ignored -- by continuing to this piece of code -- that we want to retain the extended error information for?

        And what are we going to do with that retained information? And when?

      2. Because you should only need to set or get it in those functions that use it.

        And most of the functions that currently cart it about, don't use it.

        Other than to pass it on to other functions they call, which also don't use it, but need to pass it on to the functions they call ...

        Why not just get/set it in only those functions that use it?

        The answer is apparently TLS is slow on on *nix, so this blunderbuss solution is the best option.

        Despite that, from what I can see, Perl_get/set_context isn't called many places, or very often. But it is littered all over the source code -- just in case. Aarg!


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      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.

      RIP Neil Armstrong

      div/blockquote
        Because all that should be needed (on windows) is
        #define PERL_GET_CONTEXT TlsGetValue(PL_thr_key) #define PERL_SET_CONTEXT(t) TlsSetValue(PL_thr_key, (t))

        Quite why those calls are bracketed to preserve information from a previous error is strange.

        What previous error have we ignored -- by continuing to this piece of code -- that we want to retain the extended error information for?

        And what are we going to do with that retained information? And when?

        You do realize your idea will break $^E?

        Remember there is this questionable file that can steal your C lib away from you, win32/win32iop.h in perl.git.

        errno is nearly useless on Windows since its so vague and rarely set compared to LastError/$^E. Side note, on a nytprof profiler in my experience, Win32::GetLastError() is 10 times faster than $^E. Perl does its best to always keep Win32's last error accurate to the last Win32 call you consciously made (CRT things, like malloc or free, or Kernel32 HeapAlloc (http://msdn.microsoft.com/en-us/library/windows/desktop/aa366597%28v=vs.85%29.aspx), should not and do not change LastError), otherwise a mortal sweeping at scope boundaries would make LastError absolutely useless in perl as it frees SVPVs and make it impossible to do many Win32-ish things. Sometimes I've had GetLastError be screwed up in Perl because a
        $obj = Win32::Foo->new("create me"); #new returned a blessed object $obj = Win32::Foo->new("dont create me"); #new returned undef and LastError has failure code, DESTROY of "create + me" fires, changes LastError if(! defined $obj){ #$^E happens to be ERROR_SUCCESS (it is actually undefined/random +), programmer pounds head on keyboard screaming WHY ME!!!! die "creating obj failed ".($^E+0); }
        IMHO, LastError is a terrible design. Native API's NTSTATUS error code system is much better thought out (http://msdn.microsoft.com/en-us/library/cc231200%28v=prot.10%29) with positive signed numbers being informational non-errors, 0 being success with no information, and negative being errors.

Log In?
Username:
Password:

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

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

    The best computer themed movie is:











    Results (127 votes), past polls