[php-src] master: Mark several functions with `@compile-time-eval` attribute. (#24212)
| From: | Alexander Danilov via GitHub | Date: | Fri, 09 Oct 2026 21:32:31 +0000 |
| Subject: | [php-src] master: Mark several functions with `@compile-time-eval` attribute. (#24212) | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-142140@lists.php.net to get a copy of this message | ||
Author: Alexander Danilov (adapik)
Committer: GitHub (web-flow)
Pusher: ndossche
Date: 2026-10-09T23:32:28+02:00
Commit: https://github.com/php/php-src/commit/4561d52aaf1a786ca80bf3347e482f1c97a96c34
Raw diff: https://github.com/php/php-src/commit/4561d52aaf1a786ca80bf3347e482f1c97a96c34.diff
Mark several functions with
@compile-time-eval attribute. (#24212)
Changed paths:
A ext/opcache/tests/opt/ct_eval_md5_sha1.phpt
M ext/standard/basic_functions.stub.php
M ext/standard/basic_functions_arginfo.h
M ext/standard/basic_functions_decl.h
Diff:
diff --git a/ext/opcache/tests/opt/ct_eval_md5_sha1.phpt
b/ext/opcache/tests/opt/ct_eval_md5_sha1.phpt
new file mode 100644
index 000000000000..152533a5ada0
--- /dev/null
+++ b/ext/opcache/tests/opt/ct_eval_md5_sha1.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Compile-time evaluation of md5() and sha1()
+--EXTENSIONS--
+opcache
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+opcache.opt_debug_level=0x20000
+zend_test.observer.enabled=0
+--FILE--
+<?php
+function test() {
+ return [
+ md5('hello'),
+ bin2hex(md5('hello', true)),
+ sha1('hello'),
+ bin2hex(sha1('hello', true)),
+ ];
+}
+var_dump(test());
+?>
+--EXPECTF--
+$_main:
+ ; (lines=6, args=0, vars=0, tmps=1)
+ ; (after optimizer)
+ ; %sct_eval_md5_sha1.php:1-12
+0000 INIT_FCALL 1 %d string("var_dump")
+0001 INIT_FCALL 0 %d string("test")
+0002 T0 = DO_UCALL
+0003 SEND_VAL T0 1
+0004 DO_ICALL
+0005 RETURN int(1)
+
+test:
+ ; (lines=1, args=0, vars=0, tmps=0)
+ ; (after optimizer)
+ ; %sct_eval_md5_sha1.php:2-9
+0000 RETURN array(...)
+array(4) {
+ [0]=>
+ string(32) "5d41402abc4b2a76b9719d911017c592"
+ [1]=>
+ string(32) "5d41402abc4b2a76b9719d911017c592"
+ [2]=>
+ string(40) "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"
+ [3]=>
+ string(40) "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"
+}
diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php
index 8d4d8bd9e8b5..e55993eeb23f 100644
--- a/ext/standard/basic_functions.stub.php
+++ b/ext/standard/basic_functions.stub.php
@@ -2194,7 +2194,10 @@ function hrtime(bool $as_number = false): array|int|float|false {}
/* md5.c */
-/** @refcount 1 */
+/**
+ * @refcount 1
+ * @compile-time-eval
+ */
function md5(string $string, bool $binary = false): string {}
/** @refcount 1 */
@@ -2214,7 +2217,10 @@ function getlastmod(): int|false {}
/* sha1.c */
-/** @refcount 1 */
+/**
+ * @refcount 1
+ * @compile-time-eval
+ */
function sha1(string $string, bool $binary = false): string {}
/** @refcount 1 */
diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h
index b0eb39090e00..a4bab4cbbb9c 100644
--- a/ext/standard/basic_functions_arginfo.h
+++ b/ext/standard/basic_functions_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit basic_functions.stub.php instead.
- * Stub hash: 9e08e1c2517576dbce825322fe93cbce3054f23e
+ * Stub hash: d09685377b0f033729c141c268c91cadaa587f7d
* Has decl header: yes */
#include "zend_attributes.h"
@@ -3158,14 +3158,14 @@ static const zend_function_entry ext_functions[] = {
ZEND_FE(ftok, arginfo_ftok)
#endif
ZEND_FE(hrtime, arginfo_hrtime)
- ZEND_FE(md5, arginfo_md5)
+ ZEND_RAW_FENTRY("md5", zif_md5, arginfo_md5, ZEND_ACC_COMPILE_TIME_EVAL, NULL, NULL)
ZEND_FE(md5_file, arginfo_md5_file)
ZEND_FE(getmyuid, arginfo_getmyuid)
ZEND_FE(getmygid, arginfo_getmygid)
ZEND_FE(getmypid, arginfo_getmypid)
ZEND_FE(getmyinode, arginfo_getmyinode)
ZEND_FE(getlastmod, arginfo_getlastmod)
- ZEND_FE(sha1, arginfo_sha1)
+ ZEND_RAW_FENTRY("sha1", zif_sha1, arginfo_sha1, ZEND_ACC_COMPILE_TIME_EVAL, NULL, NULL)
ZEND_FE(sha1_file, arginfo_sha1_file)
#if defined(HAVE_SYSLOG_H)
ZEND_FE(openlog, arginfo_openlog)
diff --git a/ext/standard/basic_functions_decl.h b/ext/standard/basic_functions_decl.h
index 7ed3c749a28d..5f1ea26850c8 100644
--- a/ext/standard/basic_functions_decl.h
+++ b/ext/standard/basic_functions_decl.h
@@ -1,8 +1,8 @@
/* This is a generated file, edit basic_functions.stub.php instead.
- * Stub hash: 9e08e1c2517576dbce825322fe93cbce3054f23e */
+ * Stub hash: d09685377b0f033729c141c268c91cadaa587f7d */
-#ifndef ZEND_BASIC_FUNCTIONS_DECL_9e08e1c2517576dbce825322fe93cbce3054f23e_H
-#define ZEND_BASIC_FUNCTIONS_DECL_9e08e1c2517576dbce825322fe93cbce3054f23e_H
+#ifndef ZEND_BASIC_FUNCTIONS_DECL_d09685377b0f033729c141c268c91cadaa587f7d_H
+#define ZEND_BASIC_FUNCTIONS_DECL_d09685377b0f033729c141c268c91cadaa587f7d_H
typedef enum zend_enum_SortDirection {
ZEND_ENUM_SortDirection_Ascending = 1,
@@ -20,4 +20,4 @@ typedef enum zend_enum_RoundingMode {
ZEND_ENUM_RoundingMode_PositiveInfinity = 8,
} zend_enum_RoundingMode;
-#endif /* ZEND_BASIC_FUNCTIONS_DECL_9e08e1c2517576dbce825322fe93cbce3054f23e_H */
+#endif /* ZEND_BASIC_FUNCTIONS_DECL_d09685377b0f033729c141c268c91cadaa587f7d_H */