Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

How does CATCH_SET optimize efficiency?

by PerlOnTheWay (Scribe)
on Dec 16, 2012 at 06:53 UTC ( #1009046=perlquestion: print w/ replies, xml ) Need Help??
PerlOnTheWay has asked for the wisdom of the Perl Monks concerning the following question:

Quoted from perlinterp:

for efficiency reasons, perl in fact just sets a flag, using CATCH_SET(TRUE) . The pp_require , pp_entereval and pp_entertry ops check this flag, and if true, they call docatch , which does a JMPENV_PUSH and starts a new runops level to execute the code, rather than doing it on the current loop.

So by using CATCH_SET it just moves the JMPENV_PUSH to a new runops, rather than doing it on the current loop.

But IMO the same amount of stuff has to be done in both cases, how does this make efficiency better?

Comment on How does CATCH_SET optimize efficiency?
Re: How does CATCH_SET optimize efficiency?
by Anonymous Monk on Dec 16, 2012 at 10:33 UTC

    But IMO the same amount of stuff has to be done in both cases, how does this make efficiency better?

    Being fairly ignorant, the way I understand it ( after consulting these * * * * * * * * )

    it avoids doing the same amount of stuff if some cases ... like avoid re-entering runops and setting up some stacks a second time

    but given the date of some of that code, I wouldn't be surprised if this commentary doesn't match the facts

      For example in the following:
      sub FETCH { for (1..3) { eval { $x } } } sub TIEARRAY { bless [] } my @a; tie @a, 'main'; $y = $a[0];
      When the tie FETCH method is called, je_mustcatch is set to true, so the first time pp_entertry is called, it pushes a new jump level and enters a new runops loop. The second and third time pp_entertry is called, je_mustcatch is false, so the try block is executed within the current (inner) runops loop.

      Dave.

        Dave, thanks for your reply. But I've still got several questions:

        1. when is je_mustcatch set back to false?

        2. so the way it optimizes performance is by reusing the same jump level for multiple times?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (11)
As of 2014-12-22 16:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (121 votes), past polls