Skip to content

Commit d4c195c

Browse files
Zend/Optimizer/block_pass.c: remove code disabled with #if 0 (#21791)
It has been that way since the initial public release of the optimizer in 528006a and survived through the merging as ext/opcache (34d3202) and then moving it into core (#6642). If it hasn't been needed in the last 13 years, should be safe to drop.
1 parent 1d3a9bc commit d4c195c

1 file changed

Lines changed: 0 additions & 53 deletions

File tree

Zend/Optimizer/block_pass.c

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -344,59 +344,6 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
344344
}
345345
break;
346346

347-
#if 0
348-
/* pre-evaluate functions:
349-
constant(x)
350-
function_exists(x)
351-
extension_loaded(x)
352-
BAD: interacts badly with Accelerator
353-
*/
354-
if((opline->op1_type & IS_VAR) &&
355-
VAR_SOURCE(opline->op1) && VAR_SOURCE(opline->op1)->opcode == ZEND_DO_CF_FCALL &&
356-
VAR_SOURCE(opline->op1)->extended_value == 1) {
357-
zend_op *fcall = VAR_SOURCE(opline->op1);
358-
zend_op *sv = fcall-1;
359-
if(sv >= block->start_opline && sv->opcode == ZEND_SEND_VAL &&
360-
sv->op1_type == IS_CONST && Z_TYPE(OPLINE_OP1_LITERAL(sv)) == IS_STRING &&
361-
Z_LVAL(OPLINE_OP2_LITERAL(sv)) == 1
362-
) {
363-
zval *arg = &OPLINE_OP1_LITERAL(sv);
364-
char *fname = FUNCTION_CACHE->funcs[Z_LVAL(ZEND_OP1_LITERAL(fcall))].function_name;
365-
size_t flen = FUNCTION_CACHE->funcs[Z_LVAL(ZEND_OP1_LITERAL(fcall))].name_len;
366-
if((flen == sizeof("function_exists")-1 && zend_binary_strcasecmp(fname, flen, "function_exists", sizeof("function_exists")-1) == 0) ||
367-
(flen == sizeof("is_callable")-1 && zend_binary_strcasecmp(fname, flen, "is_callable", sizeof("is_callable")-1) == 0)
368-
) {
369-
zend_function *function;
370-
if((function = zend_hash_find_ptr(EG(function_table), Z_STR_P(arg))) != NULL) {
371-
literal_dtor(arg);
372-
MAKE_NOP(sv);
373-
MAKE_NOP(fcall);
374-
LITERAL_BOOL(opline->op1, 1);
375-
opline->op1_type = IS_CONST;
376-
}
377-
} else if(flen == sizeof("constant")-1 && zend_binary_strcasecmp(fname, flen, "constant", sizeof("constant")-1) == 0) {
378-
zval c;
379-
if (zend_optimizer_get_persistent_constant(Z_STR_P(arg), &c, true ELS_CC)) {
380-
literal_dtor(arg);
381-
MAKE_NOP(sv);
382-
MAKE_NOP(fcall);
383-
ZEND_OP1_LITERAL(opline) = zend_optimizer_add_literal(op_array, &c);
384-
/* no copy ctor - get already copied it */
385-
opline->op1_type = IS_CONST;
386-
}
387-
} else if(flen == sizeof("extension_loaded")-1 && zend_binary_strcasecmp(fname, flen, "extension_loaded", sizeof("extension_loaded")-1) == 0) {
388-
if(zend_hash_exists(&module_registry, Z_STR_P(arg))) {
389-
literal_dtor(arg);
390-
MAKE_NOP(sv);
391-
MAKE_NOP(fcall);
392-
LITERAL_BOOL(opline->op1, 1);
393-
opline->op1_type = IS_CONST;
394-
}
395-
}
396-
}
397-
}
398-
#endif
399-
400347
case ZEND_FETCH_LIST_R:
401348
case ZEND_FETCH_LIST_W:
402349
if (opline->op1_type & (IS_TMP_VAR|IS_VAR)) {

0 commit comments

Comments
 (0)