From: Xinchen Hui Date: Fri, 15 Aug 2014 08:40:07 +0000 (+0800) Subject: Remove old version PHP supports X-Git-Tag: PRE_64BIT_BRANCH_MERGE~60 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e2522b4f1d3b8da8a66f397f75d0c2cf37832663;p=php Remove old version PHP supports --- diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c index a3b6d08578..82cd0e1527 100644 --- a/ext/opcache/Optimizer/block_pass.c +++ b/ext/opcache/Optimizer/block_pass.c @@ -96,14 +96,11 @@ static int find_code_blocks(zend_op_array *op_array, zend_cfg *cfg, zend_optimiz switch((unsigned)opline->opcode) { case ZEND_BRK: case ZEND_CONT: -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO case ZEND_GOTO: -#endif /* would not optimize non-optimized BRK/CONTs - we cannot really know where it jumps, so these optimizations are too dangerous */ return 0; -#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO case ZEND_FAST_CALL: START_BLOCK_OP(ZEND_OP1(opline).opline_num); if (opline->extended_value) { @@ -117,17 +114,12 @@ static int find_code_blocks(zend_op_array *op_array, zend_cfg *cfg, zend_optimiz } START_BLOCK_OP(opno + 1); break; -#endif case ZEND_JMP: START_BLOCK_OP(ZEND_OP1(opline).opline_num); /* break missing intentionally */ case ZEND_RETURN: -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO case ZEND_RETURN_BY_REF: -#endif -#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO case ZEND_GENERATOR_RETURN: -#endif case ZEND_EXIT: case ZEND_THROW: /* start new block from this+1 */ @@ -147,12 +139,8 @@ static int find_code_blocks(zend_op_array *op_array, zend_cfg *cfg, zend_optimiz case ZEND_JMPNZ_EX: case ZEND_FE_RESET: case ZEND_NEW: -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO case ZEND_JMP_SET: -#endif -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO case ZEND_JMP_SET_VAR: -#endif START_BLOCK_OP(ZEND_OP2(opline).opline_num); START_BLOCK_OP(opno + 1); break; @@ -246,16 +234,11 @@ static int find_code_blocks(zend_op_array *op_array, zend_cfg *cfg, zend_optimiz } switch((unsigned)opline->opcode) { case ZEND_RETURN: -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO case ZEND_RETURN_BY_REF: -#endif -#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO case ZEND_GENERATOR_RETURN: -#endif case ZEND_EXIT: case ZEND_THROW: break; -#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO case ZEND_FAST_CALL: if (opline->extended_value) { cur_block->op2_to = &blocks[ZEND_OP2(opline).opline_num]; @@ -267,7 +250,6 @@ static int find_code_blocks(zend_op_array *op_array, zend_cfg *cfg, zend_optimiz cur_block->op2_to = &blocks[ZEND_OP2(opline).opline_num]; } break; -#endif case ZEND_JMP: cur_block->op1_to = &blocks[ZEND_OP1(opline).opline_num]; break; @@ -285,12 +267,8 @@ static int find_code_blocks(zend_op_array *op_array, zend_cfg *cfg, zend_optimiz case ZEND_JMPNZ_EX: case ZEND_FE_RESET: case ZEND_NEW: -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO case ZEND_JMP_SET: -#endif -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO case ZEND_JMP_SET_VAR: -#endif case ZEND_FE_FETCH: cur_block->op2_to = &blocks[ZEND_OP2(opline).opline_num]; /* break missing intentionally */ @@ -520,25 +498,12 @@ static void zend_rebuild_access_path(zend_cfg *cfg, zend_op_array *op_array, int /* Data dependencies macros */ -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO - -# define VAR_NUM_EX(op) VAR_NUM((op).var) - -# define VAR_SOURCE(op) Tsource[VAR_NUM(op.var)] -# define SET_VAR_SOURCE(opline) Tsource[VAR_NUM(opline->result.var)] = opline - -# define VAR_UNSET(op) do { if (op ## _type & (IS_TMP_VAR|IS_VAR)) {VAR_SOURCE(op) = NULL;}} while (0) - -#else +#define VAR_NUM_EX(op) VAR_NUM((op).var) -# define VAR_NUM_EX(op) ((op).op_type == IS_TMP_VAR || (op).op_type == IS_VAR? VAR_NUM((op).u.var) : (op).u.var) +#define VAR_SOURCE(op) Tsource[VAR_NUM(op.var)] +#define SET_VAR_SOURCE(opline) Tsource[VAR_NUM(opline->result.var)] = opline -# define VAR_SOURCE(op) Tsource[VAR_NUM(op.u.var)] -# define SET_VAR_SOURCE(opline) Tsource[VAR_NUM(ZEND_RESULT(opline).var)] = opline - -# define VAR_UNSET(op) do { if ((op).op_type == IS_TMP_VAR || (op).op_type == IS_VAR) {VAR_SOURCE(op) = NULL;}} while (0) - -#endif +#define VAR_UNSET(op) do { if (op ## _type & (IS_TMP_VAR|IS_VAR)) {VAR_SOURCE(op) = NULL;}} while (0) #define convert_to_string_safe(v) \ if (Z_TYPE_P((v)) == IS_NULL) { \ @@ -930,15 +895,11 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array, memcpy(Z_STRVAL(ZEND_OP1_LITERAL(last_op)) + old_len, Z_STRVAL(ZEND_OP1_LITERAL(opline)), Z_STRLEN(ZEND_OP1_LITERAL(opline))); Z_STRVAL(ZEND_OP1_LITERAL(last_op))[l] = '\0'; zval_dtor(&ZEND_OP1_LITERAL(opline)); -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO Z_STR(ZEND_OP1_LITERAL(opline)) = zend_new_interned_string(Z_STR(ZEND_OP1_LITERAL(last_op)) TSRMLS_CC); if (IS_INTERNED(Z_STR(ZEND_OP1_LITERAL(opline)))) { Z_TYPE_FLAGS(ZEND_OP1_LITERAL(opline)) &= ~ (IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE); } ZVAL_NULL(&ZEND_OP1_LITERAL(last_op)); -#else - Z_STR(ZEND_OP1_LITERAL(opline)) = Z_STR(ZEND_OP1_LITERAL(last_op)); -#endif MAKE_NOP(last_op); } else if (opline->opcode == ZEND_CONCAT && ZEND_OP2_TYPE(opline) == IS_CONST && @@ -978,15 +939,11 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array, memcpy(Z_STRVAL(ZEND_OP2_LITERAL(src)) + old_len, Z_STRVAL(ZEND_OP2_LITERAL(opline)), Z_STRLEN(ZEND_OP2_LITERAL(opline))); Z_STRVAL(ZEND_OP2_LITERAL(src))[l] = '\0'; STR_RELEASE(Z_STR(ZEND_OP2_LITERAL(opline))); -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO Z_STR(ZEND_OP2_LITERAL(opline)) = zend_new_interned_string(Z_STR(ZEND_OP2_LITERAL(src)) TSRMLS_CC); if (IS_INTERNED(Z_STR(ZEND_OP2_LITERAL(opline)))) { Z_TYPE_FLAGS(ZEND_OP2_LITERAL(opline)) &= ~ (IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE); } ZVAL_NULL(&ZEND_OP2_LITERAL(src)); -#else - Z_STR(ZEND_OP2_LITERAL(opline)) = Z_STR(ZEND_OP2_LITERAL(src)); -#endif MAKE_NOP(src); } else if ((opline->opcode == ZEND_ADD_STRING || opline->opcode == ZEND_ADD_VAR) && ZEND_OP1_TYPE(opline) == IS_CONST) { /* convert ADD_STRING(C1, C2) to CONCAT(C1, C2) */ @@ -1052,11 +1009,7 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array, zval result; if (unary_op) { -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - unary_op(&result, &ZEND_OP1_LITERAL(opline)); -#else unary_op(&result, &ZEND_OP1_LITERAL(opline) TSRMLS_CC); -#endif literal_dtor(&ZEND_OP1_LITERAL(opline)); } else { /* BOOL */ @@ -1240,12 +1193,6 @@ static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array) opline->lineno = opline[-1].lineno; opline++; } -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - MAKE_NOP(opline); - opline->opcode = ZEND_HANDLE_EXCEPTION; - opline->lineno = opline[-1].lineno; - opline++; -#endif op_array->last = opline-new_opcodes; @@ -1295,7 +1242,6 @@ static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array) efree(op_array->opcodes); op_array->opcodes = erealloc(new_opcodes, op_array->last * sizeof(zend_op)); -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO /* adjust early binding list */ if (op_array->early_binding != (zend_uint)-1) { zend_uint *opline_num = &op_array->early_binding; @@ -1312,7 +1258,6 @@ static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array) } *opline_num = -1; } -#endif } static void zend_jmp_optimization(zend_code_block *block, zend_op_array *op_array, zend_code_block *blocks, zend_cfg *cfg, zend_optimizer_ctx *ctx TSRMLS_DC) @@ -1354,17 +1299,11 @@ static void zend_jmp_optimization(zend_code_block *block, zend_op_array *op_arra /* JMP L, L: JMP L1 -> JMP L1 */ /* JMP L, L: JMPZNZ L1,L2 -> JMPZNZ L1,L2 */ *last_op = *target; -#if ZEND_EXTENSION_API_NO < PHP_5_4_X_API_NO - if (ZEND_OP1_TYPE(last_op) == IS_CONST) { - zval_copy_ctor(&ZEND_OP1_LITERAL(last_op)); - } -#else if (ZEND_OP1_TYPE(last_op) == IS_CONST) { zval zv = ZEND_OP1_LITERAL(last_op); zval_copy_ctor(&zv); last_op->op1.constant = zend_optimizer_add_literal(op_array, &zv TSRMLS_CC); } -#endif del_source(block, block->op1_to); if (block->op1_to->op2_to) { block->op2_to = block->op1_to->op2_to; @@ -1381,26 +1320,16 @@ static void zend_jmp_optimization(zend_code_block *block, zend_op_array *op_arra block->op1_to = NULL; } } else if (target->opcode == ZEND_RETURN || -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO target->opcode == ZEND_RETURN_BY_REF || -#endif -#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO target->opcode == ZEND_FAST_RET || -#endif target->opcode == ZEND_EXIT) { /* JMP L, L: RETURN to immediate RETURN */ *last_op = *target; -#if ZEND_EXTENSION_API_NO < PHP_5_4_X_API_NO - if (ZEND_OP1_TYPE(last_op) == IS_CONST) { - zval_copy_ctor(&ZEND_OP1_LITERAL(last_op)); - } -#else if (ZEND_OP1_TYPE(last_op) == IS_CONST) { zval zv = ZEND_OP1_LITERAL(last_op); zval_copy_ctor(&zv); last_op->op1.constant = zend_optimizer_add_literal(op_array, &zv TSRMLS_CC); } -#endif del_source(block, block->op1_to); block->op1_to = NULL; #if 0 @@ -1465,11 +1394,7 @@ static void zend_jmp_optimization(zend_code_block *block, zend_op_array *op_arra case ZEND_JMPNZ: /* constant conditional JMPs */ if (ZEND_OP1_TYPE(last_op) == IS_CONST) { -#if ZEND_EXTENSION_API_NO > PHP_5_6_X_API_NO int should_jmp = zend_is_true(&ZEND_OP1_LITERAL(last_op) TSRMLS_CC); -#else - int should_jmp = zend_is_true(&ZEND_OP1_LITERAL(last_op)); -#endif if (last_op->opcode == ZEND_JMPZ) { should_jmp = !should_jmp; @@ -1613,11 +1538,7 @@ next_target: case ZEND_JMPZ_EX: /* constant conditional JMPs */ if (ZEND_OP1_TYPE(last_op) == IS_CONST) { -#if ZEND_EXTENSION_API_NO > PHP_5_6_X_API_NO int should_jmp = zend_is_true(&ZEND_OP1_LITERAL(last_op) TSRMLS_CC); -#else - int should_jmp = zend_is_true(&ZEND_OP1_LITERAL(last_op)); -#endif if (last_op->opcode == ZEND_JMPZ_EX) { should_jmp = !should_jmp; @@ -1730,11 +1651,7 @@ next_target_ex: } if (ZEND_OP1_TYPE(last_op) == IS_CONST) { -#if ZEND_EXTENSION_API_NO > PHP_5_6_X_API_NO if (!zend_is_true(&ZEND_OP1_LITERAL(last_op) TSRMLS_CC)) { -#else - if (!zend_is_true(&ZEND_OP1_LITERAL(last_op))) { -#endif /* JMPZNZ(false,L1,L2) -> JMP(L1) */ zend_code_block *todel; @@ -1840,31 +1757,15 @@ next_target_znz: /* Global data dependencies */ -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO - -# define T_USAGE(op) do { \ +#define T_USAGE(op) do { \ if ((op ## _type & (IS_VAR | IS_TMP_VAR)) && \ !defined_here[VAR_NUM(op.var)] && !used_ext[VAR_NUM(op.var)]) { \ used_ext[VAR_NUM(op.var)] = 1; \ } \ } while (0) -# define NEVER_USED(op) ((op ## _type & (IS_VAR | IS_TMP_VAR)) && !usage[VAR_NUM(op.var)]) /* !used_ext[op.var] && */ -# define RES_NEVER_USED(opline) (opline->result_type == IS_UNUSED || NEVER_USED(opline->result)) - -#else - -# define T_USAGE(op) do { \ - if ((op.op_type == IS_VAR || op.op_type == IS_TMP_VAR) && \ - !defined_here[VAR_NUM(op.u.var)] && !used_ext[VAR_NUM(op.u.var)]) { \ - used_ext[VAR_NUM(op.u.var)] = 1; \ - } \ - } while (0) - -# define NEVER_USED(op) ((op.op_type == IS_VAR || op.op_type == IS_TMP_VAR) && !usage[VAR_NUM(op.u.var)]) /* !used_ext[op.u.var] && */ -# define RES_NEVER_USED(opline) (ZEND_RESULT_TYPE(opline) == IS_UNUSED || NEVER_USED(opline->result)) - -#endif +#define NEVER_USED(op) ((op ## _type & (IS_VAR | IS_TMP_VAR)) && !usage[VAR_NUM(op.var)]) /* !used_ext[op.var] && */ +#define RES_NEVER_USED(opline) (opline->result_type == IS_UNUSED || NEVER_USED(opline->result)) /* Find a set of variables which are used outside of the block where they are * defined. We won't apply some optimization patterns for such variables. */ @@ -1902,9 +1803,7 @@ static void zend_t_usage(zend_code_block *block, zend_op_array *op_array, char * if (RESULT_USED(opline)) { if (!defined_here[VAR_NUM(ZEND_RESULT(opline).var)] && !used_ext[VAR_NUM(ZEND_RESULT(opline).var)] && (opline->opcode == ZEND_RECV || opline->opcode == ZEND_RECV_INIT || -#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO opline->opcode == ZEND_RECV_VARIADIC || -#endif (opline->opcode == ZEND_OP_DATA && ZEND_RESULT_TYPE(opline) == IS_TMP_VAR) || opline->opcode == ZEND_ADD_ARRAY_ELEMENT)) { /* these opcodes use the result as argument */ @@ -1959,11 +1858,7 @@ static void zend_t_usage(zend_code_block *block, zend_op_array *op_array, char * case ZEND_ASSIGN_REF: case ZEND_DO_FCALL: if (ZEND_RESULT_TYPE(opline) == IS_VAR) { -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO ZEND_RESULT_TYPE(opline) |= EXT_TYPE_UNUSED; -#else - ZEND_RESULT(opline).EA.type |= EXT_TYPE_UNUSED; -#endif } break; case ZEND_QM_ASSIGN: @@ -1988,9 +1883,7 @@ static void zend_t_usage(zend_code_block *block, zend_op_array *op_array, char * if (opline->opcode == ZEND_RECV || opline->opcode == ZEND_RECV_INIT || -#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO opline->opcode == ZEND_RECV_VARIADIC || -#endif opline->opcode == ZEND_ADD_ARRAY_ELEMENT) { if (ZEND_OP1_TYPE(opline) == IS_VAR || ZEND_OP1_TYPE(opline) == IS_TMP_VAR) { usage[VAR_NUM(ZEND_RESULT(opline).var)] = 1; @@ -2004,24 +1897,16 @@ static void zend_t_usage(zend_code_block *block, zend_op_array *op_array, char * if (ZEND_OP1_TYPE(opline) == IS_VAR || ZEND_OP1_TYPE(opline) == IS_TMP_VAR) { usage[VAR_NUM(ZEND_OP1(opline).var)] = 1; } + if (ZEND_OP2_TYPE(opline) == IS_VAR || ZEND_OP2_TYPE(opline) == IS_TMP_VAR) { usage[VAR_NUM(ZEND_OP2(opline).var)] = 1; } - -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if ((ZEND_RESULT_TYPE(opline) & IS_VAR) && (ZEND_RESULT_TYPE(opline) & EXT_TYPE_UNUSED) && usage[VAR_NUM(ZEND_RESULT(opline).var)]) { ZEND_RESULT_TYPE(opline) &= ~EXT_TYPE_UNUSED; } -#else - if (ZEND_RESULT_TYPE(opline) == IS_VAR && - usage[VAR_NUM(ZEND_RESULT(opline).var)] && - (ZEND_RESULT(opline).EA.type & EXT_TYPE_UNUSED) != 0) { - ZEND_RESULT(opline).EA.type &= ~EXT_TYPE_UNUSED; - } -#endif opline--; } @@ -2046,11 +1931,9 @@ static void zend_block_optimization(zend_op_array *op_array, zend_optimizer_ctx fflush(stderr); #endif -#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO if (op_array->has_finally_block) { return; } -#endif /* Build CFG */ checkpoint = zend_arena_checkpoint(ctx->arena); diff --git a/ext/opcache/Optimizer/compact_literals.c b/ext/opcache/Optimizer/compact_literals.c index f13bf50699..433eae453b 100644 --- a/ext/opcache/Optimizer/compact_literals.c +++ b/ext/opcache/Optimizer/compact_literals.c @@ -1,8 +1,6 @@ /* pass 11 * - compact literals table */ -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO - #define DEBUG_COMPACT_LITERALS 0 #define LITERAL_VALUE 0x0100 @@ -465,4 +463,3 @@ static void optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_c #endif } } -#endif diff --git a/ext/opcache/Optimizer/nop_removal.c b/ext/opcache/Optimizer/nop_removal.c index b2fb667ed5..4acf490738 100644 --- a/ext/opcache/Optimizer/nop_removal.c +++ b/ext/opcache/Optimizer/nop_removal.c @@ -15,7 +15,6 @@ static void nop_removal(zend_op_array *op_array) end = op_array->opcodes + op_array->last; for (opline = op_array->opcodes; opline < end; opline++) { -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO /* GOTO target is unresolved yet. We can't optimize. */ if (opline->opcode == ZEND_GOTO && Z_TYPE(ZEND_OP2_LITERAL(opline)) != IS_LONG) { @@ -23,7 +22,6 @@ static void nop_removal(zend_op_array *op_array) FREE_ALLOCA(shiftlist); return; } -#endif /* Kill JMP-over-NOP-s */ if (opline->opcode == ZEND_JMP && ZEND_OP1(opline).opline_num > i) { @@ -58,12 +56,8 @@ static void nop_removal(zend_op_array *op_array) for (opline = op_array->opcodes; oplineopcode) { case ZEND_JMP: -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO case ZEND_GOTO: -#endif -#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO case ZEND_FAST_CALL: -#endif ZEND_OP1(opline).opline_num -= shiftlist[ZEND_OP1(opline).opline_num]; break; case ZEND_JMPZ: @@ -73,12 +67,8 @@ static void nop_removal(zend_op_array *op_array) case ZEND_FE_FETCH: case ZEND_FE_RESET: case ZEND_NEW: -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO case ZEND_JMP_SET: -#endif -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO case ZEND_JMP_SET_VAR: -#endif ZEND_OP2(opline).opline_num -= shiftlist[ZEND_OP2(opline).opline_num]; break; case ZEND_JMPZNZ: @@ -102,15 +92,12 @@ static void nop_removal(zend_op_array *op_array) for (j = 0; j < op_array->last_try_catch; j++) { op_array->try_catch_array[j].try_op -= shiftlist[op_array->try_catch_array[j].try_op]; op_array->try_catch_array[j].catch_op -= shiftlist[op_array->try_catch_array[j].catch_op]; -#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO if (op_array->try_catch_array[j].finally_op) { op_array->try_catch_array[j].finally_op -= shiftlist[op_array->try_catch_array[j].finally_op]; op_array->try_catch_array[j].finally_end -= shiftlist[op_array->try_catch_array[j].finally_end]; } -#endif } -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO /* update early binding list */ if (op_array->early_binding != (zend_uint)-1) { zend_uint *opline_num = &op_array->early_binding; @@ -120,7 +107,6 @@ static void nop_removal(zend_op_array *op_array) opline_num = &ZEND_RESULT(&op_array->opcodes[*opline_num]).opline_num; } while (*opline_num != (zend_uint)-1); } -#endif } FREE_ALLOCA(shiftlist); } diff --git a/ext/opcache/Optimizer/optimize_func_calls.c b/ext/opcache/Optimizer/optimize_func_calls.c index b93fc3667c..3514e1567b 100644 --- a/ext/opcache/Optimizer/optimize_func_calls.c +++ b/ext/opcache/Optimizer/optimize_func_calls.c @@ -1,8 +1,6 @@ /* pass 4 * - optimize INIT_FCALL_BY_NAME to DO_FCALL */ -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO - typedef struct _optimizer_call_info { zend_function *func; zend_op *opline; @@ -128,12 +126,10 @@ static void optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx } break; #endif -#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO case ZEND_SEND_UNPACK: call_stack[call - 1].func = NULL; call_stack[call - 1].opline = NULL; break; -#endif default: break; } @@ -142,4 +138,3 @@ static void optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx zend_arena_release(&ctx->arena, checkpoint); } -#endif diff --git a/ext/opcache/Optimizer/optimize_temp_vars_5.c b/ext/opcache/Optimizer/optimize_temp_vars_5.c index af193802dd..2853748fe2 100644 --- a/ext/opcache/Optimizer/optimize_temp_vars_5.c +++ b/ext/opcache/Optimizer/optimize_temp_vars_5.c @@ -1,64 +1,3 @@ -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - -/* ops that use CLs: -op1: -ZEND_FETCH_CONSTANT: -ZEND_INIT_CTOR_CALL: -ZEND_INIT_STATIC_METHOD_CALL: -ZEND_INIT_METHOD_CALL: -ZEND_IMPORT_CLASS: -ZEND_IMPORT_FUNCTION: -ZEND_IMPORT_CONST: -ZEND_ADD_INTERFACE: -ZEND_VERIFY_ABSTRACT_CLASS: -ZEND_NEW: -ZEND_CATCH: -ZEND_INIT_FCALL_BY_NAME: - -op2: -ZEND_UNSET_VAR: -ZEND_ISSET_ISEMPTY_VAR: -ZEND_FETCH_UNSET: -ZEND_FETCH_IS: -ZEND_FETCH_R: -ZEND_FETCH_W: -ZEND_FETCH_RW: -ZEND_FETCH_FUNC_ARG: -ZEND_ADD_INTERFACE: -ZEND_INSTANCEOF: - -extended_value: -ZEND_DECLARE_INHERITED_CLASS: - -ignore result -INIT_METHOD_CALL: -*/ - -#define OP1_CONST_IS_CLASS 1 -#define OP2_CONST_IS_CLASS 2 -#define EXT_CONST_IS_CLASS 4 -#define RESULT_IS_UNUSED 8 - -static const char op_const_means_class[256] = { - /* 0 */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - /* 32 */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - /* 64 */ - 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, - /* 96 */ - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 9, 1, 2, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - /* 128 */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 4, 0, 0, 0, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - /* 160 */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - /* 192 */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - /* 224 */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; -#endif - #define GET_AVAILABLE_T() \ for (i = 0; i < T; i++) { \ if (!taken_T[i]) { \ @@ -95,13 +34,6 @@ static void optimize_temporary_variables(zend_op_array *op_array, zend_optimizer /* Find T definition points */ while (opline >= end) { -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - if (ZEND_RESULT_TYPE(opline) & (IS_VAR | IS_TMP_VAR | IS_CONST)) { - if (!(op_const_means_class[opline->opcode] & RESULT_IS_UNUSED)) { - start_of_T[VAR_NUM(ZEND_RESULT(opline).var) - offset] = opline; - } - } -#else if (ZEND_RESULT_TYPE(opline) & (IS_VAR | IS_TMP_VAR)) { start_of_T[VAR_NUM(ZEND_RESULT(opline).var) - offset] = opline; } @@ -115,7 +47,6 @@ static void optimize_temporary_variables(zend_op_array *op_array, zend_optimizer start_of_T[VAR_NUM(ZEND_OP1(opline).var) + 1 - offset] = opline; } } -#endif opline--; } @@ -126,11 +57,7 @@ static void optimize_temporary_variables(zend_op_array *op_array, zend_optimizer opline = &op_array->opcodes[op_array->last - 1]; while (opline >= end) { - if ((ZEND_OP1_TYPE(opline) & (IS_VAR | IS_TMP_VAR)) -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - || ((op_const_means_class[opline->opcode] & OP1_CONST_IS_CLASS) && ZEND_OP1_TYPE(opline) == IS_CONST) -#endif - ) { + if ((ZEND_OP1_TYPE(opline) & (IS_VAR | IS_TMP_VAR))) { /* special puprose variable to keep HashPointer on VM stack */ if (opline->opcode == ZEND_OP_DATA && @@ -160,11 +87,7 @@ static void optimize_temporary_variables(zend_op_array *op_array, zend_optimizer continue; } - if ((ZEND_OP2_TYPE(opline) & (IS_VAR | IS_TMP_VAR)) -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - || ((op_const_means_class[opline->opcode] & OP2_CONST_IS_CLASS) && ZEND_OP2_TYPE(opline) == IS_CONST) -#endif - ) { + if ((ZEND_OP2_TYPE(opline) & (IS_VAR | IS_TMP_VAR))) { currT = VAR_NUM(ZEND_OP2(opline).var) - offset; if (!valid_T[currT]) { GET_AVAILABLE_T(); @@ -174,12 +97,8 @@ static void optimize_temporary_variables(zend_op_array *op_array, zend_optimizer ZEND_OP2(opline).var = NUM_VAR(map_T[currT] + offset); } -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - if ((op_const_means_class[opline->opcode] & EXT_CONST_IS_CLASS)) { -#else if (opline->opcode == ZEND_DECLARE_INHERITED_CLASS || opline->opcode == ZEND_DECLARE_INHERITED_CLASS_DELAYED) { -#endif currT = VAR_NUM(opline->extended_value) - offset; if (!valid_T[currT]) { GET_AVAILABLE_T(); @@ -202,33 +121,25 @@ static void optimize_temporary_variables(zend_op_array *op_array, zend_optimizer var_to_free = i; } -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - if (ZEND_RESULT_TYPE(opline) & (IS_VAR | IS_TMP_VAR | IS_CONST)) { - if (!(op_const_means_class[opline->opcode] & RESULT_IS_UNUSED)) { -#else if (ZEND_RESULT_TYPE(opline) & (IS_VAR | IS_TMP_VAR)) { -#endif - currT = VAR_NUM(ZEND_RESULT(opline).var) - offset; - if (valid_T[currT]) { - if (start_of_T[currT] == opline) { - taken_T[map_T[currT]] = 0; - } - ZEND_RESULT(opline).var = NUM_VAR(map_T[currT] + offset); - } else { /* Au still needs to be assigned a T which is a bit dumb. Should consider changing Zend */ - GET_AVAILABLE_T(); + currT = VAR_NUM(ZEND_RESULT(opline).var) - offset; + if (valid_T[currT]) { + if (start_of_T[currT] == opline) { + taken_T[map_T[currT]] = 0; + } + ZEND_RESULT(opline).var = NUM_VAR(map_T[currT] + offset); + } else { /* Au still needs to be assigned a T which is a bit dumb. Should consider changing Zend */ + GET_AVAILABLE_T(); - if (RESULT_UNUSED(opline)) { - taken_T[i] = 0; - } else { - /* Code which gets here is using a wrongly built opcode such as RECV() */ - map_T[currT] = i; - valid_T[currT] = 1; - } - ZEND_RESULT(opline).var = NUM_VAR(i + offset); + if (RESULT_UNUSED(opline)) { + taken_T[i] = 0; + } else { + /* Code which gets here is using a wrongly built opcode such as RECV() */ + map_T[currT] = i; + valid_T[currT] = 1; } -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO + ZEND_RESULT(opline).var = NUM_VAR(i + offset); } -#endif } if (var_to_free >= 0) { diff --git a/ext/opcache/Optimizer/pass1_5.c b/ext/opcache/Optimizer/pass1_5.c index b2e5b1cb3c..4b2115a9fe 100644 --- a/ext/opcache/Optimizer/pass1_5.c +++ b/ext/opcache/Optimizer/pass1_5.c @@ -6,11 +6,7 @@ * - pre-evaluate constant function calls */ -#if ZEND_EXTENSION_API_NO > PHP_5_2_X_API_NO -# define ZEND_IS_CONSTANT_TYPE(t) ((t) == IS_CONSTANT) -#else -# define ZEND_IS_CONSTANT_TYPE(t) ((t) == IS_CONSTANT) -#endif +#define ZEND_IS_CONSTANT_TYPE(t) ((t) == IS_CONSTANT) if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) { int i = 0; @@ -25,9 +21,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) { case ZEND_MUL: case ZEND_DIV: case ZEND_MOD: -#if ZEND_EXTENSION_API_NO >= PHP_5_6_X_API_NO case ZEND_POW: -#endif case ZEND_SL: case ZEND_SR: case ZEND_CONCAT: @@ -125,11 +119,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) { er = EG(error_reporting); EG(error_reporting) = 0; -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - if (unary_op(&result, &ZEND_OP1_LITERAL(opline)) != SUCCESS) { -#else if (unary_op(&result, &ZEND_OP1_LITERAL(opline) TSRMLS_CC) != SUCCESS) { -#endif EG(error_reporting) = er; break; } @@ -254,7 +244,6 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) { replace_tmp_by_const(op_array, opline, tv, &c TSRMLS_CC); } -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO /* class constant */ if (ZEND_OP1_TYPE(opline) != IS_UNUSED && ZEND_OP2_TYPE(opline) == IS_CONST && @@ -317,7 +306,6 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) { } } } -#endif break; case ZEND_INIT_FCALL: @@ -481,7 +469,6 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) { MAKE_NOP(opline); } break; -#if ZEND_EXTENSION_API_NO > PHP_5_2_X_API_NO case ZEND_DECLARE_CONST: if (collect_constants && Z_TYPE(ZEND_OP1_LITERAL(opline)) == IS_STRING && @@ -489,27 +476,18 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) { zend_optimizer_collect_constant(ctx, &ZEND_OP1_LITERAL(opline), &ZEND_OP2_LITERAL(opline)); } break; -#endif case ZEND_RETURN: -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO case ZEND_RETURN_BY_REF: -#endif -#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO case ZEND_GENERATOR_RETURN: -#endif case ZEND_EXIT: case ZEND_THROW: case ZEND_CATCH: case ZEND_BRK: case ZEND_CONT: -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO case ZEND_GOTO: -#endif -#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO case ZEND_FAST_CALL: case ZEND_FAST_RET: -#endif case ZEND_JMP: case ZEND_JMPZNZ: case ZEND_JMPZ: @@ -520,15 +498,10 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) { case ZEND_FE_FETCH: case ZEND_NEW: case ZEND_DO_FCALL: -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO case ZEND_JMP_SET: -#endif -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO case ZEND_JMP_SET_VAR: -#endif collect_constants = 0; break; -#if ZEND_EXTENSION_API_NO >= PHP_5_5_X_API_NO case ZEND_FETCH_R: case ZEND_FETCH_W: case ZEND_FETCH_RW: @@ -591,7 +564,6 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) { } } break; -#endif } opline++; i++; diff --git a/ext/opcache/Optimizer/pass2.c b/ext/opcache/Optimizer/pass2.c index e7e6f3d591..45dc7a5dd0 100644 --- a/ext/opcache/Optimizer/pass2.c +++ b/ext/opcache/Optimizer/pass2.c @@ -89,11 +89,7 @@ if (ZEND_OPTIMIZER_PASS_2 & OPTIMIZATION_LEVEL) { /* convert Ti = JMPZ_EX(C, L) => Ti = QM_ASSIGN(C) in case we know it wouldn't jump */ } else if (ZEND_OP1_TYPE(opline) == IS_CONST) { -#if ZEND_EXTENSION_API_NO > PHP_5_6_X_API_NO int should_jmp = zend_is_true(&ZEND_OP1_LITERAL(opline) TSRMLS_CC); -#else - int should_jmp = zend_is_true(&ZEND_OP1_LITERAL(opline)); -#endif if (opline->opcode == ZEND_JMPZ_EX) { should_jmp = !should_jmp; } @@ -107,11 +103,7 @@ if (ZEND_OPTIMIZER_PASS_2 & OPTIMIZATION_LEVEL) { case ZEND_JMPZ: case ZEND_JMPNZ: if (ZEND_OP1_TYPE(opline) == IS_CONST) { -#if ZEND_EXTENSION_API_NO > PHP_5_6_X_API_NO int should_jmp = zend_is_true(&ZEND_OP1_LITERAL(opline) TSRMLS_CC); -#else - int should_jmp = zend_is_true(&ZEND_OP1_LITERAL(opline)); -#endif if (opline->opcode == ZEND_JMPZ) { should_jmp = !should_jmp; @@ -147,11 +139,7 @@ if (ZEND_OPTIMIZER_PASS_2 & OPTIMIZATION_LEVEL) { case ZEND_JMPZNZ: if (ZEND_OP1_TYPE(opline) == IS_CONST) { int opline_num; -#if ZEND_EXTENSION_API_NO > PHP_5_6_X_API_NO if (zend_is_true(&ZEND_OP1_LITERAL(opline) TSRMLS_CC)) { -#else - if (zend_is_true(&ZEND_OP1_LITERAL(opline))) { -#endif opline_num = opline->extended_value; /* JMPNZ */ } else { opline_num = ZEND_OP2(opline).opline_num; /* JMPZ */ diff --git a/ext/opcache/Optimizer/pass3.c b/ext/opcache/Optimizer/pass3.c index 1ee641ca52..bbbfe91cf3 100644 --- a/ext/opcache/Optimizer/pass3.c +++ b/ext/opcache/Optimizer/pass3.c @@ -45,9 +45,7 @@ if (ZEND_OPTIMIZER_PASS_3 & OPTIMIZATION_LEVEL) { case ZEND_MUL: case ZEND_DIV: case ZEND_MOD: -#if ZEND_EXTENSION_API_NO >= PHP_5_6_X_API_NO case ZEND_POW: -#endif case ZEND_CONCAT: case ZEND_SL: case ZEND_SR: @@ -75,12 +73,8 @@ if (ZEND_OPTIMIZER_PASS_3 & OPTIMIZATION_LEVEL) { /* change $i=expr+$i to $i=$i+expr so that the next * optimization works on it */ -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO zend_uchar tmp_type = opline->op1_type; znode_op tmp = opline->op1; -#else - znode tmp = opline->op1; -#endif if (opline->opcode != ZEND_ADD || ZEND_OP1_TYPE(opline) == IS_CONST) { /* protection from array add: $a = array + $a is not commutative! */ @@ -107,11 +101,9 @@ if (ZEND_OPTIMIZER_PASS_3 & OPTIMIZATION_LEVEL) { case ZEND_MOD: opline->opcode = ZEND_ASSIGN_MOD; break; -#if ZEND_EXTENSION_API_NO >= PHP_5_6_X_API_NO case ZEND_POW: opline->opcode = ZEND_ASSIGN_POW; break; -#endif case ZEND_CONCAT: opline->opcode = ZEND_ASSIGN_CONCAT; break; @@ -140,11 +132,9 @@ if (ZEND_OPTIMIZER_PASS_3 & OPTIMIZATION_LEVEL) { break; case ZEND_JMP: -#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO if (op_array->has_finally_block) { break; } -#endif /* convert L: JMP L+1 to NOP */ if (ZEND_OP1(opline).opline_num == opline_num + 1) { @@ -161,17 +151,11 @@ if (ZEND_OPTIMIZER_PASS_3 & OPTIMIZATION_LEVEL) { } break; -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO case ZEND_JMP_SET: -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO case ZEND_JMP_SET_VAR: -#endif - -#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO if (op_array->has_finally_block) { break; } -#endif while (ZEND_OP2(opline).opline_num < op_array->last) { int target = ZEND_OP2(opline).opline_num; @@ -182,15 +166,11 @@ if (ZEND_OPTIMIZER_PASS_3 & OPTIMIZATION_LEVEL) { } } break; -#endif - case ZEND_JMPZ: case ZEND_JMPNZ: -#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO if (op_array->has_finally_block) { break; } -#endif /* convert L: JMPZ L+1 to NOP */ if (ZEND_OP2(opline).opline_num == opline_num + 1) { @@ -241,17 +221,13 @@ if (ZEND_OPTIMIZER_PASS_3 & OPTIMIZATION_LEVEL) { case ZEND_JMPZ_EX: case ZEND_JMPNZ_EX: { -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO zend_uchar T_type = opline->result_type; znode_op T = opline->result; -#else - znode T = opline->result; -#endif -#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO + if (op_array->has_finally_block) { break; } -#endif + /* convert L: T = JMPZ_EX X,L+1 to T = BOOL(X) */ /* convert L: T = JMPZ_EX T,L+1 to NOP */ if (ZEND_OP2(opline).opline_num == opline_num + 1) { @@ -320,12 +296,8 @@ continue_jmp_ex_optimization: op->opcode == ZEND_CONT || op->opcode == ZEND_CASE || op->opcode == ZEND_RETURN || -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO op->opcode == ZEND_RETURN_BY_REF || -#endif -#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO op->opcode == ZEND_FAST_RET || -#endif op->opcode == ZEND_FE_FETCH || op->opcode == ZEND_EXIT) { break; @@ -359,12 +331,8 @@ continue_jmp_ex_optimization: op->opcode == ZEND_CONT || op->opcode == ZEND_CASE || op->opcode == ZEND_RETURN || -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO op->opcode == ZEND_RETURN_BY_REF || -#endif -#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO op->opcode == ZEND_FAST_RET || -#endif op->opcode == ZEND_FE_FETCH || op->opcode == ZEND_EXIT) { break; @@ -390,11 +358,10 @@ continue_jmp_ex_optimization: break; case ZEND_JMPZNZ: -#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO if (op_array->has_finally_block) { break; } -#endif + /* JMPZNZ(X,L1,L2), L1: JMP(L3) => JMPZNZ(X,L3,L2), L1: JMP(L3) */ while (ZEND_OP2(opline).opline_num < op_array->last && op_array->opcodes[ZEND_OP2(opline).opline_num].opcode == ZEND_JMP) { @@ -431,13 +398,7 @@ continue_jmpznz_optimization: opline->opcode = ZEND_PRE_DEC; break; } -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO ZEND_RESULT_TYPE(opline) = IS_VAR | EXT_TYPE_UNUSED; -#else - ZEND_RESULT_TYPE(opline) = IS_VAR; - ZEND_RESULT(opline).EA.type = 0; - ZEND_RESULT(opline).EA.type |= EXT_TYPE_UNUSED; -#endif } } break; diff --git a/ext/opcache/Optimizer/zend_optimizer.c b/ext/opcache/Optimizer/zend_optimizer.c index fd711cb9ee..b783c3777b 100644 --- a/ext/opcache/Optimizer/zend_optimizer.c +++ b/ext/opcache/Optimizer/zend_optimizer.c @@ -58,7 +58,6 @@ static int zend_optimizer_get_collected_constant(HashTable *constants, zval *nam return 0; } -#if ZEND_EXTENSION_API_NO >= PHP_5_5_X_API_NO static int zend_optimizer_lookup_cv(zend_op_array *op_array, zend_string* name) { int i = 0; @@ -102,9 +101,7 @@ static int zend_optimizer_lookup_cv(zend_op_array *op_array, zend_string* name) return (int)(zend_intptr_t)EX_VAR_NUM_2(NULL, i); } -#endif -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO int zend_optimizer_add_literal(zend_op_array *op_array, zval *zv TSRMLS_DC) { int i = op_array->last_literal; @@ -139,19 +136,6 @@ int zend_optimizer_add_literal(zend_op_array *op_array, zval *zv TSRMLS_DC) target = src; \ } while (0) -#else - -# define LITERAL_LONG(op, val) ZVAL_LONG(&op.u.constant, val) - -# define LITERAL_BOOL(op, val) ZVAL_BOOL(&op.u.constant, val) - -# define literal_dtor(zv) zval_dtor(zv) - -#define COPY_NODE(target, src) do { \ - target = src; \ - } while (0) - -#endif static void update_op1_const(zend_op_array *op_array, zend_op *opline, @@ -162,7 +146,6 @@ static void update_op1_const(zend_op_array *op_array, zval_dtor(val); } else { ZEND_OP1_TYPE(opline) = IS_CONST; -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (Z_TYPE_P(val) == IS_STRING) { switch (opline->opcode) { case ZEND_INIT_STATIC_METHOD_CALL: @@ -184,9 +167,6 @@ static void update_op1_const(zend_op_array *op_array, } else { opline->op1.constant = zend_optimizer_add_literal(op_array, val TSRMLS_CC); } -#else - ZEND_OP1_LITERAL(opline) = *val; -#endif } } @@ -195,7 +175,6 @@ static void update_op2_const(zend_op_array *op_array, zval *val TSRMLS_DC) { ZEND_OP2_TYPE(opline) = IS_CONST; -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (opline->opcode == ZEND_INIT_FCALL) { zend_str_tolower(Z_STRVAL_P(val), Z_STRLEN_P(val)); opline->op2.constant = zend_optimizer_add_literal(op_array, val TSRMLS_CC); @@ -264,7 +243,6 @@ static void update_op2_const(zend_op_array *op_array, op_array->last_cache_slot += 2; } break; -#if ZEND_EXTENSION_API_NO >= PHP_5_4_X_API_NO case ZEND_OP_DATA: if ((opline-1)->opcode == ZEND_ASSIGN_DIM || ((opline-1)->extended_value == ZEND_ASSIGN_DIM && @@ -304,14 +282,10 @@ check_numeric: } } break; -#endif default: break; } } -#else - ZEND_OP2_LITERAL(opline) = *val; -#endif } static int replace_var_by_const(zend_op_array *op_array, @@ -330,9 +304,7 @@ static int replace_var_by_const(zend_op_array *op_array, case ZEND_FETCH_DIM_FUNC_ARG: case ZEND_FETCH_DIM_UNSET: case ZEND_ASSIGN_DIM: -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO case ZEND_SEPARATE: -#endif return 0; case ZEND_SEND_VAR_NO_REF: if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { @@ -456,14 +428,12 @@ static void zend_optimize(zend_op_array *op_array, */ #include "Optimizer/pass3.c" -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO /* pass 4: * - INIT_FCALL_BY_NAME -> DO_FCALL */ if (ZEND_OPTIMIZER_PASS_4 & OPTIMIZATION_LEVEL) { optimize_func_calls(op_array, ctx TSRMLS_CC); } -#endif /* pass 5: * - CFG optimization @@ -480,14 +450,12 @@ static void zend_optimize(zend_op_array *op_array, */ #include "Optimizer/pass10.c" -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO /* pass 11: * - Compact literals table */ if (ZEND_OPTIMIZER_PASS_11 & OPTIMIZATION_LEVEL) { optimizer_compact_literals(op_array, ctx TSRMLS_CC); } -#endif } static void zend_accel_optimize(zend_op_array *op_array, @@ -499,22 +467,16 @@ static void zend_accel_optimize(zend_op_array *op_array, opline = op_array->opcodes; end = opline + op_array->last; while (opline < end) { -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (opline->op1_type == IS_CONST) { opline->op1.constant = opline->op1.zv - op_array->literals; } if (opline->op2_type == IS_CONST) { opline->op2.constant = opline->op2.zv - op_array->literals; } -#endif switch (opline->opcode) { case ZEND_JMP: -#if ZEND_EXTENSION_API_NO > PHP_5_2_X_API_NO case ZEND_GOTO: -#endif -#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO case ZEND_FAST_CALL: -#endif ZEND_OP1(opline).opline_num = ZEND_OP1(opline).jmp_addr - op_array->opcodes; break; case ZEND_JMPZNZ: @@ -525,12 +487,8 @@ static void zend_accel_optimize(zend_op_array *op_array, case ZEND_JMPNZ: case ZEND_JMPZ_EX: case ZEND_JMPNZ_EX: -#if ZEND_EXTENSION_API_NO > PHP_5_2_X_API_NO case ZEND_JMP_SET: -#endif -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO case ZEND_JMP_SET_VAR: -#endif case ZEND_NEW: case ZEND_FE_RESET: case ZEND_FE_FETCH: @@ -547,22 +505,16 @@ static void zend_accel_optimize(zend_op_array *op_array, opline = op_array->opcodes; end = opline + op_array->last; while (opline < end) { -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (opline->op1_type == IS_CONST) { opline->op1.zv = &op_array->literals[opline->op1.constant]; } if (opline->op2_type == IS_CONST) { opline->op2.zv = &op_array->literals[opline->op2.constant]; } -#endif switch (opline->opcode) { case ZEND_JMP: -#if ZEND_EXTENSION_API_NO > PHP_5_2_X_API_NO case ZEND_GOTO: -#endif -#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO case ZEND_FAST_CALL: -#endif ZEND_OP1(opline).jmp_addr = &op_array->opcodes[ZEND_OP1(opline).opline_num]; break; case ZEND_JMPZNZ: @@ -573,12 +525,8 @@ static void zend_accel_optimize(zend_op_array *op_array, case ZEND_JMPNZ: case ZEND_JMPZ_EX: case ZEND_JMPNZ_EX: -#if ZEND_EXTENSION_API_NO > PHP_5_2_X_API_NO case ZEND_JMP_SET: -#endif -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO case ZEND_JMP_SET_VAR: -#endif case ZEND_NEW: case ZEND_FE_RESET: case ZEND_FE_FETCH: diff --git a/ext/opcache/Optimizer/zend_optimizer_internal.h b/ext/opcache/Optimizer/zend_optimizer_internal.h index 361d1207f8..b0ba12abc7 100644 --- a/ext/opcache/Optimizer/zend_optimizer_internal.h +++ b/ext/opcache/Optimizer/zend_optimizer_internal.h @@ -24,36 +24,18 @@ #include "ZendAccelerator.h" -#if 1 // TODO: remove support for old PHP versions ??? -# define VAR_NUM(v) EX_VAR_TO_NUM(v) -# define NUM_VAR(v) ((zend_uint)(zend_uintptr_t)EX_VAR_NUM_2(0, v)) -#elif ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO -# define VAR_NUM(v) ((zend_uint)(EX_TMP_VAR_NUM(0, 0) - EX_TMP_VAR(0, v))) -# define NUM_VAR(v) ((zend_uint)(zend_uintptr_t)EX_TMP_VAR_NUM(0, v)) -#elif ZEND_EXTENSION_API_NO > PHP_5_2_X_API_NO -# define VAR_NUM(v) ((v)/ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable))) -# define NUM_VAR(v) ((v)*ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable))) -#else -# define VAR_NUM(v) ((v)/(sizeof(temp_variable))) -# define NUM_VAR(v) ((v)*(sizeof(temp_variable))) -#endif +#define VAR_NUM(v) EX_VAR_TO_NUM(v) +#define NUM_VAR(v) ((zend_uint)(zend_uintptr_t)EX_VAR_NUM_2(0, v)) #define INV_COND(op) ((op) == ZEND_JMPZ ? ZEND_JMPNZ : ZEND_JMPZ) #define INV_EX_COND(op) ((op) == ZEND_JMPZ_EX ? ZEND_JMPNZ : ZEND_JMPZ) #define INV_COND_EX(op) ((op) == ZEND_JMPZ ? ZEND_JMPNZ_EX : ZEND_JMPZ_EX) #define INV_EX_COND_EX(op) ((op) == ZEND_JMPZ_EX ? ZEND_JMPNZ_EX : ZEND_JMPZ_EX) -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO -# define MAKE_NOP(opline) { (opline)->opcode = ZEND_NOP; memset(&(opline)->result, 0, sizeof((opline)->result)); memset(&(opline)->op1, 0, sizeof((opline)->op1)); memset(&(opline)->op2, 0, sizeof((opline)->op2));(opline)->result_type=(opline)->op1_type=(opline)->op2_type=IS_UNUSED; (opline)->handler = zend_opcode_handlers[ZEND_NOP]; } -# define RESULT_USED(op) (((op->result_type & IS_VAR) && !(op->result_type & EXT_TYPE_UNUSED)) || op->result_type == IS_TMP_VAR) -# define RESULT_UNUSED(op) ((op->result_type & EXT_TYPE_UNUSED) != 0) -# define SAME_VAR(op1, op2) ((((op1 ## _type & IS_VAR) && (op2 ## _type & IS_VAR)) || (op1 ## _type == IS_TMP_VAR && op2 ## _type == IS_TMP_VAR)) && op1.var == op2.var) -#else -# define MAKE_NOP(opline) { opline->opcode = ZEND_NOP; memset(&opline->result,0,sizeof(znode)); memset(&opline->op1,0,sizeof(znode)); memset(&opline->op2,0,sizeof(znode)); opline->result.op_type=opline->op1.op_type=opline->op2.op_type=IS_UNUSED; opline->handler = zend_opcode_handlers[ZEND_NOP]; } -# define RESULT_USED(op) ((op->result.op_type == IS_VAR && (op->result.u.EA.type & EXT_TYPE_UNUSED) == 0) || (op->result.op_type == IS_TMP_VAR)) -# define RESULT_UNUSED(op) ((op->result.op_type == IS_VAR) && (op->result.u.EA.type == EXT_TYPE_UNUSED)) -# define SAME_VAR(op1, op2) (((op1.op_type == IS_VAR && op2.op_type == IS_VAR) || (op1.op_type == IS_TMP_VAR && op2.op_type == IS_TMP_VAR)) && op1.u.var == op2.u.var) -#endif +#define MAKE_NOP(opline) { (opline)->opcode = ZEND_NOP; memset(&(opline)->result, 0, sizeof((opline)->result)); memset(&(opline)->op1, 0, sizeof((opline)->op1)); memset(&(opline)->op2, 0, sizeof((opline)->op2));(opline)->result_type=(opline)->op1_type=(opline)->op2_type=IS_UNUSED; (opline)->handler = zend_opcode_handlers[ZEND_NOP]; } +#define RESULT_USED(op) (((op->result_type & IS_VAR) && !(op->result_type & EXT_TYPE_UNUSED)) || op->result_type == IS_TMP_VAR) +#define RESULT_UNUSED(op) ((op->result_type & EXT_TYPE_UNUSED) != 0) +#define SAME_VAR(op1, op2) ((((op1 ## _type & IS_VAR) && (op2 ## _type & IS_VAR)) || (op1 ## _type == IS_TMP_VAR && op2 ## _type == IS_TMP_VAR)) && op1.var == op2.var) typedef struct _zend_optimizer_ctx { zend_arena *arena; diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 6228c827c9..ebd3844e38 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -36,11 +36,7 @@ #include "main/php_open_temporary_file.h" #include "zend_API.h" #include "zend_ini.h" -#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO -# include "zend_virtual_cwd.h" -#else -# include "TSRM/tsrm_virtual_cwd.h" -#endif +#include "zend_virtual_cwd.h" #include "zend_accelerator_util_funcs.h" #include "zend_accelerator_hash.h" @@ -106,16 +102,10 @@ char *zps_api_failure_reason = NULL; static zend_op_array *(*accelerator_orig_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC); static int (*accelerator_orig_zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC); -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO static char *(*accelerator_orig_zend_resolve_path)(const char *filename, int filename_len TSRMLS_DC); -#endif static void (*orig_chdir)(INTERNAL_FUNCTION_PARAMETERS) = NULL; static ZEND_INI_MH((*orig_include_path_on_modify)) = NULL; -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO -static char *accel_php_resolve_path(const char *filename, int filename_length, const char *path TSRMLS_DC); -#endif - #ifdef ZEND_WIN32 # define INCREMENT(v) InterlockedIncrement(&ZCSG(v)) # define DECREMENT(v) InterlockedDecrement(&ZCSG(v)) @@ -249,7 +239,6 @@ static ZEND_INI_MH(accel_include_path_on_modify) return ret; } -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO /* Interned strings support */ static zend_string *(*orig_new_interned_string)(zend_string *str TSRMLS_DC); static void (*orig_interned_strings_snapshot)(TSRMLS_D); @@ -379,7 +368,6 @@ static void accel_use_shm_interned_strings(TSRMLS_D) uint idx, j; Bucket *p, *q; -#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO /* empty string */ CG(empty_string) = accel_new_interned_string(CG(empty_string) TSRMLS_CC); for (j = 0; j < 256; j++) { @@ -388,7 +376,6 @@ static void accel_use_shm_interned_strings(TSRMLS_D) s[1] = 0; CG(one_char_string)[j] = accel_new_interned_string(STR_INIT(s, 1, 0) TSRMLS_CC); } -#endif /* function table hash keys */ for (idx = 0; idx < CG(function_table)->nNumUsed; idx++) { @@ -474,7 +461,6 @@ static void accel_use_shm_interned_strings(TSRMLS_D) } } #endif -#endif static inline void accel_restart_enter(TSRMLS_D) { @@ -769,9 +755,7 @@ static accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle } break; case ZEND_HANDLE_FILENAME: -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO case ZEND_HANDLE_MAPPED: -#endif { char *file_path = file_handle->opened_path; @@ -843,11 +827,7 @@ static inline int do_validate_timestamps(zend_persistent_script *persistent_scri return FAILURE; } } else { -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - full_path_ptr = accel_php_resolve_path(file_handle->filename, strlen(file_handle->filename), ZCG(include_path) TSRMLS_CC); -#else full_path_ptr = accelerator_orig_zend_resolve_path(file_handle->filename, strlen(file_handle->filename) TSRMLS_CC); -#endif if (full_path_ptr && strcmp(persistent_script->full_path->val, full_path_ptr) != 0) { efree(full_path_ptr); return FAILURE; @@ -1065,11 +1045,7 @@ int zend_accel_invalidate(const char *filename, int filename_len, zend_bool forc return FAILURE; } -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - realpath = accel_php_resolve_path(filename, filename_len, ZCG(include_path) TSRMLS_CC); -#else realpath = accelerator_orig_zend_resolve_path(filename, filename_len TSRMLS_CC); -#endif if (!realpath) { return FAILURE; @@ -1245,9 +1221,7 @@ static const struct jit_auto_global_info { "_SERVER", sizeof("_SERVER")-1}, { "_ENV", sizeof("_ENV")-1}, { "_REQUEST", sizeof("_REQUEST")-1}, -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO { "GLOBALS", sizeof("GLOBALS")-1}, -#endif }; static zend_string *jit_auto_globals_str[4]; @@ -1267,7 +1241,6 @@ static int zend_accel_get_auto_globals(TSRMLS_D) return mask; } -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO static int zend_accel_get_auto_globals_no_jit(TSRMLS_D) { if (zend_hash_exists(&EG(symbol_table).ht, jit_auto_globals_str[3])) { @@ -1275,7 +1248,6 @@ static int zend_accel_get_auto_globals_no_jit(TSRMLS_D) } return 0; } -#endif static void zend_accel_set_auto_globals(int mask TSRMLS_DC) { @@ -1311,9 +1283,7 @@ static zend_persistent_script *compile_and_cache_file(zend_file_handle *file_han zend_op_array *op_array; int do_bailout = 0; accel_time_t timestamp = 0; -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO zend_uint orig_compiler_options = 0; -#endif /* Try to open file */ if (file_handle->type == ZEND_HANDLE_FILENAME) { @@ -1325,18 +1295,10 @@ static zend_persistent_script *compile_and_cache_file(zend_file_handle *file_han } else { *op_array_p = NULL; if (type == ZEND_REQUIRE) { -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename); -#else zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename TSRMLS_CC); -#endif zend_bailout(); } else { -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename); -#else zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename TSRMLS_CC); -#endif } return NULL; } @@ -1349,7 +1311,6 @@ static zend_persistent_script *compile_and_cache_file(zend_file_handle *file_han return NULL; } -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO if (file_handle->type == ZEND_HANDLE_STREAM && (!strstr(file_handle->filename, ".phar") || strstr(file_handle->filename, "://"))) { @@ -1364,7 +1325,6 @@ static zend_persistent_script *compile_and_cache_file(zend_file_handle *file_han return NULL; } } -#endif if (ZCG(accel_directives).validate_timestamps || ZCG(accel_directives).file_update_protection || @@ -1412,23 +1372,17 @@ static zend_persistent_script *compile_and_cache_file(zend_file_handle *file_han ZVAL_UNDEF(&EG(user_error_handler)); zend_try { -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO orig_compiler_options = CG(compiler_options); CG(compiler_options) |= ZEND_COMPILE_HANDLE_OP_ARRAY; CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES; CG(compiler_options) |= ZEND_COMPILE_DELAYED_BINDING; CG(compiler_options) |= ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION; -#endif op_array = *op_array_p = accelerator_orig_compile_file(file_handle, type TSRMLS_CC); -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO CG(compiler_options) = orig_compiler_options; -#endif } zend_catch { op_array = NULL; do_bailout = 1; -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO CG(compiler_options) = orig_compiler_options; -#endif } zend_end_try(); /* Restore originals */ @@ -1458,17 +1412,11 @@ static zend_persistent_script *compile_and_cache_file(zend_file_handle *file_han /* Fill in the ping_auto_globals_mask for the new script. If jit for auto globals is enabled we will have to ping the used auto global variables before execution */ -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (PG(auto_globals_jit)) { new_persistent_script->ping_auto_globals_mask = zend_accel_get_auto_globals(TSRMLS_C); } else { new_persistent_script->ping_auto_globals_mask = zend_accel_get_auto_globals_no_jit(TSRMLS_C); } -#else - if ((PG(auto_globals_jit) && !PG(register_globals) && !PG(register_long_arrays))) { - new_persistent_script->ping_auto_globals_mask = zend_accel_get_auto_globals(TSRMLS_C); - } -#endif if (ZCG(accel_directives).validate_timestamps) { /* Obtain the file timestamps, *before* actually compiling them, @@ -1529,13 +1477,8 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type T ZEND_USER_CODE(EG(current_execute_data)->func->common.type) && EG(current_execute_data)->opline == ZCG(cache_opline) && EG(current_execute_data)->opline->opcode == ZEND_INCLUDE_OR_EVAL && -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO (EG(current_execute_data)->opline->extended_value == ZEND_INCLUDE_ONCE || EG(current_execute_data)->opline->extended_value == ZEND_REQUIRE_ONCE))) { -#else - ((*EG(opline_ptr))->op2.u.constant.value.lval == ZEND_INCLUDE_ONCE || - (*EG(opline_ptr))->op2.u.constant.value.lval == ZEND_REQUIRE_ONCE))) { -#endif if (!ZCG(key_len)) { return accelerator_orig_compile_file(file_handle, type TSRMLS_CC); } @@ -1556,24 +1499,12 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type T /* open file to resolve the path */ if (file_handle->type == ZEND_HANDLE_FILENAME && -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO accelerator_orig_zend_stream_open_function(file_handle->filename, file_handle TSRMLS_CC) == FAILURE) { -#else - zend_stream_open(file_handle->filename, file_handle TSRMLS_CC) == FAILURE) { -#endif if (type == ZEND_REQUIRE) { -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename); -#else zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename TSRMLS_CC); -#endif zend_bailout(); } else { -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename); -#else zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename TSRMLS_CC); -#endif } return NULL; } @@ -1699,14 +1630,8 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type T !EG(current_execute_data)->func || !ZEND_USER_CODE(EG(current_execute_data)->func->common.type) || EG(current_execute_data)->opline->opcode != ZEND_INCLUDE_OR_EVAL || -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO (EG(current_execute_data)->opline->extended_value != ZEND_INCLUDE_ONCE && EG(current_execute_data)->opline->extended_value != ZEND_REQUIRE_ONCE)) { -#else - ((*EG(opline_ptr))->op2.u.constant.value.lval != ZEND_INCLUDE_ONCE && - (*EG(opline_ptr))->op2.u.constant.value.lval != ZEND_REQUIRE_ONCE)) { -#endif - if (zend_hash_add_empty_element(&EG(included_files), persistent_script->full_path) != NULL) { /* ext/phar has to load phar's metadata into memory */ if (strstr(persistent_script->full_path->val, ".phar") && !strstr(persistent_script->full_path->val, "://")) { @@ -1721,11 +1646,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type T } } } -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - zend_file_handle_dtor(file_handle); -#else zend_file_handle_dtor(file_handle TSRMLS_CC); -#endif from_shared_memory = 1; } @@ -1741,213 +1662,6 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type T return zend_accel_load_script(persistent_script, from_shared_memory TSRMLS_CC); } -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - -/* Taken from php-5.2.5 because early versions don't have correct version */ -static char *accel_tsrm_realpath(const char *path, int path_len TSRMLS_DC) -{ - cwd_state new_state; - char *real_path; - char *cwd; - int cwd_len; - - /* realpath("") returns CWD */ - if (!*path) { - new_state.cwd = (char*)malloc(1); - if (!new_state.cwd) { - zend_accel_error(ACCEL_LOG_ERROR, "malloc() failed"); - return NULL; - } - new_state.cwd[0] = '\0'; - new_state.cwd_length = 0; - if ((cwd = accel_getcwd(&cwd_len TSRMLS_CC)) != NULL) { - path = cwd; - } - } else if (!IS_ABSOLUTE_PATH(path, path_len) && - (cwd = accel_getcwd(&cwd_len TSRMLS_CC)) != NULL) { - new_state.cwd = zend_strndup(cwd, cwd_len); - if (!new_state.cwd) { - zend_accel_error(ACCEL_LOG_ERROR, "malloc() failed"); - return NULL; - } - new_state.cwd_length = cwd_len; - } else { - new_state.cwd = (char*)malloc(1); - if (!new_state.cwd) { - zend_accel_error(ACCEL_LOG_ERROR, "malloc() failed"); - return NULL; - } - new_state.cwd[0] = '\0'; - new_state.cwd_length = 0; - } - -#ifndef CWD_REALPATH -# define CWD_REALPATH 2 -#endif - if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH)) { - free(new_state.cwd); - return NULL; - } - - real_path = emalloc(new_state.cwd_length + 1); - memcpy(real_path, new_state.cwd, new_state.cwd_length + 1); - free(new_state.cwd); - return real_path; -} - -static char *accel_php_resolve_path(const char *filename, int filename_length, const char *path TSRMLS_DC) -{ - char *resolved_path; - char trypath[MAXPATHLEN]; - const char *ptr, *end; - int len; - - if (!filename) { - return NULL; - } - - if (*filename == '.' || - IS_ABSOLUTE_PATH(filename, filename_length) || - !path || - !*path) { - return accel_tsrm_realpath(filename, filename_length TSRMLS_CC); - } - - ptr = path; - while (*ptr) { - for (end = ptr; *end && *end != DEFAULT_DIR_SEPARATOR; end++); - len = end - ptr; - if (*end) end++; - if (len + 1 + filename_length + 1 >= MAXPATHLEN) { - ptr = end; - continue; - } - memcpy(trypath, ptr, len); - trypath[len] = '/'; - memcpy(trypath + len + 1, filename, filename_length + 1); - ptr = end; - if ((resolved_path = accel_tsrm_realpath(trypath, len + 1 + filename_length TSRMLS_CC)) != NULL) { - return resolved_path; - } - } /* end provided path */ - - /* check in calling scripts' current working directory as a fall back case - */ - if (EG(in_execution)) { - char *exec_fname = zend_get_executed_filename(TSRMLS_C); - int exec_fname_length = strlen(exec_fname); - - while ((--exec_fname_length >= 0) && !IS_SLASH(exec_fname[exec_fname_length])); - if (exec_fname && exec_fname[0] != '[' && - exec_fname_length > 0 && - exec_fname_length + 1 + filename_length + 1 < MAXPATHLEN) { - memcpy(trypath, exec_fname, exec_fname_length + 1); - memcpy(trypath + exec_fname_length + 1, filename, filename_length + 1); - return accel_tsrm_realpath(trypath, exec_fname_length + 1 + filename_length TSRMLS_CC); - } - } - - return NULL; -} - -/* zend_stream_open_function() replacement for PHP 5.2 */ -static int persistent_stream_open_function(const char *filename, zend_file_handle *handle TSRMLS_DC) -{ - if (ZCG(enabled) && accel_startup_ok && - (ZCG(counted) || ZCSG(accelerator_enabled)) && - !CG(interactive) && - !ZCSG(restart_in_progress)) { - - if (EG(current_execute_data) && - EG(current_execute_data)->func && - ZEND_USER_CODE(EG(current_execute_data)->func->common.type)) { - zend_op *opline = EG(current_execute_data)->opline; - - if (opline->opcode == ZEND_INCLUDE_OR_EVAL && - (opline->op2.u.constant.value.lval == ZEND_INCLUDE_ONCE || - opline->op2.u.constant.value.lval == ZEND_REQUIRE_ONCE)) { - /* we are in include_once */ - char *key = NULL; - int key_length; - char *resolved_path; - zend_accel_hash_entry *bucket; - zend_persistent_script *persistent_script; - int filename_len; - - if (opline->op1.op_type == IS_CONST) { - filename_len = Z_STRLEN(opline->op1.u.constant); - } else { - filename_len = strlen(filename); - } - handle->filename = (char*)filename; - handle->free_filename = 0; - handle->opened_path = NULL; - - /* Check if requested file already cached (by full name) */ - if (IS_ABSOLUTE_PATH(filename, filename_len) && - (persistent_script = zend_accel_hash_find(&ZCSG(hash), (char*)filename, filename_len)) != NULL && - !persistent_script->corrupted) { - - handle->opened_path = estrndup(persistent_script->full_path, persistent_script->full_path_len); - handle->type = ZEND_HANDLE_FILENAME; - memcpy(ZCG(key), persistent_script->full_path, persistent_script->full_path_len + 1); - ZCG(key_len) = persistent_script->full_path_len; - ZCG(cache_opline) = opline; - ZCG(cache_persistent_script) = persistent_script; - return SUCCESS; - } - - /* Check if requested file already cached (by key) */ - key = accel_make_persistent_key_ex(handle, filename_len, &key_length TSRMLS_CC); - if (!ZCG(accel_directives).revalidate_path && - key && - (persistent_script = zend_accel_hash_find(&ZCSG(hash), key, key_length)) != NULL && - !persistent_script->corrupted) { - - handle->opened_path = estrndup(persistent_script->full_path, persistent_script->full_path_len); - handle->type = ZEND_HANDLE_FILENAME; - ZCG(cache_opline) = opline; - ZCG(cache_persistent_script) = persistent_script; - return SUCCESS; - } - - /* find the full real path */ - resolved_path = accel_php_resolve_path(filename, filename_len, ZCG(include_path) TSRMLS_CC); - - /* Check if requested file already cached (by real name) */ - if (resolved_path && - (bucket = zend_accel_hash_find_entry(&ZCSG(hash), resolved_path, strlen(resolved_path))) != NULL) { - - persistent_script = (zend_persistent_script *)bucket->data; - if (persistent_script && !persistent_script->corrupted) { - handle->opened_path = resolved_path; - handle->type = ZEND_HANDLE_FILENAME; - if (key && !ZCG(accel_directives).revalidate_path) { - /* add another "key" for the same bucket */ - SHM_UNPROTECT(); - zend_shared_alloc_lock(TSRMLS_C); - zend_accel_add_key(key, key_length, bucket TSRMLS_CC); - zend_shared_alloc_unlock(TSRMLS_C); - SHM_PROTECT(); - } - ZCG(cache_opline) = opline; - ZCG(cache_persistent_script) = persistent_script; - return SUCCESS; - } - } - if (resolved_path) { - efree(resolved_path); - } - } - } - } - ZCG(cache_opline) = NULL; - ZCG(cache_persistent_script) = NULL; - return accelerator_orig_zend_stream_open_function(filename, handle TSRMLS_CC); -} - -#else - /* zend_stream_open_function() replacement for PHP 5.3 and above */ static int persistent_stream_open_function(const char *filename, zend_file_handle *handle TSRMLS_DC) { @@ -1963,14 +1677,8 @@ static int persistent_stream_open_function(const char *filename, zend_file_handl EG(current_execute_data)->func && ZEND_USER_CODE(EG(current_execute_data)->func->common.type) && EG(current_execute_data)->opline->opcode == ZEND_INCLUDE_OR_EVAL && -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO (EG(current_execute_data)->opline->extended_value == ZEND_INCLUDE_ONCE || EG(current_execute_data)->opline->extended_value == ZEND_REQUIRE_ONCE))) { -#else - ((*EG(opline_ptr))->op2.u.constant.value.lval == ZEND_INCLUDE_ONCE || - (*EG(opline_ptr))->op2.u.constant.value.lval == ZEND_REQUIRE_ONCE))) { -#endif - /* we are in include_once or FastCGI request */ zend_persistent_script *persistent_script; @@ -2029,14 +1737,8 @@ static char* persistent_zend_resolve_path(const char *filename, int filename_len EG(current_execute_data)->func && ZEND_USER_CODE(EG(current_execute_data)->func->common.type) && EG(current_execute_data)->opline->opcode == ZEND_INCLUDE_OR_EVAL && -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO (EG(current_execute_data)->opline->extended_value == ZEND_INCLUDE_ONCE || EG(current_execute_data)->opline->extended_value == ZEND_REQUIRE_ONCE))) { -#else - ((*EG(opline_ptr))->op2.u.constant.value.lval == ZEND_INCLUDE_ONCE || - (*EG(opline_ptr))->op2.u.constant.value.lval == ZEND_REQUIRE_ONCE))) { -#endif - /* we are in include_once or FastCGI request */ zend_file_handle handle; char *key = NULL; @@ -2107,8 +1809,6 @@ static char* persistent_zend_resolve_path(const char *filename, int filename_len return accelerator_orig_zend_resolve_path(filename, filename_len TSRMLS_CC); } -#endif - static void zend_reset_cache_vars(TSRMLS_D) { ZSMMG(memory_exhausted) = 0; @@ -2176,7 +1876,7 @@ static void accel_activate(void) ZCSG(include_paths).hash_table[zend_inline_hash_func(ZCSG(include_paths).hash_entries[0].key, ZCSG(include_paths).hash_entries[0].key_length) % ZCSG(include_paths).max_num_entries] = &ZCSG(include_paths).hash_entries[0]; } -#if (ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO) && !defined(ZTS) +#if !defined(ZTS) if (ZCG(accel_directives).interned_strings_buffer) { accel_interned_strings_restore_state(TSRMLS_C); } @@ -2232,20 +1932,10 @@ static void accel_fast_hash_destroy(HashTable *ht) static void accel_fast_zval_dtor(zval *zvalue) { if (Z_REFCOUNTED_P(zvalue) && Z_DELREF_P(zvalue) == 0) { -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO switch (Z_TYPE_P(zvalue)) { -#else - switch (Z_TYPE_P(zvalue)) { -#endif -#if ZEND_EXTENSION_API_NO <= PHP_5_5_API_NO - case IS_CONSTANT_ARRAY: -#endif case IS_ARRAY: { TSRMLS_FETCH(); - -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO GC_REMOVE_FROM_BUFFER(Z_ARR_P(zvalue)); -#endif if (Z_ARR_P(zvalue) != &EG(symbol_table)) { /* break possible cycles */ ZVAL_NULL(zvalue); @@ -2322,7 +2012,6 @@ static int accel_clean_non_persistent_class(zval *zv TSRMLS_DC) if (ce->type == ZEND_INTERNAL_CLASS) { return ZEND_HASH_APPLY_STOP; } else { -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (ce->ce_flags & ZEND_HAS_STATIC_IN_METHODS) { zend_hash_apply(&ce->function_table, (apply_func_t) accel_cleanup_function_data TSRMLS_CC); } @@ -2335,14 +2024,6 @@ static int accel_clean_non_persistent_class(zval *zv TSRMLS_DC) } ce->static_members_table = NULL; } -#else - zend_hash_apply(&ce->function_table, (apply_func_t) accel_cleanup_function_data TSRMLS_CC); - if (ce->static_members) { - ce->static_members->pDestructor = accel_fast_zval_dtor; - accel_fast_hash_destroy(ce->static_members); - ce->static_members = NULL; - } -#endif return ZEND_HASH_APPLY_REMOVE; } } @@ -2498,8 +2179,6 @@ static int zend_accel_init_shm(TSRMLS_D) zend_accel_hash_init(&ZCSG(hash), ZCG(accel_directives).max_accelerated_files); zend_accel_hash_init(&ZCSG(include_paths), 32); -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO - ZCSG(interned_strings_start) = ZCSG(interned_strings_end) = NULL; # ifndef ZTS zend_hash_init(&ZCSG(interned_strings), (ZCG(accel_directives).interned_strings_buffer * 1024 * 1024) / (sizeof(Bucket) + sizeof(Bucket*) + 8 /* average string length */), NULL, NULL, 1); @@ -2537,8 +2216,6 @@ static int zend_accel_init_shm(TSRMLS_D) } # endif -#endif - zend_reset_cache_vars(TSRMLS_C); ZCSG(oom_restarts) = 0; @@ -2589,11 +2266,7 @@ static int accel_startup(zend_extension *extension) _setmaxstdio(2048); /* The default configuration is limited to 512 stdio files */ #endif -#if ZEND_EXTENSION_API_NO > PHP_5_6_X_API_NO if (start_accel_module(TSRMLS_C) == FAILURE) { -#else - if (start_accel_module() == FAILURE) { -#endif accel_startup_ok = 0; zend_error(E_WARNING, ACCELERATOR_PRODUCT_NAME ": module registration failed!"); return FAILURE; @@ -2630,7 +2303,6 @@ static int accel_startup(zend_extension *extension) return SUCCESS; case SUCCESSFULLY_REATTACHED: accel_shared_globals = (zend_accel_shared_globals *) ZSMMG(app_shared_globals); -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO zend_shared_alloc_lock(TSRMLS_C); orig_new_interned_string = zend_new_interned_string; orig_interned_strings_snapshot = zend_interned_strings_snapshot; @@ -2639,14 +2311,10 @@ static int accel_startup(zend_extension *extension) zend_new_interned_string = accel_new_interned_string_for_php; zend_interned_strings_snapshot = accel_interned_strings_snapshot_for_php; zend_interned_strings_restore = accel_interned_strings_restore_for_php; - -# ifndef ZTS +#ifndef ZTS accel_use_shm_interned_strings(TSRMLS_C); -# endif - - zend_shared_alloc_unlock(TSRMLS_C); #endif - + zend_shared_alloc_unlock(TSRMLS_C); break; case FAILED_REATTACHED: accel_startup_ok = 0; @@ -2669,12 +2337,10 @@ static int accel_startup(zend_extension *extension) accelerator_orig_zend_stream_open_function = zend_stream_open_function; zend_stream_open_function = persistent_stream_open_function; -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO /* Override path resolver function (to eliminate stat() calls caused by * include_once/require_once statements */ accelerator_orig_zend_resolve_path = zend_resolve_path; zend_resolve_path = persistent_zend_resolve_path; -#endif if (ZCG(accel_directives).validate_timestamps) { ZCSG(revalidate_at) = zend_accel_get_time() + ZCG(accel_directives).revalidate_freq; @@ -2767,19 +2433,18 @@ void accel_shutdown(TSRMLS_D) return; } -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (ZCG(accel_directives).interned_strings_buffer) { -# ifndef ZTS +#ifndef ZTS zend_hash_clean(CG(auto_globals)); zend_hash_clean(CG(function_table)); zend_hash_clean(CG(class_table)); zend_hash_clean(EG(zend_constants)); -# endif +#endif } + zend_new_interned_string = orig_new_interned_string; zend_interned_strings_snapshot = orig_interned_strings_snapshot; zend_interned_strings_restore = orig_interned_strings_restore; -#endif accel_free_ts_resources(); zend_shared_alloc_shutdown(); diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h index bfa0386697..94c467e5fb 100644 --- a/ext/opcache/ZendAccelerator.h +++ b/ext/opcache/ZendAccelerator.h @@ -127,47 +127,17 @@ extern int lock_file; # endif #endif -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - #define Z_REFCOUNT_P(pz) (pz)->refcount - #define Z_SET_REFCOUNT_P(pz, v) (pz)->refcount = (v) - #define Z_ADDREF_P(pz) ++((pz)->refcount) - #define Z_DELREF_P(pz) --((pz)->refcount) - #define Z_ISREF_P(pz) (pz)->is_ref - #define Z_SET_ISREF_P(pz) Z_SET_ISREF_TO_P(pz, 1) - #define Z_UNSET_ISREF_P(pz) Z_SET_ISREF_TO_P(pz, 0) - #define Z_SET_ISREF_TO_P(pz, isref) (pz)->is_ref = (isref) - #define PZ_REFCOUNT_P(pz) (pz)->refcount - #define PZ_SET_REFCOUNT_P(pz, v) (pz)->refcount = (v) - #define PZ_ADDREF_P(pz) ++((pz)->refcount) - #define PZ_DELREF_P(pz) --((pz)->refcount) - #define PZ_ISREF_P(pz) (pz)->is_ref - #define PZ_SET_ISREF_P(pz) Z_SET_ISREF_TO_P(pz, 1) - #define PZ_UNSET_ISREF_P(pz) Z_SET_ISREF_TO_P(pz, 0) - #define PZ_SET_ISREF_TO_P(pz, isref) (pz)->is_ref = (isref) -#else - #define PZ_REFCOUNT_P(pz) (pz)->refcount__gc - #define PZ_SET_REFCOUNT_P(pz, v) (pz)->refcount__gc = (v) - #define PZ_ADDREF_P(pz) ++((pz)->refcount__gc) - #define PZ_DELREF_P(pz) --((pz)->refcount__gc) - #define PZ_ISREF_P(pz) (pz)->is_ref__gc - #define PZ_SET_ISREF_P(pz) Z_SET_ISREF_TO_P(pz, 1) - #define PZ_UNSET_ISREF_P(pz) Z_SET_ISREF_TO_P(pz, 0) - #define PZ_SET_ISREF_TO_P(pz, isref) (pz)->is_ref__gc = (isref) -#endif +#define PZ_REFCOUNT_P(pz) (pz)->refcount__gc +#define PZ_SET_REFCOUNT_P(pz, v) (pz)->refcount__gc = (v) +#define PZ_ADDREF_P(pz) ++((pz)->refcount__gc) +#define PZ_DELREF_P(pz) --((pz)->refcount__gc) +#define PZ_ISREF_P(pz) (pz)->is_ref__gc +#define PZ_SET_ISREF_P(pz) Z_SET_ISREF_TO_P(pz, 1) +#define PZ_UNSET_ISREF_P(pz) Z_SET_ISREF_TO_P(pz, 0) +#define PZ_SET_ISREF_TO_P(pz, isref) (pz)->is_ref__gc = (isref) -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO -# ifdef ALLOCA_FLAG - #define DO_ALLOCA(x) do_alloca_with_limit(x, use_heap) - #define FREE_ALLOCA(x) free_alloca_with_limit(x, use_heap) -# else - #define ALLOCA_FLAG(x) - #define DO_ALLOCA(x) do_alloca(x) - #define FREE_ALLOCA(x) free_alloca(x) -# endif -#else - #define DO_ALLOCA(x) do_alloca(x, use_heap) - #define FREE_ALLOCA(x) free_alloca(x, use_heap) -#endif +#define DO_ALLOCA(x) do_alloca(x, use_heap) +#define FREE_ALLOCA(x) free_alloca(x, use_heap) #if ZEND_WIN32 @@ -191,9 +161,6 @@ typedef struct _zend_persistent_script { int ping_auto_globals_mask; /* which autoglobals are used by the script */ accel_time_t timestamp; /* the script modification time */ zend_bool corrupted; -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - zend_uint early_binding; /* the linked list of delayed declarations */ -#endif void *mem; /* shared memory area used by script structures */ size_t size; /* size of used shared memory */ @@ -239,9 +206,7 @@ typedef struct _zend_accel_directives { long optimization_level; long max_file_size; -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO long interned_strings_buffer; -#endif char *restrict_api; } zend_accel_directives; @@ -298,14 +263,12 @@ typedef struct _zend_accel_shared_globals { #endif zend_bool restart_in_progress; time_t revalidate_at; -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO /* Interned Strings Support */ char *interned_strings_start; char *interned_strings_top; char *interned_strings_end; char *interned_strings_saved_top; HashTable interned_strings; -#endif } zend_accel_shared_globals; extern zend_bool accel_startup_ok; @@ -344,8 +307,6 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type T #define IS_ACCEL_INTERNED(str) \ ((char*)(str) >= ZCSG(interned_strings_start) && (char*)(str) < ZCSG(interned_strings_end)) -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO - zend_string *accel_new_interned_string(zend_string *str TSRMLS_DC); # define ZEND_RESULT_TYPE(opline) (opline)->result_type @@ -362,25 +323,5 @@ zend_string *accel_new_interned_string(zend_string *str TSRMLS_DC); # define ZEND_CE_FILENAME(ce) (ce)->info.user.filename # define ZEND_CE_DOC_COMMENT(ce) (ce)->info.user.doc_comment # define ZEND_CE_DOC_COMMENT_LEN(ce) (ce)->info.user.doc_comment_len -#else -# define IS_INTERNED(s) 0 -# define interned_free(s) free(s) -# define interned_efree(s) efree(s) -# define interned_estrndup(s, n) estrndup(s, n) -# define ZEND_RESULT_TYPE(opline) (opline)->result.op_type -# define ZEND_RESULT(opline) (opline)->result.u -# define ZEND_OP1_TYPE(opline) (opline)->op1.op_type -# define ZEND_OP1(opline) (opline)->op1.u -# define ZEND_OP1_CONST(opline) (opline)->op1.u.constant -# define ZEND_OP1_LITERAL(opline) (opline)->op1.u.constant -# define ZEND_OP2_TYPE(opline) (opline)->op2.op_type -# define ZEND_OP2(opline) (opline)->op2.u -# define ZEND_OP2_CONST(opline) (opline)->op2.u.constant -# define ZEND_OP2_LITERAL(opline) (opline)->op2.u.constant -# define ZEND_DONE_PASS_TWO(op_array) ((op_array)->done_pass_two != 0) -# define ZEND_CE_FILENAME(ce) (ce)->filename -# define ZEND_CE_DOC_COMMENT(ce) (ce)->doc_comment -# define ZEND_CE_DOC_COMMENT_LEN(ce) (ce)->doc_comment_len -#endif #endif /* ZEND_ACCELERATOR_H */ diff --git a/ext/opcache/zend_accelerator_blacklist.c b/ext/opcache/zend_accelerator_blacklist.c index af56fbf9e9..7263ed3c93 100644 --- a/ext/opcache/zend_accelerator_blacklist.c +++ b/ext/opcache/zend_accelerator_blacklist.c @@ -23,16 +23,7 @@ #include "main/fopen_wrappers.h" #include "ZendAccelerator.h" #include "zend_accelerator_blacklist.h" - -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO -# include "ext/ereg/php_regex.h" -#else -# include "main/php_regex.h" -#endif - -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO -# include "ext/standard/php_string.h" -#endif +#include "ext/ereg/php_regex.h" #ifdef ZEND_WIN32 # define REGEX_MODE (REG_EXTENDED|REG_NOSUB|REG_ICASE) @@ -256,11 +247,7 @@ void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename) zend_accel_error(ACCEL_LOG_DEBUG,"Loading blacklist file: '%s'", filename); if (VCWD_REALPATH(filename, buf)) { -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - blacklist_path_length = php_dirname(buf, strlen(buf)); -#else blacklist_path_length = zend_dirname(buf, strlen(buf)); -#endif blacklist_path = zend_strndup(buf, blacklist_path_length); } diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index 7c0383e0c3..ff8ace863b 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -28,11 +28,7 @@ #include "zend_accelerator_blacklist.h" #include "php_ini.h" #include "SAPI.h" -#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO -# include "zend_virtual_cwd.h" -#else -# include "TSRM/tsrm_virtual_cwd.h" -#endif +#include "zend_virtual_cwd.h" #include "ext/standard/info.h" #include "ext/standard/php_filestat.h" @@ -258,9 +254,7 @@ ZEND_INI_BEGIN() STD_PHP_INI_ENTRY("opcache.log_verbosity_level" , "1" , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.log_verbosity_level, zend_accel_globals, accel_globals) STD_PHP_INI_ENTRY("opcache.memory_consumption" , "64" , PHP_INI_SYSTEM, OnUpdateMemoryConsumption, accel_directives.memory_consumption, zend_accel_globals, accel_globals) -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO STD_PHP_INI_ENTRY("opcache.interned_strings_buffer", "4" , PHP_INI_SYSTEM, OnUpdateLong, accel_directives.interned_strings_buffer, zend_accel_globals, accel_globals) -#endif STD_PHP_INI_ENTRY("opcache.max_accelerated_files" , "2000", PHP_INI_SYSTEM, OnUpdateMaxAcceleratedFiles, accel_directives.max_accelerated_files, zend_accel_globals, accel_globals) STD_PHP_INI_ENTRY("opcache.max_wasted_percentage" , "5" , PHP_INI_SYSTEM, OnUpdateMaxWastedPercentage, accel_directives.max_wasted_percentage, zend_accel_globals, accel_globals) STD_PHP_INI_ENTRY("opcache.consistency_checks" , "0" , PHP_INI_ALL , OnUpdateLong, accel_directives.consistency_checks, zend_accel_globals, accel_globals) @@ -287,26 +281,6 @@ ZEND_INI_BEGIN() #endif ZEND_INI_END() -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - -#undef EX -#define EX(element) execute_data->element -#define EX_T(offset) (*(temp_variable *)((char *) EX(Ts) + offset)) - -static int ZEND_DECLARE_INHERITED_CLASS_DELAYED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_class_entry **pce, **pce_orig; - - if (zend_hash_find(EG(class_table), Z_STRVAL(EX(opline)->op2.u.constant), Z_STRLEN(EX(opline)->op2.u.constant) + 1, (void **)&pce) == FAILURE || - (zend_hash_find(EG(class_table), Z_STRVAL(EX(opline)->op1.u.constant), Z_STRLEN(EX(opline)->op1.u.constant), (void**)&pce_orig) == SUCCESS && - *pce != *pce_orig)) { - do_bind_inherited_class(EX(opline), EG(class_table), EX_T(EX(opline)->extended_value).class_entry, 0 TSRMLS_CC); - } - EX(opline)++; - return ZEND_USER_OPCODE_CONTINUE; -} -#endif - static int filename_is_in_cache(char *filename, int filename_len TSRMLS_DC) { char *key; @@ -379,9 +353,7 @@ static ZEND_MINIT_FUNCTION(zend_accelerator) (void)type; /* keep the compiler happy */ REGISTER_INI_ENTRIES(); -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - zend_set_user_opcode_handler(ZEND_DECLARE_INHERITED_CLASS_DELAYED, ZEND_DECLARE_INHERITED_CLASS_DELAYED_HANDLER); -#endif + return SUCCESS; } @@ -445,14 +417,12 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS) php_info_print_table_row(2, "Free memory", buf); snprintf(buf, sizeof(buf), "%ld", ZSMMG(wasted_shared_memory)); php_info_print_table_row(2, "Wasted memory", buf); -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (ZCSG(interned_strings_start) && ZCSG(interned_strings_end) && ZCSG(interned_strings_top)) { snprintf(buf, sizeof(buf), "%ld", ZCSG(interned_strings_top) - ZCSG(interned_strings_start)); php_info_print_table_row(2, "Interned Strings Used memory", buf); snprintf(buf, sizeof(buf), "%ld", ZCSG(interned_strings_end) - ZCSG(interned_strings_top)); php_info_print_table_row(2, "Interned Strings Free memory", buf); } -#endif snprintf(buf, sizeof(buf), "%ld", ZCSG(hash).num_direct_entries); php_info_print_table_row(2, "Cached scripts", buf); snprintf(buf, sizeof(buf), "%ld", ZCSG(hash).num_entries); @@ -485,17 +455,10 @@ static zend_module_entry accel_module_entry = { STANDARD_MODULE_PROPERTIES }; -#if ZEND_EXTENSION_API_NO > PHP_5_6_X_API_NO int start_accel_module(TSRMLS_D) { return zend_startup_module(&accel_module_entry TSRMLS_CC); } -#else -int start_accel_module(void) -{ - return zend_startup_module(&accel_module_entry); -} -#endif /* {{{ proto array accelerator_get_scripts() Get the scripts which are accelerated by ZendAccelerator */ @@ -583,7 +546,6 @@ static ZEND_FUNCTION(opcache_get_status) add_assoc_double(&memory_usage, "current_wasted_percentage", (((double) ZSMMG(wasted_shared_memory))/ZCG(accel_directives).memory_consumption)*100.0); add_assoc_zval(return_value, "memory_usage", &memory_usage); -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (ZCSG(interned_strings_start) && ZCSG(interned_strings_end) && ZCSG(interned_strings_top)) { zval interned_strings_usage; @@ -594,7 +556,6 @@ static ZEND_FUNCTION(opcache_get_status) add_assoc_long(&interned_strings_usage, "number_of_strings", ZCSG(interned_strings).nNumOfElements); add_assoc_zval(return_value, "interned_strings_usage", &interned_strings_usage); } -#endif /* Accelerator statistics */ array_init(&statistics); @@ -634,11 +595,9 @@ static ZEND_FUNCTION(opcache_get_configuration) { zval directives, version, blacklist; -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO if (zend_parse_parameters_none() == FAILURE) { RETURN_FALSE; } -#endif if (!validate_api_restriction(TSRMLS_C)) { RETURN_FALSE; @@ -658,9 +617,7 @@ static ZEND_FUNCTION(opcache_get_configuration) add_assoc_long(&directives, "opcache.log_verbosity_level", ZCG(accel_directives).log_verbosity_level); add_assoc_long(&directives, "opcache.memory_consumption", ZCG(accel_directives).memory_consumption); -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO add_assoc_long(&directives, "opcache.interned_strings_buffer",ZCG(accel_directives).interned_strings_buffer); -#endif add_assoc_long(&directives, "opcache.max_accelerated_files", ZCG(accel_directives).max_accelerated_files); add_assoc_double(&directives, "opcache.max_wasted_percentage", ZCG(accel_directives).max_wasted_percentage); add_assoc_long(&directives, "opcache.consistency_checks", ZCG(accel_directives).consistency_checks); @@ -696,11 +653,9 @@ static ZEND_FUNCTION(opcache_get_configuration) Request that the contents of the opcode cache to be reset */ static ZEND_FUNCTION(opcache_reset) { -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO if (zend_parse_parameters_none() == FAILURE) { RETURN_FALSE; } -#endif if (!validate_api_restriction(TSRMLS_C)) { RETURN_FALSE; diff --git a/ext/opcache/zend_accelerator_module.h b/ext/opcache/zend_accelerator_module.h index 6e772b8c7e..c7fe7d8e17 100644 --- a/ext/opcache/zend_accelerator_module.h +++ b/ext/opcache/zend_accelerator_module.h @@ -22,11 +22,7 @@ #ifndef ZEND_ACCELERATOR_MODULE_H #define ZEND_ACCELERATOR_MODULE_H -#if ZEND_EXTENSION_API_NO > PHP_5_6_X_API_NO int start_accel_module(TSRMLS_D); -#else -int start_accel_module(void); -#endif void zend_accel_override_file_functions(TSRMLS_D); diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c index 3391694e24..fc16fbeb24 100644 --- a/ext/opcache/zend_accelerator_util_funcs.c +++ b/ext/opcache/zend_accelerator_util_funcs.c @@ -41,9 +41,7 @@ static zend_uint zend_accel_refcount = ZEND_PROTECTED_REFCOUNT; typedef int (*id_function_t)(void *, void *); typedef void (*unique_copy_ctor_func_t)(void *pElement); -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO static const zend_uint uninitialized_bucket = {INVALID_IDX}; -#endif static int zend_prepare_function_for_execution(zend_op_array *op_array); static void zend_hash_clone_zval(HashTable *ht, HashTable *source, int bind); @@ -180,18 +178,11 @@ void zend_accel_free_user_functions(HashTable *ht TSRMLS_DC) ht->pDestructor = orig_dtor; } -static int move_user_function(zval *zv -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO - TSRMLS_DC -#endif - , int num_args, va_list args, zend_hash_key *hash_key) +static int move_user_function(zval *zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) { zend_function *function = Z_PTR_P(zv); HashTable *function_table = va_arg(args, HashTable *); (void)num_args; /* keep the compiler happy */ -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - TSRMLS_FETCH(); -#endif if (function->type == ZEND_USER_FUNCTION) { zend_hash_update_ptr(function_table, hash_key->key, function); @@ -206,11 +197,7 @@ void zend_accel_move_user_functions(HashTable *src, HashTable *dst TSRMLS_DC) dtor_func_t orig_dtor = src->pDestructor; src->pDestructor = NULL; -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - zend_hash_apply_with_arguments(src, (apply_func_args_t)move_user_function, 1, dst); -#else zend_hash_apply_with_arguments(src TSRMLS_CC, (apply_func_args_t)move_user_function, 1, dst); -#endif src->pDestructor = orig_dtor; } @@ -265,19 +252,12 @@ static inline void zend_clone_zval(zval *src, int bind TSRMLS_DC) return; } -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO switch (Z_TYPE_P(src)) { -#else - switch (Z_TYPE_P(src)) { -#endif case IS_STRING: case IS_CONSTANT: Z_STR_P(src) = zend_clone_str(Z_STR_P(src) TSRMLS_CC); break; case IS_ARRAY: -#if ZEND_EXTENSION_API_NO <= PHP_5_5_API_NO - case IS_CONSTANT_ARRAY: -#endif if (Z_ARR_P(src) != &EG(symbol_table)) { if (bind && Z_REFCOUNT_P(src) > 1 && (ptr = accel_xlat_get(Z_ARR_P(src))) != NULL) { Z_ARR_P(src) = ptr; @@ -323,7 +303,6 @@ static inline void zend_clone_zval(zval *src, int bind TSRMLS_DC) } } -#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO static zend_ast *zend_ast_clone(zend_ast *ast TSRMLS_DC) { int i; @@ -349,7 +328,6 @@ static zend_ast *zend_ast_clone(zend_ast *ast TSRMLS_DC) } return node; } -#endif static void zend_hash_clone_zval(HashTable *ht, HashTable *source, int bind) { @@ -369,12 +347,10 @@ static void zend_hash_clone_zval(HashTable *ht, HashTable *source, int bind) ht->arHash = NULL; ht->nInternalPointer = source->nNumOfElements ? 0 : INVALID_IDX; -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (!ht->nTableMask) { ht->arHash = (zend_uint*)&uninitialized_bucket; return; } -#endif if (source->u.flags & HASH_FLAG_PACKED) { ht->u.flags |= HASH_FLAG_PACKED; @@ -450,12 +426,10 @@ static void zend_hash_clone_methods(HashTable *ht, HashTable *source, zend_class ht->u.flags = 0; ht->nInternalPointer = source->nNumOfElements ? 0 : INVALID_IDX; -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (!ht->nTableMask) { ht->arHash = (zend_uint*)&uninitialized_bucket; return; } -#endif ZEND_ASSERT(!(source->u.flags & HASH_FLAG_PACKED)); ht->arData = (Bucket *) emalloc(ht->nTableSize * (sizeof(Bucket) + sizeof(zend_uint))); @@ -529,12 +503,10 @@ static void zend_hash_clone_prop_info(HashTable *ht, HashTable *source, zend_cla ht->u.flags = 0; ht->nInternalPointer = source->nNumOfElements ? 0 : INVALID_IDX; -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (!ht->nTableMask) { ht->arHash = (zend_uint*)&uninitialized_bucket; return; } -#endif ZEND_ASSERT(!(source->u.flags & HASH_FLAG_PACKED)); ht->arData = (Bucket *) emalloc(ht->nTableSize * (sizeof(Bucket) + sizeof(zend_uint))); @@ -628,7 +600,6 @@ static void zend_class_copy_ctor(zend_class_entry **pce) accel_xlat_set(old_ce, ce); } -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (old_ce->default_properties_table) { int i; @@ -638,14 +609,10 @@ static void zend_class_copy_ctor(zend_class_entry **pce) zend_clone_zval(&ce->default_properties_table[i], 1 TSRMLS_CC); } } -#else - zend_hash_clone_zval(&ce->default_properties, &old_ce->default_properties, 0); -#endif zend_hash_clone_methods(&ce->function_table, &old_ce->function_table, old_ce, ce TSRMLS_CC); /* static members */ -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (old_ce->default_static_members_table) { int i; @@ -656,10 +623,6 @@ static void zend_class_copy_ctor(zend_class_entry **pce) } } ce->static_members_table = ce->default_static_members_table; -#else - zend_hash_clone_zval(&ce->default_static_members, &old_ce->default_static_members, 1); - ce->static_members = &ce->default_static_members; -#endif /* properties_info */ zend_hash_clone_prop_info(&ce->properties_info, &old_ce->properties_info, old_ce, ce TSRMLS_CC); @@ -707,13 +670,10 @@ static void zend_class_copy_ctor(zend_class_entry **pce) /* 5.2 stuff */ zend_update_inherited_handler(__tostring); -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO /* 5.3 stuff */ zend_update_inherited_handler(__callstatic); -#endif zend_update_inherited_handler(__debugInfo); -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO /* 5.4 traits */ if (ce->trait_aliases) { zend_trait_alias **trait_aliases; @@ -792,7 +752,6 @@ static void zend_class_copy_ctor(zend_class_entry **pce) trait_precedences[i] = NULL; ce->trait_precedences = trait_precedences; } -#endif } static void zend_accel_function_hash_copy(HashTable *target, HashTable *source, unique_copy_ctor_func_t pCopyConstructor TSRMLS_DC) @@ -889,39 +848,11 @@ static void zend_accel_class_hash_copy(HashTable *target, HashTable *source, uni failure: ce1 = Z_PTR(p->val); CG(in_compilation) = 1; -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO zend_set_compiled_filename(ce1->info.user.filename TSRMLS_CC); CG(zend_lineno) = ce1->info.user.line_start; -#else - zend_set_compiled_filename(ce1->filename TSRMLS_CC); - CG(zend_lineno) = ce1->line_start; -#endif zend_error(E_ERROR, "Cannot redeclare class %s", ce1->name->val); } -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO -static void zend_do_delayed_early_binding(zend_op_array *op_array, zend_uint early_binding TSRMLS_DC) -{ - zend_uint opline_num = early_binding; - - if ((int)opline_num != -1) { - zend_bool orig_in_compilation = CG(in_compilation); - char *orig_compiled_filename = zend_set_compiled_filename(op_array->filename TSRMLS_CC); - zend_class_entry **pce; - - CG(in_compilation) = 1; - while ((int)opline_num != -1) { - if (zend_lookup_class(Z_STRVAL(op_array->opcodes[opline_num - 1].op2.u.constant), Z_STRLEN(op_array->opcodes[opline_num - 1].op2.u.constant), &pce TSRMLS_CC) == SUCCESS) { - do_bind_inherited_class(&op_array->opcodes[opline_num], EG(class_table), *pce, 1 TSRMLS_CC); - } - opline_num = op_array->opcodes[opline_num].result.u.opline_num; - } - zend_restore_compiled_filename(orig_compiled_filename TSRMLS_CC); - CG(in_compilation) = orig_in_compilation; - } -} -#endif - zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script, int from_shared_memory TSRMLS_DC) { zend_op_array *op_array; @@ -958,13 +889,6 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script, } zend_hash_destroy(&ZCG(bind_hash)); - -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - if ((int)persistent_script->early_binding != -1) { - zend_do_delayed_early_binding(op_array, persistent_script->early_binding TSRMLS_CC); - } -#endif - } else /* if (!from_shared_memory) */ { if (zend_hash_num_elements(&persistent_script->function_table) > 0) { zend_accel_function_hash_copy(CG(function_table), &persistent_script->function_table, NULL TSRMLS_CC); @@ -974,14 +898,12 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script, } } -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO if (op_array->early_binding != (zend_uint)-1) { zend_string *orig_compiled_filename = CG(compiled_filename); CG(compiled_filename) = persistent_script->full_path; zend_do_delayed_early_binding(op_array TSRMLS_CC); CG(compiled_filename) = orig_compiled_filename; } -#endif if (!from_shared_memory) { free_persistent_script(persistent_script, 0); /* free only hashes */ diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index 070d77670b..e87a942bfa 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -33,8 +33,7 @@ #define zend_accel_memdup(p, size) \ _zend_shared_memdup((void*)p, size, 0 TSRMLS_CC) -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO -# define zend_accel_store_string(str) do { \ +#define zend_accel_store_string(str) do { \ zend_string *new_str = zend_shared_alloc_get_xlat_entry(str); \ if (new_str) { \ STR_RELEASE(str); \ @@ -47,34 +46,28 @@ GC_FLAGS(str) = IS_STR_INTERNED | IS_STR_PERMANENT; \ } \ } while (0) -# define zend_accel_memdup_string(str) do { \ +#define zend_accel_memdup_string(str) do { \ str = zend_accel_memdup(str, _STR_HEADER_SIZE + (str)->len + 1); \ STR_HASH_VAL(str); \ GC_FLAGS(str) = IS_STR_INTERNED | IS_STR_PERMANENT; \ } while (0) -# define zend_accel_store_interned_string(str) do { \ +#define zend_accel_store_interned_string(str) do { \ if (!IS_ACCEL_INTERNED(str)) { \ zend_accel_store_string(str); \ } \ } while (0) -# define zend_accel_memdup_interned_string(str) do { \ +#define zend_accel_memdup_interned_string(str) do { \ if (!IS_ACCEL_INTERNED(str)) { \ zend_accel_memdup_string(str); \ } \ } while (0) -#else -# define zend_accel_store_interned_string(str, len) \ - zend_accel_store(str, len) -#endif typedef void (*zend_persist_func_t)(zval* TSRMLS_DC); static void zend_persist_zval(zval *z TSRMLS_DC); static void zend_persist_zval_const(zval *z TSRMLS_DC); -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO static const zend_uint uninitialized_bucket = {INVALID_IDX}; -#endif static void zend_hash_persist(HashTable *ht, zend_persist_func_t pPersistElement TSRMLS_DC) { @@ -149,7 +142,6 @@ static void zend_hash_persist_immutable(HashTable *ht TSRMLS_DC) } } -#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO static zend_ast *zend_persist_ast(zend_ast *ast TSRMLS_DC) { int i; @@ -169,18 +161,13 @@ static zend_ast *zend_persist_ast(zend_ast *ast TSRMLS_DC) efree(ast); return node; } -#endif static void zend_persist_zval(zval *z TSRMLS_DC) { zend_uchar flags; void *new_ptr; -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO switch (Z_TYPE_P(z)) { -#else - switch (Z_TYPE_P(z)) { -#endif case IS_STRING: case IS_CONSTANT: flags = Z_GC_FLAGS_P(z) & ~ (IS_STR_PERSISTENT | IS_STR_INTERNED | IS_STR_PERMANENT); @@ -189,9 +176,6 @@ static void zend_persist_zval(zval *z TSRMLS_DC) Z_TYPE_FLAGS_P(z) &= ~(IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE); break; case IS_ARRAY: -#if ZEND_EXTENSION_API_NO <= PHP_5_5_API_NO - case IS_CONSTANT_ARRAY: -#endif new_ptr = zend_shared_alloc_get_xlat_entry(Z_ARR_P(z)); if (new_ptr) { Z_ARR_P(z) = new_ptr; @@ -210,7 +194,6 @@ static void zend_persist_zval(zval *z TSRMLS_DC) } } break; -#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO case IS_REFERENCE: new_ptr = zend_shared_alloc_get_xlat_entry(Z_REF_P(z)); if (new_ptr) { @@ -229,7 +212,6 @@ static void zend_persist_zval(zval *z TSRMLS_DC) Z_ASTVAL_P(z) = zend_persist_ast(Z_ASTVAL_P(z) TSRMLS_CC); } break; -#endif } } @@ -238,11 +220,7 @@ static void zend_persist_zval_const(zval *z TSRMLS_DC) zend_uchar flags; void *new_ptr; -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO - switch (Z_TYPE_P(z)) { -#else switch (Z_TYPE_P(z)) { -#endif case IS_STRING: case IS_CONSTANT: flags = Z_GC_FLAGS_P(z) & ~ (IS_STR_PERSISTENT | IS_STR_INTERNED | IS_STR_PERMANENT); @@ -251,9 +229,6 @@ static void zend_persist_zval_const(zval *z TSRMLS_DC) Z_TYPE_FLAGS_P(z) &= ~(IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE); break; case IS_ARRAY: -#if ZEND_EXTENSION_API_NO <= PHP_5_5_API_NO - case IS_CONSTANT_ARRAY: -#endif new_ptr = zend_shared_alloc_get_xlat_entry(Z_ARR_P(z)); if (new_ptr) { Z_ARR_P(z) = new_ptr; @@ -272,7 +247,6 @@ static void zend_persist_zval_const(zval *z TSRMLS_DC) } } break; -#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO case IS_REFERENCE: new_ptr = zend_shared_alloc_get_xlat_entry(Z_REF_P(z)); if (new_ptr) { @@ -291,7 +265,6 @@ static void zend_persist_zval_const(zval *z TSRMLS_DC) Z_ASTVAL_P(z) = zend_persist_ast(Z_ASTVAL_P(z) TSRMLS_CC); } break; -#endif } } @@ -299,21 +272,12 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc { int already_stored = 0; zend_op *persist_ptr; -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - int has_jmp = 0; -#endif -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO zval *orig_literals = NULL; -#endif if (op_array->type != ZEND_USER_FUNCTION) { return; } -#if ZEND_EXTENSION_API_NO <= PHP_5_3_X_API_NO - op_array->size = op_array->last; -#endif - if (--(*op_array->refcount) == 0) { efree(op_array->refcount); } @@ -324,9 +288,6 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc zend_execute_data fake_execute_data; zval *offset; -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - main_persistent_script->early_binding = -1; -#endif memset(&fake_execute_data, 0, sizeof(fake_execute_data)); fake_execute_data.func = (zend_function*)op_array; EG(current_execute_data) = &fake_execute_data; @@ -345,7 +306,6 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc already_stored = 1; } -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (op_array->literals) { if (already_stored) { orig_literals = zend_shared_alloc_get_xlat_entry(op_array->literals); @@ -363,7 +323,6 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc efree(orig_literals); } } -#endif if (already_stored) { persist_ptr = zend_shared_alloc_get_xlat_entry(op_array->opcodes); @@ -377,76 +336,18 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc for (; opline < end ; opline++, offset++) { if (ZEND_OP1_TYPE(opline) == IS_CONST) { -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO opline->op1.zv = (zval*)((char*)opline->op1.zv + ((char*)op_array->literals - (char*)orig_literals)); -#else - zend_persist_zval(&opline->op1.u.constant TSRMLS_CC); -#endif } if (ZEND_OP2_TYPE(opline) == IS_CONST) { -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO opline->op2.zv = (zval*)((char*)opline->op2.zv + ((char*)op_array->literals - (char*)orig_literals)); -#else - zend_persist_zval(&opline->op2.u.constant TSRMLS_CC); -#endif } -#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO - switch (opline->opcode) { - case ZEND_JMP: - has_jmp = 1; - if (ZEND_DONE_PASS_TWO(op_array)) { - ZEND_OP1(opline).jmp_addr = &new_opcodes[ZEND_OP1(opline).jmp_addr - op_array->opcodes]; - } - break; - case ZEND_JMPZNZ: - /* relative extended_value don't have to be changed */ - /* break omitted intentionally */ - case ZEND_JMPZ: - case ZEND_JMPNZ: - case ZEND_JMPZ_EX: - case ZEND_JMPNZ_EX: - has_jmp = 1; - if (ZEND_DONE_PASS_TWO(op_array)) { - ZEND_OP2(opline).jmp_addr = &new_opcodes[ZEND_OP2(opline).jmp_addr - op_array->opcodes]; - } - break; - case ZEND_BRK: - case ZEND_CONT: - has_jmp = 1; - break; - case ZEND_DECLARE_INHERITED_CLASS: - if (main_persistent_script && ZCG(accel_directives).inherited_hack) { - if (!has_jmp && - ((opline + 2) >= end || - (opline + 1)->opcode != ZEND_FETCH_CLASS || - (opline + 2)->opcode != ZEND_ADD_INTERFACE)) { - - zend_uint *opline_num = &main_persistent_script->early_binding; - - while ((int)*opline_num != -1) { - opline_num = &new_opcodes[*opline_num].result.u.opline_num; - } - *opline_num = opline - new_opcodes; - opline->result.op_type = IS_UNUSED; - opline->result.u.opline_num = -1; - opline->opcode = ZEND_DECLARE_INHERITED_CLASS_DELAYED; - ZEND_VM_SET_OPCODE_HANDLER(opline); - } - break; - } - } - -#else /* if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO */ - if (ZEND_DONE_PASS_TWO(op_array)) { /* fix jumps to point to new array */ switch (opline->opcode) { case ZEND_JMP: case ZEND_GOTO: -#if ZEND_EXTENSION_API_NO > PHP_5_4_X_API_NO case ZEND_FAST_CALL: -#endif ZEND_OP1(opline).jmp_addr = &new_opcodes[ZEND_OP1(opline).jmp_addr - op_array->opcodes]; break; case ZEND_JMPZNZ: @@ -457,9 +358,7 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc case ZEND_JMPZ_EX: case ZEND_JMPNZ_EX: case ZEND_JMP_SET: -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO case ZEND_JMP_SET_VAR: -#endif case ZEND_NEW: case ZEND_FE_RESET: case ZEND_FE_FETCH: @@ -467,18 +366,15 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc break; } } -#endif /* if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO */ } efree(op_array->opcodes); op_array->opcodes = new_opcodes; -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (op_array->run_time_cache) { efree(op_array->run_time_cache); op_array->run_time_cache = NULL; } -#endif } if (op_array->function_name && !IS_ACCEL_INTERNED(op_array->function_name)) { @@ -606,7 +502,6 @@ static void zend_persist_class_entry(zval *zv TSRMLS_DC) ce = Z_PTR_P(zv) = zend_accel_memdup(ce, sizeof(zend_class_entry)); zend_accel_store_interned_string(ce->name); zend_hash_persist(&ce->function_table, zend_persist_op_array TSRMLS_CC); -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (ce->default_properties_table) { int i; @@ -624,11 +519,7 @@ static void zend_persist_class_entry(zval *zv TSRMLS_DC) } } ce->static_members_table = NULL; -#else - zend_hash_persist(&ce->default_properties, zend_persist_zval TSRMLS_CC); - zend_hash_persist(&ce->default_static_members, zend_persist_zval TSRMLS_CC); - ce->static_members = NULL; -#endif + zend_hash_persist(&ce->constants_table, zend_persist_zval TSRMLS_CC); if (ZEND_CE_FILENAME(ce)) { @@ -652,7 +543,6 @@ static void zend_persist_class_entry(zval *zv TSRMLS_DC) } ce->interfaces = NULL; /* will be filled in on fetch */ -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (ce->num_traits && ce->traits) { efree(ce->traits); } @@ -677,9 +567,6 @@ static void zend_persist_class_entry(zval *zv TSRMLS_DC) zend_accel_store_interned_string(ce->trait_aliases[i]->alias); } -#if ZEND_EXTENSION_API_NO <= PHP_5_4_X_API_NO - ce->trait_aliases[i]->function = NULL; -#endif zend_accel_store(ce->trait_aliases[i], sizeof(zend_trait_alias)); i++; } @@ -708,16 +595,12 @@ static void zend_persist_class_entry(zval *zv TSRMLS_DC) sizeof(zend_class_entry*) * (j + 1)); } -#if ZEND_EXTENSION_API_NO <= PHP_5_4_X_API_NO - ce->trait_precedences[i]->function = NULL; -#endif zend_accel_store(ce->trait_precedences[i], sizeof(zend_trait_precedence)); i++; } zend_accel_store( ce->trait_precedences, sizeof(zend_trait_precedence*) * (i + 1)); } -#endif } } @@ -785,18 +668,14 @@ static int zend_update_parent_ce(zval *zv TSRMLS_DC) ce->__tostring = zend_shared_alloc_get_xlat_entry(ce->__tostring); ce->__tostring->op_array.refcount++; } -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO if (ce->__callstatic) { ce->__callstatic = zend_shared_alloc_get_xlat_entry(ce->__callstatic); ce->__callstatic->op_array.refcount++; } -#endif -#if ZEND_EXTENSION_API_NO >= PHP_5_6_X_API_NO if (ce->__debugInfo) { ce->__debugInfo = zend_shared_alloc_get_xlat_entry(ce->__debugInfo); ce->__debugInfo->op_array.refcount++; } -#endif zend_hash_apply(&ce->properties_info, (apply_func_t) zend_update_property_info_ce TSRMLS_CC); return 0; } diff --git a/ext/opcache/zend_persist_calc.c b/ext/opcache/zend_persist_calc.c index 0732cc2188..08e9211350 100644 --- a/ext/opcache/zend_persist_calc.c +++ b/ext/opcache/zend_persist_calc.c @@ -31,7 +31,6 @@ #define ADD_SIZE(m) memory_used += ZEND_ALIGNED_SIZE(m) #define RETURN_SIZE() return memory_used -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO # define ADD_STRING(str) \ ADD_DUP_SIZE((str), _STR_HEADER_SIZE + (str)->len + 1) # define ADD_INTERNED_STRING(str, do_free) do { \ @@ -47,9 +46,6 @@ } \ } \ } while (0) -#else -# define ADD_INTERNED_STRING(str, len) ADD_DUP_SIZE((str), (len)) -#endif static uint zend_persist_zval_calc(zval *z TSRMLS_DC); @@ -85,7 +81,6 @@ static uint zend_hash_persist_calc(HashTable *ht, uint (*pPersistElement)(zval * RETURN_SIZE(); } -#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO static uint zend_persist_ast_calc(zend_ast *ast TSRMLS_DC) { int i; @@ -104,7 +99,6 @@ static uint zend_persist_ast_calc(zend_ast *ast TSRMLS_DC) } RETURN_SIZE(); } -#endif static uint zend_persist_zval_calc(zval *z TSRMLS_DC) { @@ -112,11 +106,7 @@ static uint zend_persist_zval_calc(zval *z TSRMLS_DC) uint size; START_SIZE(); -#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO switch (Z_TYPE_P(z)) { -#else - switch (Z_TYPE_P(z)) { -#endif case IS_STRING: case IS_CONSTANT: flags = Z_GC_FLAGS_P(z) & ~ (IS_STR_PERSISTENT | IS_STR_INTERNED | IS_STR_PERMANENT); @@ -127,16 +117,12 @@ static uint zend_persist_zval_calc(zval *z TSRMLS_DC) Z_GC_FLAGS_P(z) |= flags; break; case IS_ARRAY: -#if ZEND_EXTENSION_API_NO <= PHP_5_5_API_NO - case IS_CONSTANT_ARRAY: -#endif size = zend_shared_memdup_size(Z_ARR_P(z), sizeof(zend_array)); if (size) { ADD_SIZE(size); ADD_SIZE(zend_hash_persist_calc(Z_ARRVAL_P(z), zend_persist_zval_calc TSRMLS_CC)); } break; -#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO case IS_REFERENCE: size = zend_shared_memdup_size(Z_REF_P(z), sizeof(zend_reference)); if (size) { @@ -151,7 +137,6 @@ static uint zend_persist_zval_calc(zval *z TSRMLS_DC) ADD_SIZE(zend_persist_ast_calc(Z_ASTVAL_P(z) TSRMLS_CC)); } break; -#endif } RETURN_SIZE(); } @@ -180,7 +165,6 @@ static uint zend_persist_op_array_calc_ex(zend_op_array *op_array TSRMLS_DC) RETURN_SIZE(); } -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (op_array->literals) { zval *p = op_array->literals; zval *end = p + op_array->last_literal; @@ -190,25 +174,8 @@ static uint zend_persist_op_array_calc_ex(zend_op_array *op_array TSRMLS_DC) p++; } } -#endif - -#if ZEND_EXTENSION_API_NO <= PHP_5_3_X_API_NO - opline = op_array->opcodes; - end = op_array->opcodes + op_array->last; ADD_DUP_SIZE(op_array->opcodes, sizeof(zend_op) * op_array->last); - while (oplineop1.op_type == IS_CONST) { - ADD_SIZE(zend_persist_zval_calc(&opline->op1.u.constant TSRMLS_CC)); - } - if (opline->op2.op_type == IS_CONST) { - ADD_SIZE(zend_persist_zval_calc(&opline->op2.u.constant TSRMLS_CC)); - } - opline++; - } -#else - ADD_DUP_SIZE(op_array->opcodes, sizeof(zend_op) * op_array->last); -#endif if (op_array->function_name) { zend_string *old_name = op_array->function_name; @@ -297,7 +264,6 @@ static uint zend_persist_class_entry_calc(zval *zv TSRMLS_DC) ADD_DUP_SIZE(ce, sizeof(zend_class_entry)); ADD_INTERNED_STRING(ce->name, 0); ADD_SIZE(zend_hash_persist_calc(&ce->function_table, zend_persist_op_array_calc TSRMLS_CC)); -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (ce->default_properties_table) { int i; @@ -314,10 +280,6 @@ static uint zend_persist_class_entry_calc(zval *zv TSRMLS_DC) ADD_SIZE(zend_persist_zval_calc(&ce->default_static_members_table[i] TSRMLS_CC)); } } -#else - ADD_SIZE(zend_hash_persist_calc(&ce->default_properties, (int (*)(void* TSRMLS_DC)) zend_persist_zval_ptr_calc, sizeof(zval**) TSRMLS_CC)); - ADD_SIZE(zend_hash_persist_calc(&ce->default_static_members, (int (*)(void* TSRMLS_DC)) zend_persist_zval_ptr_calc, sizeof(zval**) TSRMLS_CC)); -#endif ADD_SIZE(zend_hash_persist_calc(&ce->constants_table, zend_persist_zval_calc TSRMLS_CC)); if (ZEND_CE_FILENAME(ce)) { @@ -329,7 +291,6 @@ static uint zend_persist_class_entry_calc(zval *zv TSRMLS_DC) ADD_SIZE(zend_hash_persist_calc(&ce->properties_info, zend_persist_property_info_calc TSRMLS_CC)); -#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO if (ce->trait_aliases) { int i = 0; while (ce->trait_aliases[i]) { @@ -374,7 +335,6 @@ static uint zend_persist_class_entry_calc(zval *zv TSRMLS_DC) } ADD_SIZE(sizeof(zend_trait_precedence*) * (i + 1)); } -#endif } RETURN_SIZE(); }