Skip to content

Commit e4e334e

Browse files
committed
Remove dead code for ADD_STRING/ADD_CHAR optimization
These opcodes don't exist anymore. The modern equivalent would be the ROPE_* opcodes. However the code would have to be different anyway.
1 parent 3b07c6c commit e4e334e

File tree

1 file changed

+0
-74
lines changed

1 file changed

+0
-74
lines changed

ext/opcache/Optimizer/pass1_5.c

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
/* pass 1
2323
* - substitute persistent constants (true, false, null, etc)
2424
* - perform compile-time evaluation of constant binary and unary operations
25-
* - optimize series of ADD_STRING and/or ADD_CHAR
2625
* - convert CAST(IS_BOOL,x) into BOOL(x)
2726
* - pre-evaluate constant function calls
2827
*/
@@ -129,79 +128,6 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
129128
}
130129
break;
131130

132-
#if 0
133-
case ZEND_ADD_STRING:
134-
case ZEND_ADD_CHAR:
135-
{
136-
zend_op *next_op = opline + 1;
137-
int requires_conversion = (opline->opcode == ZEND_ADD_CHAR? 1 : 0);
138-
size_t final_length = 0;
139-
zend_string *str;
140-
char *ptr;
141-
zend_op *last_op;
142-
143-
/* There is always a ZEND_RETURN at the end
144-
if (next_op>=end) {
145-
break;
146-
}
147-
*/
148-
while (next_op->opcode == ZEND_ADD_STRING || next_op->opcode == ZEND_ADD_CHAR) {
149-
if (opline->result.var != next_op->result.var) {
150-
break;
151-
}
152-
if (next_op->opcode == ZEND_ADD_CHAR) {
153-
final_length += 1;
154-
} else { /* ZEND_ADD_STRING */
155-
final_length += Z_STRLEN(ZEND_OP2_LITERAL(next_op));
156-
}
157-
next_op++;
158-
}
159-
if (final_length == 0) {
160-
break;
161-
}
162-
last_op = next_op;
163-
final_length += (requires_conversion? 1 : Z_STRLEN(ZEND_OP2_LITERAL(opline)));
164-
str = zend_string_alloc(final_length, 0);
165-
str->len = final_length;
166-
ptr = str->val;
167-
ptr[final_length] = '\0';
168-
if (requires_conversion) { /* ZEND_ADD_CHAR */
169-
char chval = (char)Z_LVAL(ZEND_OP2_LITERAL(opline));
170-
171-
ZVAL_NEW_STR(&ZEND_OP2_LITERAL(opline), str);
172-
ptr[0] = chval;
173-
opline->opcode = ZEND_ADD_STRING;
174-
ptr++;
175-
} else { /* ZEND_ADD_STRING */
176-
memcpy(ptr, Z_STRVAL(ZEND_OP2_LITERAL(opline)), Z_STRLEN(ZEND_OP2_LITERAL(opline)));
177-
ptr += Z_STRLEN(ZEND_OP2_LITERAL(opline));
178-
zend_string_release_ex(Z_STR(ZEND_OP2_LITERAL(opline)), 0);
179-
ZVAL_NEW_STR(&ZEND_OP2_LITERAL(opline), str);
180-
}
181-
next_op = opline + 1;
182-
while (next_op < last_op) {
183-
if (next_op->opcode == ZEND_ADD_STRING) {
184-
memcpy(ptr, Z_STRVAL(ZEND_OP2_LITERAL(next_op)), Z_STRLEN(ZEND_OP2_LITERAL(next_op)));
185-
ptr += Z_STRLEN(ZEND_OP2_LITERAL(next_op));
186-
literal_dtor(&ZEND_OP2_LITERAL(next_op));
187-
} else { /* ZEND_ADD_CHAR */
188-
*ptr = (char)Z_LVAL(ZEND_OP2_LITERAL(next_op));
189-
ptr++;
190-
}
191-
MAKE_NOP(next_op);
192-
next_op++;
193-
}
194-
if (!((ZEND_OPTIMIZER_PASS_5|ZEND_OPTIMIZER_PASS_10) & OPTIMIZATION_LEVEL)) {
195-
/* NOP removal is disabled => insert JMP over NOPs */
196-
if (last_op-opline >= 3) { /* If we have more than 2 NOPS then JMP over them */
197-
(opline + 1)->opcode = ZEND_JMP;
198-
(opline + 1)->op1.opline_num = last_op - op_array->opcodes; /* that's OK even for ZE2, since opline_num's are resolved in pass 2 later */
199-
}
200-
}
201-
}
202-
break;
203-
#endif
204-
205131
case ZEND_FETCH_CONSTANT:
206132
if (opline->op2_type == IS_CONST &&
207133
Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING &&

0 commit comments

Comments
 (0)