in reply to Re^3: How does CATCH_SET optimize efficiency?
in thread How does CATCH_SET optimize efficiency?
An optimisation to this is to have a flag (je_mustcatch) that can be set to indicate that the caller of the current runops loop can catch longjumps, handle the exception, and if necessary restart a new runops loop. In this case, there's no need to push a new jumplevel and runops loop each time.
The top-level execution of a perl program consists of setting up a jump level and entering a runops loop, so it sets je_mustcatch to false there: the top-level is already set up to handle expections.
Whenever perl code is called "from C" rather than directly from perl, such as FETCHes, overload code, or perl code called from XS, then it creates a new runops loop, but in this case the loop isn't protected by a new jumplevel and expection handler. So the caller of FETCH sets je_mustcatch to true, to notify any potential eval ops that they should set up their own handler.
So the net effect is that in practice, eval {} almost never has to push a new jump level and runops.
Dave.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: How does CATCH_SET optimize efficiency?
by PerlOnTheWay (Monk) on Dec 17, 2012 at 04:11 UTC | |
by dave_the_m (Monsignor) on Dec 17, 2012 at 15:54 UTC | |
by PerlOnTheWay (Monk) on Dec 18, 2012 at 01:16 UTC | |
by dave_the_m (Monsignor) on Dec 18, 2012 at 12:39 UTC | |
by PerlOnTheWay (Monk) on Dec 19, 2012 at 08:18 UTC | |
|