Changeset 1558 in svn for trunk/processor/foot.m4


Ignore:
Timestamp:
2014-11-10T06:08:07Z (5 years ago)
Author:
Xuefer
Message:

closes #342: object caching

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/processor/foot.m4

    r1551 r1558  
    8484dnl }}}
    8585')
    86 DEFINE_STORE_API(`xc_entry_var_t')
    8786DEFINE_STORE_API(`xc_entry_php_t')
    8887DEFINE_STORE_API(`xc_entry_data_php_t')
     88DEFINE_STORE_API(`xc_entry_var_t')
    8989EXPORTED_FUNCTION(`xc_entry_php_t *xc_processor_restore_xc_entry_php_t(xc_entry_php_t *dst, const xc_entry_php_t *src TSRMLS_DC)') dnl {{{
    9090{
     
    119119}
    120120dnl }}}
    121 EXPORTED_FUNCTION(`zval *xc_processor_restore_zval(zval *dst, const zval *src, zend_bool have_references TSRMLS_DC)') dnl {{{
     121EXPORTED_FUNCTION(`zval *xc_processor_restore_var(zval *dst, const xc_entry_var_t *src TSRMLS_DC)') dnl {{{
    122122{
    123123    xc_processor_t processor;
     124    size_t i;
    124125
    125126    memset(&processor, 0, sizeof(processor));
    126     processor.handle_reference = have_references;
     127    processor.handle_reference = src->have_references;
    127128
    128129    if (processor.handle_reference) {
    129130        zend_hash_init(&processor.zvalptrs, 0, NULL, NULL, 0);
    130131        dnl fprintf(stderr, "mark[%p] = %p\n", src, dst);
    131         zend_hash_add(&processor.zvalptrs, (char *)src, sizeof(src), (void*)&dst, sizeof(dst), NULL);
     132        zend_hash_add(&processor.zvalptrs, (char *)src->value, sizeof(src->value), (void *) &dst, sizeof(dst), NULL);
    132133    }
    133     xc_restore_zval(&processor, dst, src TSRMLS_CC);
     134    processor.entry_var_src = src;
     135
     136#ifdef ZEND_ENGINE_2
     137    if (src->objects_count) {
     138        processor.object_handles = emalloc(sizeof(*processor.object_handles) * src->objects_count);
     139        xc_vector_init(zend_object_handle, &processor.objects, 0);
     140        for (i = 0; i < src->objects_count; ++i) {
     141            zend_object *object = emalloc(sizeof(*object));
     142            xc_restore_zend_object(&processor, object, &src->objects[i] TSRMLS_CC);
     143            processor.object_handles[i] = zend_objects_store_put(object, (zend_objects_store_dtor_t) zend_objects_destroy_object, (zend_objects_free_object_storage_t) zend_objects_free_object_storage, NULL TSRMLS_CC);
     144        }
     145    }
     146#endif
     147    xc_restore_zval(&processor, dst, src->value TSRMLS_CC);
    134148    if (processor.handle_reference) {
    135149        zend_hash_destroy(&processor.zvalptrs);
    136150    }
     151
     152#ifdef ZEND_ENGINE_2
     153    if (src->objects_count) {
     154        for (i = 0; i < src->objects_count; ++i) {
     155            zend_objects_store_del_ref_by_handle_ex(processor.object_handles[i], NULL TSRMLS_CC);
     156        }
     157        efree(processor.object_handles);
     158    }
     159#endif
    137160
    138161    return dst;
Note: See TracChangeset for help on using the changeset viewer.