Given they way-below margin of error difference I have to wonder if perhaps the added "parse" times would more then offset any (if any) benefits gained. Given that most users still do not use opcode caches this is something to consider for performance tweaks where the difference is >1%.

On 20-Jan-07, at 4:57 PM, Sara Golemon wrote:

One last thought on global CVs... How's this for fixing the loophole of:

ZEND_BEGIN_SILENCE
ZEND_FETCH_R $0 '_POST' (global)
ZEND_FETCH_DIM_R $1 $0 'foo'
ZEND_END_SILENCE

I know it seems like a pretty minor gain, but (A) using @$_GET ['foo'] isn't an uncommon practice, and (B) pushing this all into CV based FETCH_DIM ops would greatly simplify the runtime JIT stuff I'm working on.

The short-version summary of this patch is that when the engine is going to do a FETCH_DIM based on prior nodes, it checks the top of the backpatch stack to see where the container element is coming from, if it's coming from a simple FETCH, it rewrites that to a FETCH_DIM, rather than adding a new element to the BP stack.

-Sara

P.S. - Bench numbers follow (0.1% difference):

               unpatched   patched
simple             0.472   0.473
simplecall         1.914   1.916
simpleucall        2.920   2.920
simpleudcall       3.507   3.507
mandel             2.056   2.055
mandel2            3.273   3.277
ackermann(7)       3.389   3.390
ary(50000)         0.157   0.157
ary2(50000)        0.138   0.138
ary3(2000)         1.057   1.056
fibo(30)           9.789   9.750
hash1(50000)       0.395   0.396
hash2(500)         0.300   0.300
heapsort(20000)    0.770   0.771
matrix(20)         0.508   0.508
nestedloop(12)     0.872   0.872
sieve(30)          0.640   0.640
strcat(200000)     0.289   0.289
--------------------------------
Total             32.446  32.416

Index: Zend/zend_compile.c
===================================================================
RCS file: /repository/ZendEngine2/zend_compile.c,v
retrieving revision 1.736
diff -u -p -r1.736 zend_compile.c
--- Zend/zend_compile.c 20 Jan 2007 20:36:55 -0000      1.736
+++ Zend/zend_compile.c 20 Jan 2007 21:55:50 -0000
@@ -489,9 +489,33 @@ void fetch_array_begin(znode *result, zn

void fetch_array_dim(znode *result, znode *parent, znode *dim TSRMLS_DC)
 {
-       zend_op opline;
+       zend_op opline, *parentop;
        zend_llist *fetch_list_ptr;

+       zend_stack_top(&CG(bp_stack), (void **) &fetch_list_ptr);
+       parentop = zend_llist_get_last(fetch_list_ptr);
+       if (parentop && parent->op_type == IS_VAR &&
+               parentop->opcode == ZEND_FETCH_W &&
+               parentop->op1.op_type == IS_CONST &&
+ (Z_TYPE(parentop->op1.u.constant) == IS_STRING || Z_TYPE (parentop->op1.u.constant) == IS_UNICODE) && + !(Z_UNILEN(parentop->op1.u.constant) == (sizeof("this")-1) && ZEND_U_EQUAL(Z_TYPE(parentop->op1.u.constant), Z_UNIVAL(parentop- >op1.u.constant), Z_UNILEN(parentop->op1.u.constant), "this", sizeof ("this")-1)) ) {
+               /* Recompile CV and rewrite previous op to direct FETCH_DIM */
+               zval tmp = parentop->op1.u.constant;
+               parentop->opcode = ZEND_FETCH_DIM_W;
+               parentop->op1.op_type = IS_CV;
+ parentop->op1.u.var = lookup_cv(CG(active_op_array), Z_TYPE (tmp), Z_UNIVAL(tmp), Z_UNILEN(tmp) TSRMLS_CC);
+               parentop->op1.u.EA.type = 0;
+               parentop->op2 = *dim;
+               parentop->extended_value = ZEND_FETCH_STANDARD;
+               *result = parentop->result;
+
+               /* Give temp var back if it was the most recently assigned only 
*/
+               if (CG(active_op_array)->T == (parent->u.var - 1)) {
+                       CG(active_op_array)->T--;
+               }
+               return;
+       }
+
        init_op(&opline TSRMLS_CC);
opline.opcode = ZEND_FETCH_DIM_W; /* the backpatching routine assumes W */
        opline.result.op_type = IS_VAR;
@@ -502,7 +526,6 @@ void fetch_array_dim(znode *result, znod
        opline.extended_value = ZEND_FETCH_STANDARD;
        *result = opline.result;

-       zend_stack_top(&CG(bp_stack), (void **) &fetch_list_ptr);
        zend_llist_add_element(fetch_list_ptr, &opline);
 }


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Ilia Alshanetsky

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to