Changeset 268 for trunk/utils.c


Ignore:
Timestamp:
2006-10-29T03:05:01+01:00 (8 years ago)
Author:
moo
Message:

full compatible with auto_globals_jit, no need to disable it from now on

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/utils.c

    r264 r268  
    511511#define OG(x) (sandbox->orig_##x) 
    512512/* }}} */ 
     513#ifdef ZEND_ENGINE_2_1 
     514static zend_bool xc_auto_global_callback(char *name, uint name_len TSRMLS_DC) /* {{{ */ 
     515{ 
     516    zend_auto_global *auto_global; 
     517    if (zend_u_hash_find(CG(auto_globals), UG(unicode) ? IS_UNICODE : IS_STRING, ZSTR(name), name_len + 1, (void **) &auto_global) == FAILURE) { 
     518        return 1; 
     519    } 
     520    return 0; 
     521} 
     522/* }}} */ 
     523static int xc_auto_global_arm(zend_auto_global *auto_global TSRMLS_DC) /* {{{ */ 
     524{ 
     525    if (auto_global->auto_global_callback) { 
     526        auto_global->armed = 1; 
     527        auto_global->auto_global_callback = xc_auto_global_callback; 
     528    } 
     529    else { 
     530        auto_global->armed = 0; 
     531    } 
     532    return ZEND_HASH_APPLY_KEEP; 
     533} 
     534/* }}} */ 
     535#endif 
    513536xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /* {{{ */ 
    514537{ 
     
    535558    EG(class_table) = CG(class_table); 
    536559 
     560#ifdef ZEND_ENGINE_2_1 
     561    OG(auto_globals) = CG(auto_globals); 
     562    CG(auto_globals) = &TG(auto_globals); 
     563#endif 
     564 
    537565    TG(included_files) = &EG(included_files); 
    538566 
     
    543571    zend_hash_init_ex(&TG(function_table), 128, NULL, OG(function_table)->pDestructor, 0, 0); 
    544572    zend_hash_init_ex(&TG(class_table), 16, NULL, OG(class_table)->pDestructor, 0, 0); 
     573#ifdef ZEND_ENGINE_2_1 
     574    zend_hash_init_ex(&TG(auto_globals), 8, NULL, OG(auto_globals)->pDestructor, 0, 0); 
     575    { 
     576        zend_auto_global tmp_autoglobal; 
     577 
     578        zend_hash_copy(&TG(auto_globals), OG(auto_globals), NULL, (void *) &tmp_autoglobal, sizeof(tmp_autoglobal)); 
     579        zend_hash_apply(&TG(auto_globals), (apply_func_t) xc_auto_global_arm TSRMLS_CC); 
     580    } 
     581#endif 
    545582 
    546583    sandbox->filename = filename; 
     
    592629        b = b->pListNext; 
    593630    } 
     631 
     632#ifdef ZEND_ENGINE_2_1 
     633    /* trigger auto_globals jit */ 
     634    for (b = TG(auto_globals).pListHead; b != NULL; b = b->pListNext) { 
     635        zend_auto_global *auto_global = (zend_auto_global *) b->pData; 
     636        /* check if actived */ 
     637        if (auto_global->auto_global_callback && !auto_global->armed) { 
     638            zend_u_is_auto_global(BUCKET_KEY_TYPE(b), ZSTR(BUCKET_KEY_S(b)), auto_global->name_len TSRMLS_CC); 
     639        } 
     640    } 
     641#endif 
     642 
    594643    xc_undo_pass_two(CG(active_op_array) TSRMLS_CC); 
    595644    xc_foreach_early_binding_class(CG(active_op_array), xc_early_binding_cb, (void *) sandbox TSRMLS_CC); 
     
    609658    CG(class_table)    = OG(class_table); 
    610659    EG(class_table)    = CG(class_table); 
     660#ifdef ZEND_ENGINE_2_1 
     661    CG(auto_globals)   = OG(auto_globals); 
     662#endif 
    611663 
    612664    if (install) { 
     
    624676        TG(function_table).pDestructor = NULL; 
    625677        TG(class_table).pDestructor = NULL; 
     678#ifdef ZEND_ENGINE_2_1 
     679        TG(auto_globals).pDestructor = NULL; 
     680#endif 
    626681    } 
    627682 
     
    632687    zend_hash_destroy(&TG(function_table)); 
    633688    zend_hash_destroy(&TG(class_table)); 
     689#ifdef ZEND_ENGINE_2_1 
     690    zend_hash_destroy(&TG(auto_globals)); 
     691#endif 
    634692    zend_hash_destroy(TG(included_files)); 
    635693 
Note: See TracChangeset for help on using the changeset viewer.