Changeset 212 for trunk/xcache.c


Ignore:
Timestamp:
2006-10-04T02:38:45+02:00 (9 years ago)
Author:
moo
Message:

fixed #41, early class binding

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xcache.c

    r205 r212  
    6666    } \
    6767} while(0)
     68
     69#ifndef max
     70#define max(a, b) ((a) < (b) ? (b) : (a))
     71#endif
    6872
    6973/* }}} */
     
    542546#endif
    543547
     548    CG(active_op_array) = p->op_array;
     549
    544550#ifdef HAVE_XCACHE_CONSTANT
    545551    /* install constant */
     
    571577        new_cest_ptrs[i] =
    572578#endif
    573         xc_install_class(xce->name.str.val, &ci->cest,
     579        xc_install_class(xce->name.str.val, &ci->cest, ci->oplineno,
    574580                UNISW(0, ci->type), ci->key, ci->key_size TSRMLS_CC);
    575581    }
     
    771777    xce->type = XC_TYPE_PHP;
    772778    return 1;
     779}
     780/* }}} */
     781static void xc_cache_early_binding_class_cb(zend_op *opline, int oplineno, void *data TSRMLS_DC) /* {{{ */
     782{
     783    char *class_name;
     784    int i, class_len;
     785    xc_cest_t cest;
     786    xc_entry_data_php_t *php = (xc_entry_data_php_t *) data;
     787
     788    class_name = opline->op1.u.constant.value.str.val;
     789    class_len  = opline->op1.u.constant.value.str.len;
     790    if (zend_hash_find(CG(class_table), class_name, class_len, (void **) &cest) == FAILURE) {
     791        assert(0);
     792    }
     793#ifdef DEBUG
     794    fprintf(stderr, "got ZEND_DECLARE_INHERITED_CLASS: %s\n", class_name + 1);
     795#endif
     796    /* let's see which class */
     797    for (i = 0; i < php->classinfo_cnt; i ++) {
     798        if (memcmp(ZSTR_S(php->classinfos[i].key), class_name, class_len) == 0) {
     799            php->classinfos[i].oplineno = oplineno;
     800            php->have_early_binding = 1;
     801            break;
     802        }
     803    }
     804
     805    if (i == php->classinfo_cnt) {
     806        assert(0);
     807    }
    773808}
    774809/* }}} */
     
    785820    char opened_path_buffer[MAXPATHLEN];
    786821    int old_constinfo_cnt, old_funcinfo_cnt, old_classinfo_cnt;
     822    int i;
    787823
    788824    if (!xc_initized) {
     
    895931#ifdef HAVE_INODE
    896932    if (xce.data.php->inode)
    897 #endif
    898933    {
    899934        if (xce.name.str.val != filename) {
     
    902937        }
    903938    }
     939#endif
    904940
    905941#ifdef HAVE_XCACHE_OPTIMIZER
     
    908944    }
    909945#endif
    910 
     946    /* }}} */
     947    /* {{{ prepare */
    911948    php.op_array      = op_array;
    912949
     
    9721009    }
    9731010    /* }}} */
     1011    /* {{{ find inherited classes that should be early-binding */
     1012    php.have_early_binding = 0;
     1013    for (i = 0; i < php.classinfo_cnt; i ++) {
     1014        php.classinfos[i].oplineno = -1;
     1015    }
     1016
     1017    xc_undo_pass_two(php.op_array TSRMLS_CC);
     1018    xc_foreach_early_binding_class(php.op_array, xc_cache_early_binding_class_cb, (void *) &php TSRMLS_CC);
     1019    xc_redo_pass_two(php.op_array TSRMLS_CC);
     1020    /* }}} */
    9741021    ENTER_LOCK_EX(cache) { /* {{{ store/add entry */
    9751022        stored_xce = xc_entry_store_dmz(&xce TSRMLS_CC);
     
    10011048    }
    10021049    else {
     1050        CG(active_op_array) = op_array;
    10031051        xc_sandbox_free(&sandbox, 1 TSRMLS_CC);
    10041052    }
Note: See TracChangeset for help on using the changeset viewer.