Show
Ignore:
Timestamp:
06/19/08 18:01:31 (7 months ago)
Author:
bart
Message:

Remove support for all php versions older than php 5.1

Files:

Legend:

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

    r324 r344  
    197197        if ((op->op2.op_type == IS_VAR || op->op2.op_type == IS_TMP_VAR) && 
    198198            !def[VAR_NUM(op->op2.u.var)] && !global[VAR_NUM(op->op2.u.var)]) { 
    199 #ifdef ZEND_ENGINE_2 
    200199          if (op->opcode != ZEND_OP_DATA) { 
    201200            global[VAR_NUM(op->op2.u.var)] = 1; 
    202201          } 
    203 #else 
    204           global[VAR_NUM(op->op2.u.var)] = 1; 
    205 #endif 
    206         } 
    207 #ifdef ZEND_ENGINE_2 
     202        } 
    208203        if (op->opcode == ZEND_DECLARE_INHERITED_CLASS && 
    209204            !def[VAR_NUM(op->extended_value)] && 
     
    211206          global[VAR_NUM(op->extended_value)] = 1; 
    212207        } 
    213 #endif 
    214208        if ((op->result.op_type == IS_VAR && 
    215 #ifdef ZEND_ENGINE_2 
    216209             (op->opcode == ZEND_RECV || op->opcode == ZEND_RECV_INIT || 
    217210              (op->result.u.EA.type & EXT_TYPE_UNUSED) == 0)) || 
    218 #else 
    219              (op->result.u.EA.type & EXT_TYPE_UNUSED) == 0) || 
    220 #endif 
    221211            (op->result.op_type == IS_TMP_VAR)) { 
    222212          if (!def[VAR_NUM(op->result.u.var)] && !global[VAR_NUM(op->result.u.var)]) { 
     
    247237        end--; 
    248238        if (((end->result.op_type == IS_VAR && 
    249 #ifdef ZEND_ENGINE_2 
    250239             (end->opcode == ZEND_RECV || end->opcode == ZEND_RECV_INIT || 
    251240              (end->result.u.EA.type & EXT_TYPE_UNUSED) == 0)) || 
    252 #else 
    253              (end->result.u.EA.type & EXT_TYPE_UNUSED) == 0) || 
    254 #endif 
    255241             (end->result.op_type == IS_TMP_VAR)) && 
    256242            !global[VAR_NUM(end->result.u.var)] && !used[VAR_NUM(end->result.u.var)]) { 
     
    288274               break; 
    289275             case ZEND_UNSET_VAR: 
    290 #ifndef ZEND_ENGINE_2_1 
    291 /* Pre-PHP 5.1 only */ 
    292              case ZEND_UNSET_DIM_OBJ: 
    293                end->result.op_type = IS_UNUSED; 
    294                break; 
    295 #else 
    296276             case ZEND_UNSET_DIM: 
    297277             case ZEND_UNSET_OBJ: 
    298278               end->result.op_type = IS_UNUSED; 
    299279               break; 
    300 #endif 
    301280             case ZEND_RECV: 
    302281             case ZEND_RECV_INIT: 
    303282             /*case ZEND_ADD_ARRAY_ELEMENT:*/ 
    304283             case ZEND_INCLUDE_OR_EVAL: 
    305 #ifndef ZEND_ENGINE_2_1 
    306 /* Pre-PHP 5.1 only */ 
    307              case ZEND_JMP_NO_CTOR: 
    308 #else 
    309284             case ZEND_NEW: 
    310 #endif 
    311285             case ZEND_FE_FETCH: 
    312286             case ZEND_PRINT: 
    313 #ifdef ZEND_ENGINE_2 
    314287             case ZEND_INIT_METHOD_CALL: 
    315288             case ZEND_INIT_STATIC_METHOD_CALL: 
     
    318291             case ZEND_DECLARE_CLASS: 
    319292             case ZEND_DECLARE_INHERITED_CLASS: 
    320 #endif 
    321293              break; 
    322294            default: 
     
    331303        } else if (end->result.op_type == IS_VAR && 
    332304                   (end->result.u.EA.type & EXT_TYPE_UNUSED) != 0 && 
    333 #ifdef ZEND_ENGINE_2 
    334305                   end->opcode != ZEND_RECV && end->opcode != ZEND_RECV_INIT && 
    335 #endif 
    336306                   used[VAR_NUM(end->result.u.var)]) { 
    337307          end->result.u.EA.type &= ~EXT_TYPE_UNUSED; 
    338308        } 
    339309        if ((end->result.op_type == IS_VAR && 
    340 #ifdef ZEND_ENGINE_2 
    341310            (end->opcode == ZEND_RECV || end->opcode == ZEND_RECV_INIT || 
    342311             (end->result.u.EA.type & EXT_TYPE_UNUSED) == 0)) || 
    343 #else 
    344             (end->result.u.EA.type & EXT_TYPE_UNUSED) == 0) || 
    345 #endif 
    346312            (end->result.op_type == IS_TMP_VAR)) { 
    347313          switch (end->opcode) { 
     
    361327          used[VAR_NUM(end->op2.u.var)] = 1; 
    362328        } 
    363 #ifdef ZEND_ENGINE_2 
    364329        if (end->opcode == ZEND_DECLARE_INHERITED_CLASS) { 
    365330          used[VAR_NUM(end->extended_value)] = 1; 
    366331        } 
    367 #endif 
    368332      } 
    369333      p = p->next; 
     
    13341298            } 
    13351299            goto jmp_2; 
    1336 #ifndef ZEND_ENGINE_2_1 
    1337 /* Pre-PHP 5.1 only */ 
    1338           case ZEND_JMP_NO_CTOR: 
    1339 #else 
    13401300          case ZEND_NEW: 
    1341 #endif 
    13421301          case ZEND_FE_FETCH: 
    13431302jmp_2: 
     
    16261585} 
    16271586 
    1628 #ifndef ZEND_ENGINE_2 
    1629 #define FETCH_TYPE(op) ((op)->op2.u.fetch_type) 
    1630 #else 
    16311587#define FETCH_TYPE(op) ((op)->op2.u.EA.type) 
    1632 #endif 
    1633  
    16341588#define SET_UNDEFINED(op) Ts[VAR_NUM((op).u.var)] = NULL; 
    16351589#define SET_DEFINED(op)   Ts[VAR_NUM((op)->result.u.var)] = (op); 
     
    20822036    */ 
    20832037    } else if ( 
    2084 #ifndef ZEND_ENGINE_2 
    2085                op_array->uses_globals && 
    2086 #endif 
    20872038               ((op->opcode == ZEND_FETCH_DIM_R && 
    20882039                op->op1.op_type == IS_VAR && 
     
    21102061                IS_DEFINED(op->op1) && 
    21112062                DEFINED_OP(op->op1)->opcode == ZEND_FETCH_UNSET)) && 
    2112 #ifdef ZEND_ENGINE_2 
    21132063                FETCH_TYPE(DEFINED_OP(op->op1)) == ZEND_FETCH_GLOBAL && 
    2114 #else 
    2115                 FETCH_TYPE(DEFINED_OP(op->op1)) == ZEND_FETCH_LOCAL && 
    2116 #endif 
    21172064                DEFINED_OP(op->op1)->op1.op_type == IS_CONST && 
    21182065                DEFINED_OP(op->op1)->op1.u.constant.type == IS_STRING && 
     
    21292076        SET_DEFINED(x); 
    21302077        SET_TO_NOP(op); 
    2131 #ifndef ZEND_ENGINE_2 
    2132         if (x->op1.op_type == IS_VAR) { 
    2133           memcpy(&op->op1,&x->op1,sizeof(znode)); 
    2134           op->opcode = ZEND_SWITCH_FREE; 
    2135           op->extended_value = 0; 
    2136         } 
    2137 #endif 
    2138       } 
    2139 #ifdef ZEND_ENGINE_2 
     2078      } 
    21402079    /* FETCH_IS               local("GLOBALS"),$x    ISSET_ISEMPTY_VAR $y(global),res 
    21412080       ISSET_ISEMPTY_DIM_OBJ  $x,$y,$res          => NOP 
     
    21592098      SET_DEFINED(x); 
    21602099      SET_TO_NOP(op); 
    2161 #endif 
    21622100    } else if (op->opcode == ZEND_FREE && 
    21632101               op->op1.op_type == IS_TMP_VAR && 
     
    25002438          op->opcode == ZEND_POST_INC || 
    25012439          op->opcode == ZEND_POST_DEC || 
    2502 #ifndef ZEND_ENGINE_2_1 
    2503 /* Pre-PHP 5.1 only */ 
    2504           op->opcode == ZEND_UNSET_DIM_OBJ || 
    2505 #else 
    25062440          op->opcode == ZEND_UNSET_DIM || 
    25072441          op->opcode == ZEND_UNSET_OBJ || 
    2508 #endif 
    2509           op->opcode == ZEND_INCLUDE_OR_EVAL 
    2510 #ifdef ZEND_ENGINE_2 
    2511           || op->opcode == ZEND_ASSIGN_DIM 
    2512           || op->opcode == ZEND_ASSIGN_OBJ 
    2513 #endif 
    2514           ) { 
     2442          op->opcode == ZEND_INCLUDE_OR_EVAL || 
     2443          op->opcode == ZEND_ASSIGN_DIM || 
     2444          op->opcode == ZEND_ASSIGN_OBJ) { 
    25152445        zend_hash_clean(&assigns); 
    25162446        zend_hash_clean(&fetch_dim); 
     
    25342464        if ((op->result.u.EA.type & EXT_TYPE_UNUSED) != 0 && 
    25352465            op->op1.op_type == IS_VAR && 
    2536 #ifdef  ZEND_ENGINE_2 
    25372466            op->extended_value != ZEND_ASSIGN_DIM && 
    25382467            op->extended_value != ZEND_ASSIGN_OBJ && 
    2539 #endif 
    25402468            IS_DEFINED(op->op1)) { 
    25412469          zend_op *x = DEFINED_OP(op->op1); 
     
    26422570    } 
    26432571    if ((op->result.op_type == IS_VAR && 
    2644 #ifdef ZEND_ENGINE_2 
    26452572        (op->opcode == ZEND_RECV || op->opcode == ZEND_RECV_INIT || 
    26462573         (op->result.u.EA.type & EXT_TYPE_UNUSED) == 0)) || 
    2647 #else 
    2648         (op->result.u.EA.type & EXT_TYPE_UNUSED) == 0) || 
    2649 #endif 
    26502574        (op->result.op_type == IS_TMP_VAR)) { 
    26512575      if (op->opcode == ZEND_RECV || 
     
    26962620        BB* p; 
    26972621        int remove_brk_cont_array = 1; 
    2698 #ifndef ZEND_ENGINE_2 
    2699         int* overload_var = do_alloca(op_array->T * sizeof(int)); 
    2700         memset(overload_var,-1,op_array->T * sizeof(int)); 
    2701 #else 
    2702         /* HOESH: Just to use later... */ 
     2622 
     2623    /* HOESH: Just to use later... */ 
    27032624        zend_uint innermost_ketchup; 
    27042625 
     
    27172638                } 
    27182639        } 
    2719 #endif 
    2720        /* Find Starts of Basic Blocks */ 
     2640         
     2641    /* Find Starts of Basic Blocks */ 
    27212642        bb[0].start = op; 
    27222643        for (line_num=0; line_num < len; op++,line_num++) 
    27232644        { 
    2724 #ifdef ZEND_ENGINE_2 
    27252645                const opcode_dsc* dsc = get_opcode_dsc(op->opcode); 
    27262646                if (dsc != NULL) 
     
    27642684                        } 
    27652685                } 
    2766 #endif 
    27672686                switch(op->opcode) 
    27682687                { 
     
    27842703                        case ZEND_JMPZ_EX: 
    27852704                        case ZEND_JMPNZ_EX: 
    2786 #ifndef ZEND_ENGINE_2_1 
    2787 /* Pre-PHP 5.1 only */ 
    2788                         case ZEND_JMP_NO_CTOR: 
    2789 #else 
    27902705                        case ZEND_NEW: 
    27912706                        case ZEND_FE_RESET: 
    2792 #endif 
    27932707                        case ZEND_FE_FETCH: 
    27942708                                bb[line_num+1].start = op+1; 
     
    28752789                                bb[line_num+1].start = op+1; 
    28762790                                break; 
    2877 #ifdef ZEND_ENGINE_2 
    28782791                        case ZEND_CATCH: 
    28792792                                bb[op->extended_value].start = &op_array->opcodes[op->extended_value]; 
     
    28952808                                } 
    28962809                                break; 
    2897 #else 
    2898                         case ZEND_INIT_FCALL_BY_NAME: 
    2899                                 if (op->op1.op_type == IS_VAR && op->result.op_type == IS_VAR) 
    2900                                 { 
    2901                                         overload_var[op->result.u.var] = op->op1.u.var; 
    2902                                         op->result.u.var = op->op1.u.var; 
    2903                                 } 
    2904                                 break; 
    2905                         case ZEND_DO_FCALL_BY_NAME: 
    2906                                 if (op->op1.op_type == IS_VAR && overload_var[op->op1.u.var] >= 0) 
    2907                                 { 
    2908                                         op->op1.u.var = overload_var[op->op1.u.var]; 
    2909                                 } 
    2910                                 break; 
    2911 #endif 
    29122810                        case ZEND_UNSET_VAR: 
    2913 #ifndef ZEND_ENGINE_2_1 
    2914 /* Pre-PHP 5.1 only */ 
    2915                         case ZEND_UNSET_DIM_OBJ: 
    2916                                 op->result.op_type = IS_UNUSED; 
    2917                                 break; 
    2918 #else 
    29192811                        case ZEND_UNSET_DIM: 
    29202812                                op->result.op_type = IS_UNUSED; 
     
    29232815                                op->result.op_type = IS_UNUSED; 
    29242816                                break; 
    2925 #endif 
    29262817                        default: 
    29272818                                break; 
     
    29292820        } 
    29302821 
    2931 #ifndef ZEND_ENGINE_2 
    2932         free_alloca(overload_var); 
    2933 #endif 
    2934  
    29352822        /* Find Lengths of Basic Blocks and build CFG */ 
    29362823        p = bb; 
    29372824        for (line_num=1; line_num < len; line_num++) 
    29382825        { 
    2939 #ifdef ZEND_ENGINE_2 
    29402826                /* Calculate innermost CATCH op */ 
    29412827                innermost_ketchup = 0; 
     
    29572843                        } 
    29582844                } 
    2959 #endif 
    29602845                if (bb[line_num].start != NULL) 
    29612846                { 
     
    29672852                                case ZEND_JMP: 
    29682853                                        p->jmp_1 = &bb[op->op1.u.opline_num]; 
    2969 #ifdef ZEND_ENGINE_2 
    29702854                                        if (op->extended_value == ZEND_BRK || op->extended_value == ZEND_CONT) 
    29712855                                        { 
     
    29832867                                        } 
    29842868#  endif 
    2985 #endif 
    29862869                                        break; 
    29872870                                case ZEND_JMPZNZ: 
     
    29932876                                case ZEND_JMPZ_EX: 
    29942877                                case ZEND_JMPNZ_EX: 
    2995 #ifndef ZEND_ENGINE_2_1 
    2996 /* Pre-PHP 5.1 only */ 
    2997                                 case ZEND_JMP_NO_CTOR: 
    2998 #else 
    29992878                                case ZEND_NEW: 
    30002879                                case ZEND_FE_RESET: 
    3001 #endif 
    30022880                                case ZEND_FE_FETCH: 
    30032881                                        p->jmp_2 = &bb[op->op2.u.opline_num]; 
     
    30082886                                case ZEND_BRK: 
    30092887                                case ZEND_CONT: 
    3010 #ifdef ZEND_ENGINE_2 
    30112888                                        /* HOESH: The control might flow to the innermost CATCH 
    30122889                                         * op if an exception thrown earlier. We can follow to CATCH 
     
    30362913                                        } 
    30372914                                        p->follow = &bb[line_num]; 
    3038 #endif 
    30392915                                        break; 
    30402916                                default: 
     
    31112987  } 
    31122988 
    3113 #ifdef ZEND_ENGINE_2 
    31142989        /* 
    31152990         * HOESH: Reassign try & catch blocks 
     
    31603035                } 
    31613036        } 
    3162 #endif 
    31633037} 
    31643038 
     
    31863060  zend_uint i; 
    31873061  zend_uint n = 0; 
    3188 #ifndef ZEND_ENGINE_2 
    3189   int uses_globals = 0; 
    3190 #endif 
    31913062  int* assigned = do_alloca(op_array->T * sizeof(int)); 
    31923063  char* reg_pool = do_alloca(op_array->T * sizeof(char)); 
     
    32033074      zend_op* start = p->start; 
    32043075      zend_op* op    = start + p->len; 
    3205 #ifdef ZEND_ENGINE_2 
    32063076      zend_op* op_data; 
    3207 #endif 
    32083077 
    32093078      for (i = 0; i < op_array->T; i++) { 
     
    32173086        --op; 
    32183087        /* zend_printf("op=%d\n", op-op_array->opcodes); */ 
    3219 #ifdef ZEND_ENGINE_2 
    32203088        op_data = NULL; 
    3221 #else 
    3222         if (op_array->uses_globals && 
    3223             (op->opcode == ZEND_FETCH_R || 
    3224              op->opcode == ZEND_FETCH_W || 
    3225              op->opcode == ZEND_FETCH_RW || 
    3226              op->opcode == ZEND_FETCH_IS || 
    3227              op->opcode == ZEND_FETCH_FUNC_ARG || 
    3228              op->opcode == ZEND_FETCH_UNSET) && 
    3229              op->op1.op_type == IS_CONST && 
    3230              op->op1.u.constant.type == IS_STRING && 
    3231              op->op1.u.constant.value.str.len == (sizeof("GLOBALS")-1) && 
    3232              memcmp(op->op1.u.constant.value.str.val, "GLOBALS", sizeof("GLOBALS")-1) == 0) { 
    3233           uses_globals = 1; 
    3234         } 
    3235 #endif 
    32363089        if (op->opcode == ZEND_DO_FCALL_BY_NAME && 
    32373090            op->op1.op_type == IS_CONST) { 
     
    32573110          op->op2.u.var = VAR_VAL(assigned[r]); 
    32583111        } 
    3259 #ifdef ZEND_ENGINE_2 
    32603112        if (op->opcode == ZEND_DECLARE_INHERITED_CLASS) { 
    32613113          int r = VAR_NUM(op->extended_value); 
     
    32633115          op->extended_value = VAR_VAL(assigned[r]); 
    32643116        } 
    3265 #endif 
    32663117        if (op->result.op_type == IS_VAR || 
    32673118            op->result.op_type == IS_TMP_VAR) { 
     
    32703121          op->result.u.var = VAR_VAL(assigned[r]); 
    32713122          if (op->result.op_type == IS_VAR && 
    3272 #ifdef ZEND_ENGINE_2 
    32733123              op->opcode != ZEND_RECV && op->opcode != ZEND_RECV_INIT && 
    3274 #endif 
    32753124              ((op->result.u.EA.type & EXT_TYPE_UNUSED) != 0)) { 
    32763125            FREE_REG(VAR_NUM(op->result.u.var)) 
     
    32953144  } 
    32963145  op_array->T = n; 
    3297 #ifndef ZEND_ENGINE_2 
    3298   if (op_array->uses_globals && !uses_globals) { 
    3299     op_array->uses_globals = 0; 
    3300   } 
    3301 #endif 
    33023146  free_alloca(used); 
    33033147  free_alloca(reg_pool); 
     
    33293173 
    33303174  TSRMLS_FETCH(); 
    3331 /*??? 
    3332 #ifdef ZEND_ENGINE_2 
    3333   return; 
    3334 #endif 
    3335 */ 
    33363175  if (!EAG(compiler) || op_array->type != ZEND_USER_FUNCTION) { 
    33373176    return; 
     
    33903229    free_alloca(global); 
    33913230  } 
    3392 #  ifdef ZEND_ENGINE_2_1 
    33933231  else { 
    33943232    /* build_cfg encountered some nested ZEND_BRK or ZEND_CONT's 
     
    34023240    restore_operand_types(op_array); 
    34033241  } 
    3404 #  endif 
    34053242  free_alloca(bb); 
    34063243}