Revision: 892
http://vcs.pcre.org/viewvc?view=rev&revision=892
Author: ph10
Date: 2012-01-18 17:23:20 +0000 (Wed, 18 Jan 2012)
Log Message:
-----------
Put top level heap frame on the stack.
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/pcre_exec.c
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2012-01-18 16:26:18 UTC (rev 891)
+++ code/trunk/ChangeLog 2012-01-18 17:23:20 UTC (rev 892)
@@ -52,9 +52,13 @@
13. Applied Dmitry V. Levin's patch for a more portable method for linking with
-lreadline.
-14. ZH added PCRE_CONFIG_JITTARGET; added it's output to pcretest -C.
+14. ZH added PCRE_CONFIG_JITTARGET; added its output to pcretest -C.
+15. Applied Graycode's patch to put the top-level frame on the stack rather
+ than the heap when not using the stack for recursion. This gives a
+ performance improvement in many cases when recursion is not deep.
+
Version 8.21 12-Dec-2011
------------------------
Modified: code/trunk/pcre_exec.c
===================================================================
--- code/trunk/pcre_exec.c 2012-01-18 16:26:18 UTC (rev 891)
+++ code/trunk/pcre_exec.c 2012-01-18 17:23:20 UTC (rev 892)
@@ -332,7 +332,7 @@
{\
heapframe *oldframe = frame;\
frame = oldframe->Xprevframe;\
- (PUBL(stack_free))(oldframe);\
+ if (oldframe != &frame_zero) (PUBL(stack_free))(oldframe);\
if (frame != NULL)\
{\
rrc = ra;\
@@ -485,13 +485,15 @@
int condcode;
/* When recursion is not being used, all "local" variables that have to be
-preserved over calls to RMATCH() are part of a "frame" which is obtained from
-heap storage. Set up the top-level frame here; others are obtained from the
-heap whenever RMATCH() does a "recursion". See the macro definitions above. */
+preserved over calls to RMATCH() are part of a "frame". We set up the top-level
+frame on the stack here; subsequent instantiations are obtained from the heap
+whenever RMATCH() does a "recursion". See the macro definitions above. Putting
+the top-level on the stack rather than malloc-ing them all gives a performance
+boost in many cases where there is not much "recursion". */
#ifdef NO_RECURSE
-heapframe *frame = (heapframe *)(PUBL(stack_malloc))(sizeof(heapframe));
-if (frame == NULL) RRETURN(PCRE_ERROR_NOMEMORY);
+heapframe frame_zero;
+heapframe *frame = &frame_zero;
frame->Xprevframe = NULL; /* Marks the top level */
/* Copy in the original argument variables */