Changeset 291


Ignore:
Timestamp:
02/13/07 16:11:14 (4 years ago)
Author:
bart
Message:

Cleanup: Removed some commented out code, changed some debug statements,

reordered some conditional includes to reduce ifdef statements

Location:
eaccelerator/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • eaccelerator/trunk/ChangeLog

    r290 r291  
    55        * Fixed a nullpointer dereference in some special cases in ea_restore.c:509 
    66        * Always compile a ea_debug_error message in ea_restore.c 
     7        * Cleanup: Removed some commented out code, changed some debug statements, 
     8            reordered some conditional includes to reduce ifdef statements 
    79 
    8102007-01-29  Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> 
  • eaccelerator/trunk/ea_restore.c

    r290 r291  
    583583        } 
    584584#endif 
    585         to->opcodes = from->opcodes; 
    586         to->last = to->size = from->last; 
    587         to->T = from->T; 
    588         to->brk_cont_array = from->brk_cont_array; 
    589         to->last_brk_cont = from->last_brk_cont; 
    590          
    591            to->current_brk_cont = -1; 
    592            to->static_variables = from->static_variables; 
    593 /*         to->start_op         = to->opcodes; */ 
    594            to->backpatch_count  = 0; 
    595          
    596         to->return_reference = from->return_reference; 
    597         to->done_pass_two = 1; 
    598         to->filename = from->filename; 
    599 /*      if (from->filename != NULL) { 
    600                 size_t len = strlen(from->filename) + 1; 
    601                 to->filename = emalloc(len); 
    602                 memcpy(to->filename, from->filename, len); 
    603         }*/ 
    604  
    605 #ifdef ZEND_ENGINE_2 
    606         /* HOESH: try & catch support */ 
    607         to->try_catch_array = from->try_catch_array; 
    608         to->last_try_catch = from->last_try_catch; 
     585    to->opcodes = from->opcodes; 
     586    to->last = to->size = from->last; 
     587    to->T = from->T; 
     588    to->brk_cont_array = from->brk_cont_array; 
     589    to->last_brk_cont = from->last_brk_cont; 
     590 
     591    to->current_brk_cont = -1; 
     592    to->static_variables = from->static_variables; 
     593    to->backpatch_count  = 0; 
     594 
     595    to->return_reference = from->return_reference; 
     596    to->done_pass_two = 1; 
     597    to->filename = from->filename; 
     598 
     599#ifdef ZEND_ENGINE_2 
     600    to->try_catch_array = from->try_catch_array; 
     601    to->last_try_catch = from->last_try_catch; 
    609602        to->uses_this = from->uses_this; 
    610603 
     
    639632        to->last_var         = from->last_var; 
    640633        to->size_var         = 0; 
    641 /*      if (from->vars) { 
    642                 zend_uint i; 
    643                 to->vars = (zend_compiled_variable*)emalloc(from->last_var*sizeof(zend_compiled_variable));              
    644                 memcpy(to->vars, from->vars, sizeof(zend_compiled_variable) * from->last_var); 
    645                 for (i = 0; i < from->last_var; i ++) { 
    646                         to->vars[i].name = estrndup(from->vars[i].name, from->vars[i].name_len); 
    647                 } 
    648         }*/ 
    649634#endif 
    650635 
     
    795780        memset(to, 0, sizeof(zend_class_entry)); 
    796781        to->type = from->type; 
    797         /* 
    798            to->name        = NULL; 
    799            to->name_length = from->name_length; 
    800            to->constants_updated = 0; 
    801            to->parent      = NULL; 
    802          */ 
    803 #ifdef ZEND_ENGINE_2 
    804         to->ce_flags = from->ce_flags; 
    805         to->num_interfaces = from->num_interfaces; 
    806         to->interfaces = NULL; 
    807  
    808         if (to->num_interfaces > 0) { 
    809                 /* hrak: Allocate the slots which will later be populated by ZEND_ADD_INTERFACE */ 
    810                 to->interfaces = (zend_class_entry **) emalloc(sizeof(zend_class_entry *) * to->num_interfaces); 
    811                 memset(to->interfaces, 0, sizeof(zend_class_entry *) * to->num_interfaces); 
    812         } 
    813 #endif 
    814782 
    815783        if (from->name != NULL) { 
     
    823791 
    824792#ifdef ZEND_ENGINE_2 
     793    to->ce_flags = from->ce_flags; 
     794    to->num_interfaces = from->num_interfaces; 
     795    to->interfaces = NULL; 
    825796        to->refcount = 1; 
    826  
    827797        to->line_start = from->line_start; 
    828798        to->line_end = from->line_end; 
     799     
     800    if (to->num_interfaces > 0) { 
     801        /* hrak: Allocate the slots which will later be populated by ZEND_ADD_INTERFACE */ 
     802        to->interfaces = (zend_class_entry **) emalloc(sizeof(zend_class_entry *) * to->num_interfaces); 
     803        memset(to->interfaces, 0, sizeof(zend_class_entry *) * to->num_interfaces); 
     804    } 
    829805#ifdef INCLUDE_DOC_COMMENTS 
    830806        to->doc_comment_len = from->doc_comment_len; 
     807    if (from->doc_comment != NULL) { 
     808        to->doc_comment = emalloc(from->doc_comment_len + 1); 
     809        memcpy(to->doc_comment, from->doc_comment, from->doc_comment_len + 1); 
     810    } 
    831811#else 
    832812        to->doc_comment_len = 0; 
    833813    to->doc_comment = NULL; 
    834814#endif 
    835 /*      if (from->filename != NULL) { 
    836                 size_t len = strlen(from->filename) + 1; 
    837                 to->filename = emalloc(len); 
    838                 memcpy(to->filename, from->filename, len); 
    839         }*/ 
    840         to->filename = from->filename; 
    841 #ifdef INCLUDE_DOC_COMMENTS 
    842      if (from->doc_comment != NULL) { 
    843      to->doc_comment = emalloc(from->doc_comment_len + 1); 
    844      memcpy(to->doc_comment, from->doc_comment, from->doc_comment_len + 1); 
    845      } 
    846 #endif 
     815 
     816    to->filename = from->filename; 
    847817 
    848818        /* restore constants table */ 
     
    853823        to->default_properties.pDestructor = ZVAL_PTR_DTOR; 
    854824        /* restore properties */ 
    855         restore_hash(&to->properties_info, &from->properties_info,  
    856             (restore_bucket_t) restore_property_info TSRMLS_CC); 
     825        restore_hash(&to->properties_info, &from->properties_info, (restore_bucket_t) restore_property_info TSRMLS_CC); 
    857826        to->properties_info.pDestructor = properties_info_dtor; 
    858827 
     
    891860        } 
    892861#endif 
     862 
    893863        if (from->parent != NULL) { 
    894864                restore_class_parent(from->parent, strlen(from->parent), to TSRMLS_CC); 
     
    905875        restore_class_methods(to TSRMLS_CC); 
    906876#endif 
    907         if (to->parent) 
     877 
     878        if (to->parent) { 
    908879#ifdef ZEND_ENGINE_2 
    909880                zend_do_inheritance(to, to->parent TSRMLS_CC); 
     
    911882        zend_do_inheritance(to, to->parent); 
    912883#endif 
     884    } 
    913885        EAG(class_entry) = old; 
    914886 
  • eaccelerator/trunk/ea_store.c

    r286 r291  
    191191                EAG(compress) = 0; 
    192192                for (; opline < end; opline++) { 
    193 /* 
    194       if (opline->result.op_type == IS_CONST) calc_zval(&opline->result.u.constant  TSRMLS_CC); 
    195 */ 
    196193                        if (opline->op1.op_type == IS_CONST) 
    197194                                calc_zval(&opline->op1.u.constant TSRMLS_CC); 
     
    206203        } 
    207204#ifdef ZEND_ENGINE_2 
    208         /* HOESH: try & catch support */ 
    209205        if (from->try_catch_array != NULL) { 
    210206                EACCELERATOR_ALIGN(EAG(mem)); 
     
    261257    calc_zval_hash(&from->constants_table); 
    262258        calc_zval_hash(&from->default_properties); 
    263  
    264259        calc_hash(&from->properties_info, (calc_bucket_t) calc_property_info); 
    265260 
     
    592587        to->last_try_catch = from->last_try_catch; 
    593588        to->uses_this = from->uses_this; 
     589    if (from->try_catch_array != NULL) { 
     590        EACCELERATOR_ALIGN(EAG(mem)); 
     591        to->try_catch_array = (zend_try_catch_element *) EAG(mem); 
     592        EAG(mem) += sizeof(zend_try_catch_element) * from->last_try_catch; 
     593        memcpy(to->try_catch_array, from->try_catch_array, sizeof(zend_try_catch_element) * from->last_try_catch); 
     594    } else { 
     595        to->last_try_catch = 0; 
     596    } 
    594597#else 
    595598        to->uses_globals = from->uses_globals; 
    596599#endif 
     600 
    597601        to->static_variables = from->static_variables; 
    598602        to->return_reference = from->return_reference; 
     
    609613                EAG(compress) = 0; 
    610614                for (; opline < end; opline++) { 
    611                         /* 
    612                            if (opline->result.op_type == IS_CONST)  
    613                            store_zval(&opline->result.u.constant TSRMLS_CC); 
    614                          */ 
    615615                        if (opline->op1.op_type == IS_CONST) 
    616616                                store_zval(&opline->op1.u.constant TSRMLS_CC); 
     
    641641                to->last_brk_cont = 0; 
    642642        } 
    643 #ifdef ZEND_ENGINE_2 
    644         if (from->try_catch_array != NULL) { 
    645                 EACCELERATOR_ALIGN(EAG(mem)); 
    646                 to->try_catch_array = (zend_try_catch_element *) EAG(mem); 
    647                 EAG(mem) += sizeof(zend_try_catch_element) * from->last_try_catch; 
    648                 memcpy(to->try_catch_array, from->try_catch_array, sizeof(zend_try_catch_element) * from->last_try_catch); 
    649         } else { 
    650                 to->last_try_catch = 0; 
    651         } 
    652 #endif 
     643 
    653644        if (from->static_variables != NULL) { 
    654645                EACCELERATOR_ALIGN(EAG(mem)); 
     
    672663                to->vars = NULL; 
    673664        } 
    674 #endif 
    675         if (from->filename != NULL) { 
    676                 to->filename = store_string(from->filename, strlen(from->filename) + 1 TSRMLS_CC); 
    677         } 
    678 #ifdef ZEND_ENGINE_2 
    679         to->line_start = from->line_start; 
    680         to->line_end = from->line_end; 
    681 #ifdef INCLUDE_DOC_COMMENTS 
     665    to->line_start = from->line_start; 
     666    to->line_end = from->line_end; 
     667#  ifdef INCLUDE_DOC_COMMENTS 
    682668    to->doc_comment_len = from->doc_comment_len; 
    683669    if (from->doc_comment != NULL) 
    684670        to->doc_comment = store_string(from->doc_comment, from->doc_comment_len + 1 TSRMLS_CC); 
    685 #endif 
    686 #endif 
     671#  endif 
     672#endif 
     673 
     674        if (from->filename != NULL) { 
     675                to->filename = store_string(from->filename, strlen(from->filename) + 1 TSRMLS_CC); 
     676        } 
    687677        return to; 
    688678} 
     
    698688        to->name = store_string(from->name, from->name_length + 1 TSRMLS_CC); 
    699689#ifdef ZEND_ENGINE_2_1 
    700 #ifdef INCLUDE_DOC_COMMENTS 
    701 to->doc_comment_len = from->doc_comment_len;  
    702 if (from->doc_comment != NULL) {  
     690#  ifdef INCLUDE_DOC_COMMENTS 
     691    to->doc_comment_len = from->doc_comment_len;  
     692    if (from->doc_comment != NULL) {  
    703693       to->doc_comment = store_string(from->doc_comment, from->doc_comment_len + 1 TSRMLS_CC); 
    704 } 
    705 #else 
     694    } 
     695#  else 
    706696        to->doc_comment_len = 0; 
    707697        to->doc_comment = NULL; 
     
    816806        to->name_length = from->name_length; 
    817807        to->parent = NULL; 
    818 #ifdef ZEND_ENGINE_2 
    819         to->ce_flags = from->ce_flags; 
    820         to->static_members = NULL; 
    821  
    822         /* 
    823          * Scan the interfaces looking for the first one which isn't 0 
    824          * This is the first inherited interface and should not be counted in the stored object 
    825          */ 
    826         for (i = 0 ; i < from->num_interfaces ; i++) { 
    827                 if (from->interfaces[i] != 0) { 
    828                         break; 
    829                 } 
    830         } 
    831         to->num_interfaces = i; 
    832         DBG(ea_debug_printf, (EA_DEBUG, "from->num_interfaces=%d, to->num_interfaces=%d\n", from->num_interfaces, to->num_interfaces)); 
    833  
    834         /* 
    835          * hrak: no need to really store the interfaces since these get populated 
    836          * at/after restore by zend_do_inheritance and ZEND_ADD_INTERFACE 
    837          */ 
    838 #endif 
    839808 
    840809        DBG(ea_debug_pad, (EA_DEBUG TSRMLS_CC)); 
     
    846815#endif 
    847816 
    848         if (from->name != NULL) 
     817        if (from->name != NULL) { 
    849818                to->name = store_string(from->name, from->name_length + 1 TSRMLS_CC); 
    850         if (from->parent != NULL && from->parent->name) 
    851                 to->parent = store_string(from->parent->name, from->parent->name_length + 1 TSRMLS_CC); 
    852  
    853 #ifdef ZEND_ENGINE_2 
     819    } 
     820    if (from->parent != NULL && from->parent->name) { 
     821        to->parent = store_string(from->parent->name, from->parent->name_length + 1 TSRMLS_CC); 
     822    } 
     823 
     824#ifdef ZEND_ENGINE_2 /* php >= 5.0 */ 
     825    to->ce_flags = from->ce_flags; 
     826    to->static_members = NULL; 
     827 
     828    /* 
     829     * Scan the interfaces looking for the first one which isn't 0 
     830     * This is the first inherited interface and should not be counted in the stored object 
     831     */ 
     832    for (i = 0 ; i < from->num_interfaces ; i++) { 
     833        if (from->interfaces[i] != 0) { 
     834            break; 
     835        } 
     836    } 
     837    to->num_interfaces = i; 
     838 
     839    /* 
     840     * hrak: no need to really store the interfaces since these get populated 
     841     * at/after restore by zend_do_inheritance and ZEND_ADD_INTERFACE 
     842     */ 
     843      
    854844        to->line_start = from->line_start; 
    855845        to->line_end = from->line_end; 
     
    867857        store_zval_hash(&to->constants_table, &from->constants_table); 
    868858        store_zval_hash(&to->default_properties, &from->default_properties); 
    869         //store_hash(&to->properties_info, &from->properties_info, (store_bucket_t) store_property_info, NULL, NULL); 
    870859        store_hash(&to->properties_info, &from->properties_info, (store_bucket_t) store_property_info, (check_bucket_t) store_property_access_check, from); 
    871 #  ifdef ZEND_ENGINE_2_1 
    872         if((from->static_members != NULL) && (from->static_members != &from->default_static_members)) { 
     860     
     861#  ifdef ZEND_ENGINE_2_1 /* php >= 5.1 */ 
     862        if ((from->static_members != NULL) && (from->static_members != &from->default_static_members)) { 
    873863                store_zval_hash(&to->default_static_members, &from->default_static_members); 
    874864                EACCELERATOR_ALIGN(EAG(mem)); 
     
    877867                store_hash(to->static_members, from->static_members, (store_bucket_t) store_zval_ptr, (check_bucket_t) store_static_member_access_check, from); 
    878868        } else { 
    879                 /*EACCELERATOR_ALIGN(EAG(mem)); 
    880                 to->static_members = (HashTable *) EAG(mem); 
    881                 EAG(mem) += sizeof(HashTable);*/ 
    882869                store_hash(&to->default_static_members, &from->default_static_members, (store_bucket_t) store_zval_ptr, (check_bucket_t) store_static_member_access_check, from); 
    883870                to->static_members = &to->default_static_members; 
    884871        } 
    885 #  elif defined(ZEND_ENGINE_2) && !defined(ZEND_ENGINE_2_1) 
    886         /* for php-5.0 */ 
    887         if(from->static_members != NULL) { 
     872#  else /* php == 5.0 */ 
     873        if (from->static_members != NULL) { 
    888874                EACCELERATOR_ALIGN(EAG(mem)); 
    889875                to->static_members = (HashTable *) EAG(mem); 
     
    892878        }        
    893879#  endif 
    894 #else 
     880    store_hash(&to->function_table, &from->function_table, (store_bucket_t) store_op_array, (check_bucket_t) store_function_inheritance_check, from); 
     881     
     882#else /* PHP 4 */ 
    895883        store_zval_hash(&to->default_properties, &from->default_properties); 
    896 #endif 
    897  
    898 #ifdef ZEND_ENGINE_2 
    899         store_hash(&to->function_table, &from->function_table, (store_bucket_t) store_op_array, (check_bucket_t) store_function_inheritance_check, from); 
    900 #else 
    901         store_hash(&to->function_table, &from->function_table, (store_bucket_t) store_op_array, NULL, NULL); 
     884    store_hash(&to->function_table, &from->function_table, (store_bucket_t) store_op_array, NULL, NULL); 
    902885#endif 
    903886 
     
    911894/* Create a cache entry from the given op_array, functions and classes of a 
    912895   script */ 
    913 ea_cache_entry *eaccelerator_store_int (char *key, int len,  
     896ea_cache_entry *eaccelerator_store_int(char *key, int len,  
    914897        zend_op_array *op_array, Bucket *f, Bucket *c TSRMLS_DC) 
    915898{ 
     
    920903 
    921904    DBG(ea_debug_pad, (EA_DEBUG TSRMLS_CC)); 
    922     DBG(ea_debug_printf, (EA_DEBUG, "[%d] eaccelerator_store_int: key='%s'\n",  
    923                 getpid (), key)); 
    924  
    925     EAG (compress) = 1; 
    926     zend_hash_init (&EAG (strings), 0, NULL, NULL, 0); 
     905    DBG(ea_debug_printf, (EA_DEBUG, "[%d] eaccelerator_store_int: key='%s'\n", getpid (), key)); 
     906 
     907    EAG(compress) = 1; 
     908    zend_hash_init(&EAG(strings), 0, NULL, NULL, 0); 
    927909    p = (ea_cache_entry *) EAG (mem); 
    928     EAG (mem) += offsetof (ea_cache_entry, realfilename) + len + 1; 
     910    EAG(mem) += offsetof(ea_cache_entry, realfilename) + len + 1; 
    929911 
    930912    p->nhits = 0; 
     
    933915    p->f_head = NULL; 
    934916    p->c_head = NULL; 
    935     memcpy (p->realfilename, key, len + 1); 
     917    memcpy(p->realfilename, key, len + 1); 
    936918    x = p->realfilename; 
    937     zend_hash_add (&EAG (strings), key, len + 1, &x, sizeof (char *), NULL); 
     919    zend_hash_add(&EAG(strings), key, len + 1, &x, sizeof(char *), NULL); 
    938920 
    939921    q = NULL; 
    940922    while (c != NULL) { 
    941923        DBG(ea_debug_pad, (EA_DEBUG TSRMLS_CC)); 
    942         DBG(ea_debug_printf, (EA_DEBUG,  
    943                     "[%d] eaccelerator_store_int:     class hashkey=", getpid ())); 
     924        DBG(ea_debug_printf, (EA_DEBUG, "[%d] eaccelerator_store_int:     class hashkey=", getpid ())); 
    944925        DBG(ea_debug_binary_print, (EA_DEBUG, c->arKey, c->nKeyLength)); 
    945926 
    946         EACCELERATOR_ALIGN (EAG (mem)); 
    947         fc = (ea_fc_entry *) EAG (mem); 
    948         EAG (mem) += offsetof (ea_fc_entry, htabkey) + c->nKeyLength; 
    949         memcpy (fc->htabkey, c->arKey, c->nKeyLength); 
     927        EACCELERATOR_ALIGN(EAG(mem)); 
     928        fc = (ea_fc_entry *) EAG(mem); 
     929        EAG(mem) += offsetof(ea_fc_entry, htabkey) + c->nKeyLength; 
     930        memcpy(fc->htabkey, c->arKey, c->nKeyLength); 
    950931        fc->htablen = c->nKeyLength; 
    951932        fc->next = NULL; 
     
    957938        c = c->pListNext; 
    958939        x = fc->htabkey; 
    959         zend_hash_add (&EAG (strings), fc->htabkey, fc->htablen, &x,  
    960                 sizeof (char *), NULL); 
     940        zend_hash_add(&EAG(strings), fc->htabkey, fc->htablen, &x, sizeof(char *), NULL); 
    961941        if (q == NULL) { 
    962942            p->c_head = fc; 
     
    970950    while (f != NULL) { 
    971951        DBG(ea_debug_pad, (EA_DEBUG TSRMLS_CC)); 
    972         DBG(ea_debug_printf, (EA_DEBUG,  
    973                     "[%d] eaccelerator_store_int:     function hashkey='%s'\n", getpid (), f->arKey)); 
    974  
    975         EACCELERATOR_ALIGN (EAG (mem)); 
    976         fc = (ea_fc_entry *) EAG (mem); 
    977         EAG (mem) += offsetof (ea_fc_entry, htabkey) + f->nKeyLength; 
    978         memcpy (fc->htabkey, f->arKey, f->nKeyLength); 
     952        DBG(ea_debug_printf, (EA_DEBUG, "[%d] eaccelerator_store_int:     function hashkey='%s'\n", getpid (), f->arKey)); 
     953 
     954        EACCELERATOR_ALIGN(EAG(mem)); 
     955        fc = (ea_fc_entry *) EAG(mem); 
     956        EAG(mem) += offsetof (ea_fc_entry, htabkey) + f->nKeyLength; 
     957        memcpy(fc->htabkey, f->arKey, f->nKeyLength); 
    979958        fc->htablen = f->nKeyLength; 
    980959        fc->next = NULL; 
     
    982961        f = f->pListNext; 
    983962        x = fc->htabkey; 
    984         zend_hash_add (&EAG (strings), fc->htabkey, fc->htablen, &x, 
    985                 sizeof (char *), NULL); 
     963        zend_hash_add(&EAG(strings), fc->htabkey, fc->htablen, &x, sizeof(char *), NULL); 
    986964        if (q == NULL) { 
    987965            p->f_head = fc; 
     
    994972    q = p->c_head; 
    995973    while (q != NULL) { 
    996         q->fc = store_class_entry ((zend_class_entry *) q->fc TSRMLS_CC); 
     974        q->fc = store_class_entry((zend_class_entry *) q->fc TSRMLS_CC); 
    997975        q = q->next; 
    998976    } 
     
    1000978    q = p->f_head; 
    1001979    while (q != NULL) { 
    1002         q->fc = store_op_array ((zend_op_array *) q->fc TSRMLS_CC); 
     980        q->fc = store_op_array((zend_op_array *) q->fc TSRMLS_CC); 
    1003981        q = q->next; 
    1004982    } 
    1005     p->op_array = store_op_array (op_array TSRMLS_CC); 
    1006  
    1007     zend_hash_destroy (&EAG (strings)); 
     983    p->op_array = store_op_array(op_array TSRMLS_CC); 
     984 
     985    zend_hash_destroy(&EAG(strings)); 
    1008986    return p; 
    1009987} 
  • eaccelerator/trunk/eaccelerator.c

    r287 r291  
    803803    return 0; 
    804804  } 
    805   DBG(ea_debug_printf, (EA_DEBUG, "[%d] eaccelerator_store: calc_size returned %d, mm=%x", getpid(), size, eaccelerator_mm_instance->mm)); 
     805   
     806  DBG(ea_debug_pad, (EA_DEBUG TSRMLS_CC)); 
     807  DBG(ea_debug_printf, (EA_DEBUG, "[%d] eaccelerator_store:  returned %d, mm=%x\n", getpid(), size, eaccelerator_mm_instance->mm)); 
     808   
    806809  EACCELERATOR_UNPROTECT(); 
    807810  EAG(mem) = eaccelerator_malloc(size); 
     
    13611364  for (i=0;i<EAG(profile_level);i++) 
    13621365    DBG(ea_debug_put, (EA_PROFILE_OPCODES, "  ")); 
    1363   ea_debug_printf(EA_DEBUG, "zend_op_array compile: %s (%ld)\n", file_handle->filename, usec); 
    13641366  return t; 
    13651367} 
Note: See TracChangeset for help on using the changeset viewer.