Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ on:
skip_wordpress:
required: true
type: boolean
variation_enable_zend_max_execution_timers:
required: true
type: boolean
permissions:
contents: read
jobs:
Expand Down Expand Up @@ -198,6 +201,7 @@ jobs:
zts: true
configuration_parameters: >-
CFLAGS="-DZEND_RC_DEBUG=1 -DPROFITABILITY_CHECKS=0 -DZEND_VERIFY_FUNC_INFO=1 -DZEND_VERIFY_TYPE_INFERENCE"
${{ inputs.variation_enable_zend_max_execution_timers && '--enable-zend-max-execution-timers' || '' }}
run_tests_parameters: -d zend_test.observer.enabled=1 -d zend_test.observer.show_output=0
timeout_minutes: 360
test_function_jit: true
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/root.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ jobs:
skip_laravel: ${{ matrix.branch.version[0] == 8 && matrix.branch.version[1] == 1 }}
skip_symfony: ${{ matrix.branch.version[0] == 8 && matrix.branch.version[1] == 1 }}
skip_wordpress: ${{ matrix.branch.version[0] == 8 && matrix.branch.version[1] == 1 }}
variation_enable_zend_max_execution_timers: ${{ (matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 3) || matrix.branch.version[0] >= 9 }}
secrets: inherit
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ PHP NEWS
. Fixed bug GH-19765 (object_properties_load() bypasses readonly property
checks). (timwolla)
. The __sleep() and __wakeup() magic methods have been deprecated. (Girgias)
. Fixed hard_timeout with --enable-zend-max-execution-timers. (Appla)

- Opcache:
. Fixed bug GH-19669 (assertion failure in zend_jit_trace_type_to_info_ex).
Expand Down
8 changes: 6 additions & 2 deletions Zend/zend_execute_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,9 @@ static void zend_set_timeout_ex(zend_long seconds, bool reset_signals) /* {{{ */
return;
}
#elif defined(ZEND_MAX_EXECUTION_TIMERS)
zend_max_execution_timer_settime(seconds);
if (seconds > 0) {
zend_max_execution_timer_settime(seconds);
}

if (reset_signals) {
sigset_t sigset;
Expand Down Expand Up @@ -1667,7 +1669,9 @@ void zend_unset_timeout(void) /* {{{ */
tq_timer = NULL;
}
#elif defined(ZEND_MAX_EXECUTION_TIMERS)
zend_max_execution_timer_settime(0);
if (EG(timeout_seconds)) {
zend_max_execution_timer_settime(0);
}
#elif defined(HAVE_SETITIMER)
if (EG(timeout_seconds)) {
struct itimerval no_timeout;
Expand Down
86 changes: 45 additions & 41 deletions Zend/zend_vm_gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -545,24 +545,28 @@
$helpers = array(); // opcode helpers by name
$params = array(); // parameters of helpers
$opnames = array(); // opcode name to code mapping
$line_no = 1;
$line_nos = [];

$used_extra_spec = array();

// Writes $s into resulting executor
function out($f, $s) {
global $line_no;
global $line_nos;

fputs($f,$s);
$line_no += substr_count($s, "\n");

$line_nos[(int)$f] ??= 1;
$line_nos[(int)$f] += substr_count($s, "\n");
}

// Resets #line directives in resulting executor
function out_line($f) {
global $line_no, $executor_file;
global $line_nos, $executor_file;

$line_nos[(int)$f] ??= 1;
$line_nos[(int)$f]++;

fputs($f,"#line ".($line_no+1)." \"".$executor_file."\"\n");
++$line_no;
fputs($f,"#line ".$line_nos[(int)$f]." \"".$executor_file."\"\n");
}

function is_hot_helper($name) {
Expand Down Expand Up @@ -2839,46 +2843,46 @@ function gen_vm($def, $skel) {

// Insert header
out($f, HEADER_TEXT);
fputs($f,"#include <stdio.h>\n");
fputs($f,"#include <zend.h>\n");
fputs($f,"#include <zend_vm_opcodes.h>\n\n");
out($f,"#include <stdio.h>\n");
out($f,"#include <zend.h>\n");
out($f,"#include <zend_vm_opcodes.h>\n\n");

fputs($f,"static const char *zend_vm_opcodes_names[".($max_opcode + 1)."] = {\n");
out($f,"static const char *zend_vm_opcodes_names[".($max_opcode + 1)."] = {\n");
for ($i = 0; $i <= $max_opcode; $i++) {
fputs($f,"\t".(isset($opcodes[$i]["op"])?'"'.$opcodes[$i]["op"].'"':"NULL").",\n");
out($f,"\t".(isset($opcodes[$i]["op"])?'"'.$opcodes[$i]["op"].'"':"NULL").",\n");
}
fputs($f, "};\n\n");
out($f, "};\n\n");

fputs($f,"static uint32_t zend_vm_opcodes_flags[".($max_opcode + 1)."] = {\n");
out($f,"static uint32_t zend_vm_opcodes_flags[".($max_opcode + 1)."] = {\n");
for ($i = 0; $i <= $max_opcode; $i++) {
fprintf($f, "\t0x%08x,\n", isset($opcodes[$i]["flags"]) ? $opcodes[$i]["flags"] : 0);
}
fputs($f, "};\n\n");

fputs($f, "ZEND_API const char* ZEND_FASTCALL zend_get_opcode_name(uint8_t opcode) {\n");
fputs($f, "\tif (UNEXPECTED(opcode > ZEND_VM_LAST_OPCODE)) {\n");
fputs($f, "\t\treturn NULL;\n");
fputs($f, "\t}\n");
fputs($f, "\treturn zend_vm_opcodes_names[opcode];\n");
fputs($f, "}\n");

fputs($f, "ZEND_API uint32_t ZEND_FASTCALL zend_get_opcode_flags(uint8_t opcode) {\n");
fputs($f, "\tif (UNEXPECTED(opcode > ZEND_VM_LAST_OPCODE)) {\n");
fputs($f, "\t\topcode = ZEND_NOP;\n");
fputs($f, "\t}\n");
fputs($f, "\treturn zend_vm_opcodes_flags[opcode];\n");
fputs($f, "}\n");

fputs($f, "ZEND_API uint8_t zend_get_opcode_id(const char *name, size_t length) {\n");
fputs($f, "\tuint8_t opcode;\n");
fputs($f, "\tfor (opcode = 0; opcode < (sizeof(zend_vm_opcodes_names) / sizeof(zend_vm_opcodes_names[0])) - 1; opcode++) {\n");
fputs($f, "\t\tconst char *opcode_name = zend_vm_opcodes_names[opcode];\n");
fputs($f, "\t\tif (opcode_name && strncmp(opcode_name, name, length) == 0) {\n");
fputs($f, "\t\t\treturn opcode;\n");
fputs($f, "\t\t}\n");
fputs($f, "\t}\n");
fputs($f, "\treturn ZEND_VM_LAST_OPCODE + 1;\n");
fputs($f, "}\n");
out($f, sprintf("\t0x%08x,\n", isset($opcodes[$i]["flags"]) ? $opcodes[$i]["flags"] : 0));
}
out($f, "};\n\n");

out($f, "ZEND_API const char* ZEND_FASTCALL zend_get_opcode_name(uint8_t opcode) {\n");
out($f, "\tif (UNEXPECTED(opcode > ZEND_VM_LAST_OPCODE)) {\n");
out($f, "\t\treturn NULL;\n");
out($f, "\t}\n");
out($f, "\treturn zend_vm_opcodes_names[opcode];\n");
out($f, "}\n");

out($f, "ZEND_API uint32_t ZEND_FASTCALL zend_get_opcode_flags(uint8_t opcode) {\n");
out($f, "\tif (UNEXPECTED(opcode > ZEND_VM_LAST_OPCODE)) {\n");
out($f, "\t\topcode = ZEND_NOP;\n");
out($f, "\t}\n");
out($f, "\treturn zend_vm_opcodes_flags[opcode];\n");
out($f, "}\n");

out($f, "ZEND_API uint8_t zend_get_opcode_id(const char *name, size_t length) {\n");
out($f, "\tuint8_t opcode;\n");
out($f, "\tfor (opcode = 0; opcode < (sizeof(zend_vm_opcodes_names) / sizeof(zend_vm_opcodes_names[0])) - 1; opcode++) {\n");
out($f, "\t\tconst char *opcode_name = zend_vm_opcodes_names[opcode];\n");
out($f, "\t\tif (opcode_name && strncmp(opcode_name, name, length) == 0) {\n");
out($f, "\t\t\treturn opcode;\n");
out($f, "\t\t}\n");
out($f, "\t}\n");
out($f, "\treturn ZEND_VM_LAST_OPCODE + 1;\n");
out($f, "}\n");

fclose($f);
echo "zend_vm_opcodes.c generated successfully.\n";
Expand Down
Loading