Changeset 233 for trunk


Ignore:
Timestamp:
2006-10-10T02:46:00+02:00 (8 years ago)
Author:
moo
Message:

processor: apply reference handling on opcode caching. reverted [196] [199] [220] and refix for #36

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/processor/head.m4

    r230 r233  
    6262    HashTable zvalptrs; 
    6363    zend_bool reference; /* enable if to deal with reference */ 
     64    zend_bool have_references; 
    6465    const xc_entry_t *xce_src; 
    6566    const xc_entry_t *xce_dst; 
     
    261262} 
    262263/* }}} */ 
    263 static int xc_hash_static_member_check(xc_processor_t *processor, Bucket *b TSRMLS_DC) /* {{{ */ 
    264 { 
    265     const zend_class_entry *src = processor->active_class_entry_src; 
    266     if (src->parent) { 
    267         zval **parentzv; 
    268         if (zend_u_hash_quick_find(CE_STATIC_MEMBERS(src->parent), BUCKET_KEY_TYPE(b), ZSTR(BUCKET_KEY_S(b)), b->nKeyLength, b->h, (void **) &parentzv) == SUCCESS) { 
    269             zval **zv = (zval **) b->pData; 
    270             if (*parentzv == *zv) { 
    271                 return ZEND_HASH_APPLY_REMOVE; 
    272             } 
    273         } 
    274     } 
    275     return ZEND_HASH_APPLY_KEEP; 
    276 } 
    277 /* }}} */ 
    278 /* fix static members on restore */ 
    279 static void inherit_static_prop(zval **p) /* {{{ */ 
    280 { 
    281     /* already set */ 
    282 #if 0 
    283     (*p)->refcount++; 
    284     (*p)->is_ref = 1; 
    285 #endif 
    286 } 
    287 /* }}} */ 
    288 static void xc_fix_static_members(xc_processor_t *processor, zend_class_entry *dst TSRMLS_DC) /* {{{ */ 
    289 { 
    290     zend_hash_merge(&dst->default_static_members, &dst->parent->default_static_members, (void (*)(void *)) inherit_static_prop, NULL, sizeof(zval *), 0); 
    291 } 
    292 /* }}} */ 
    293 #endif 
    294 int xc_hash_reset_zval_refcount_applyer(void *pDest TSRMLS_DC) /* {{{ */ 
    295 { 
    296     zval **zv = (zval **) pDest; 
    297     ZVAL_REFCOUNT(*zv) = 1; 
    298     return ZEND_HASH_APPLY_KEEP; 
    299 } 
    300 /* }}} */ 
    301 static void xc_hash_reset_zval_refcount(HashTable *hash TSRMLS_DC) /* {{{ */ 
    302 { 
    303     zend_hash_apply(hash, xc_hash_reset_zval_refcount_applyer TSRMLS_CC); 
    304 } 
    305 /* }}} */ 
     264#endif 
    306265/* {{{ call op_array ctor handler */ 
    307266extern zend_bool xc_have_op_array_ctor; 
     
    320279 
    321280    memset(&processor, 0, sizeof(processor)); 
    322     if (src->type == XC_TYPE_VAR) { 
    323         processor.reference = 1; 
    324     } 
     281    processor.reference = 1; 
    325282 
    326283    IFASSERT(`xc_stack_init(&processor.allocsizes);') 
     
    343300    } 
    344301    src->size = processor.size; 
     302    src->have_references = processor.have_references; 
    345303 
    346304    IFASSERT(`xc_stack_reverse(&processor.allocsizes);') 
     
    394352    memset(&processor, 0, sizeof(processor)); 
    395353    processor.readonly_protection = readonly_protection; 
    396  
     354    if (src->have_references) { 
     355        processor.reference = 1; 
     356    } 
     357 
     358    if (processor.reference) { 
     359        zend_hash_init(&processor.zvalptrs, 0, NULL, NULL, 0); 
     360    } 
    397361    xc_restore_xc_entry_t(&processor, dst, src TSRMLS_CC); 
     362    if (processor.reference) { 
     363        zend_hash_destroy(&processor.zvalptrs); 
     364    } 
    398365    return dst; 
    399366} 
    400367/* }}} */ 
    401 /* export: zval *xc_processor_restore_zval(zval *dst, const zval *src TSRMLS_DC); :export {{{ */ 
    402 zval *xc_processor_restore_zval(zval *dst, const zval *src TSRMLS_DC) { 
     368/* export: zval *xc_processor_restore_zval(zval *dst, const zval *src, zend_bool have_references TSRMLS_DC); :export {{{ */ 
     369zval *xc_processor_restore_zval(zval *dst, const zval *src, zend_bool have_references TSRMLS_DC) { 
    403370    xc_processor_t processor; 
    404371 
    405372    memset(&processor, 0, sizeof(processor)); 
    406     processor.reference = 1; 
    407  
    408     zend_hash_init(&processor.zvalptrs, 0, NULL, NULL, 0); 
    409     dnl fprintf(stderr, "mark[%p] = %p\n", src, dst); 
    410     zend_hash_add(&processor.zvalptrs, (char *)src, sizeof(src), (void*)&dst, sizeof(dst), NULL); 
     373    processor.reference = have_references; 
     374 
     375    if (processor.reference) { 
     376        zend_hash_init(&processor.zvalptrs, 0, NULL, NULL, 0); 
     377        dnl fprintf(stderr, "mark[%p] = %p\n", src, dst); 
     378        zend_hash_add(&processor.zvalptrs, (char *)src, sizeof(src), (void*)&dst, sizeof(dst), NULL); 
     379    } 
    411380    xc_restore_zval(&processor, dst, src TSRMLS_CC); 
    412     zend_hash_destroy(&processor.zvalptrs); 
     381    if (processor.reference) { 
     382        zend_hash_destroy(&processor.zvalptrs); 
     383    } 
    413384 
    414385    return dst; 
  • trunk/processor/main.m4

    r198 r233  
    1111define(`m4_errprint', `ONCE(`errprint(`$1 
    1212')')') 
     13define(`ZEND_STRS', `($1), (sizeof($1))') 
     14define(`ZEND_STRL', `($1), (sizeof($1) - 1)') 
    1315dnl ============ 
    1416define(`INDENT', `xc_dprint_indent(indent);') 
  • trunk/processor/processor.m4

    r231 r233  
    6767dnl }}} 
    6868DEF_HASH_TABLE_FUNC(`HashTable_zval_ptr',           `zval_ptr') 
    69 DEF_HASH_TABLE_FUNC(`HashTable_zval_ptr_static_member_check',  `zval_ptr', , `xc_hash_static_member_check(processor, BUCKET TSRMLS_CC)') 
    7069#ifdef HAVE_XCACHE_CONSTANT 
    7170DEF_HASH_TABLE_FUNC(`HashTable_zend_constant',      `zend_constant') 
     
    168167                            dnl fprintf(stderr, "*dst is set to %p\n", dst[0]); 
    169168                        ') 
     169                        IFCALCSTORE(`processor->have_references = 1;') 
    170170                        IFSTORE(`assert(xc_is_shm(dst[0]));') 
    171171                        IFRESTORE(`assert(!xc_is_shm(dst[0]));') 
     
    300300 
    301301    STRUCT(HashTable, default_properties, HashTable_zval_ptr) 
    302     IFSTORE(`xc_hash_reset_zval_refcount(&dst->default_properties TSRMLS_CC);') 
    303302    IFCOPY(`dst->builtin_functions = src->builtin_functions;') 
    304303    DONE(builtin_functions) 
     
    306305    STRUCT(HashTable, properties_info, HashTable_zend_property_info) 
    307306#   ifdef ZEND_ENGINE_2_1 
    308     STRUCT(HashTable, default_static_members, IFCALCSTORE(HashTable_zval_ptr_static_member_check, HashTable_zval_ptr)) 
     307    STRUCT(HashTable, default_static_members, HashTable_zval_ptr) 
    309308    IFCOPY(`dst->static_members = &dst->default_static_members;') 
    310     IFRESTORE(`if (dst->parent) xc_fix_static_members(processor, dst TSRMLS_CC);') 
    311309    DONE(static_members) 
    312310#   else 
    313     STRUCT_P(HashTable, static_members, IFCALCSTORE(HashTable_zval_ptr_static_member_check, HashTable_zval_ptr)) 
     311    STRUCT_P(HashTable, static_members, HashTable_zval_ptr) 
    314312#   endif 
    315313    STRUCT(HashTable, constants_table, HashTable_zval_ptr) 
    316     IFSTORE(`xc_hash_reset_zval_refcount(&dst->constants_table TSRMLS_CC);') 
    317314 
    318315    dnl runtime binding: ADD_INTERFACE will deal with it 
     
    815812    DONE(data) 
    816813    dnl }}} 
     814    DISPATCH(zend_bool, have_references) 
    817815') 
    818816dnl }}} 
  • trunk/xcache-test.ini

    r225 r233  
    66zend_extension_ts=./modules/xcache.so 
    77zend_extension=./modules/xcache.so 
    8 xcache.cacher = On 
     8xcache.cacher = Off 
    99xcache.test=1 
    1010xcache.size = 1M 
  • trunk/xcache.c

    r230 r233  
    16731673        if (stored_xce) { 
    16741674            if (XG(request_time) <= stored_xce->ctime + stored_xce->ttl) { 
    1675                 xc_processor_restore_zval(return_value, stored_xce->data.var->value TSRMLS_CC); 
     1675                xc_processor_restore_zval(return_value, stored_xce->data.var->value, stored_xce->have_references TSRMLS_CC); 
    16761676                /* return */ 
    16771677                break; 
     
    18301830                    fprintf(stderr, "incdec: notlong\n"); 
    18311831#endif 
    1832                     xc_processor_restore_zval(&oldzval, stored_xce->data.var->value TSRMLS_CC); 
     1832                    xc_processor_restore_zval(&oldzval, stored_xce->data.var->value, stored_xce->have_references TSRMLS_CC); 
    18331833                    convert_to_long(&oldzval); 
    18341834                    value = Z_LVAL(oldzval); 
  • trunk/xcache.h

    r212 r233  
    249249        xc_entry_data_var_t *var; 
    250250    } data; 
     251 
     252    zend_bool  have_references; 
    251253}; 
    252254/* }}} */ 
Note: See TracChangeset for help on using the changeset viewer.