Lines Matching refs:f

609 function out($f, $s) {  argument
612 fputs($f,$s);
617 function out_line($f) { argument
620 fputs($f,"#line ".($line_no+1)." \"".$executor_file."\"\n");
676 function gen_code($f, $spec, $kind, $export, $code, $op1, $op2, $name, $extra_spec=null) { argument
941 out($f, $code);
945 function gen_handler($f, $spec, $kind, $name, $op1, $op2, $use, $code, $lineno, $extra_spec = null,… argument
971 out($f, "#line $lineno \"$definition_file\"\n");
978 …out($f,"static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL {$spec_name}_HANDLER(ZEND_OPCODE_HANDLER_ARGS…
983 out($f,"case $cur: /* $spec_name */");
986 out($f,"case ".$name.":");
990 out($f," {$spec_name}_LABEL:\n");
992 out($f,"\n");
996 out($f,"{$spec_name}_HANDLER: ZEND_VM_GUARD($spec_name);\n");
1001 gen_code($f, $spec, $kind, 0, $code, $op1, $op2, $name, $extra_spec);
1005 function gen_helper($f, $spec, $kind, $name, $op1, $op2, $param, $code, $lineno, $inline) { argument
1009 out($f, "#line $lineno \"$definition_file\"\n");
1024 …out($f, "static$zend_always_inline ZEND_OPCODE_HANDLER_RET$zend_fastcall ".$name.($spec?"_SPEC":""…
1027 …out($f, "static$zend_always_inline ZEND_OPCODE_HANDLER_RET$zend_fastcall ".$name.($spec?"_SPEC":""…
1031 out($f, $name.($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2].":\n");
1034 out($f, $name.($spec?"_SPEC":"").$prefix[$op1].$prefix[$op2].":\n");
1039 gen_code($f, $spec, $kind, 0, $code, $op1, $op2, $name);
1043 function gen_null_label($f, $kind, $prolog) { argument
1046 out($f,$prolog."ZEND_NULL_HANDLER,\n");
1049 out($f,$prolog."(void*)(uintptr_t)-1,\n");
1052 out($f,$prolog."(void*)&&ZEND_NULL_HANDLER,\n");
1058 function gen_labels($f, $spec, $kind, $prolog, &$specs, $switch_labels = array()) { argument
1177 …$generate = function ($op1, $op2, $extra_spec = array()) use ($f, $kind, $dsc, $prefix, $prolog, $…
1189 gen_null_label($f, $kind, $prolog);
1195 gen_null_label($f, $kind, $prolog);
1202 gen_null_label($f, $kind, $prolog);
1211 out($f,"$prolog{$spec_name}_HANDLER,\n");
1215 out($f,$prolog."(void*)(uintptr_t)$switch_labels[$spec_name],\n");
1219 out($f,$prolog."(void*)&&{$spec_name}_HANDLER,\n");
1225 gen_null_label($f, $kind, $prolog);
1259 out($f,$prolog."ZEND_NULL_HANDLER,\n");
1262 out($f,$prolog."(void*)(uintptr_t)-1,\n");
1265 out($f,$prolog."(void*)&&ZEND_NULL_HANDLER,\n");
1280 out($f,$prolog.$dsc["op"]."_HANDLER,\n");
1283 out($f,$prolog."(void*)(uintptr_t)".((string)$num).",\n");
1286 out($f,$prolog."(void*)&&".$dsc["op"]."_HANDLER,\n");
1292 out($f,$prolog."ZEND_NULL_HANDLER,\n");
1295 out($f,$prolog."(void*)(uintptr_t)-1,\n");
1298 out($f,$prolog."(void*)&&ZEND_NULL_HANDLER,\n");
1308 out($f,$prolog."ZEND_NULL_HANDLER\n");
1311 out($f,$prolog."(void*)(uintptr_t)-1\n");
1314 out($f,$prolog."(void*)&&ZEND_NULL_HANDLER\n");
1321 function gen_specs($f, $spec, $kind, $prolog, $specs) { argument
1326 out($f, "$prolog$lastdef,\n");
1329 out($f, "$prolog$def,\n");
1331 out($f, "$prolog$lastdef\n");
1335 function gen_null_handler($f) { argument
1342 …out($f,"static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_NULL_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n…
1343 out($f,"{\n");
1344 out($f,"\tUSE_OPLINE\n");
1345 out($f,"\n");
1346 …out($f,"\tzend_error_noreturn(E_ERROR, \"Invalid opcode %d/%d/%d.\", OPLINE->opcode, OPLINE->op1_t…
1347 out($f,"\tZEND_VM_NEXT_OPCODE(); /* Never reached */\n");
1348 out($f,"}\n\n");
1422 $f = function($specs) use (&$f) {
1426 $next = $f($specs);
1438 return $f($specs);
1442 function gen_executor_code($f, $spec, $kind, $prolog, &$switch_labels = array()) { argument
1462 …gen_handler($f, 1, $kind, $opcodes[$num]["op"], $op1, $op2, isset($opcodes[$num]["use"]), $opcodes…
1471 …gen_helper($f, 1, $kind, $num, $op1, $op2, $helpers[$num]["param"], $helpers[$num]["code"], $linen…
1489 …gen_handler($f, 0, $kind, $opcodes[$num]["op"], "ANY", "ANY", isset($opcodes[$num]["use"]), $opcod…
1494 …gen_helper($f, 0, $kind, $num, "ANY", "ANY", $helpers[$num]["param"], $helpers[$num]["code"], $lin…
1504 out_line($f);
1510 gen_null_handler($f);
1513 out($f,"default:\n");
1514 …out($f,"\tzend_error_noreturn(E_ERROR, \"Invalid opcode %d/%d/%d.\", OPLINE->opcode, OPLINE->op1_t…
1515 out($f,"\tZEND_VM_NEXT_OPCODE(); /* Never reached */\n");
1518 out($f,"ZEND_NULL_HANDLER:\n");
1519 …out($f,"\tzend_error_noreturn(E_ERROR, \"Invalid opcode %d/%d/%d.\", OPLINE->opcode, OPLINE->op1_t…
1520 out($f,"\tZEND_VM_NEXT_OPCODE(); /* Never reached */\n");
1525 function skip_blanks($f, $prolog, $epilog) { argument
1527 out($f, $prolog.$epilog);
1532 function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name) { argument
1543 out($f,"#define SPEC_START_MASK 0x0000ffff\n");
1544 out($f,"#define SPEC_RULE_OP1 0x00010000\n");
1545 out($f,"#define SPEC_RULE_OP2 0x00020000\n");
1546 out($f,"#define SPEC_RULE_OP_DATA 0x00040000\n");
1547 out($f,"#define SPEC_RULE_RETVAL 0x00080000\n");
1548 out($f,"#define SPEC_RULE_QUICK_ARG 0x00100000\n");
1549 out($f,"#define SPEC_RULE_SMART_BRANCH 0x00200000\n");
1550 out($f,"#define SPEC_RULE_DIM_OBJ 0x00400000\n");
1551 out($f,"\n");
1552 out($f,"static const uint32_t *zend_spec_handlers;\n");
1553 out($f,"static const void **zend_opcode_handlers;\n");
1554 out($f,"static int zend_handlers_count;\n");
1555 …out($f,"static const void *zend_vm_get_opcode_handler(zend_uchar opcode, const zend_op* op);\n\n");
1558 out($f,"\n");
1559 out($f,"#ifdef ZEND_VM_FP_GLOBAL_REG\n");
1560 out($f,"#pragma GCC diagnostic ignored \"-Wvolatile-register-var\"\n");
1561 … out($f,"register zend_execute_data* volatile execute_data __asm__(ZEND_VM_FP_GLOBAL_REG);\n");
1562 out($f,"#pragma GCC diagnostic warning \"-Wvolatile-register-var\"\n");
1563 out($f,"#endif\n");
1564 out($f,"\n");
1565 out($f,"#ifdef ZEND_VM_IP_GLOBAL_REG\n");
1566 out($f,"#pragma GCC diagnostic ignored \"-Wvolatile-register-var\"\n");
1567 out($f,"register const zend_op* volatile opline __asm__(ZEND_VM_IP_GLOBAL_REG);\n");
1568 out($f,"#pragma GCC diagnostic warning \"-Wvolatile-register-var\"\n");
1569 out($f,"#endif\n");
1570 out($f,"\n");
1571 out($f,"#ifdef ZEND_VM_FP_GLOBAL_REG\n");
1572 out($f,"# define ZEND_OPCODE_HANDLER_ARGS void\n");
1573 out($f,"# define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU\n");
1574 out($f,"# define ZEND_OPCODE_HANDLER_ARGS_DC\n");
1575 out($f,"# define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC\n");
1576 out($f,"#else\n");
1577 out($f,"# define ZEND_OPCODE_HANDLER_ARGS zend_execute_data *execute_data\n");
1578 out($f,"# define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU execute_data\n");
1579 out($f,"# define ZEND_OPCODE_HANDLER_ARGS_DC , ZEND_OPCODE_HANDLER_ARGS\n");
1580 … out($f,"# define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC , ZEND_OPCODE_HANDLER_ARGS_PASSTHRU\n");
1581 out($f,"#endif\n");
1582 out($f,"\n");
1583 out($f,"#if defined(ZEND_VM_FP_GLOBAL_REG) && defined(ZEND_VM_IP_GLOBAL_REG)\n");
1584 out($f,"# define ZEND_OPCODE_HANDLER_RET void\n");
1585 out($f,"# define ZEND_VM_TAIL_CALL(call) call; return\n");
1586 out($f,"# ifdef ZEND_VM_TAIL_CALL_DISPATCH\n");
1587 …out($f,"# define ZEND_VM_CONTINUE() ((opcode_handler_t)OPLINE->handler)(ZEND_OPCODE_HANDLER_A…
1588 out($f,"# else\n");
1589 out($f,"# define ZEND_VM_CONTINUE() return\n");
1590 out($f,"# endif\n");
1591 out($f,"# define ZEND_VM_RETURN() opline = NULL; return\n");
1592 out($f,"#else\n");
1593 out($f,"# define ZEND_OPCODE_HANDLER_RET int\n");
1594 out($f,"# define ZEND_VM_TAIL_CALL(call) return call\n");
1595 out($f,"# define ZEND_VM_CONTINUE() return 0\n");
1596 out($f,"# define ZEND_VM_RETURN() return -1\n");
1597 out($f,"#endif\n");
1598 out($f,"\n");
1599 …out($f,"typedef ZEND_OPCODE_HANDLER_RET (ZEND_FASTCALL *opcode_handler_t) (ZEND_OPCODE_HANDLER_ARG…
1600 out($f,"\n");
1601 out($f,"#undef OPLINE\n");
1602 out($f,"#undef DCL_OPLINE\n");
1603 out($f,"#undef USE_OPLINE\n");
1604 out($f,"#undef LOAD_OPLINE\n");
1605 out($f,"#undef LOAD_OPLINE_EX\n");
1606 out($f,"#undef SAVE_OPLINE\n");
1607 out($f,"#define DCL_OPLINE\n");
1608 out($f,"#ifdef ZEND_VM_IP_GLOBAL_REG\n");
1609 out($f,"# define OPLINE opline\n");
1610 out($f,"# define USE_OPLINE\n");
1611 out($f,"# define LOAD_OPLINE() opline = EX(opline)\n");
1612 out($f,"# define LOAD_NEXT_OPLINE() opline = EX(opline) + 1\n");
1613 out($f,"# define SAVE_OPLINE() EX(opline) = opline\n");
1614 out($f,"#else\n");
1615 out($f,"# define OPLINE EX(opline)\n");
1616 out($f,"# define USE_OPLINE const zend_op *opline = EX(opline);\n");
1617 out($f,"# define LOAD_OPLINE()\n");
1618 out($f,"# define LOAD_NEXT_OPLINE() ZEND_VM_INC_OPCODE()\n");
1619 out($f,"# define SAVE_OPLINE()\n");
1620 out($f,"#endif\n");
1621 out($f,"#undef HANDLE_EXCEPTION\n");
1622 out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
1623 out($f,"#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
1624 out($f,"#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE()\n");
1625 out($f,"#if defined(ZEND_VM_FP_GLOBAL_REG)\n");
1626 …out($f,"# define ZEND_VM_ENTER() execute_data = EG(current_execute_data); LOAD_OPLINE();…
1627 out($f,"# define ZEND_VM_LEAVE() ZEND_VM_CONTINUE()\n");
1628 out($f,"#elif defined(ZEND_VM_IP_GLOBAL_REG)\n");
1629 …out($f,"# define ZEND_VM_ENTER() opline = EG(current_execute_data)->opline; return 1\n");
1630 out($f,"# define ZEND_VM_LEAVE() return 2\n");
1631 out($f,"#else\n");
1632 out($f,"# define ZEND_VM_ENTER() return 1\n");
1633 out($f,"# define ZEND_VM_LEAVE() return 2\n");
1634 out($f,"#endif\n");
1635 …out($f,"#define ZEND_VM_INTERRUPT() ZEND_VM_TAIL_CALL(zend_interrupt_helper".($spec?"_SPEC":"…
1636 …out($f,"#define ZEND_VM_LOOP_INTERRUPT() zend_interrupt_helper".($spec?"_SPEC":"")."(ZEND_OPCODE_H…
1637 …out($f,"#define ZEND_VM_DISPATCH(opcode, opline) ZEND_VM_TAIL_CALL(((opcode_handler_t)zend_vm_get_…
1638 out($f,"\n");
1639 …out($f,"static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_interrupt_helper".($spec?"_SPEC":"")."(Z…
1640 out($f,"\n");
1643 out($f,"\n");
1644 out($f,"#undef OPLINE\n");
1645 out($f,"#undef DCL_OPLINE\n");
1646 out($f,"#undef USE_OPLINE\n");
1647 out($f,"#undef LOAD_OPLINE\n");
1648 out($f,"#undef LOAD_NEXT_OPLINE\n");
1649 out($f,"#undef SAVE_OPLINE\n");
1650 out($f,"#define OPLINE opline\n");
1651 out($f,"#ifdef ZEND_VM_IP_GLOBAL_REG\n");
1652 … out($f,"# define DCL_OPLINE register const zend_op *opline __asm__(ZEND_VM_IP_GLOBAL_REG);\n");
1653 out($f,"#else\n");
1654 out($f,"# define DCL_OPLINE const zend_op *opline;\n");
1655 out($f,"#endif\n");
1656 out($f,"#define USE_OPLINE\n");
1657 out($f,"#define LOAD_OPLINE() opline = EX(opline)\n");
1658 out($f,"#define LOAD_NEXT_OPLINE() opline = EX(opline) + 1\n");
1659 out($f,"#define SAVE_OPLINE() EX(opline) = opline\n");
1660 out($f,"#undef HANDLE_EXCEPTION\n");
1661 out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
1662 out($f,"#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
1663 out($f,"#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE()\n");
1664 out($f,"#define ZEND_VM_CONTINUE() goto zend_vm_continue\n");
1665 out($f,"#define ZEND_VM_RETURN() return\n");
1666 …out($f,"#define ZEND_VM_ENTER() execute_data = EG(current_execute_data); LOAD_OPLINE(); ZEND_VM…
1667 out($f,"#define ZEND_VM_LEAVE() ZEND_VM_CONTINUE()\n");
1668 …out($f,"#define ZEND_VM_INTERRUPT() goto zend_interrupt_helper".($spec?"_SPEC":"").";…
1669 …out($f,"#define ZEND_VM_LOOP_INTERRUPT() goto zend_interrupt_helper".($spec?"_SPEC":"").";…
1670 …out($f,"#define ZEND_VM_DISPATCH(opcode, opline) dispatch_handler = zend_vm_get_opcode_handler(opc…
1671 out($f,"\n");
1674 out($f,"\n");
1675 out($f,"#undef OPLINE\n");
1676 out($f,"#undef DCL_OPLINE\n");
1677 out($f,"#undef USE_OPLINE\n");
1678 out($f,"#undef LOAD_OPLINE\n");
1679 out($f,"#undef LOAD_NEXT_OPLINE\n");
1680 out($f,"#undef SAVE_OPLINE\n");
1681 out($f,"#define OPLINE opline\n");
1682 out($f,"#ifdef ZEND_VM_IP_GLOBAL_REG\n");
1683 … out($f,"# define DCL_OPLINE register const zend_op *opline __asm__(ZEND_VM_IP_GLOBAL_REG);\n");
1684 out($f,"#else\n");
1685 out($f,"# define DCL_OPLINE const zend_op *opline;\n");
1686 out($f,"#endif\n");
1687 out($f,"#define USE_OPLINE\n");
1688 out($f,"#define LOAD_OPLINE() opline = EX(opline)\n");
1689 out($f,"#define LOAD_NEXT_OPLINE() opline = EX(opline) + 1\n");
1690 out($f,"#define SAVE_OPLINE() EX(opline) = opline\n");
1691 out($f,"#undef HANDLE_EXCEPTION\n");
1692 out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
1694 out($f,"#define HANDLE_EXCEPTION() goto ZEND_HANDLE_EXCEPTION_SPEC_HANDLER\n");
1695 out($f,"#define HANDLE_EXCEPTION_LEAVE() goto ZEND_HANDLE_EXCEPTION_SPEC_HANDLER\n");
1697 out($f,"#define HANDLE_EXCEPTION() goto ZEND_HANDLE_EXCEPTION_HANDLER\n");
1698 out($f,"#define HANDLE_EXCEPTION_LEAVE() goto ZEND_HANDLE_EXCEPTION_HANDLER\n");
1700 out($f,"#define ZEND_VM_CONTINUE() goto *(void**)(OPLINE->handler)\n");
1701 out($f,"#define ZEND_VM_RETURN() return\n");
1702 …out($f,"#define ZEND_VM_ENTER() execute_data = EG(current_execute_data); LOAD_OPLINE(); ZEND_VM…
1703 out($f,"#define ZEND_VM_LEAVE() ZEND_VM_CONTINUE()\n");
1704 …out($f,"#define ZEND_VM_INTERRUPT() goto zend_interrupt_helper".($spec?"_SPEC":"").";…
1705 …out($f,"#define ZEND_VM_LOOP_INTERRUPT() goto zend_interrupt_helper".($spec?"_SPEC":"").";…
1706 …out($f,"#define ZEND_VM_DISPATCH(opcode, opline) goto *(void**)(zend_vm_get_opcode_handler(opcode,…
1707 out($f,"\n");
1712 out($f, $m[1].$executor_name.$m[3]."\n");
1717 out($f,$m[1]."const void *dispatch_handler;\n");
1721 out($f,$m[1].$param.";\n");
1723 out($f,"#ifdef ZEND_VM_FP_GLOBAL_REG\n");
1724 … out($f,$m[1]."register zend_execute_data *execute_data __asm__(ZEND_VM_FP_GLOBAL_REG) = ex;\n");
1725 out($f,"#else\n");
1726 out($f,$m[1]."zend_execute_data *execute_data = ex;\n");
1727 out($f,"#endif\n");
1729 out($f,"#ifdef ZEND_VM_IP_GLOBAL_REG\n");
1730 out($f,$m[1]."const zend_op *orig_opline = opline;\n");
1731 out($f,"#endif\n");
1732 out($f,"#ifdef ZEND_VM_FP_GLOBAL_REG\n");
1733 out($f,$m[1]."zend_execute_data *orig_execute_data = execute_data;\n");
1734 out($f,$m[1]."execute_data = ex;\n");
1735 out($f,"#else\n");
1736 out($f,$m[1]."zend_execute_data *execute_data = ex;\n");
1737 out($f,"#endif\n");
1745 out($f,$prolog."if (UNEXPECTED(execute_data == NULL)) {\n");
1746 out($f,$prolog."\tstatic const void* labels[] = {\n");
1747 gen_labels($f, $spec, $kind, $prolog."\t\t", $specs);
1748 out($f,$prolog."\t};\n");
1749 out($f,$prolog."static const uint32_t specs[] = {\n");
1750 gen_specs($f, $spec, $kind, $prolog."\t", $specs);
1751 out($f,$prolog."};\n");
1752 out($f,$prolog."\tzend_opcode_handlers = (const void **) labels;\n");
1753 out($f,$prolog."\tzend_handlers_count = sizeof(labels) / sizeof(void*);\n");
1754 out($f,$prolog."\tzend_spec_handlers = (const uint32_t *) specs;\n");
1755 out($f,$prolog."\treturn;\n");
1756 out($f,$prolog."}\n");
1758 skip_blanks($f, $m[1], $m[3]);
1764 out($f,"#if !defined(ZEND_VM_FP_GLOBAL_REG) || !defined(ZEND_VM_IP_GLOBAL_REG)\n");
1765 out($f,$m[1]."\tint ret;".$m[3]."\n");
1766 out($f,"#endif\n");
1769 out($f,"zend_vm_continue:".$m[3]."\n");
1771 skip_blanks($f, $m[1], $m[3]);
1778 out($f,"#if defined(ZEND_VM_FP_GLOBAL_REG) && defined(ZEND_VM_IP_GLOBAL_REG)\n");
1779 out($f, $m[1]."((opcode_handler_t)OPLINE->handler)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n");
1780 out($f, $m[1]."if (UNEXPECTED(!OPLINE))".$m[3]."\n");
1781 out($f,"#else\n");
1782 …out($f, $m[1]."if (UNEXPECTED((ret = ((opcode_handler_t)OPLINE->handler)(ZEND_OPCODE_HANDLER_ARGS_…
1783 out($f,"#endif\n");
1786 …out($f, $m[1]."dispatch_handler = OPLINE->handler;\nzend_vm_dispatch:\n".$m[1]."switch ((int)(uint…
1789 out($f, $m[1]."goto *(void**)(OPLINE->handler);".$m[3]."\n");
1796 out($f,
1816 gen_executor_code($f, $spec, $kind, $m[1], $switch_labels);
1821 gen_executor_code($f, $spec, $kind, $m[1]);
1825 out($f, $m[1].$initializer_name.$m[3]."\n");
1833 out($f,$prolog."");
1834 out($f,$prolog.$executor_name."_ex(NULL);\n");
1836 out($f,$prolog."static const void *labels[] = {\n");
1837 gen_labels($f, $spec, $kind, $prolog."\t", $specs, $switch_labels);
1838 out($f,$prolog."};\n");
1839 out($f,$prolog."static const uint32_t specs[] = {\n");
1840 gen_specs($f, $spec, $kind, $prolog."\t", $specs);
1841 out($f,$prolog."};\n");
1842 out($f,$prolog."zend_opcode_handlers = labels;\n");
1843 out($f,$prolog."zend_handlers_count = sizeof(labels) / sizeof(void*);\n");
1844 out($f,$prolog."zend_spec_handlers = specs;\n");
1852 out($f, $line);
2157 …$f = fopen(__DIR__ . "/zend_vm_opcodes.h", "w+") or die("ERROR: Cannot create zend_vm_opcodes.h\n"…
2160 out($f, HEADER_TEXT);
2161 fputs($f, "#ifndef ZEND_VM_OPCODES_H\n#define ZEND_VM_OPCODES_H\n\n");
2162 fputs($f, "#define ZEND_VM_SPEC\t\t" . ZEND_VM_SPEC . "\n");
2163 fputs($f, "#define ZEND_VM_LINES\t\t" . ZEND_VM_LINES . "\n");
2164 fputs($f, "#define ZEND_VM_KIND_CALL\t" . ZEND_VM_KIND_CALL . "\n");
2165 fputs($f, "#define ZEND_VM_KIND_SWITCH\t" . ZEND_VM_KIND_SWITCH . "\n");
2166 fputs($f, "#define ZEND_VM_KIND_GOTO\t" . ZEND_VM_KIND_GOTO . "\n");
2167 fputs($f, "#define ZEND_VM_KIND\t\t" . $GLOBALS["vm_kind_name"][ZEND_VM_KIND] . "\n");
2168 fputs($f, "\n");
2170 fprintf($f, "#define %-24s 0x%08x\n", $name, $val);
2172 fputs($f, "#define ZEND_VM_OP1_FLAGS(flags) (flags & 0xff)\n");
2173 fputs($f, "#define ZEND_VM_OP2_FLAGS(flags) ((flags >> 8) & 0xff)\n");
2174 fputs($f, "\n");
2175 fputs($f, "BEGIN_EXTERN_C()\n\n");
2176 fputs($f, "ZEND_API const char *zend_get_opcode_name(zend_uchar opcode);\n");
2177 fputs($f, "ZEND_API uint32_t zend_get_opcode_flags(zend_uchar opcode);\n\n");
2178 fputs($f, "END_EXTERN_C()\n\n");
2184 fputs($f,"#define $op $code\n");
2190 fputs($f,"\n#define $op $code\n");
2192 fputs($f, "\n#endif\n");
2193 fclose($f);
2197 …$f = fopen(__DIR__ . "/zend_vm_opcodes.c", "w+") or die("ERROR: Cannot create zend_vm_opcodes.c\n"…
2200 out($f, HEADER_TEXT);
2201 fputs($f,"#include <stdio.h>\n");
2202 fputs($f,"#include <zend.h>\n\n");
2204 fputs($f,"static const char *zend_vm_opcodes_names[".($max_opcode + 1)."] = {\n");
2206 fputs($f,"\t".(isset($opcodes[$i]["op"])?'"'.$opcodes[$i]["op"].'"':"NULL").",\n");
2208 fputs($f, "};\n\n");
2210 fputs($f,"static uint32_t zend_vm_opcodes_flags[".($max_opcode + 1)."] = {\n");
2212 fprintf($f, "\t0x%08x,\n", isset($opcodes[$i]["flags"]) ? $opcodes[$i]["flags"] : 0);
2214 fputs($f, "};\n\n");
2216 fputs($f, "ZEND_API const char* zend_get_opcode_name(zend_uchar opcode) {\n");
2217 fputs($f, "\treturn zend_vm_opcodes_names[opcode];\n");
2218 fputs($f, "}\n");
2220 fputs($f, "ZEND_API uint32_t zend_get_opcode_flags(zend_uchar opcode) {\n");
2221 fputs($f, "\treturn zend_vm_opcodes_flags[opcode];\n");
2222 fputs($f, "}\n");
2224 fclose($f);
2228 …$f = fopen(__DIR__ . "/zend_vm_execute.h", "w+") or die("ERROR: Cannot create zend_vm_execute.h\n"…
2232 out($f, HEADER_TEXT);
2234 out($f, "#ifdef ZEND_WIN32\n");
2236 out($f, "# pragma warning(once : 4101)\n");
2239 out($f, "# pragma warning(once : 6235)\n");
2241 out($f, "# pragma warning(once : 6237)\n");
2243 out($f, "# pragma warning(once : 6239)\n");
2245 out($f, "# pragma warning(once : 6240)\n");
2247 out($f, "# pragma warning(once : 6285)\n");
2249 out($f, "# pragma warning(once : 6286)\n");
2251 out($f, "# pragma warning(once : 6326)\n");
2253 out($f, "#endif\n");
2256 out($f, "static user_opcode_handler_t zend_user_opcode_handlers[256] = {\n");
2258 out($f, "\t(user_opcode_handler_t)NULL,\n");
2260 out($f, "\t(user_opcode_handler_t)NULL\n};\n\n");
2262 out($f, "static zend_uchar zend_user_opcodes[256] = {");
2264 if ($i % 16 == 1) out($f, "\n\t");
2265 out($f, "$i,");
2267 out($f, "255\n};\n\n");
2270 gen_executor($f, $skl, ZEND_VM_SPEC, ZEND_VM_KIND, "execute", "zend_init_opcodes_handlers");
2273 out($f, "static const void *zend_vm_get_opcode_handler_ex(uint32_t spec, const zend_op* op)\n");
2274 out($f, "{\n");
2276 out($f, "\treturn zend_opcode_handlers[spec];\n");
2278 out($f, "\tstatic const int zend_vm_decode[] = {\n");
2279 out($f, "\t\t_UNUSED_CODE, /* 0 */\n");
2280 out($f, "\t\t_CONST_CODE, /* 1 = IS_CONST */\n");
2281 out($f, "\t\t_TMP_CODE, /* 2 = IS_TMP_VAR */\n");
2282 out($f, "\t\t_UNUSED_CODE, /* 3 */\n");
2283 out($f, "\t\t_VAR_CODE, /* 4 = IS_VAR */\n");
2284 out($f, "\t\t_UNUSED_CODE, /* 5 */\n");
2285 out($f, "\t\t_UNUSED_CODE, /* 6 */\n");
2286 out($f, "\t\t_UNUSED_CODE, /* 7 */\n");
2287 out($f, "\t\t_UNUSED_CODE, /* 8 = IS_UNUSED */\n");
2288 out($f, "\t\t_UNUSED_CODE, /* 9 */\n");
2289 out($f, "\t\t_UNUSED_CODE, /* 10 */\n");
2290 out($f, "\t\t_UNUSED_CODE, /* 11 */\n");
2291 out($f, "\t\t_UNUSED_CODE, /* 12 */\n");
2292 out($f, "\t\t_UNUSED_CODE, /* 13 */\n");
2293 out($f, "\t\t_UNUSED_CODE, /* 14 */\n");
2294 out($f, "\t\t_UNUSED_CODE, /* 15 */\n");
2295 out($f, "\t\t_CV_CODE /* 16 = IS_CV */\n");
2296 out($f, "\t};\n");
2297 out($f, "\tuint32_t offset = 0;\n");
2298 out($f, "\tif (spec & SPEC_RULE_OP1) offset = offset * 5 + zend_vm_decode[op->op1_type];\n");
2299 out($f, "\tif (spec & SPEC_RULE_OP2) offset = offset * 5 + zend_vm_decode[op->op2_type];\n");
2301 …out($f, "\tif (spec & SPEC_RULE_OP_DATA) offset = offset * 5 + zend_vm_decode[(op + 1)->op1_type];…
2304 … out($f, "\tif (spec & SPEC_RULE_RETVAL) offset = offset * 2 + (op->result_type != IS_UNUSED);\n");
2307 …out($f, "\tif (spec & SPEC_RULE_QUICK_ARG) offset = offset * 2 + (op->op2.num < MAX_ARG_FLAG_NUM);…
2310 out($f, "\tif (spec & SPEC_RULE_SMART_BRANCH) {\n");
2311 out($f, "\t\toffset = offset * 3;\n");
2312 out($f, "\t\tif ((op+1)->opcode == ZEND_JMPZ) {\n");
2313 out($f, "\t\t\toffset += 1;\n");
2314 out($f, "\t\t} else if ((op+1)->opcode == ZEND_JMPNZ) {\n");
2315 out($f, "\t\t\toffset += 2;\n");
2316 out($f, "\t\t}\n");
2317 out($f, "\t}\n");
2320 out($f, "\tif (spec & SPEC_RULE_DIM_OBJ) {\n");
2321 out($f, "\t\toffset = offset * 3;\n");
2322 out($f, "\t\tif (op->extended_value == ZEND_ASSIGN_DIM) {\n");
2323 out($f, "\t\t\toffset += 1;\n");
2324 out($f, "\t\t} else if (op->extended_value == ZEND_ASSIGN_OBJ) {\n");
2325 out($f, "\t\t\toffset += 2;\n");
2326 out($f, "\t\t}\n");
2327 out($f, "\t}\n");
2329 out($f, "\treturn zend_opcode_handlers[(spec & SPEC_START_MASK) + offset];\n");
2331 out($f, "}\n\n");
2332 out($f, "static const void *zend_vm_get_opcode_handler(zend_uchar opcode, const zend_op* op)\n");
2333 out($f, "{\n");
2335 out($f, "\treturn zend_vm_get_opcode_handler_ex(opcode, op);\n");
2337 out($f, "\treturn zend_vm_get_opcode_handler_ex(zend_spec_handlers[opcode], op);\n");
2339 out($f, "}\n\n");
2342 out($f, "ZEND_API void zend_vm_set_opcode_handler(zend_op* op)\n");
2343 out($f, "{\n");
2344 out($f, "\top->handler = zend_vm_get_opcode_handler(zend_user_opcodes[op->opcode], op);\n");
2345 out($f, "}\n\n");
2348 …out($f, "ZEND_API void zend_vm_set_opcode_handler_ex(zend_op* op, uint32_t op1_info, uint32_t op2_…
2349 out($f, "{\n");
2350 out($f, "\tzend_uchar opcode = zend_user_opcodes[op->opcode];\n");
2352 out($f, "\top->handler = zend_vm_get_opcode_handler_ex(opcode, op);\n");
2354 out($f, "\tuint32_t spec = zend_spec_handlers[opcode];\n");
2356 out($f, "\tswitch (opcode) {\n");
2360 out($f, "\t\tcase $orig_op:\n");
2365 out($f, "\t\t\tif $condition {\n");
2368 out($f, "\t\t\t} else if $condition {\n");
2372 out($f, "\t\t\t\tif (op->op1_type == IS_CONST && op->op2_type == IS_CONST) {\n");
2373 out($f, "\t\t\t\t\tbreak;\n");
2374 out($f, "\t\t\t\t}\n");
2376 out($f, "\t\t\t\tspec = ${spec_dsc['spec_code']};\n");
2378 out($f, "\t\t\t\tif (op->op1_type > op->op2_type) {\n");
2379 out($f, "\t\t\t\t\tzend_swap_operands(op);\n");
2380 out($f, "\t\t\t\t}\n");
2384 out($f, "\t\t\t}\n");
2386 out($f, "\t\t\tbreak;\n");
2389 out($f, "\t\tdefault:\n");
2390 out($f, "\t\t\tbreak;\n");
2391 out($f, "\t}\n");
2393 out($f, "\top->handler = zend_vm_get_opcode_handler_ex(spec, op);\n");
2395 out($f, "}\n\n");
2399 out($f, "ZEND_API int zend_vm_call_opcode_handler(zend_execute_data* ex)\n");
2400 out($f, "{\n");
2401 out($f, "\tint ret;\n");
2402 out($f, "#ifdef ZEND_VM_IP_GLOBAL_REG\n");
2403 out($f, "\tconst zend_op *orig_opline = opline;\n");
2404 out($f, "#endif\n");
2405 out($f, "#ifdef ZEND_VM_FP_GLOBAL_REG\n");
2406 out($f, "\tzend_execute_data *orig_execute_data = execute_data;\n");
2407 out($f, "\texecute_data = ex;\n");
2408 out($f, "#else\n");
2409 out($f, "\tzend_execute_data *execute_data = ex;\n");
2410 out($f, "#endif\n");
2411 out($f, "\n");
2412 out($f, "\tLOAD_OPLINE();\n");
2413 out($f,"#if defined(ZEND_VM_FP_GLOBAL_REG) && defined(ZEND_VM_IP_GLOBAL_REG)\n");
2414 out($f, "\t((opcode_handler_t)OPLINE->handler)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n");
2415 out($f, "\tif (EXPECTED(opline)) {\n");
2416 out($f, "\t\tret = execute_data != ex ? (int)(execute_data->prev_execute_data != ex) + 1 : 0;\n");
2417 out($f, "\t\tSAVE_OPLINE();\n");
2418 out($f, "\t} else {\n");
2419 out($f, "\t\tret = -1;\n");
2420 out($f, "\t}\n");
2421 out($f, "#else\n");
2422 out($f, "\tret = ((opcode_handler_t)OPLINE->handler)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n");
2423 out($f, "\tSAVE_OPLINE();\n");
2424 out($f, "#endif\n");
2425 out($f, "#ifdef ZEND_VM_FP_GLOBAL_REG\n");
2426 out($f, "\texecute_data = orig_execute_data;\n");
2427 out($f, "#endif\n");
2428 out($f, "#ifdef ZEND_VM_IP_GLOBAL_REG\n");
2429 out($f, "\topline = orig_opline;\n");
2430 out($f, "#endif\n");
2431 out($f, "\treturn ret;\n");
2432 out($f, "}\n\n");
2434 out($f, "ZEND_API int zend_vm_call_opcode_handler(zend_execute_data* ex)\n");
2435 out($f, "{\n");
2436 …out($f, "\tzend_error_noreturn(E_CORE_ERROR, \"zend_vm_call_opcode_handler() is not supported\");\…
2437 out($f, "\treturn 0;\n");
2438 out($f, "}\n\n");
2444 out($f,"#undef OPLINE\n");
2445 out($f,"#undef DCL_OPLINE\n");
2446 out($f,"#undef USE_OPLINE\n");
2447 out($f,"#undef LOAD_OPLINE\n");
2448 out($f,"#undef LOAD_NEXT_OPLINE\n");
2449 out($f,"#undef SAVE_OPLINE\n");
2450 out($f,"#define OPLINE EX(opline)\n");
2451 out($f,"#define DCL_OPLINE\n");
2452 out($f,"#define USE_OPLINE const zend_op *opline = EX(opline);\n");
2453 out($f,"#define LOAD_OPLINE()\n");
2454 out($f,"#define LOAD_NEXT_OPLINE() ZEND_VM_INC_OPCODE()\n");
2455 out($f,"#define SAVE_OPLINE()\n");
2456 out($f,"#undef HANDLE_EXCEPTION\n");
2457 out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
2458 out($f,"#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
2459 out($f,"#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE()\n");
2460 out($f,"#undef ZEND_VM_CONTINUE\n");
2461 out($f,"#undef ZEND_VM_RETURN\n");
2462 out($f,"#undef ZEND_VM_ENTER\n");
2463 out($f,"#undef ZEND_VM_LEAVE\n");
2464 out($f,"#undef ZEND_VM_DISPATCH\n");
2465 out($f,"#define ZEND_VM_CONTINUE() return 0\n");
2466 out($f,"#define ZEND_VM_RETURN() return -1\n");
2467 out($f,"#define ZEND_VM_ENTER() return 1\n");
2468 out($f,"#define ZEND_VM_LEAVE() return 2\n");
2469 …out($f,"#define ZEND_VM_INTERRUPT() return zend_interrupt_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHR…
2470 …out($f,"#define ZEND_VM_DISPATCH(opcode, opline) return zend_vm_get_opcode_handler(opcode, opline)…
2471 out($f,"\n");
2475 out($f, "ZEND_API int $func(");
2477 out($f, "ZEND_OPCODE_HANDLER_ARGS)\n");
2482 out($f, "ZEND_OPCODE_HANDLER_ARGS)\n");
2484 out($f, $h['param']. " ZEND_OPCODE_HANDLER_ARGS_DC)\n");
2493 …out($f, "{\n\treturn ".$name.(ZEND_VM_SPEC?"_SPEC":"")."_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU…
2499 …out($f, "{\n\treturn ".$name.(ZEND_VM_SPEC?"_SPEC":"")."(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\…
2505 gen_code($f, 0, ZEND_VM_KIND_CALL, 1, $code, 'ANY', 'ANY', $name);
2509 fclose($f);