Author: chromatic
Date: Wed Mar 26 00:13:21 2008
New Revision: 26562
Modified:
trunk/compilers/pge/PGE/Exp.pir
Log:
[PGE] Reordered generated code to bail out of an obviously-failing match before
creating PMCs to store results for successful results. This is a minor
optimization.
Modified: trunk/compilers/pge/PGE/Exp.pir
==============================================================================
--- trunk/compilers/pge/PGE/Exp.pir (original)
+++ trunk/compilers/pge/PGE/Exp.pir Wed Mar 26 00:13:21 2008
@@ -170,6 +170,9 @@
(mob, cpos, target, mfrom, mpos, iscont) = $P0.'new'(mob, adverbs
:flat :named)
$P0 = interpinfo %2
setattribute mob, '&!corou', $P0
+ .local int lastpos
+ lastpos = length target
+ if cpos > lastpos goto fail_rule
CODE
goto code_body
@@ -185,6 +188,9 @@
.local int cpos, iscont :unique_reg
$P0 = get_hll_global ['PGE'], 'Match'
(mob, cpos, target, mfrom, mpos, iscont) = $P0.'new'(self, adverbs
:flat :named)
+ .local int lastpos
+ lastpos = length target
+ if cpos > lastpos goto fail_rule
CODE
code_body:
@@ -210,8 +216,7 @@
code_body_3:
code.emit(<<" CODE", PGE_CUT_RULE, returnop)
- .local int pos, lastpos, rep, cutmark :unique_reg
- lastpos = length target
+ .local int pos, rep, cutmark :unique_reg
try_match:
if cpos > lastpos goto fail_rule
mfrom = cpos