Lines Matching refs:block

73 static inline void print_block(zend_code_block *block, zend_op *opcodes, char *txt)  in print_block()  argument
75 …derr, "%sBlock: %d-%d (%d)", txt, block->start_opline - opcodes, block->start_opline - opcodes + b… in print_block()
76 if (!block->access) { in print_block()
79 if (block->op1_to) { in print_block()
80 fprintf(stderr, " 1: %d", block->op1_to->start_opline - opcodes); in print_block()
82 if (block->op2_to) { in print_block()
83 fprintf(stderr, " 2: %d", block->op2_to->start_opline - opcodes); in print_block()
85 if (block->ext_to) { in print_block()
86 fprintf(stderr, " e: %d", block->ext_to->start_opline - opcodes); in print_block()
88 if (block->follow_to) { in print_block()
89 fprintf(stderr, " f: %d", block->follow_to->start_opline - opcodes); in print_block()
92 if (block->sources) { in print_block()
93 zend_block_source *bs = block->sources; in print_block()
449 static void delete_code_block(zend_code_block *block, zend_optimizer_ctx *ctx) in delete_code_block() argument
451 if (block->protected) { in delete_code_block()
454 if (block->follow_to) { in delete_code_block()
455 zend_block_source *bs = block->sources; in delete_code_block()
458 zend_code_block *to = block->follow_to; in delete_code_block()
459 if (from_block->op1_to == block) { in delete_code_block()
463 if (from_block->op2_to == block) { in delete_code_block()
467 if (from_block->ext_to == block) { in delete_code_block()
471 if (from_block->follow_to == block) { in delete_code_block()
478 block->access = 0; in delete_code_block()
481 static void zend_access_path(zend_code_block *block, zend_optimizer_ctx *ctx) in zend_access_path() argument
483 if (block->access) { in zend_access_path()
487 block->access = 1; in zend_access_path()
488 if (block->op1_to) { in zend_access_path()
489 zend_access_path(block->op1_to, ctx); in zend_access_path()
490 ADD_SOURCE(block, block->op1_to); in zend_access_path()
492 if (block->op2_to) { in zend_access_path()
493 zend_access_path(block->op2_to, ctx); in zend_access_path()
494 ADD_SOURCE(block, block->op2_to); in zend_access_path()
496 if (block->ext_to) { in zend_access_path()
497 zend_access_path(block->ext_to, ctx); in zend_access_path()
498 ADD_SOURCE(block, block->ext_to); in zend_access_path()
500 if (block->follow_to) { in zend_access_path()
501 zend_access_path(block->follow_to, ctx); in zend_access_path()
502 ADD_SOURCE(block, block->follow_to); in zend_access_path()
575 static void strip_nop(zend_code_block *block, zend_op_array *op_array, zend_optimizer_ctx *ctx) in strip_nop() argument
577 zend_op *opline = block->start_opline; in strip_nop()
581 while (block->len > 0 && block->start_opline->opcode == ZEND_NOP) { in strip_nop()
582 if (block->len == 1) { in strip_nop()
584 if (block->follow_to) { in strip_nop()
585 delete_code_block(block, ctx); in strip_nop()
589 if (block->len == 2 in strip_nop()
590 && ((block->start_opline + 1)->opcode == ZEND_JMPZ in strip_nop()
591 || (block->start_opline + 1)->opcode == ZEND_JMPNZ) in strip_nop()
592 && (block->start_opline + 1)->op1_type & (IS_CV|IS_CONST) in strip_nop()
593 && block->start_opline > op_array->opcodes in strip_nop()
594 && zend_is_smart_branch(block->start_opline - 1)) { in strip_nop()
597 block->start_opline++; in strip_nop()
598 block->start_opline_no++; in strip_nop()
599 block->len--; in strip_nop()
603 opline = new_end = block->start_opline; in strip_nop()
604 end = opline + block->len; in strip_nop()
635 block->len = new_end - block->start_opline; in strip_nop()
638 static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array, zend_bitset used_e… in zend_optimize_block() argument
640 zend_op *opline = block->start_opline; in zend_optimize_block()
644 print_block(block, op_array->opcodes, "Opt "); in zend_optimize_block()
647 while (block->len > 0 && block->start_opline->opcode == ZEND_NOP) { in zend_optimize_block()
648 if (block->len == 1) { in zend_optimize_block()
650 if (block->follow_to) { in zend_optimize_block()
651 delete_code_block(block, ctx); in zend_optimize_block()
653 if (block->len == 2 in zend_optimize_block()
654 && ((block->start_opline + 1)->opcode == ZEND_JMPZ in zend_optimize_block()
655 || (block->start_opline + 1)->opcode == ZEND_JMPNZ) in zend_optimize_block()
656 && (block->start_opline + 1)->op1_type & (IS_CV|IS_CONST) in zend_optimize_block()
657 && block->start_opline > op_array->opcodes in zend_optimize_block()
658 && zend_is_smart_branch(block->start_opline - 1)) { in zend_optimize_block()
663 block->start_opline++; in zend_optimize_block()
664 block->start_opline_no++; in zend_optimize_block()
665 block->len--; in zend_optimize_block()
670 opline = block->start_opline; in zend_optimize_block()
671 end = opline + block->len; in zend_optimize_block()
753 if(sv >= block->start_opline && sv->opcode == ZEND_SEND_VAL && in zend_optimize_block()
887 op_b = block->ext_to; in zend_optimize_block()
888 block->ext_to = block->op2_to; in zend_optimize_block()
889 block->op2_to = op_b; in zend_optimize_block()
1177 strip_nop(block, op_array, ctx); in zend_optimize_block()
1291 static void zend_jmp_optimization(zend_code_block *block, zend_op_array *op_array, zend_code_block … in zend_jmp_optimization() argument
1294 zend_op *last_op = (block->start_opline + block->len - 1); in zend_jmp_optimization()
1296 if (!block->len) { in zend_jmp_optimization()
1302 zend_op *target = block->op1_to->start_opline; in zend_jmp_optimization()
1303 zend_code_block *next = block->next; in zend_jmp_optimization()
1311 if (block->op1_to == next) { in zend_jmp_optimization()
1312 block->follow_to = block->op1_to; in zend_jmp_optimization()
1313 block->op1_to = NULL; in zend_jmp_optimization()
1315 block->len--; in zend_jmp_optimization()
1316 if (block->len == 0) { in zend_jmp_optimization()
1318 delete_code_block(block, ctx); in zend_jmp_optimization()
1324 block->op1_to != block->op1_to->op1_to) || in zend_jmp_optimization()
1326 !block->op1_to->protected) { in zend_jmp_optimization()
1335 del_source(block, block->op1_to); in zend_jmp_optimization()
1336 if (block->op1_to->op2_to) { in zend_jmp_optimization()
1337 block->op2_to = block->op1_to->op2_to; in zend_jmp_optimization()
1338 ADD_SOURCE(block, block->op2_to); in zend_jmp_optimization()
1340 if (block->op1_to->ext_to) { in zend_jmp_optimization()
1341 block->ext_to = block->op1_to->ext_to; in zend_jmp_optimization()
1342 ADD_SOURCE(block, block->ext_to); in zend_jmp_optimization()
1344 if (block->op1_to->op1_to) { in zend_jmp_optimization()
1345 block->op1_to = block->op1_to->op1_to; in zend_jmp_optimization()
1346 ADD_SOURCE(block, block->op1_to); in zend_jmp_optimization()
1348 block->op1_to = NULL; in zend_jmp_optimization()
1361 del_source(block, block->op1_to); in zend_jmp_optimization()
1362 block->op1_to = NULL; in zend_jmp_optimization()
1365 } else if (0&& block->op1_to != block && in zend_jmp_optimization()
1366 block->op1_to != blocks && in zend_jmp_optimization()
1374 zend_block_source *cs = block->op1_to->sources; in zend_jmp_optimization()
1378 if (cs->from->follow_to == block->op1_to) { in zend_jmp_optimization()
1385 next = block->op1_to; in zend_jmp_optimization()
1388 if (next->follow_to == block) { in zend_jmp_optimization()
1397 while (prev->next != block->op1_to) { in zend_jmp_optimization()
1401 next->next = block->next; in zend_jmp_optimization()
1402 block->next = block->op1_to; in zend_jmp_optimization()
1404 block->follow_to = block->op1_to; in zend_jmp_optimization()
1405 block->op1_to = NULL; in zend_jmp_optimization()
1407 block->len--; in zend_jmp_optimization()
1408 if(block->len == 0) { in zend_jmp_optimization()
1410 delete_code_block(block, ctx); in zend_jmp_optimization()
1435 block->op1_to = block->op2_to; in zend_jmp_optimization()
1436 del_source(block, block->follow_to); in zend_jmp_optimization()
1437 block->op2_to = NULL; in zend_jmp_optimization()
1438 block->follow_to = NULL; in zend_jmp_optimization()
1442 del_source(block, block->op2_to); in zend_jmp_optimization()
1443 block->op2_to = NULL; in zend_jmp_optimization()
1448 if (block->op2_to == block->follow_to) { in zend_jmp_optimization()
1461 block->op2_to = NULL; in zend_jmp_optimization()
1470 block->op2_to = NULL; in zend_jmp_optimization()
1473 block->op2_to = NULL; in zend_jmp_optimization()
1478 if (block->op2_to) { in zend_jmp_optimization()
1483 zend_code_block *target_block = block->op2_to;; in zend_jmp_optimization()
1504 del_source(block, block->op2_to); in zend_jmp_optimization()
1505 block->op2_to = target_block->follow_to; in zend_jmp_optimization()
1506 ADD_SOURCE(block, block->op2_to); in zend_jmp_optimization()
1516 del_source(block, block->op2_to); in zend_jmp_optimization()
1517 block->op2_to = target_block->follow_to; in zend_jmp_optimization()
1518 ADD_SOURCE(block, block->op2_to); in zend_jmp_optimization()
1526 del_source(block, block->op2_to); in zend_jmp_optimization()
1527 block->op2_to = target_block->op2_to; in zend_jmp_optimization()
1528 ADD_SOURCE(block, block->op2_to); in zend_jmp_optimization()
1533 del_source(block, block->op2_to); in zend_jmp_optimization()
1534 block->op2_to = target_block->op1_to; in zend_jmp_optimization()
1535 ADD_SOURCE(block, block->op2_to); in zend_jmp_optimization()
1544 del_source(block, block->op2_to); in zend_jmp_optimization()
1546 block->op2_to = target_block->op2_to; in zend_jmp_optimization()
1548 block->op2_to = target_block->ext_to; in zend_jmp_optimization()
1550 ADD_SOURCE(block, block->op2_to); in zend_jmp_optimization()
1554 if (block->follow_to && in zend_jmp_optimization()
1560 target = block->follow_to->start_opline; in zend_jmp_optimization()
1561 target_end = block->follow_to->start_opline + block->follow_to->len; in zend_jmp_optimization()
1567 if (target == target_end && ! block->follow_to->protected) { in zend_jmp_optimization()
1568 del_source(block, block->follow_to); in zend_jmp_optimization()
1569 block->follow_to = block->follow_to->follow_to; in zend_jmp_optimization()
1570 ADD_SOURCE(block, block->follow_to); in zend_jmp_optimization()
1577 block->follow_to->op1_to && in zend_jmp_optimization()
1578 !block->follow_to->protected) { in zend_jmp_optimization()
1579 del_source(block, block->follow_to); in zend_jmp_optimization()
1581 block->ext_to = block->follow_to->op1_to; in zend_jmp_optimization()
1582 ADD_SOURCE(block, block->ext_to); in zend_jmp_optimization()
1584 block->ext_to = block->op2_to; in zend_jmp_optimization()
1585 block->op2_to = block->follow_to->op1_to; in zend_jmp_optimization()
1586 ADD_SOURCE(block, block->op2_to); in zend_jmp_optimization()
1588 block->follow_to = NULL; in zend_jmp_optimization()
1609 del_source(block, block->op2_to); in zend_jmp_optimization()
1610 block->op2_to = NULL; in zend_jmp_optimization()
1615 if (block->op2_to) { in zend_jmp_optimization()
1628 target_block = block->op2_to; in zend_jmp_optimization()
1645 del_source(block, block->op2_to); in zend_jmp_optimization()
1646 block->op2_to = target_block->op2_to; in zend_jmp_optimization()
1647 ADD_SOURCE(block, block->op2_to); in zend_jmp_optimization()
1654 del_source(block, block->op2_to); in zend_jmp_optimization()
1655 block->op2_to = target_block->follow_to; in zend_jmp_optimization()
1656 ADD_SOURCE(block, block->op2_to); in zend_jmp_optimization()
1664 del_source(block, block->op2_to); in zend_jmp_optimization()
1665 block->op2_to = target_block->follow_to; in zend_jmp_optimization()
1666 ADD_SOURCE(block, block->op2_to); in zend_jmp_optimization()
1674 del_source(block, block->op2_to); in zend_jmp_optimization()
1675 block->op2_to = target_block->op2_to; in zend_jmp_optimization()
1676 ADD_SOURCE(block, block->op2_to); in zend_jmp_optimization()
1681 del_source(block, block->op2_to); in zend_jmp_optimization()
1682 block->op2_to = target_block->op1_to; in zend_jmp_optimization()
1683 ADD_SOURCE(block, block->op2_to); in zend_jmp_optimization()
1691 del_source(block, block->op2_to); in zend_jmp_optimization()
1693 block->op2_to = target_block->op2_to; in zend_jmp_optimization()
1695 block->op2_to = target_block->ext_to; in zend_jmp_optimization()
1697 ADD_SOURCE(block, block->op2_to); in zend_jmp_optimization()
1703 zend_code_block *next = block->next; in zend_jmp_optimization()
1719 block->op1_to = block->op2_to; in zend_jmp_optimization()
1720 todel = block->ext_to; in zend_jmp_optimization()
1721 block->op2_to = NULL; in zend_jmp_optimization()
1722 block->ext_to = NULL; in zend_jmp_optimization()
1723 del_source(block, todel); in zend_jmp_optimization()
1732 block->op1_to = block->ext_to; in zend_jmp_optimization()
1733 todel = block->op2_to; in zend_jmp_optimization()
1734 block->op2_to = NULL; in zend_jmp_optimization()
1735 block->ext_to = NULL; in zend_jmp_optimization()
1736 del_source(block, todel); in zend_jmp_optimization()
1738 } else if (block->op2_to == block->ext_to) { in zend_jmp_optimization()
1745 block->op1_to = block->op2_to; in zend_jmp_optimization()
1746 block->op2_to = NULL; in zend_jmp_optimization()
1747 block->ext_to = NULL; in zend_jmp_optimization()
1749 } else if (block->op2_to == next) { in zend_jmp_optimization()
1753 block->op2_to = block->ext_to; in zend_jmp_optimization()
1754 block->follow_to = next; in zend_jmp_optimization()
1755 block->ext_to = NULL; in zend_jmp_optimization()
1757 } else if (block->ext_to == next) { in zend_jmp_optimization()
1761 block->follow_to = next; in zend_jmp_optimization()
1762 block->ext_to = NULL; in zend_jmp_optimization()
1766 if (last_op->opcode == ZEND_JMPZNZ && block->op2_to) { in zend_jmp_optimization()
1771 zend_code_block *target_block = block->op2_to; in zend_jmp_optimization()
1790 del_source(block, block->op2_to); in zend_jmp_optimization()
1791 block->op2_to = target_block->op2_to; in zend_jmp_optimization()
1792 ADD_SOURCE(block, block->op2_to); in zend_jmp_optimization()
1800 del_source(block, block->op2_to); in zend_jmp_optimization()
1801 block->op2_to = target_block->follow_to; in zend_jmp_optimization()
1802 ADD_SOURCE(block, block->op2_to); in zend_jmp_optimization()
1807 del_source(block, block->op2_to); in zend_jmp_optimization()
1808 block->op2_to = target_block->op1_to; in zend_jmp_optimization()
1809 ADD_SOURCE(block, block->op2_to); in zend_jmp_optimization()
1831 static void zend_t_usage(zend_code_block *block, zend_op_array *op_array, zend_bitset used_ext, zen… in zend_t_usage() argument
1833 zend_code_block *next_block = block->next; in zend_t_usage()
1893 while (block) { in zend_t_usage()
1894 zend_op *opline = block->start_opline + block->len - 1; in zend_t_usage()
1896 if (!block->access) { in zend_t_usage()
1897 block = block->next; in zend_t_usage()
1903 while (opline >= block->start_opline) { in zend_t_usage()
1979 block = block->next; in zend_t_usage()