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) {
}
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 */
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;
}
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];
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;
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 */
/* 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) { \
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 &&
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) */
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 */
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;
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;
}
*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)
/* 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;
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
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;
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;
}
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;
/* 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. */
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 */
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:
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;
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--;
}
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);
/* 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
#endif
}
}
-#endif
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) {
FREE_ALLOCA(shiftlist);
return;
}
-#endif
/* Kill JMP-over-NOP-s */
if (opline->opcode == ZEND_JMP && ZEND_OP1(opline).opline_num > i) {
for (opline = op_array->opcodes; opline<end; opline++) {
switch (opline->opcode) {
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:
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:
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;
opline_num = &ZEND_RESULT(&op_array->opcodes[*opline_num]).opline_num;
} while (*opline_num != (zend_uint)-1);
}
-#endif
}
FREE_ALLOCA(shiftlist);
}
/* 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;
}
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;
}
zend_arena_release(&ctx->arena, checkpoint);
}
-#endif
-#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]) { \
/* 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;
}
start_of_T[VAR_NUM(ZEND_OP1(opline).var) + 1 - offset] = opline;
}
}
-#endif
opline--;
}
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 &&
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();
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();
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) {
* - 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;
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:
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;
}
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 &&
}
}
}
-#endif
break;
case ZEND_INIT_FCALL:
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 &&
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:
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:
}
}
break;
-#endif
}
opline++;
i++;
/* 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;
}
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;
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 */
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:
/* 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! */
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;
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) {
}
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;
}
}
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) {
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) {
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;
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;
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) {
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;
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;
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;
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,
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:
} else {
opline->op1.constant = zend_optimizer_add_literal(op_array, val TSRMLS_CC);
}
-#else
- ZEND_OP1_LITERAL(opline) = *val;
-#endif
}
}
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);
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 &&
}
}
break;
-#endif
default:
break;
}
}
-#else
- ZEND_OP2_LITERAL(opline) = *val;
-#endif
}
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) {
*/
#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
*/
#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,
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:
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:
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:
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:
#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;
#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"
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))
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);
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++) {
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++) {
}
}
#endif
-#endif
static inline void accel_restart_enter(TSRMLS_D)
{
}
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;
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;
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;
{ "_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];
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])) {
}
return 0;
}
-#endif
static void zend_accel_set_auto_globals(int mask TSRMLS_DC)
{
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) {
} 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;
}
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, "://"))) {
return NULL;
}
}
-#endif
if (ZCG(accel_directives).validate_timestamps ||
ZCG(accel_directives).file_update_protection ||
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 */
/* 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,
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);
}
/* 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;
}
!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, "://")) {
}
}
}
-#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;
}
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)
{
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;
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;
return accelerator_orig_zend_resolve_path(filename, filename_len TSRMLS_CC);
}
-#endif
-
static void zend_reset_cache_vars(TSRMLS_D)
{
ZSMMG(memory_exhausted) = 0;
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);
}
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);
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);
}
}
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;
}
}
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);
}
# endif
-#endif
-
zend_reset_cache_vars(TSRMLS_C);
ZCSG(oom_restarts) = 0;
_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;
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;
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;
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;
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();
# 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
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 */
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;
#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;
#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
# 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 */
#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)
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);
}
#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"
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)
#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;
(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;
}
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);
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 */
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;
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);
{
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;
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);
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;
#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);
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);
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);
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;
}
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;
}
}
-#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO
static zend_ast *zend_ast_clone(zend_ast *ast TSRMLS_DC)
{
int i;
}
return node;
}
-#endif
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;
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)));
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)));
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;
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;
}
}
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);
/* 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;
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)
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;
}
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);
}
}
-#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 */
#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); \
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)
{
}
}
-#if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO
static zend_ast *zend_persist_ast(zend_ast *ast TSRMLS_DC)
{
int i;
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);
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;
}
}
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) {
Z_ASTVAL_P(z) = zend_persist_ast(Z_ASTVAL_P(z) TSRMLS_CC);
}
break;
-#endif
}
}
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);
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;
}
}
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) {
Z_ASTVAL_P(z) = zend_persist_ast(Z_ASTVAL_P(z) TSRMLS_CC);
}
break;
-#endif
}
}
{
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);
}
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;
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);
efree(orig_literals);
}
}
-#endif
if (already_stored) {
persist_ptr = zend_shared_alloc_get_xlat_entry(op_array->opcodes);
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:
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:
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)) {
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;
}
}
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)) {
}
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);
}
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++;
}
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
}
}
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;
}
#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 { \
} \
} \
} 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);
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;
}
RETURN_SIZE();
}
-#endif
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);
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) {
ADD_SIZE(zend_persist_ast_calc(Z_ASTVAL_P(z) TSRMLS_CC));
}
break;
-#endif
}
RETURN_SIZE();
}
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;
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 (opline<end) {
- if (opline->op1.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;
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;
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)) {
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]) {
}
ADD_SIZE(sizeof(zend_trait_precedence*) * (i + 1));
}
-#endif
}
RETURN_SIZE();
}