Show
Ignore:
Timestamp:
07/10/05 10:12:34 (4 years ago)
Author:
zoeloelip
Message:

* Renamed some macros from MMC (mmcache) to EA (eg MMCG is now EAG)
* Added eA file header to mm.c, mm.h and x86-spinlocks.h
* Readded a hack to the loader to prevent zend2 segfaults

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • eaccelerator/trunk/ea_store.c

    r120 r123  
    4747static void calc_string (char *str, int len TSRMLS_DC) 
    4848{ 
    49     if (len > MAX_DUP_STR_LEN || zend_hash_add (&MMCG (strings), str, len,  
     49    if (len > MAX_DUP_STR_LEN || zend_hash_add (&EAG (strings), str, len,  
    5050                &str, sizeof (char *), NULL) == SUCCESS) { 
    51         EACCELERATOR_ALIGN (MMCG (mem)); 
    52         MMCG (mem) += len; 
     51        EACCELERATOR_ALIGN (EAG (mem)); 
     52        EAG (mem) += len; 
    5353    } 
    5454} 
     
    7171static void calc_zval_ptr (zval ** from TSRMLS_DC) 
    7272{ 
    73     EACCELERATOR_ALIGN (MMCG (mem)); 
    74     MMCG (mem) += sizeof (zval); 
     73    EACCELERATOR_ALIGN (EAG (mem)); 
     74    EAG (mem) += sizeof (zval); 
    7575    calc_zval (*from TSRMLS_CC); 
    7676} 
     
    7979static void calc_property_info (zend_property_info * from TSRMLS_DC) 
    8080{ 
    81     EACCELERATOR_ALIGN (MMCG (mem)); 
    82     MMCG (mem) += sizeof (zend_property_info); 
     81    EACCELERATOR_ALIGN (EAG (mem)); 
     82    EAG (mem) += sizeof (zend_property_info); 
    8383    calc_string (from->name, from->name_length + 1 TSRMLS_CC); 
    8484} 
     
    9898 
    9999    if (source->nNumOfElements > 0) { 
    100         if (!MMCG (compress)) { 
    101             EACCELERATOR_ALIGN (MMCG (mem)); 
    102             MMCG (mem) += source->nTableSize * sizeof (Bucket *); 
     100        if (!EAG (compress)) { 
     101            EACCELERATOR_ALIGN (EAG (mem)); 
     102            EAG (mem) += source->nTableSize * sizeof (Bucket *); 
    103103        } 
    104104        p = start; 
    105105        while (p) { 
    106             EACCELERATOR_ALIGN (MMCG (mem)); 
    107             MMCG (mem) += offsetof (Bucket, arKey) + p->nKeyLength; 
     106            EACCELERATOR_ALIGN (EAG (mem)); 
     107            EAG (mem) += offsetof (Bucket, arKey) + p->nKeyLength; 
    108108            calc_bucket (p->pData TSRMLS_CC); 
    109109            p = p->pListNext; 
     
    127127        if (zv->value.ht == NULL || zv->value.ht == &EG (symbol_table)) { 
    128128        } else { 
    129             EACCELERATOR_ALIGN (MMCG (mem)); 
    130             MMCG (mem) += sizeof (HashTable); 
     129            EACCELERATOR_ALIGN (EAG (mem)); 
     130            EAG (mem) += sizeof (HashTable); 
    131131            calc_zval_hash (zv->value.ht); 
    132132        } 
     
    136136        if (zv->value.obj.ce != NULL) { 
    137137            zend_class_entry *ce = zv->value.obj.ce; 
    138             if (!MMCG (compress)) { 
     138            if (!EAG (compress)) { 
    139139                ea_debug_error ("[%d] EACCELERATOR can't cache objects\n", 
    140140                                getpid ()); 
     
    154154        } 
    155155        if (zv->value.obj.properties != NULL) { 
    156             EACCELERATOR_ALIGN (MMCG (mem)); 
    157             MMCG (mem) += sizeof (HashTable); 
     156            EACCELERATOR_ALIGN (EAG (mem)); 
     157            EAG (mem) += sizeof (HashTable); 
    158158            calc_zval_hash (zv->value.obj.properties); 
    159159        } 
     
    175175 
    176176    if (from->type == ZEND_INTERNAL_FUNCTION) { 
    177         EACCELERATOR_ALIGN (MMCG (mem)); 
    178         MMCG (mem) += sizeof (zend_internal_function); 
     177        EACCELERATOR_ALIGN (EAG (mem)); 
     178        EAG (mem) += sizeof (zend_internal_function); 
    179179    } else if (from->type == ZEND_USER_FUNCTION) { 
    180         EACCELERATOR_ALIGN (MMCG (mem)); 
    181         MMCG (mem) += sizeof (eaccelerator_op_array); 
     180        EACCELERATOR_ALIGN (EAG (mem)); 
     181        EAG (mem) += sizeof (eaccelerator_op_array); 
    182182    } else { 
    183183        ea_debug_error ("[%d] EACCELERATOR can't cache function \"%s\"\n", 
     
    188188    if (from->num_args > 0) { 
    189189        zend_uint i; 
    190         EACCELERATOR_ALIGN (MMCG (mem)); 
    191         MMCG (mem) += from->num_args * sizeof (zend_arg_info); 
     190        EACCELERATOR_ALIGN (EAG (mem)); 
     191        EAG (mem) += from->num_args * sizeof (zend_arg_info); 
    192192        for (i = 0; i < from->num_args; i++) { 
    193193            if (from->arg_info[i].name) { 
     
    229229 
    230230    if (from->opcodes != NULL) { 
    231         EACCELERATOR_ALIGN (MMCG (mem)); 
    232         MMCG (mem) += from->last * sizeof (zend_op); 
     231        EACCELERATOR_ALIGN (EAG (mem)); 
     232        EAG (mem) += from->last * sizeof (zend_op); 
    233233 
    234234        opline = from->opcodes; 
    235235        end = opline + from->last; 
    236         MMCG (compress) = 0; 
     236        EAG (compress) = 0; 
    237237        for (; opline < end; opline++) { 
    238238/* 
     
    244244                calc_zval (&opline->op2.u.constant TSRMLS_CC); 
    245245        } 
    246         MMCG (compress) = 1; 
     246        EAG (compress) = 1; 
    247247    } 
    248248    if (from->brk_cont_array != NULL) { 
    249         EACCELERATOR_ALIGN (MMCG (mem)); 
    250         MMCG (mem) += sizeof (zend_brk_cont_element) * from->last_brk_cont; 
     249        EACCELERATOR_ALIGN (EAG (mem)); 
     250        EAG (mem) += sizeof (zend_brk_cont_element) * from->last_brk_cont; 
    251251    } 
    252252#ifdef ZEND_ENGINE_2 
    253253    /* HOESH: try & catch support */ 
    254254    if (from->try_catch_array != NULL) { 
    255         EACCELERATOR_ALIGN (MMCG (mem)); 
    256         MMCG (mem) += sizeof (zend_try_catch_element) * from->last_try_catch; 
     255        EACCELERATOR_ALIGN (EAG (mem)); 
     256        EAG (mem) += sizeof (zend_try_catch_element) * from->last_try_catch; 
    257257    } 
    258258#endif 
    259259    if (from->static_variables != NULL) { 
    260         EACCELERATOR_ALIGN (MMCG (mem)); 
    261         MMCG (mem) += sizeof (HashTable); 
     260        EACCELERATOR_ALIGN (EAG (mem)); 
     261        EAG (mem) += sizeof (HashTable); 
    262262        calc_zval_hash (from->static_variables); 
    263263    } 
     
    280280        zend_bailout (); 
    281281    } 
    282     EACCELERATOR_ALIGN (MMCG (mem)); 
    283     MMCG (mem) += sizeof (eaccelerator_class_entry); 
     282    EACCELERATOR_ALIGN (EAG (mem)); 
     283    EAG (mem) += sizeof (eaccelerator_class_entry); 
    284284 
    285285    if (from->name != NULL) { 
     
    311311    calc_hash (&from->properties_info, (calc_bucket_t) calc_property_info); 
    312312    if (from->static_members != NULL) { 
    313         EACCELERATOR_ALIGN (MMCG (mem)); 
    314         MMCG (mem) += sizeof (HashTable); 
     313        EACCELERATOR_ALIGN (EAG (mem)); 
     314        EAG (mem) += sizeof (HashTable); 
    315315        calc_zval_hash (from->static_members); 
    316316    } 
     
    329329    char *x; 
    330330    int len = strlen (key); 
    331     MMCG (compress) = 1; 
    332     MMCG (mem) = NULL; 
    333  
    334     zend_hash_init (&MMCG (strings), 0, NULL, NULL, 0); 
    335     MMCG (mem) += offsetof (mm_cache_entry, realfilename) + len + 1; 
    336     zend_hash_add (&MMCG (strings), key, len + 1, &key, sizeof (char *), NULL); 
     331    EAG (compress) = 1; 
     332    EAG (mem) = NULL; 
     333 
     334    zend_hash_init (&EAG (strings), 0, NULL, NULL, 0); 
     335    EAG (mem) += offsetof (mm_cache_entry, realfilename) + len + 1; 
     336    zend_hash_add (&EAG (strings), key, len + 1, &key, sizeof (char *), NULL); 
    337337    b = c; 
    338338    while (b != NULL) { 
    339         EACCELERATOR_ALIGN (MMCG (mem)); 
    340         MMCG (mem) += offsetof (mm_fc_entry, htabkey) + b->nKeyLength; 
     339        EACCELERATOR_ALIGN (EAG (mem)); 
     340        EAG (mem) += offsetof (mm_fc_entry, htabkey) + b->nKeyLength; 
    341341        x = b->arKey; 
    342         zend_hash_add (&MMCG (strings), b->arKey, b->nKeyLength, &x, 
     342        zend_hash_add (&EAG (strings), b->arKey, b->nKeyLength, &x, 
    343343                       sizeof (char *), NULL); 
    344344        b = b->pListNext; 
     
    346346    b = f; 
    347347    while (b != NULL) { 
    348         EACCELERATOR_ALIGN (MMCG (mem)); 
    349         MMCG (mem) += offsetof (mm_fc_entry, htabkey) + b->nKeyLength; 
     348        EACCELERATOR_ALIGN (EAG (mem)); 
     349        EAG (mem) += offsetof (mm_fc_entry, htabkey) + b->nKeyLength; 
    350350        x = b->arKey; 
    351         zend_hash_add (&MMCG (strings), b->arKey, b->nKeyLength, &x, 
     351        zend_hash_add (&EAG (strings), b->arKey, b->nKeyLength, &x, 
    352352                       sizeof (char *), NULL); 
    353353        b = b->pListNext; 
     
    366366    } 
    367367    calc_op_array (op_array TSRMLS_CC); 
    368     EACCELERATOR_ALIGN (MMCG (mem)); 
    369     zend_hash_destroy (&MMCG (strings)); 
    370     return (size_t) MMCG (mem); 
     368    EACCELERATOR_ALIGN (EAG (mem)); 
     369    zend_hash_destroy (&EAG (strings)); 
     370    return (size_t) EAG (mem); 
    371371} 
    372372 
     
    376376    char *p; 
    377377    if (len > MAX_DUP_STR_LEN) { 
    378         EACCELERATOR_ALIGN (MMCG (mem)); 
    379         p = (char *) MMCG (mem); 
    380         MMCG (mem) += len; 
     378        EACCELERATOR_ALIGN (EAG (mem)); 
     379        p = (char *) EAG (mem); 
     380        EAG (mem) += len; 
    381381        memcpy (p, str, len); 
    382     } else if (zend_hash_find (&MMCG (strings), str, len, (void *) &p) == 
     382    } else if (zend_hash_find (&EAG (strings), str, len, (void *) &p) == 
    383383               SUCCESS) { 
    384384        p = *(char **) p; 
    385385    } else { 
    386         EACCELERATOR_ALIGN (MMCG (mem)); 
    387         p = (char *) MMCG (mem); 
    388         MMCG (mem) += len; 
     386        EACCELERATOR_ALIGN (EAG (mem)); 
     387        p = (char *) EAG (mem); 
     388        EAG (mem) += len; 
    389389        memcpy (p, str, len); 
    390         zend_hash_add (&MMCG (strings), str, len, (void *) &p, sizeof (char *), 
     390        zend_hash_add (&EAG (strings), str, len, (void *) &p, sizeof (char *), 
    391391                       NULL); 
    392392    } 
     
    411411{ 
    412412    zval *to; 
    413     EACCELERATOR_ALIGN (MMCG (mem)); 
    414     to = (zval *) MMCG (mem); 
    415     MMCG (mem) += sizeof (zval); 
     413    EACCELERATOR_ALIGN (EAG (mem)); 
     414    to = (zval *) EAG (mem); 
     415    EAG (mem) += sizeof (zval); 
    416416    memcpy (to, from, sizeof (zval)); 
    417417    store_zval (to TSRMLS_CC); 
     
    428428 
    429429    if (source->nNumOfElements > 0) { 
    430         if (!MMCG (compress)) { 
    431             EACCELERATOR_ALIGN (MMCG (mem)); 
    432             target->arBuckets = (Bucket **) MMCG (mem); 
    433             MMCG (mem) += target->nTableSize * sizeof (Bucket *); 
     430        if (!EAG (compress)) { 
     431            EACCELERATOR_ALIGN (EAG (mem)); 
     432            target->arBuckets = (Bucket **) EAG (mem); 
     433            EAG (mem) += target->nTableSize * sizeof (Bucket *); 
    434434            memset (target->arBuckets, 0, 
    435435                    target->nTableSize * sizeof (Bucket *)); 
     
    445445        np = NULL; 
    446446        while (p) { 
    447             EACCELERATOR_ALIGN (MMCG (mem)); 
    448             np = (Bucket *) MMCG (mem); 
    449             MMCG (mem) += offsetof (Bucket, arKey) + p->nKeyLength; 
    450  
    451             if (!MMCG (compress)) { 
     447            EACCELERATOR_ALIGN (EAG (mem)); 
     448            np = (Bucket *) EAG (mem); 
     449            EAG (mem) += offsetof (Bucket, arKey) + p->nKeyLength; 
     450 
     451            if (!EAG (compress)) { 
    452452                int nIndex = p->h % source->nTableSize; 
    453453                if (target->arBuckets[nIndex]) { 
     
    510510        } else { 
    511511            HashTable *p; 
    512             EACCELERATOR_ALIGN (MMCG (mem)); 
    513             p = (HashTable *) MMCG (mem); 
    514             MMCG (mem) += sizeof (HashTable); 
     512            EACCELERATOR_ALIGN (EAG (mem)); 
     513            p = (HashTable *) EAG (mem); 
     514            EAG (mem) += sizeof (HashTable); 
    515515            store_zval_hash (p, zv->value.ht); 
    516516            zv->value.ht = p; 
     
    518518        break; 
    519519    case IS_OBJECT: 
    520         if (!MMCG (compress)) { 
     520        if (!EAG (compress)) { 
    521521            return; 
    522522        } 
     
    531531        if (zv->value.obj.properties != NULL) { 
    532532            HashTable *p; 
    533             EACCELERATOR_ALIGN (MMCG (mem)); 
    534             p = (HashTable *) MMCG (mem); 
    535             MMCG (mem) += sizeof (HashTable); 
     533            EACCELERATOR_ALIGN (EAG (mem)); 
     534            p = (HashTable *) EAG (mem); 
     535            EAG (mem) += sizeof (HashTable); 
    536536            store_zval_hash (p, zv->value.obj.properties); 
    537537            zv->value.obj.properties = p; 
     
    561561 
    562562    if (from->type == ZEND_INTERNAL_FUNCTION) { 
    563         EACCELERATOR_ALIGN (MMCG (mem)); 
    564         to = (eaccelerator_op_array *) MMCG (mem); 
    565         MMCG (mem) += offsetof (eaccelerator_op_array, opcodes); 
     563        EACCELERATOR_ALIGN (EAG (mem)); 
     564        to = (eaccelerator_op_array *) EAG (mem); 
     565        EAG (mem) += offsetof (eaccelerator_op_array, opcodes); 
    566566    } else if (from->type == ZEND_USER_FUNCTION) { 
    567         EACCELERATOR_ALIGN (MMCG (mem)); 
    568         to = (eaccelerator_op_array *) MMCG (mem); 
    569         MMCG (mem) += sizeof (eaccelerator_op_array); 
     567        EACCELERATOR_ALIGN (EAG (mem)); 
     568        to = (eaccelerator_op_array *) EAG (mem); 
     569        EAG (mem) += sizeof (eaccelerator_op_array); 
    570570    } else { 
    571571        return NULL; 
     
    578578    if (from->num_args > 0) { 
    579579        zend_uint i; 
    580         EACCELERATOR_ALIGN (MMCG (mem)); 
    581         to->arg_info = (zend_arg_info *) MMCG (mem); 
    582         MMCG (mem) += from->num_args * sizeof (zend_arg_info); 
     580        EACCELERATOR_ALIGN (EAG (mem)); 
     581        to->arg_info = (zend_arg_info *) EAG (mem); 
     582        EAG (mem) += from->num_args * sizeof (zend_arg_info); 
    583583        for (i = 0; i < from->num_args; i++) { 
    584584            if (from->arg_info[i].name) { 
     
    677677 
    678678    if (from->opcodes != NULL) { 
    679         EACCELERATOR_ALIGN (MMCG (mem)); 
    680         to->opcodes = (zend_op *) MMCG (mem); 
    681         MMCG (mem) += from->last * sizeof (zend_op); 
     679        EACCELERATOR_ALIGN (EAG (mem)); 
     680        to->opcodes = (zend_op *) EAG (mem); 
     681        EAG (mem) += from->last * sizeof (zend_op); 
    682682        memcpy (to->opcodes, from->opcodes, from->last * sizeof (zend_op)); 
    683683 
    684684        opline = to->opcodes; 
    685685        end = opline + to->last; 
    686         MMCG (compress) = 0; 
     686        EAG (compress) = 0; 
    687687        for (; opline < end; opline++) { 
    688688/* 
     
    709709#endif 
    710710        } 
    711         MMCG (compress) = 1; 
     711        EAG (compress) = 1; 
    712712    } 
    713713    if (from->brk_cont_array != NULL) { 
    714         EACCELERATOR_ALIGN (MMCG (mem)); 
    715         to->brk_cont_array = (zend_brk_cont_element *) MMCG (mem); 
    716         MMCG (mem) += sizeof (zend_brk_cont_element) * from->last_brk_cont; 
     714        EACCELERATOR_ALIGN (EAG (mem)); 
     715        to->brk_cont_array = (zend_brk_cont_element *) EAG (mem); 
     716        EAG (mem) += sizeof (zend_brk_cont_element) * from->last_brk_cont; 
    717717        memcpy (to->brk_cont_array, from->brk_cont_array, 
    718718                sizeof (zend_brk_cont_element) * from->last_brk_cont); 
     
    723723    /* HOESH: try & catch support */ 
    724724    if (from->try_catch_array != NULL) { 
    725         EACCELERATOR_ALIGN (MMCG (mem)); 
    726         to->try_catch_array = (zend_try_catch_element *) MMCG (mem); 
    727         MMCG (mem) += sizeof (zend_try_catch_element) * from->last_try_catch; 
     725        EACCELERATOR_ALIGN (EAG (mem)); 
     726        to->try_catch_array = (zend_try_catch_element *) EAG (mem); 
     727        EAG (mem) += sizeof (zend_try_catch_element) * from->last_try_catch; 
    728728        memcpy (to->try_catch_array, from->try_catch_array, 
    729729                sizeof (zend_try_catch_element) * from->last_try_catch); 
     
    733733#endif 
    734734    if (from->static_variables != NULL) { 
    735         EACCELERATOR_ALIGN (MMCG (mem)); 
    736         to->static_variables = (HashTable *) MMCG (mem); 
    737         MMCG (mem) += sizeof (HashTable); 
     735        EACCELERATOR_ALIGN (EAG (mem)); 
     736        to->static_variables = (HashTable *) EAG (mem); 
     737        EAG (mem) += sizeof (HashTable); 
    738738        store_zval_hash (to->static_variables, from->static_variables); 
    739739    } 
     
    760760{ 
    761761    zend_property_info *to; 
    762     EACCELERATOR_ALIGN (MMCG (mem)); 
    763     to = (zend_property_info *) MMCG (mem); 
    764     MMCG (mem) += sizeof (zend_property_info); 
     762    EACCELERATOR_ALIGN (EAG (mem)); 
     763    to = (zend_property_info *) EAG (mem); 
     764    EAG (mem) += sizeof (zend_property_info); 
    765765    memcpy (to, from, sizeof (zend_property_info)); 
    766766    to->name = store_string (from->name, from->name_length + 1 TSRMLS_CC); 
     
    772772{ 
    773773    eaccelerator_class_entry *to; 
    774     EACCELERATOR_ALIGN (MMCG (mem)); 
    775     to = (eaccelerator_class_entry *) MMCG (mem); 
    776     MMCG (mem) += sizeof (eaccelerator_class_entry); 
     774    EACCELERATOR_ALIGN (EAG (mem)); 
     775    to = (eaccelerator_class_entry *) EAG (mem); 
     776    EAG (mem) += sizeof (eaccelerator_class_entry); 
    777777    to->type = from->type; 
    778778    to->name = NULL; 
     
    803803                     from->parent ? from->parent->name : "NULL"); 
    804804#ifdef DEBUG 
    805     MMCG (xpad)++; 
     805    EAG (xpad)++; 
    806806#endif 
    807807 
     
    850850                (store_bucket_t) store_property_info); 
    851851    if (from->static_members != NULL) { 
    852         EACCELERATOR_ALIGN (MMCG (mem)); 
    853         to->static_members = (HashTable *) MMCG (mem); 
    854         MMCG (mem) += sizeof (HashTable); 
     852        EACCELERATOR_ALIGN (EAG (mem)); 
     853        to->static_members = (HashTable *) EAG (mem); 
     854        EAG (mem) += sizeof (HashTable); 
    855855        store_zval_hash (to->static_members, from->static_members); 
    856856    } 
     
    862862 
    863863#ifdef DEBUG 
    864     MMCG (xpad)--; 
     864    EAG (xpad)--; 
    865865#endif 
    866866