Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by bulk88 (Priest)
on Aug 29, 2012 at 22:57 UTC ( #990589=note: print w/ replies, xml ) Need Help??


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

Why? It is analogous to "this" parameter in C++. The alternative is calling 4 functions each time, win32/win32thread.c#l23 in perl.git.


Comment on Re^14: Perl 5 Optimizing Compiler, Part 4: LLVM Backend?
Re^15: Perl 5 Optimizing Compiler, Part 4: LLVM Backend?
by BrowserUk (Pope) on Aug 30, 2012 at 00:18 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.
        You do realize your idea will break $^E?

        It not "my idea"....

        Please think about the following sequence of events:

        1. User program calls some built-in or XS function.

          Program enters C ...

        2. ... does some stuff ...

          Still in C

        3. An system API is called, that fails and causes GetLastError() to be set.

          Still in C

        4. Oh. Let's fiddle with the context at this point

          But we must preserve that extended error information

          So that when we get around to telling the user that the other API we called, failed,

          he can query for some extra information

        5. ... do some more stuff ...
        6. return (failure) to user.

        Think. What API might we be calling at 3, that fails, but not so badly that we can't fiddle with the context, before we report that failure back to user, who might want to get the extended error information?

        And, if SetContext should fail, is the extended error information from that mysterious API still important? Will we ever get back to the user for him to be able to query that extended error information?

        Details. Details... Off topic. Let's stop.


        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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2014-08-21 03:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (127 votes), past polls