Changeset 1321 in svn for trunk/mod_cacher/xc_cacher.c


Ignore:
Timestamp:
2013-07-15T17:37:57Z (2 years ago)
Author:
Xuefer
Message:

add back PHP_4 code for disassembler

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mod_cacher/xc_cacher.c

    r1313 r1321  
    763763    xc_entry_data_php_t *p = entry_php->php;
    764764    zend_op_array *old_active_op_array = CG(active_op_array);
     765#ifndef ZEND_ENGINE_2
     766    ALLOCA_FLAG(use_heap)
     767    /* new ptr which is stored inside CG(class_table) */
     768    xc_cest_t **new_cest_ptrs = (xc_cest_t **)xc_do_alloca(sizeof(xc_cest_t*) * p->classinfo_cnt, use_heap);
     769#endif
    765770
    766771    CG(active_op_array) = p->op_array;
     
    785790    for (i = 0; i < p->classinfo_cnt; i ++) {
    786791        xc_classinfo_t *ci = &p->classinfos[i];
     792#ifndef ZEND_ENGINE_2
     793        zend_class_entry *ce = CestToCePtr(ci->cest);
     794        /* fix pointer to the be which inside class_table */
     795        if (ce->parent) {
     796            zend_uint class_idx = (/* class_num */ (int) (long) ce->parent) - 1;
     797            assert(class_idx < i);
     798            ci->cest.parent = new_cest_ptrs[class_idx];
     799        }
     800        new_cest_ptrs[i] =
     801#endif
    787802#ifdef ZEND_COMPILE_DELAYED_BINDING
    788         xc_install_class(entry_php->entry.name.str.val, ci->class_entry, -1,
     803        xc_install_class(entry_php->entry.name.str.val, &ci->cest, -1,
    789804                UNISW(0, ci->type), ci->key, ci->key_size, ci->h TSRMLS_CC);
    790805#else
    791         xc_install_class(entry_php->entry.name.str.val, ci->class_entry, ci->oplineno,
     806        xc_install_class(entry_php->entry.name.str.val, &ci->cest, ci->oplineno,
    792807                UNISW(0, ci->type), ci->key, ci->key_size, ci->h TSRMLS_CC);
    793808#endif
     
    811826#endif
    812827
     828    i = 1;
     829#ifndef ZEND_ENGINE_2_2
     830    zend_hash_add(&EG(included_files), entry_php->entry.name.str.val, entry_php->entry.name.str.len+1, (void *)&i, sizeof(int), NULL);
     831#endif
     832
     833#ifndef ZEND_ENGINE_2
     834    xc_free_alloca(new_cest_ptrs, use_heap);
     835#endif
    813836    CG(active_op_array) = old_active_op_array;
    814837    return p->op_array;
     
    9961019        wrapper = php_stream_locate_url_wrapper(filepath, &path_for_open, 0 TSRMLS_CC);
    9971020        if (wrapper && wrapper->wops->url_stat
    998          && wrapper->wops->url_stat(wrapper, path_for_open, PHP_STREAM_URL_STAT_QUIET, &ssb, NULL TSRMLS_CC) == SUCCESS) {
     1021#ifdef ZEND_ENGINE_2
     1022         && wrapper->wops->url_stat(wrapper, path_for_open, PHP_STREAM_URL_STAT_QUIET, &ssb, NULL TSRMLS_CC) == SUCCESS
     1023#else
     1024         && wrapper->wops->url_stat(wrapper, path_for_open, &ssb TSRMLS_CC) == SUCCESS
     1025#endif
     1026        ) {
    9991027            *statbuf = ssb.sb;
    10001028            return SUCCESS;
     
    12741302    zend_uint i;
    12751303    int class_len;
    1276     zend_class_entry *class_entry;
     1304    xc_cest_t cest;
    12771305    xc_entry_data_php_t *php = (xc_entry_data_php_t *) data;
    12781306
    12791307    class_name = Z_OP_CONSTANT(opline->op1).value.str.val;
    12801308    class_len  = Z_OP_CONSTANT(opline->op1).value.str.len;
    1281     if (zend_hash_find(CG(class_table), class_name, class_len, (void **) &class_entry) == FAILURE) {
     1309    if (zend_hash_find(CG(class_table), class_name, class_len, (void **) &cest) == FAILURE) {
    12821310        assert(0);
    12831311    }
     
    17221750
    17231751#ifdef HAVE_XCACHE_CONSTANT
    1724         b = EG(zend_constants)->pListHead; COPY_H(xc_constinfo_t, constinfos, constinfo_cnt, constant,    zend_constant);
    1725 #endif
    1726         b = CG(function_table)->pListHead; COPY_H(xc_funcinfo_t,  funcinfos,  funcinfo_cnt,  func,        zend_function);
    1727         b = CG(class_table)->pListHead;    COPY_H(xc_classinfo_t, classinfos, classinfo_cnt, class_entry, zend_class_entry *);
     1752        b = EG(zend_constants)->pListHead; COPY_H(xc_constinfo_t, constinfos, constinfo_cnt, constant, zend_constant);
     1753#endif
     1754        b = CG(function_table)->pListHead; COPY_H(xc_funcinfo_t,  funcinfos,  funcinfo_cnt,  func,     zend_function);
     1755        b = CG(class_table)->pListHead;    COPY_H(xc_classinfo_t, classinfos, classinfo_cnt, cest,     xc_cest_t);
    17281756
    17291757#undef COPY_H
     1758
     1759        /* for ZE1, cest need to be fixed inside store */
    17301760
    17311761#ifdef ZEND_ENGINE_2_1
     
    17651795        for (i = 0; i < compiler->new_php.classinfo_cnt; i ++) {
    17661796            xc_classinfo_t *classinfo = &compiler->new_php.classinfos[i];
    1767             classinfo->methodinfo_cnt = classinfo->class_entry->function_table.nTableSize;
     1797            zend_class_entry *ce = CestToCePtr(classinfo->cest);
     1798            classinfo->methodinfo_cnt = ce->function_table.nTableSize;
    17681799            if (classinfo->methodinfo_cnt) {
    17691800                int j;
     
    17741805                }
    17751806
    1776                 for (j = 0, b = classinfo->class_entry->function_table.pListHead; b; j ++, b = b->pListNext) {
     1807                for (j = 0, b = ce->function_table.pListHead; b; j ++, b = b->pListNext) {
    17771808                    xc_collect_op_array_info(compiler, &const_usage, &classinfo->methodinfos[j], (zend_op_array *) b->pData TSRMLS_CC);
    17781809                }
     
    19742005        /* discard newly compiled result, restore from stored one */
    19752006        if (compiler->new_php.op_array) {
     2007#ifdef ZEND_ENGINE_2
    19762008            destroy_op_array(compiler->new_php.op_array TSRMLS_CC);
     2009#else
     2010            destroy_op_array(compiler->new_php.op_array);
     2011#endif
    19772012            efree(compiler->new_php.op_array);
    19782013            compiler->new_php.op_array = NULL;
     
    21482183     || !h->filename
    21492184     || !SG(request_info).path_translated
    2150 
    21512185    ) {
    21522186        TRACE("%s", "cacher not enabled");
     
    22372271{
    22382272    xc_gc_op_array_t *op_array = (xc_gc_op_array_t *) pDest;
    2239     zend_uint i;
     2273#ifdef ZEND_ENGINE_2
    22402274    if (op_array->arg_info) {
     2275        zend_uint i;
    22412276        for (i = 0; i < op_array->num_args; i++) {
    22422277            efree((char *) ZSTR_V(op_array->arg_info[i].name));
     
    22472282        efree(op_array->arg_info);
    22482283    }
     2284#endif
    22492285    if (op_array->opcodes) {
    22502286        efree(op_array->opcodes);
     
    27622798{
    27632799    if (!XG(internal_table_copied)) {
    2764         zend_function dummy_func;
    2765         zend_class_entry *dummy_class_entry;
     2800        zend_function tmp_func;
     2801        xc_cest_t tmp_cest;
    27662802
    27672803#ifdef HAVE_XCACHE_CONSTANT
     
    27802816        xc_copy_internal_zend_constants(&XG(internal_constant_table), EG(zend_constants));
    27812817#endif
    2782         zend_hash_copy(&XG(internal_function_table), CG(function_table), NULL, &dummy_func, sizeof(dummy_func));
    2783         zend_hash_copy(&XG(internal_class_table), CG(class_table), NULL, &dummy_class_entry, sizeof(dummy_class_entry));
     2818        zend_hash_copy(&XG(internal_function_table), CG(function_table), NULL, &tmp_func, sizeof(tmp_func));
     2819        zend_hash_copy(&XG(internal_class_table), CG(class_table), NULL, &tmp_cest, sizeof(tmp_cest));
    27842820
    27852821        XG(internal_table_copied) = 1;
     
    27872823    xc_holds_init(TSRMLS_C);
    27882824    xc_var_namespace_init(TSRMLS_C);
     2825#ifdef ZEND_ENGINE_2
    27892826    zend_llist_init(&XG(gc_op_arrays), sizeof(xc_gc_op_array_t), xc_gc_op_array, 0);
     2827#endif
    27902828
    27912829#if PHP_API_VERSION <= 20041225
     
    28082846    xc_gc_deletes(TSRMLS_C);
    28092847    xc_var_namespace_destroy(TSRMLS_C);
     2848#ifdef ZEND_ENGINE_2
    28102849    zend_llist_destroy(&XG(gc_op_arrays));
     2850#endif
    28112851}
    28122852/* }}} */
     
    37393779}
    37403780/* }}} */
    3741 /* {{{ static ZEND_MODULE_POST_ZEND_DEACTIVATE_D(xcache_cacher) */
     3781/* {{{ static PHP_RSHUTDOWN_FUNCTION(xcache_cacher) */
     3782#ifndef ZEND_ENGINE_2
     3783static PHP_RSHUTDOWN_FUNCTION(xcache_cacher)
     3784#else
    37423785static ZEND_MODULE_POST_ZEND_DEACTIVATE_D(xcache_cacher)
    3743 {
     3786#endif
     3787{
     3788#ifdef ZEND_ENGINE_2
    37443789    TSRMLS_FETCH();
     3790#endif
    37453791
    37463792    xc_request_shutdown(TSRMLS_C);
     
    37553801    PHP_MSHUTDOWN(xcache_cacher),
    37563802    PHP_RINIT(xcache_cacher),
     3803#ifndef ZEND_ENGINE_2
     3804    PHP_RSHUTDOWN(xcache_cacher),
     3805#else
    37573806    NULL,
     3807#endif
    37583808    PHP_MINFO(xcache_cacher),
    37593809    XCACHE_VERSION,
     
    37613811    NO_MODULE_GLOBALS,
    37623812#endif
     3813#ifdef ZEND_ENGINE_2
    37633814    ZEND_MODULE_POST_ZEND_DEACTIVATE_N(xcache_cacher),
     3815#else
     3816    NULL,
     3817    NULL,
     3818#endif
    37643819    STANDARD_MODULE_PROPERTIES_EX
    37653820};
Note: See TracChangeset for help on using the changeset viewer.