Changeset 146

Show
Ignore:
Timestamp:
01/12/06 14:57:37 (3 years ago)
Author:
hrak
Message:

First batch of PHP-5.1 related changes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • eaccelerator/branches/PHP_5_1/AUTHORS

    r84 r146  
    44- Bart Vanbrabant <zoeloelip at users.sourceforge.net> 
    55- Shin Seung Woo <segv74 at users.sourceforge.net> 
     6- Hans Rakers <hrak at users.sourceforge.net> 
    67 
    78Inactive member(s) : 
  • eaccelerator/branches/PHP_5_1/ChangeLog

    r142 r146  
     12006-01-12  Hans Rakers <hans at parse dot nl> 
     2 
     3        * First batch of PHP-5.1 related changes committed to the newly created 
     4          PHP_5_1 branch. This is a work in progress, so YMMV. 
     5 
    162006-01-10 Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> 
    27 
  • eaccelerator/branches/PHP_5_1/content.c

    r123 r146  
    594594        eaccelerator_content_cache_place != eaccelerator_none) { 
    595595 
     596#ifndef ZEND_ENGINE_2_1 
     597/* No worko on php >= 5.1.0 */ 
    596598      /* clean garbage */ 
    597599      while (EG(garbage_ptr)) { 
    598600        zval_ptr_dtor(&EG(garbage)[--EG(garbage_ptr)]); 
    599601      } 
     602#endif 
    600603 
    601604      eaccelerator_put(key, key_len, return_value, ttl, eaccelerator_content_cache_place TSRMLS_CC); 
  • eaccelerator/branches/PHP_5_1/ea_restore.c

    r127 r146  
    4040#include "zend_API.h" 
    4141#include "zend_extensions.h" 
     42#ifdef ZEND_ENGINE_2_1 
     43#include "zend_vm.h" 
     44#endif 
    4245 
    4346#ifndef INCOMPLETE_CLASS 
     
    7073 
    7174        zend_hash_destroy(&dummy_class_entry.default_properties); 
     75        zend_hash_destroy(&dummy_class_entry.function_table); 
     76#ifdef ZEND_ENGINE_2 
     77        zend_hash_destroy(&dummy_class_entry.constants_table); 
    7278        zend_hash_destroy(&dummy_class_entry.properties_info); 
     79#endif 
     80#if defined(ZEND_ENGINE_2) && !defined(ZEND_ENGINE_2_1) 
    7381        zend_hash_destroy(dummy_class_entry.static_members); 
    74         zend_hash_destroy(&dummy_class_entry.function_table); 
    75         FREE_HASHTABLE(dummy_class_entry.static_members); 
    76         zend_hash_destroy(&dummy_class_entry.constants_table); 
     82        FREE_HASHTABLE(dummy_class_entry.static_members); 
     83#endif 
     84#ifdef ZEND_ENGINE_2_1 
     85        zend_hash_destroy(&dummy_class_entry.default_static_members); 
     86#endif 
    7787 
    7888        return property_dtor; 
     
    93103{ 
    94104        FIXUP(from->name); 
     105#ifdef ZEND_ENGINE_2_1 
     106        FIXUP(from->doc_comment); 
     107#endif 
    95108} 
    96109#endif 
     
    222235                                break; 
    223236                        } 
     237#  ifdef ZEND_ENGINE_2_1 
     238                        ZEND_VM_SET_OPCODE_HANDLER(opline); 
     239#  else 
    224240                        opline->handler = get_opcode_handler(opline->opcode TSRMLS_CC); 
     241#  endif 
     242 
    225243#endif 
    226244                } 
     
    235253                fixup_zval_hash(from->static_variables); 
    236254        } 
     255#ifdef ZEND_ENGINE_2_1 
     256        if (from->vars != NULL) { 
     257                zend_uint i; 
     258                FIXUP(from->vars); 
     259                for (i = 0; i < from->last_var; i++) { 
     260                        FIXUP(from->vars[i].name); 
     261                } 
     262        } 
     263#endif 
    237264        FIXUP(from->filename); 
    238265#ifdef ZEND_ENGINE_2 
     
    571598        to->brk_cont_array = from->brk_cont_array; 
    572599        to->last_brk_cont = from->last_brk_cont; 
    573         /* 
     600         
    574601           to->current_brk_cont = -1; 
    575602           to->static_variables = from->static_variables; 
    576            to->start_op         = to->opcodes; 
     603/*         to->start_op         = to->opcodes; */ 
    577604           to->backpatch_count  = 0; 
    578         */ 
     605         
    579606        to->return_reference = from->return_reference; 
    580607        to->done_pass_two = 1; 
     
    613640        } 
    614641 
     642#ifdef ZEND_ENGINE_2_1 
     643        to->vars             = from->vars; 
     644        to->last_var         = from->last_var; 
     645        to->size_var         = 0; 
     646        if (to->vars) {          
     647                zend_uint i; 
     648                to->vars = (zend_compiled_variable*)emalloc(from->last_var*sizeof(zend_compiled_variable));              
     649                memcpy(to->vars, from->vars, sizeof(zend_compiled_variable) * from->last_var); 
     650                for (i = 0; i < from->last_var; i ++) { 
     651                        to->vars[i].name = estrndup(from->vars[i].name, from->vars[i].name_len); 
     652                } 
     653        } 
     654#endif 
     655 
    615656        /* disable deletion in destroy_op_array */ 
    616657        ++EAG(refcount_helper); 
     
    634675        to->name = emalloc(from->name_length + 1); 
    635676        memcpy(to->name, from->name, from->name_length + 1); 
     677#ifdef ZEND_ENGINE_2_1 
     678        if (from->doc_comment != NULL) { 
     679                to->doc_comment = emalloc(from->doc_comment_len+1); 
     680                memcpy(to->doc_comment, from->doc_comment, from->doc_comment_len+1); 
     681        } 
     682#endif 
    636683        return to; 
    637684} 
     
    661708                to->__get = to->parent->__get; 
    662709                to->__set = to->parent->__set; 
     710#  ifdef ZEND_ENGINE_2_1 
     711                to->__unset = to->parent->__unset; 
     712                to->__isset = to->parent->__isset; 
     713#  endif 
    663714                to->__call = to->parent->__call; 
    664715                to->create_object = to->parent->create_object; 
     
    709760                                         memcmp(fname_lc, ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME)) == 0) 
    710761                                to->__set = f; 
     762#  ifdef ZEND_ENGINE_2_1 
     763                        else if (fname_len == sizeof(ZEND_UNSET_FUNC_NAME) - 1 && 
     764                                        memcmp(fname_lc, ZEND_UNSET_FUNC_NAME, sizeof(ZEND_UNSET_FUNC_NAME)) == 0) 
     765                                to->__unset = f; 
     766                        else if (fname_len == sizeof(ZEND_ISSET_FUNC_NAME) - 1 && 
     767                                        memcmp(fname_lc, ZEND_ISSET_FUNC_NAME, sizeof(ZEND_ISSET_FUNC_NAME)) == 0) 
     768                                to->__isset = f; 
     769#  endif 
    711770                        else if (fname_len == sizeof(ZEND_CALL_FUNC_NAME) - 1 && 
    712771                                         memcmp(fname_lc, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)) == 0) 
     
    814873        to->properties_info.pDestructor = properties_info_dtor; 
    815874 
     875#ifdef ZEND_ENGINE_2_1 
     876        /* restore default_static_members */ 
     877        restore_zval_hash(&to->default_static_members, &from->default_static_members); 
     878        to->default_static_members.pDestructor = ZVAL_PTR_DTOR; 
     879#endif 
     880         
    816881        if (from->static_members != NULL) { 
    817882                ALLOC_HASHTABLE(to->static_members); 
  • eaccelerator/branches/PHP_5_1/ea_restore.h

    r124 r146  
    3535void fixup_class_entry (eaccelerator_class_entry * from TSRMLS_DC); 
    3636 
     37void restore_zval(zval * zv TSRMLS_DC); 
    3738void restore_class(mm_fc_entry *p TSRMLS_DC); 
    3839void restore_function(mm_fc_entry *p TSRMLS_DC); 
  • eaccelerator/branches/PHP_5_1/ea_store.c

    r124 r146  
    8383        EAG(mem) += sizeof(zend_property_info); 
    8484        calc_string(from->name, from->name_length + 1 TSRMLS_CC); 
     85#ifdef ZEND_ENGINE_2_1 
     86        if (from->doc_comment != NULL) { 
     87                calc_string(from->doc_comment, from->doc_comment_len + 1 TSRMLS_CC); 
     88        } 
     89#endif 
    8590} 
    8691 
     
    247252                calc_zval_hash(from->static_variables); 
    248253        } 
     254#ifdef ZEND_ENGINE_2_1 
     255        if (from->vars != NULL) { 
     256                zend_uint i; 
     257                EACCELERATOR_ALIGN(EAG(mem)); 
     258                EAG(mem) += sizeof(zend_compiled_variable) * from->last_var; 
     259                for (i = 0; i < from->last_var; i ++) { 
     260                        calc_string(from->vars[i].name, from->vars[i].name_len+1 TSRMLS_CC); 
     261                } 
     262        } 
     263#endif 
    249264        if (from->filename != NULL) 
    250265                calc_string(from->filename, strlen(from->filename) + 1 TSRMLS_CC); 
     
    286301        calc_zval_hash(&from->constants_table); 
    287302        calc_zval_hash(&from->default_properties); 
     303 
     304#ifdef ZEND_ENGINE_2_1 
     305        calc_zval_hash(&from->default_static_members); 
     306#endif 
     307         
    288308        calc_hash(&from->properties_info, (calc_bucket_t) calc_property_info); 
    289309        if (from->static_members != NULL) { 
     
    611631#endif 
    612632        to->static_variables = from->static_variables; 
     633#ifdef ZEND_ENGINE_2_1 
     634        to->vars             = from->vars; 
     635        to->last_var         = from->last_var; 
     636#endif 
    613637        to->return_reference = from->return_reference; 
    614638        to->filename = from->filename; 
     
    672696                store_zval_hash(to->static_variables, from->static_variables); 
    673697        } 
     698#ifdef ZEND_ENGINE_2_1 
     699        if (from->vars != NULL) { 
     700                zend_uint i; 
     701                EACCELERATOR_ALIGN(EAG(mem)); 
     702                to->last_var = from->last_var; 
     703                to->vars = (zend_compiled_variable*)EAG(mem); 
     704                EAG(mem) += sizeof(zend_compiled_variable) * from->last_var; 
     705                        memcpy(to->vars, from->vars, sizeof(zend_compiled_variable) * from->last_var); 
     706                for (i = 0; i < from->last_var; i ++) { 
     707                        to->vars[i].name = store_string(from->vars[i].name, from->vars[i].name_len+1 TSRMLS_CC); 
     708                } 
     709        } else { 
     710                to->last_var = 0; 
     711                to->vars = NULL; 
     712        } 
     713#endif 
    674714        if (from->filename != NULL) { 
    675                 to->filename = store_string(to->filename, strlen(from->filename) + 1 TSRMLS_CC); 
     715                to->filename = store_string(from->filename, strlen(from->filename) + 1 TSRMLS_CC); 
    676716        } 
    677717#ifdef ZEND_ENGINE_2 
     
    694734        memcpy(to, from, sizeof(zend_property_info)); 
    695735        to->name = store_string(from->name, from->name_length + 1 TSRMLS_CC); 
     736#ifdef ZEND_ENGINE_2_1 
     737        to->doc_comment_len = from->doc_comment_len; 
     738        if (from->doc_comment != NULL) { 
     739                to->doc_comment = store_string(from->doc_comment, from->doc_comment_len + 1 TSRMLS_CC); 
     740        } 
     741#endif 
    696742        return to; 
    697743} 
     
    772818        store_zval_hash(&to->default_properties, &from->default_properties); 
    773819#endif 
     820 
     821#ifdef ZEND_ENGINE_2_1 
     822        store_zval_hash(&to->default_static_members, &from->default_static_members); //LYLE 
     823#endif 
     824 
    774825        store_hash(&to->function_table, &from->function_table, (store_bucket_t) store_op_array); 
    775826 
  • eaccelerator/branches/PHP_5_1/eaccelerator.c

    r140 r146  
    110110/* saved original functions */ 
    111111static zend_op_array *(*mm_saved_zend_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC); 
     112 
     113#ifdef DEBUG 
     114static void (*mm_saved_zend_execute)(zend_op_array *op_array TSRMLS_DC); 
     115#endif 
    112116 
    113117/* external declarations */ 
     
    843847  while (q != NULL) { 
    844848#ifdef ZEND_ENGINE_2 
    845       q->fc = store_class_entry ((zend_class_entry *) q->fc TSRMLS_CC); 
     849      q->fc = store_class_entry ((zend_class_entry *) q->fc TSRMLS_CC);  // hra: exactly the same?! 
    846850#else 
    847851      q->fc = store_class_entry ((zend_class_entry *) q->fc TSRMLS_CC); 
     
    15621566  for (i=0;i<EAG(profile_level);i++) 
    15631567    ea_debug_put(EA_PROFILE_OPCODES, "  "); 
    1564   ea_debug_printf(EA_PROFILE_OPCODES, "enter: %s:%s\n", op_array->filename, op_array->function_name); 
     1568  ea_debug_printf(EA_PROFILE_OPCODES, "enter profile_execute: %s:%s\n", op_array->filename, op_array->function_name); 
    15651569  ea_debug_start_time(&tv_start); 
    15661570  EAG(self_time)[EAG(profile_level)] = 0; 
    15671571  EAG(profile_level)++; 
     1572  ea_debug_printf(EA_PROFILE_OPCODES, "About to enter zend_execute...\n"); 
    15681573  mm_saved_zend_execute(op_array TSRMLS_CC); 
     1574  ea_debug_printf(EA_PROFILE_OPCODES, "Finished zend_execute...\n"); 
    15691575  usec = ea_debug_elapsed_time(&tv_start); 
    15701576  EAG(profile_level)--; 
     
    15731579  for (i=0;i<EAG(profile_level);i++) 
    15741580    ea_debug_put(EA_PROFILE_OPCODES, "  "); 
    1575   ea_debug_printf(EA_PROFILE_OPCODES, "leave: %s:%s (%ld,%ld)\n", op_array->filename, op_array->function_name, usec, usec-EAG(self_time)[EAG(profile_level)]); 
     1581  ea_debug_printf(EA_PROFILE_OPCODES, "leave profile_execute: %s:%s (%ld,%ld)\n", op_array->filename, op_array->function_name, usec, usec-EAG(self_time)[EAG(profile_level)]); 
    15761582} 
    15771583 
     
    15901596  for (i=0;i<EAG(profile_level);i++) 
    15911597    ea_debug_put(EA_PROFILE_OPCODES, "  "); 
    1592   ea_debug_printf(EA_DEBUG, "compile: %s (%ld)\n", file_handle->filename, usec); 
     1598  ea_debug_printf(EA_DEBUG, "zend_op_array compile: %s (%ld)\n", file_handle->filename, usec); 
    15931599  return t; 
    15941600} 
  • eaccelerator/branches/PHP_5_1/eaccelerator.h

    r140 r146  
    4343#    include "php_config.h" 
    4444#  endif 
     45#endif 
     46 
     47#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 1 
     48#   define ZEND_ENGINE_2_1 
    4549#endif 
    4650 
     
    200204        zend_op *opcodes; 
    201205        zend_uint last; 
     206#ifdef ZEND_ENGINE_2_1 
     207        zend_compiled_variable *vars; 
     208    int last_var; 
     209#endif 
    202210        zend_uint T; 
    203211        zend_brk_cont_element *brk_cont_array; 
     
    225233        HashTable function_table; 
    226234        HashTable default_properties; 
     235#ifdef ZEND_ENGINE_2_1 
     236        HashTable default_static_members; 
     237#endif 
    227238#ifdef ZEND_ENGINE_2 
    228239        zend_uint ce_flags; 
     
    231242        HashTable constants_table; 
    232243        zend_uint num_interfaces; 
     244 
    233245        char **interfaces; 
    234246        zend_class_iterator_funcs iterator_funcs; 
  • eaccelerator/branches/PHP_5_1/loader.c

    r127 r146  
    4040#include "ea_restore.h" 
    4141#include <math.h> 
     42 
     43#ifdef HAVE_EACCELERATOR_STANDALONE_LOADER 
     44zend_extension* ZendOptimizer = NULL; 
     45#endif 
    4246 
    4347typedef struct loader_data { 
  • eaccelerator/branches/PHP_5_1/opcodes.c

    r102 r146  
    4444#endif 
    4545 
    46 #ifdef ZEND_ENGINE_2 
    47 #  define LAST_OPCODE 149 
    48 #else 
    49 #  define LAST_OPCODE 106 
    50 #endif 
     46#define LAST_OPCODE (sizeof(opcodes)/sizeof(opcodes[0])) 
    5147 
    5248static const opcode_dsc opcodes[] = { 
     
    159155  OPDEF("ADD_ARRAY_ELEMENT",         EXT_BIT    | OP1_STD    | OP2_STD    | RES_TMP), /* 72 */ 
    160156  OPDEF("INCLUDE_OR_EVAL",           EXT_UNUSED | OP1_STD    | OP2_INCLUDE| RES_VAR), /* 73 */ 
    161 #ifdef ZEND_ENGINE_2 
     157#ifdef ZEND_ENGINE_2_1 
     158  /* php 5.1 and up */ 
    162159  OPDEF("UNSET_VAR",                 EXT_UNUSED | OP1_STD    | OP2_FETCH  | RES_UNUSED), /* 74 */ 
    163   OPDEF("UNSET_DIM_OBJ",             EXT_STD    | OP1_STD    | OP2_STD    | RES_UNUSED), /* 75 */ 
    164   OPDEF("ISSET_ISEMPTY",             EXT_ISSET  | OP1_VAR    | OP2_UNUSED | RES_TMP), /* 76 */ 
    165 #else 
     160  OPDEF("UNSET_DIM",                 EXT_STD    | OP1_STD    | OP2_STD    | RES_UNUSED), /* 75 */ 
     161  OPDEF("UNSET_OBJ",                 EXT_STD    | OP1_STD    | OP2_STD    | RES_UNUSED), /* 76 */ 
     162  OPDEF("FE_RESET",                  EXT_BIT    | OP1_STD    | OP2_OPLINE | RES_VAR), /* 77 */ 
     163#else 
     164  /* <= php 5.0 */ 
     165  /* though there is no ISSET_ISEMPTY in php 5.0 it's better to leave it here i guess */ 
    166166  OPDEF("UNSET_VAR",                 EXT_UNUSED | OP1_STD    | OP2_UNUSED | RES_UNUSED), /* 74 */ 
    167167  OPDEF("UNSET_DIM_OBJ",             EXT_UNUSED | OP1_VAR    | OP2_STD    | RES_UNUSED), /* 75 */ 
    168168  OPDEF("ISSET_ISEMPTY",             EXT_UNUSED | OP1_VAR    | OP2_ISSET  | RES_TMP), /* 76 */ 
    169 #endif 
    170169  OPDEF("FE_RESET",                  EXT_BIT    | OP1_STD    | OP2_UNUSED | RES_VAR), /* 77 */ 
     170#endif 
    171171  OPDEF("FE_FETCH",                  EXT_FE     | OP1_STD    | OP2_OPLINE | RES_TMP), /* 78 */ 
    172172  OPDEF("EXIT",                      EXT_UNUSED | OP1_STD    | OP2_UNUSED | RES_UNUSED), /* 79 */ 
     
    235235  OPDEF("POST_DEC_OBJ",              EXT_UNUSED | OP1_STD    | OP2_STD    | RES_TMP), /* 135 */ 
    236236  OPDEF("ASSIGN_OBJ",                EXT_UNUSED | OP1_STD    | OP2_STD    | RES_VAR), /* 136 */ 
    237   OPDEF("OP_DATA",                   EXT_UNUSED | OP1_STD    | OP2_STD    | RES_UNUSED), /* 137 */ 
     237  OPDEF("OP_DATA",                   EXT_UNUSED | OP1_STD    | OP2_STD    | RES_STD), /* 137 */ 
    238238  OPDEF("INSTANCEOF",                EXT_UNUSED | OP1_STD    | OP2_CLASS  | RES_TMP), /* 138 */ 
    239239  OPDEF("DECLARE_CLASS",             EXT_UNUSED | OP1_STD    | OP2_STD    | RES_CLASS), /* 139 */ 
     
    246246  OPDEF("VERIFY_ABSTRACT_CLASS",     EXT_UNUSED | OP1_CLASS  | OP2_UNUSED | RES_UNUSED), /* 146 */ 
    247247  OPDEF("ASSIGN_DIM",                EXT_UNUSED | OP1_STD    | OP2_STD    | RES_VAR),  /* 147 */ 
    248  
    249248  OPDEF("ISSET_ISEMPTY_PROP_OBJ",    EXT_ISSET  | OP1_STD    | OP2_STD    | RES_TMP), /* 148 */ 
    250249  OPDEF("HANDLE_EXCEPTION",          EXT_STD    | OP1_UNUSED | OP2_UNUSED | RES_STD)  /* 149 */ 
     250# ifdef ZEND_ENGINE_2_1 
     251  , 
     252  OPDEF("USER_OPCODE",               EXT_STD    | OP1_UNUSED | OP2_UNUSED | RES_STD)  /* 150 */ 
     253# endif     
    251254#endif 
    252255}; 
    253256 
    254257const opcode_dsc* get_opcode_dsc(unsigned int n) { 
    255   if (n <= LAST_OPCODE) { 
     258  if (n < LAST_OPCODE) { 
    256259    return &opcodes[n]; 
    257260  } else { 
     
    262265 
    263266#ifdef ZEND_ENGINE_2 
    264 static opcode_handler_t eaccelerator_opcode_handlers[LAST_OPCODE+1]; 
     267static opcode_handler_t eaccelerator_opcode_handlers[LAST_OPCODE]; 
    265268static int handlers_retrived = 0; 
    266269 
     
    268271  unsigned char i; 
    269272  efree(op_array->opcodes); 
    270   op_array->opcodes = (zend_op*)emalloc(sizeof(zend_op)*(LAST_OPCODE+1)); 
    271   op_array->last = LAST_OPCODE+1
    272   op_array->size = LAST_OPCODE+1
     273  op_array->opcodes = (zend_op*)emalloc(sizeof(zend_op)*(LAST_OPCODE)); 
     274  op_array->last = LAST_OPCODE
     275  op_array->size = LAST_OPCODE
    273276  op_array->T    = 0; 
    274   for (i=0; i<=LAST_OPCODE; i++) { 
     277  for (i=0; i<LAST_OPCODE; i++) { 
    275278    op_array->opcodes[i].opcode = i; 
    276279    op_array->opcodes[i].op1.op_type = IS_UNUSED; 
     
    299302    p = compile_string(&str, empty_string TSRMLS_CC); 
    300303    ext->op_array_handler = old; 
    301     if (p != NULL && p->last == LAST_OPCODE+1) { 
     304    if (p != NULL && p->last == (LAST_OPCODE - 1)) { 
    302305      int i = 0; 
    303       while (i <= LAST_OPCODE) { 
     306      while (i < LAST_OPCODE) { 
    304307         eaccelerator_opcode_handlers[p->opcodes[i].opcode] = p->opcodes[i].handler; 
    305308         ++i; 
     
    319322    } 
    320323  } 
    321   if (opcode <= LAST_OPCODE) { 
     324  if (opcode < LAST_OPCODE) { 
    322325    return eaccelerator_opcode_handlers[opcode]; 
    323326  } else { 
  • eaccelerator/branches/PHP_5_1/optimize.c

    r133 r146  
    6565} BBlink; 
    6666 
    67 #if 0 
    6867static void dump_bb(BB* bb, zend_op_array *op_array) { 
    6968  BB* p = bb; 
     
    131130  fflush(stdout); 
    132131} 
    133 #endif 
     132 
     133static void dump_array(int nb,void *pos,char type) 
     134{  int j; 
     135 
     136   switch(type) { 
     137   case 'i': { 
     138     int *ptr=pos; 
     139     for (j=0;j<nb;j++) { 
     140       zend_printf("%d:%6d ",j,*ptr); 
     141       ptr++; 
     142     } 
     143   } 
     144   break;  
     145   case 'x': { 
     146     int *ptr=pos; 
     147     for (j=0;j<nb;j++) { 
     148       zend_printf("%d:%x ",j,*ptr); 
     149       ptr++; 
     150     } 
     151   } 
     152   break;  
     153   case 'c': { 
     154     unsigned char *ptr=pos; 
     155     for (j=0;j<nb;j++) { 
     156/*       if (*ptr>=32 && *ptr<128) zend_printf("%d:%c",j,*ptr); 
     157       else if (*ptr>=128) zend_printf("%d:%2x",j,*ptr); 
     158       else if (*ptr<16) zend_printf("%d:&%1x",j,*ptr); 
     159       else zend_printf("%d:$%1x",j,(*ptr)-16); */ 
     160       zend_printf("%d:%1x ",j,*ptr); 
     161       ptr++; 
     162     } 
     163   } 
     164   break;    
     165   default: 
     166     for (j=0;j<nb;j++) 
     167       zend_printf("# "); 
     168   } 
     169   zend_printf("<br>\n"); 
     170
    134171 
    135172#define SET_TO_NOP(op) \ 
     
    251288               break; 
    252289             case ZEND_UNSET_VAR: 
     290#ifndef ZEND_ENGINE_2_1 
     291/* Pre-PHP 5.1 only */ 
    253292             case ZEND_UNSET_DIM_OBJ: 
    254293               end->result.op_type = IS_UNUSED; 
    255294               break; 
     295#else 
     296             case ZEND_UNSET_DIM: 
     297             case ZEND_UNSET_OBJ: 
     298               end->result.op_type = IS_UNUSED; 
     299               break; 
     300#endif 
    256301             case ZEND_RECV: 
    257302             case ZEND_RECV_INIT: 
    258303             /*case ZEND_ADD_ARRAY_ELEMENT:*/ 
    259304             case ZEND_INCLUDE_OR_EVAL: 
     305#ifndef ZEND_ENGINE_2_1 
     306/* Pre-PHP 5.1 only */ 
    260307             case ZEND_JMP_NO_CTOR: 
     308#else 
     309             case ZEND_NEW: 
     310#endif 
    261311             case ZEND_FE_FETCH: 
    262312#ifdef ZEND_ENGINE_2 
     
    12801330            } 
    12811331            goto jmp_2; 
     1332#ifndef ZEND_ENGINE_2_1 
     1333/* Pre-PHP 5.1 only */ 
    12821334          case ZEND_JMP_NO_CTOR: 
     1335#else 
     1336          case ZEND_NEW: 
     1337#endif 
    12831338          case ZEND_FE_FETCH: 
    12841339jmp_2: 
     
    17151770    } else  
    17161771#endif 
     1772 
    17171773    if ((op->opcode == ZEND_ADD || 
    17181774                op->opcode == ZEND_SUB || 
     
    24442500          op->opcode == ZEND_POST_INC || 
    24452501          op->opcode == ZEND_POST_DEC || 
     2502#ifndef ZEND_ENGINE_2_1 
     2503/* Pre-PHP 5.1 only */ 
    24462504          op->opcode == ZEND_UNSET_DIM_OBJ || 
     2505#else 
     2506          op->opcode == ZEND_UNSET_DIM || 
     2507          op->opcode == ZEND_UNSET_OBJ || 
     2508#endif 
    24472509          op->opcode == ZEND_INCLUDE_OR_EVAL 
    24482510#ifdef ZEND_ENGINE_2 
     
    27222784                        case ZEND_JMPZ_EX: 
    27232785                        case ZEND_JMPNZ_EX: 
     2786#ifndef ZEND_ENGINE_2_1 
     2787/* Pre-PHP 5.1 only */ 
    27242788                        case ZEND_JMP_NO_CTOR: 
     2789#else 
     2790                        case ZEND_NEW: 
     2791                        case ZEND_FE_RESET: 
     2792#endif 
    27252793                        case ZEND_FE_FETCH: 
    27262794                                bb[line_num+1].start = op+1; 
     
    28412909#endif 
    28422910                        case ZEND_UNSET_VAR: 
     2911#ifndef ZEND_ENGINE_2_1 
     2912/* Pre-PHP 5.1 only */ 
    28432913                        case ZEND_UNSET_DIM_OBJ: 
    28442914                                op->result.op_type = IS_UNUSED; 
    28452915                                break; 
     2916#else 
     2917                        case ZEND_UNSET_DIM: 
     2918                                op->result.op_type = IS_UNUSED; 
     2919                                break; 
     2920                        case ZEND_UNSET_OBJ: 
     2921                                op->result.op_type = IS_UNUSED; 
     2922                                break; 
     2923#endif 
    28462924                        default: 
    28472925                                break; 
     
    28952973                                case ZEND_JMPZ_EX: 
    28962974                                case ZEND_JMPNZ_EX: 
     2975#ifndef ZEND_ENGINE_2_1 
     2976/* Pre-PHP 5.1 only */ 
    28972977                                case ZEND_JMP_NO_CTOR: 
     2978#else 
     2979                                case ZEND_NEW: 
     2980                                case ZEND_FE_RESET: 
     2981#endif 
    28982982                                case ZEND_FE_FETCH: 
    28992983                                        p->jmp_2 = &bb[op->op2.u.opline_num]; 
     
    31103194      while (start < op) { 
    31113195        --op; 
     3196        /* zend_printf("op=%d\n", op-op_array->opcodes); */ 
    31123197#ifdef ZEND_ENGINE_2 
    31133198        op_data = NULL; 
     
    31513236          GET_REG(r); 
    31523237          op->extended_value = VAR_VAL(assigned[r]); 
    3153         } 
    3154         if (op->opcode == ZEND_OP_DATA) { 
    3155           op_data = op; 
    3156           --op; 
    3157           if (op->op1.op_type == IS_VAR || op->op1.op_type == IS_TMP_VAR) { 
    3158             int r = VAR_NUM(op->op1.u.var); 
    3159             GET_REG(r); 
    3160             op->op1.u.var = VAR_VAL(assigned[r]); 
    3161           } 
    3162           if (op->op2.op_type == IS_VAR || op->op2.op_type == IS_TMP_VAR) { 
    3163             int r = VAR_NUM(op->op2.u.var); 
    3164             GET_REG(r); 
    3165             op->op2.u.var = VAR_VAL(assigned[r]); 
    3166           } 
    31673238        } 
    31683239#endif 
     
    31933264          } 
    31943265        } 
    3195 #ifdef ZEND_ENGINE_2 
    3196         if (op_data != NULL && op_data->op2.op_type == IS_VAR) { 
    3197           FREE_REG(VAR_NUM(op_data->op2.u.var)); 
    3198         } 
    3199 #endif 
    32003266      } 
    32013267    } 
     
    32803346    emit_cfg(op_array, bb); 
    32813347    reassign_registers(op_array, bb, global); 
     3348    /* dump_bb(bb, op_array); */ 
    32823349 
    32833350    free_alloca(global); 
  • eaccelerator/branches/PHP_5_1/webui.c

    r123 r146  
    264264                goto string_dump; 
    265265        case IS_CONSTANT_ARRAY: 
    266                 ZEND_PUTS ("constatnt_array("); 
     266                ZEND_PUTS ("constant_array("); 
    267267                goto array_dump; 
    268268        default: 
     
    272272 
    273273static const char *color_list[] = { 
    274         "#FF0000", 
    275         "#00FF00", 
    276         "#0000FF", 
    277         "#FFFF00", 
    278         "#00FFFF", 
    279         "#FF00FF", 
    280         "#800000", 
    281         "#008000", 
    282         "#000080", 
    283         "#808000", 
    284         "#008080", 
    285         "#800080" 
     274    /* color from irc */ 
     275    /* 0  // "#ffffff",          white                    */ 
     276    /* 1  // "#000000",          black                    */ 
     277    /* 4  */ "#ff0000",         /* light red                */ 
     278    /* 7  */ "#fc7f00",         /* orange                   */ 
     279    /* 6  */ "#9c009c",         /* magenta                  */ 
     280    /* 5  */ "#7f0000",         /* red                      */ 
     281    /* 9  */ "#00fc00",         /* light green (lime)       */ 
     282    /* 10 */ "#009393",         /* cyan                     */ 
     283    /* 12 */ "#0000fc",         /* light blue               */ 
     284    /* 13 */ "#ff00ff",         /* light magenta (pink)     */     
     285    /* 2  */ "#00007f",         /* blue                     */ 
     286    /* 3  */ "#009300",         /* green                    */ 
     287    /* 8  // "#ffff00",        yellow                   */ 
     288    /* 11 // "#00ffff",        light cyan (aqua)        */  
     289    /* 14 */ "#7f7f7f",         /* grey                     */ 
     290    /* 15 */ "#d2d2d2"          /* light grey (silver)      */ 
    286291}; 
    287292 
    288 static char const *color (int num) 
     293static const char *color (int num) 
    289294{ 
    290295        return color_list[num % (sizeof (color_list) / sizeof (char *))]; 
     
    323328                if (*p == '\n') { 
    324329                        line--; 
     330        } else if (*p == '\r') { 
     331            line--; 
     332            if (p[1] == '\n') { 
     333                p++; 
     334            } 
    325335                } else if (line == 1) { 
    326336                        if (*p == '<') 
     
    344354 
    345355#ifdef ZEND_ENGINE_2 
     356#ifdef ZEND_ENGINE_2_1 
     357    zend_printf ("last_var = %u, ", p->last_var); 
     358#endif 
    346359        zend_printf ("T = %u, size = %u\n, brk_count = %u, file = %s<br>\n", 
    347360                                 p->T, p->last, p->last_brk_cont, p->filename); 
     
    368381                        q = q->pListNext; 
    369382                } 
    370                 ZEND_PUTS ("<tbody></table><br>\n"); 
    371         } 
    372  
     383                ZEND_PUTS ("</tbody></table><br>\n"); 
     384        } 
     385#ifdef ZEND_ENGINE_2_1 
     386    if (p->last_var) { 
     387        int i; 
     388         
     389        ZEND_PUTS("<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"600\" bgcolor=\"#000000\" align=\"center\" style=\"table-layout:fixed\">\n"); 
     390        ZEND_PUTS("<thead valign=\"middle\" bgcolor=\"#9999cc\"><tr><th width=\"200\">Compiled variable</th><th width=\"200\">Len</th><th width=\"200\">Hash</th></tr></thead>\n"); 
     391        ZEND_PUTS("<tbody valign=\"top\" bgcolor=\"#cccccc\" style=\"word-break:break-all\">\n"); 
     392         
     393        for (i = 0; i < p->last_var; i ++) { 
     394            zend_printf ("<tr><td bgcolor=\"#ccccff\">$%s&nbsp;</td>", p->vars[i].name); 
     395            zend_printf ("<td bgcolor=\"#ccccff\">%u&nbsp;</td>", p->vars[i].name_len); 
     396            zend_printf ("<td bgcolor=\"#ccccff\">%u&nbsp;</td></tr>\n", p->vars[i].hash_value); 
     397        } 
     398        ZEND_PUTS ("</tbody></table><br>\n"); 
     399    } 
     400#endif 
     401     
    373402        if (p->opcodes) { 
    374403                int n = 0; 
     
    378407                filebuf = get_file_contents (p->filename); 
    379408 
    380                 ZEND_PUTS 
    381                         ("<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"900\" bgcolor=\"#000000\" align=\"center\" style=\"table-layout:fixed\">\n"); 
    382                 ZEND_PUTS 
    383                         ("<thead valign=\"middle\" bgcolor=\"#9999cc\"><tr><th width=\"40\">N</th><th width=\"160\">OPCODE</th><th width=\"160\">EXTENDED_VALUE</th><th width=\"220\">OP1</th><th width=\"220\">OP2</th><th width=\"80\">RESULT</th></tr></thead>\n"); 
    384                 ZEND_PUTS 
    385                         ("<tbody valign=\"top\" bgcolor=\"#cccccc\" style=\"word-break:break-all; font-size: x-small\">\n"); 
     409                ZEND_PUTS("<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"900\" bgcolor=\"#000000\" align=\"center\" style=\"table-layout:fixed\">\n"); 
     410                ZEND_PUTS("<thead valign=\"middle\" bgcolor=\"#9999cc\"><tr><th width=\"40\">N</th><th width=\"160\">OPCODE</th><th width=\"160\">EXTENDED_VALUE</th><th width=\"220\">OP1</th><th width=\"220\">OP2</th><th width=\"80\">RESULT</th></tr></thead>\n"); 
     411                ZEND_PUTS("<tbody valign=\"top\" bgcolor=\"#cccccc\" style=\"word-break:break-all; font-size: x-small\">\n"); 
     412         
    386413                for (; opline < end; opline++) { 
    387414                        const opcode_dsc *op = get_opcode_dsc (opline->opcode); 
    388415 
    389                         while (last_line < opline->lineno) { 
    390                                 last_line++; 
    391                                 zend_printf 
    392                                         ("<tr><td colspan=6 bgcolor=black><pre><font color=#80ff80>"); 
    393                                 print_file_line (filebuf, last_line); 
     416                        if (last_line < opline->lineno) { 
     417                                zend_printf("<tr><td colspan=6 bgcolor=black><pre><font color=#80ff80>"); 
     418                                while (last_line < opline->lineno) { 
     419                    last_line++; 
     420                    print_file_line(filebuf, last_line); 
     421                    ZEND_PUTS("\n"); 
     422                } 
    394423                                zend_printf ("</font></pre></td></tr>\n"); 
    395424                        } 
     
    460489                                                ZEND_PUTS ("<td>&nbsp; </td>"); 
    461490                                        } 
     491#ifndef ZEND_ENGINE_2_1 
    462492                                } else if (opline->opcode == ZEND_UNSET_DIM_OBJ) { 
    463493                                        if (opline->extended_value == ZEND_UNSET_DIM) { 
     
    469499                                        } 
    470500#endif 
     501#endif 
    471502                                } else if (opline->extended_value != 0) { 
    472503                                        zend_printf ("<td>%ld </td>", opline->extended_value); 
     
    480511                                op = get_opcode_dsc (0); 
    481512                        } 
    482  
     513#ifdef ZEND_ENGINE_2_1 
     514            if (opline->op1.op_type == IS_CV) { 
     515                zend_printf("<td><font color=%s>$cv%u(%s)</font> </td>",  
     516                        color (opline->op1.u.var), opline->op1.u.var, 
     517                        p->vars[opline->op1.u.var].name); 
     518            } else 
     519#endif 
    483520                        if ((op->ops & OP1_MASK) == OP1_OPLINE) { 
    484521                                zend_printf 
     
    587624                                } 
    588625                        } 
    589  
     626#ifdef ZEND_ENGINE_2_1 
     627            if (opline->op2.op_type == IS_CV) { 
     628                zend_printf("<td><font color=%s>$cv%u(%s)</font> </td>", 
     629                        color (opline->op2.u.var), opline->op2.u.var, 
     630                        p->vars[opline->op2.u.var].name); 
     631            } else  
     632#endif 
    590633                        if ((op->ops & OP2_MASK) == OP2_OPLINE) { 
    591634                                zend_printf 
     
    675718                                } 
    676719                        } 
    677  
     720#ifdef ZEND_ENGINE_2_1 
     721            if (opline->result.op_type == IS_CV) { 
     722                zend_printf("<td><font color=%s>$cv%u(%s)</font> </td>", 
     723                        color (opline->result.u.var), opline->result.u.var, 
     724                        p->vars[opline->result.u.var].name); 
     725            } else  
     726#endif 
     727     
    678728                        switch (op->ops & RES_MASK) { 
    679729                        case RES_STD: 
     
    18341884 
    18351885        { 
    1836                 char *s = php_get_uname (); 
     1886                char *s = php_get_uname ('a'); 
    18371887                zend_printf ("<nobr>%s</nobr>\n", s); 
    18381888                efree (s); 
  • eaccelerator/branches/PHP_5_1/win32/eAccelerator.dsp