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
5 changes: 4 additions & 1 deletion .github/actions/apk/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ runs:
run: |
set -x

OPCACHE_TLS_TESTS_DEPS="clang gcc binutils-gold lld"

apk update -q
apk add \
util-linux \
Expand Down Expand Up @@ -53,4 +55,5 @@ runs:
postgresql14-dev \
tzdata \
musl-locales \
musl-locales-lang
musl-locales-lang \
$OPCACHE_TLS_TESTS_DEPS
5 changes: 4 additions & 1 deletion .github/actions/apt-x32/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ runs:
run: |
set -x

OPCACHE_TLS_TESTS_DEPS="gcc clang lld"

export DEBIAN_FRONTEND=noninteractive
dpkg --add-architecture i386
apt-get update -y | true
Expand Down Expand Up @@ -44,4 +46,5 @@ runs:
re2c \
unzip \
wget \
zlib1g-dev:i386
zlib1g-dev:i386 \
$OPCACHE_TLS_TESTS_DEPS
5 changes: 4 additions & 1 deletion .github/actions/apt-x64/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ runs:
run: |
set -x

OPCACHE_TLS_TESTS_DEPS="gcc clang lld"

export DEBIAN_FRONTEND=noninteractive

# Install sudo in Docker for consistent actions
Expand Down Expand Up @@ -74,4 +76,5 @@ runs:
libqdbm-dev \
libjpeg-dev \
libpng-dev \
libfreetype6-dev
libfreetype6-dev \
$OPCACHE_TLS_TESTS_DEPS
7 changes: 7 additions & 0 deletions .github/actions/extra-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: Extra tests
runs:
using: composite
steps:
- shell: sh
run: |
sapi/cli/php run-extra-tests.php
13 changes: 12 additions & 1 deletion .github/actions/freebsd/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ inputs:
configurationParameters:
default: ''
required: false
runExtraTests:
default: false
required: false
runs:
using: composite
steps:
Expand All @@ -17,6 +20,8 @@ runs:
prepare: |
cd $GITHUB_WORKSPACE

OPCACHE_TLS_TESTS_DEPS="gcc"

kldload accf_http
pkg install -y \
autoconf \
Expand All @@ -41,9 +46,11 @@ runs:
webp \
libavif \
`#sqlite3` \
curl
curl \
$OPCACHE_TLS_TESTS_DEPS

./buildconf -f
CC=clang CXX=clang++ \
./configure \
--prefix=/usr/local \
--enable-debug \
Expand Down Expand Up @@ -108,3 +115,7 @@ runs:
--show-slow 1000 \
--set-timeout 120 \
-d zend_extension=opcache.so

if test "${{ inputs.runExtraTests }}" = "true"; then
sapi/cli/php run-extra-tests.php
fi
11 changes: 11 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ jobs:
with:
runTestsParameters: >-
--asan -x
- name: Extra tests
uses: ./.github/actions/extra-tests
ALPINE:
if: inputs.run_alpine
name: ALPINE_X64_ASAN_UBSAN_DEBUG_ZTS
Expand Down Expand Up @@ -134,6 +136,8 @@ jobs:
--asan -x
-d zend_extension=opcache.so
-d opcache.enable_cli=1
- name: Extra tests
uses: ./.github/actions/extra-tests
- name: Notify Slack
if: failure()
uses: ./.github/actions/notify-slack
Expand Down Expand Up @@ -266,6 +270,8 @@ jobs:
${{ matrix.run_tests_parameters }}
-d zend_extension=opcache.so
-d opcache.enable_cli=1
- name: Extra tests
uses: ./.github/actions/extra-tests
- name: Verify generated files are up to date
uses: ./.github/actions/verify-generated-files
- name: Notify Slack
Expand Down Expand Up @@ -355,6 +361,8 @@ jobs:
${{ matrix.run_tests_parameters }}
-d zend_extension=opcache.so
-d opcache.enable_cli=1
- name: Extra tests
uses: ./.github/actions/extra-tests
- name: Notify Slack
if: failure()
uses: ./.github/actions/notify-slack
Expand Down Expand Up @@ -414,6 +422,8 @@ jobs:
runTestsParameters: >-
-d zend_extension=opcache.so
-d opcache.enable_cli=1
- name: Extra tests
uses: ./.github/actions/extra-tests
- name: Verify generated files are up to date
uses: ./.github/actions/verify-generated-files
- name: Notify Slack
Expand Down Expand Up @@ -1076,3 +1086,4 @@ jobs:
with:
configurationParameters: >-
--${{ matrix.zts && 'enable' || 'disable' }}-zts
runExtraTests: true
3 changes: 2 additions & 1 deletion Zend/zend_compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "zend_types.h"
#include "zend_map_ptr.h"
#include "zend_alloc.h"
#include "zend_vm_opcodes.h"

#include <stdarg.h>
#include <stdint.h>
Expand Down Expand Up @@ -135,7 +136,7 @@ void zend_const_expr_to_zval(zval *result, zend_ast **ast_ptr, bool allow_dynami
typedef int (*user_opcode_handler_t) (zend_execute_data *execute_data);

struct _zend_op {
const void *handler;
zend_vm_opcode_handler_t handler;
znode_op op1;
znode_op op2;
znode_op result;
Expand Down
22 changes: 13 additions & 9 deletions Zend/zend_vm_execute.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Zend/zend_vm_execute.skl
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ ZEND_API void ZEND_FASTCALL zend_serialize_opcode_handler(zend_op *op)
}
zv = zend_hash_index_find(zend_handlers_table, (zend_long)(uintptr_t)op->handler);
ZEND_ASSERT(zv != NULL);
op->handler = (const void *)(uintptr_t)Z_LVAL_P(zv);
op->handler = (zend_vm_opcode_handler_t)(uintptr_t)Z_LVAL_P(zv);
}

ZEND_API void ZEND_FASTCALL zend_deserialize_opcode_handler(zend_op *op)
Expand Down
48 changes: 33 additions & 15 deletions Zend/zend_vm_gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ function gen_null_label($f, $kind, $prolog) {
out($f,$prolog."ZEND_NULL_HANDLER,\n");
break;
case ZEND_VM_KIND_SWITCH:
out($f,$prolog."(void*)(uintptr_t)-1,\n");
out($f,$prolog."-1,\n");
break;
case ZEND_VM_KIND_GOTO:
out($f,$prolog."(void*)&&ZEND_NULL_LABEL,\n");
Expand Down Expand Up @@ -1388,7 +1388,7 @@ function gen_labels($f, $spec, $kind, $prolog, &$specs, $switch_labels = array()
out($f,"$prolog{$spec_name}_HANDLER,\n");
break;
case ZEND_VM_KIND_SWITCH:
out($f,$prolog."(void*)(uintptr_t)$switch_labels[$spec_name],\n");
out($f,$prolog."$switch_labels[$spec_name],\n");
break;
case ZEND_VM_KIND_GOTO:
out($f,$prolog."(void*)&&{$spec_name}_LABEL,\n");
Expand Down Expand Up @@ -1436,7 +1436,7 @@ function gen_labels($f, $spec, $kind, $prolog, &$specs, $switch_labels = array()
out($f,$prolog."ZEND_NULL_HANDLER,\n");
break;
case ZEND_VM_KIND_SWITCH:
out($f,$prolog."(void*)(uintptr_t)-1,\n");
out($f,$prolog."-1,\n");
break;
case ZEND_VM_KIND_GOTO:
out($f,$prolog."(void*)&&ZEND_NULL_LABEL,\n");
Expand Down Expand Up @@ -1467,7 +1467,7 @@ function gen_labels($f, $spec, $kind, $prolog, &$specs, $switch_labels = array()
out($f,$prolog.$dsc["op"]."_HANDLER,\n");
break;
case ZEND_VM_KIND_SWITCH:
out($f,$prolog."(void*)(uintptr_t)".((string)$num).",\n");
out($f,$prolog.((string)$num).",\n");
break;
case ZEND_VM_KIND_GOTO:
out($f,$prolog."(void*)&&".$dsc["op"]."_LABEL,\n");
Expand All @@ -1480,7 +1480,7 @@ function gen_labels($f, $spec, $kind, $prolog, &$specs, $switch_labels = array()
out($f,$prolog."ZEND_NULL_HANDLER,\n");
break;
case ZEND_VM_KIND_SWITCH:
out($f,$prolog."(void*)(uintptr_t)-1,\n");
out($f,$prolog."-1,\n");
break;
case ZEND_VM_KIND_GOTO:
out($f,$prolog."(void*)&&ZEND_NULL_LABEL,\n");
Expand All @@ -1497,7 +1497,7 @@ function gen_labels($f, $spec, $kind, $prolog, &$specs, $switch_labels = array()
out($f,$prolog."ZEND_NULL_HANDLER\n");
break;
case ZEND_VM_KIND_SWITCH:
out($f,$prolog."(void*)(uintptr_t)-1\n");
out($f,$prolog."-1\n");
break;
case ZEND_VM_KIND_GOTO:
out($f,$prolog."(void*)&&ZEND_NULL_LABEL\n");
Expand Down Expand Up @@ -1813,16 +1813,16 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
out($f,"#define SPEC_RULE_OBSERVER 0x02000000\n");
out($f,"\n");
out($f,"static const uint32_t *zend_spec_handlers;\n");
out($f,"static const void * const *zend_opcode_handlers;\n");
out($f,"static zend_vm_opcode_handler_t const *zend_opcode_handlers;\n");
out($f,"static int zend_handlers_count;\n");
if ($kind == ZEND_VM_KIND_HYBRID) {
out($f,"#if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID)\n");
out($f,"static const void * const * zend_opcode_handler_funcs;\n");
out($f,"static zend_vm_opcode_handler_func_t const * zend_opcode_handler_funcs;\n");
out($f,"static zend_op hybrid_halt_op;\n");
out($f,"#endif\n");
}
out($f,"#if (ZEND_VM_KIND != ZEND_VM_KIND_HYBRID) || !ZEND_VM_SPEC\n");
out($f,"static const void *zend_vm_get_opcode_handler(uint8_t opcode, const zend_op* op);\n");
out($f,"static zend_vm_opcode_handler_t zend_vm_get_opcode_handler(uint8_t opcode, const zend_op* op);\n");
out($f,"#endif\n\n");
if ($kind == ZEND_VM_KIND_HYBRID) {
out($f,"#if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID)\n");
Expand Down Expand Up @@ -2040,7 +2040,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
break;
case "HELPER_VARS":
if ($kind == ZEND_VM_KIND_SWITCH) {
out($f,$m[1]."const void *dispatch_handler;\n");
out($f,$m[1]."zend_vm_opcode_handler_t dispatch_handler;\n");
}
if ($kind != ZEND_VM_KIND_CALL && count($params)) {
if ($kind == ZEND_VM_KIND_HYBRID) {
Expand Down Expand Up @@ -2097,8 +2097,8 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
out($f,$prolog."\tstatic const void * const labels[] = {\n");
gen_labels($f, $spec, ($kind == ZEND_VM_KIND_HYBRID) ? ZEND_VM_KIND_GOTO : $kind, $prolog."\t\t", $specs);
out($f,$prolog."\t};\n");
out($f,$prolog."\tzend_opcode_handlers = (const void **) labels;\n");
out($f,$prolog."\tzend_handlers_count = sizeof(labels) / sizeof(void*);\n");
out($f,$prolog."\tzend_opcode_handlers = (zend_vm_opcode_handler_t*) labels;\n");
out($f,$prolog."\tzend_handlers_count = sizeof(labels) / sizeof(labels[0]);\n");
if ($kind == ZEND_VM_KIND_HYBRID) {
out($f,$prolog."\tmemset(&hybrid_halt_op, 0, sizeof(hybrid_halt_op));\n");
out($f,$prolog."\thybrid_halt_op.handler = (void*)&&HYBRID_HALT_LABEL;\n");
Expand Down Expand Up @@ -2212,7 +2212,11 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
out($f,$prolog."zend_spec_handlers = specs;\n");
out($f,$prolog.$executor_name."_ex(NULL);\n");
} else {
out($f,$prolog."static const void * const labels[] = {\n");
out($f,"#if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID)\n");
out($f,$prolog."static zend_vm_opcode_handler_func_t const labels[] = {\n");
out($f,"#else\n");
out($f,$prolog."static zend_vm_opcode_handler_t const labels[] = {\n");
out($f,"#endif\n");
gen_labels($f, $spec, ($kind == ZEND_VM_KIND_HYBRID) ? ZEND_VM_KIND_CALL : $kind, $prolog."\t", $specs, $switch_labels);
out($f,$prolog."};\n");
out($f,$prolog."static const uint32_t specs[] = {\n");
Expand All @@ -2226,7 +2230,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
out($f,"#else\n");
}
out($f,$prolog."zend_opcode_handlers = labels;\n");
out($f,$prolog."zend_handlers_count = sizeof(labels) / sizeof(void*);\n");
out($f,$prolog."zend_handlers_count = sizeof(labels) / sizeof(labels[0]);\n");
out($f,$prolog."zend_spec_handlers = specs;\n");
if ($kind == ZEND_VM_KIND_HYBRID) {
out($f,"#endif\n");
Expand Down Expand Up @@ -2359,6 +2363,20 @@ function gen_vm_opcodes_header(
$str .= "# endif\n";
$str .= "#endif\n";
$str .= "\n";
$str .= "#if ZEND_VM_KIND == ZEND_VM_KIND_HYBRID\n";
$str .= "typedef const void* zend_vm_opcode_handler_t;\n";
$str .= "typedef void (ZEND_FASTCALL *zend_vm_opcode_handler_func_t)(void);\n";
$str .= "#elif ZEND_VM_KIND == ZEND_VM_KIND_CALL\n";
$str .= "typedef const struct _zend_op *(ZEND_FASTCALL *zend_vm_opcode_handler_t)(struct _zend_execute_data *execute_data, const struct _zend_op *opline);\n";
$str .= "typedef const struct _zend_op *(ZEND_FASTCALL *zend_vm_opcode_handler_func_t)(struct _zend_execute_data *execute_data, const struct _zend_op *opline);\n";
$str .= "#elif ZEND_VM_KIND == ZEND_VM_KIND_SWITCH\n";
$str .= "typedef int zend_vm_opcode_handler_t;\n";
$str .= "#elif ZEND_VM_KIND == ZEND_VM_KIND_GOTO\n";
$str .= "typedef const void* zend_vm_opcode_handler_t;\n";
$str .= "#else\n";
$str .= "# error\n";
$str .= "#endif\n";
$str .= "\n";
foreach ($vm_op_flags as $name => $val) {
$str .= sprintf("#define %-24s 0x%08x\n", $name, $val);
}
Expand Down Expand Up @@ -2840,7 +2858,7 @@ function gen_vm($def, $skel) {
}
out($f, "}\n\n");
out($f, "#if (ZEND_VM_KIND != ZEND_VM_KIND_HYBRID) || !ZEND_VM_SPEC\n");
out($f, "static const void *zend_vm_get_opcode_handler(uint8_t opcode, const zend_op* op)\n");
out($f, "static zend_vm_opcode_handler_t zend_vm_get_opcode_handler(uint8_t opcode, const zend_op* op)\n");
out($f, "{\n");
if (!ZEND_VM_SPEC) {
out($f, "\treturn zend_opcode_handlers[zend_vm_get_opcode_handler_idx(opcode, op)];\n");
Expand Down
Loading