1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

ext/opcache: add const qualifiers

This commit is contained in:
Gina Peter Banyard
2025-10-03 15:23:28 +01:00
parent fd1c3660ca
commit aed3acfa11
8 changed files with 53 additions and 53 deletions

View File

@@ -205,7 +205,7 @@ void zend_accel_blacklist_shutdown(zend_blacklist *blacklist)
return;
}
zend_blacklist_entry *p = blacklist->entries, *end = blacklist->entries + blacklist->pos;
const zend_blacklist_entry *p = blacklist->entries, *end = blacklist->entries + blacklist->pos;
while (p<end) {
free(p->path);
p++;
@@ -336,10 +336,10 @@ void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename)
zend_accel_blacklist_update_regexp(blacklist);
}
bool zend_accel_blacklist_is_blacklisted(zend_blacklist *blacklist, char *verify_path, size_t verify_path_len)
bool zend_accel_blacklist_is_blacklisted(const zend_blacklist *blacklist, const char *verify_path, size_t verify_path_len)
{
int ret = 0;
zend_regexp_list *regexp_list_it = blacklist->regexp_list;
const zend_regexp_list *regexp_list_it = blacklist->regexp_list;
pcre2_match_context *mctx = php_pcre_mctx();
if (regexp_list_it == NULL) {
@@ -363,7 +363,7 @@ bool zend_accel_blacklist_is_blacklisted(zend_blacklist *blacklist, char *verify
return ret;
}
void zend_accel_blacklist_apply(zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument)
void zend_accel_blacklist_apply(const zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument)
{
int i;

View File

@@ -45,7 +45,7 @@ void zend_accel_blacklist_init(zend_blacklist *blacklist);
void zend_accel_blacklist_shutdown(zend_blacklist *blacklist);
void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename);
bool zend_accel_blacklist_is_blacklisted(zend_blacklist *blacklist, char *verify_path, size_t verify_path_len);
void zend_accel_blacklist_apply(zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument);
bool zend_accel_blacklist_is_blacklisted(const zend_blacklist *blacklist, const char *verify_path, size_t verify_path_len);
void zend_accel_blacklist_apply(const zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument);
#endif /* ZEND_ACCELERATOR_BLACKLIST_H */

View File

@@ -138,7 +138,7 @@ zend_accel_hash_entry* zend_accel_hash_update(zend_accel_hash *accel_hash, zend_
return entry;
}
static zend_always_inline void* zend_accel_hash_find_ex(zend_accel_hash *accel_hash, zend_string *key, int data)
static zend_always_inline void* zend_accel_hash_find_ex(const zend_accel_hash *accel_hash, zend_string *key, int data)
{
zend_ulong index;
zend_accel_hash_entry *entry;
@@ -176,7 +176,7 @@ static zend_always_inline void* zend_accel_hash_find_ex(zend_accel_hash *accel_h
/* Returns the data associated with key on success
* Returns NULL if data doesn't exist
*/
void* zend_accel_hash_find(zend_accel_hash *accel_hash, zend_string *key)
void* zend_accel_hash_find(const zend_accel_hash *accel_hash, zend_string *key)
{
return zend_accel_hash_find_ex(accel_hash, key, 1);
}
@@ -184,7 +184,7 @@ void* zend_accel_hash_find(zend_accel_hash *accel_hash, zend_string *key)
/* Returns the hash entry associated with key on success
* Returns NULL if it doesn't exist
*/
zend_accel_hash_entry* zend_accel_hash_find_entry(zend_accel_hash *accel_hash, zend_string *key)
zend_accel_hash_entry* zend_accel_hash_find_entry(const zend_accel_hash *accel_hash, zend_string *key)
{
return (zend_accel_hash_entry *)zend_accel_hash_find_ex(accel_hash, key, 0);
}

View File

@@ -72,18 +72,18 @@ zend_accel_hash_entry* zend_accel_hash_update(
void *data);
void* zend_accel_hash_find(
zend_accel_hash *accel_hash,
const zend_accel_hash *accel_hash,
zend_string *key);
zend_accel_hash_entry* zend_accel_hash_find_entry(
zend_accel_hash *accel_hash,
const zend_accel_hash *accel_hash,
zend_string *key);
int zend_accel_hash_unlink(
zend_accel_hash *accel_hash,
zend_string *key);
static inline bool zend_accel_hash_is_full(zend_accel_hash *accel_hash)
static inline bool zend_accel_hash_is_full(const zend_accel_hash *accel_hash)
{
if (accel_hash->num_entries == accel_hash->max_num_entries) {
return true;

View File

@@ -105,7 +105,7 @@ void zend_accel_move_user_classes(HashTable *src, uint32_t count, zend_script *s
{
Bucket *p, *end;
HashTable *dst;
zend_string *filename;
const zend_string *filename;
dtor_func_t orig_dtor;
zend_class_entry *ce;
@@ -132,10 +132,10 @@ void zend_accel_move_user_classes(HashTable *src, uint32_t count, zend_script *s
src->pDestructor = orig_dtor;
}
static zend_always_inline void _zend_accel_function_hash_copy(HashTable *target, HashTable *source, bool call_observers)
static zend_always_inline void _zend_accel_function_hash_copy(HashTable *target, const HashTable *source, bool call_observers)
{
zend_function *function1, *function2;
Bucket *p, *end;
const Bucket *p, *end;
zval *t;
zend_hash_extend(target, target->nNumUsed + source->nNumUsed, 0);
@@ -174,20 +174,20 @@ failure:
}
}
static zend_always_inline void zend_accel_function_hash_copy(HashTable *target, HashTable *source)
static zend_always_inline void zend_accel_function_hash_copy(HashTable *target, const HashTable *source)
{
_zend_accel_function_hash_copy(target, source, false);
}
static zend_never_inline void zend_accel_function_hash_copy_notify(HashTable *target, HashTable *source)
static zend_never_inline void zend_accel_function_hash_copy_notify(HashTable *target, const HashTable *source)
{
_zend_accel_function_hash_copy(target, source, true);
}
static zend_always_inline void _zend_accel_class_hash_copy(HashTable *target, HashTable *source, bool call_observers)
static zend_always_inline void _zend_accel_class_hash_copy(HashTable *target, const HashTable *source, bool call_observers)
{
Bucket *p, *end;
zval *t;
const Bucket *p, *end;
const zval *t;
zend_hash_extend(target, target->nNumUsed + source->nNumUsed, 0);
p = source->arData;
@@ -209,7 +209,7 @@ static zend_always_inline void _zend_accel_class_hash_copy(HashTable *target, Ha
* value. */
continue;
} else if (UNEXPECTED(!ZCG(accel_directives).ignore_dups)) {
zend_class_entry *ce1 = Z_PTR(p->val);
const zend_class_entry *ce1 = Z_PTR(p->val);
if (!(ce1->ce_flags & ZEND_ACC_ANON_CLASS)) {
CG(in_compilation) = 1;
zend_set_compiled_filename(ce1->info.user.filename);
@@ -235,25 +235,25 @@ static zend_always_inline void _zend_accel_class_hash_copy(HashTable *target, Ha
target->nInternalPointer = 0;
}
static zend_always_inline void zend_accel_class_hash_copy(HashTable *target, HashTable *source)
static zend_always_inline void zend_accel_class_hash_copy(HashTable *target, const HashTable *source)
{
_zend_accel_class_hash_copy(target, source, false);
}
static zend_never_inline void zend_accel_class_hash_copy_notify(HashTable *target, HashTable *source)
static zend_never_inline void zend_accel_class_hash_copy_notify(HashTable *target, const HashTable *source)
{
_zend_accel_class_hash_copy(target, source, true);
}
void zend_accel_build_delayed_early_binding_list(zend_persistent_script *persistent_script)
{
zend_op_array *op_array = &persistent_script->script.main_op_array;
const zend_op_array *op_array = &persistent_script->script.main_op_array;
if (!(op_array->fn_flags & ZEND_ACC_EARLY_BINDING)) {
return;
}
zend_op *end = op_array->opcodes + op_array->last;
for (zend_op *opline = op_array->opcodes; opline < end; opline++) {
const zend_op *end = op_array->opcodes + op_array->last;
for (const zend_op *opline = op_array->opcodes; opline < end; opline++) {
if (opline->opcode == ZEND_DECLARE_CLASS_DELAYED) {
persistent_script->num_early_bindings++;
}
@@ -264,7 +264,7 @@ void zend_accel_build_delayed_early_binding_list(zend_persistent_script *persist
for (zend_op *opline = op_array->opcodes; opline < end; opline++) {
if (opline->opcode == ZEND_DECLARE_CLASS_DELAYED) {
zval *lcname = RT_CONSTANT(opline, opline->op1);
const zval *lcname = RT_CONSTANT(opline, opline->op1);
early_binding->lcname = zend_string_copy(Z_STR_P(lcname));
early_binding->rtd_key = zend_string_copy(Z_STR_P(lcname + 1));
early_binding->lc_parent_name =
@@ -275,19 +275,19 @@ void zend_accel_build_delayed_early_binding_list(zend_persistent_script *persist
}
}
void zend_accel_finalize_delayed_early_binding_list(zend_persistent_script *persistent_script)
void zend_accel_finalize_delayed_early_binding_list(const zend_persistent_script *persistent_script)
{
if (!persistent_script->num_early_bindings) {
return;
}
zend_early_binding *early_binding = persistent_script->early_bindings;
zend_early_binding *early_binding_end = early_binding + persistent_script->num_early_bindings;
zend_op_array *op_array = &persistent_script->script.main_op_array;
zend_op *opline_end = op_array->opcodes + op_array->last;
const zend_early_binding *early_binding_end = early_binding + persistent_script->num_early_bindings;
const zend_op_array *op_array = &persistent_script->script.main_op_array;
const zend_op *opline_end = op_array->opcodes + op_array->last;
for (zend_op *opline = op_array->opcodes; opline < opline_end; opline++) {
if (opline->opcode == ZEND_DECLARE_CLASS_DELAYED) {
zend_string *rtd_key = Z_STR_P(RT_CONSTANT(opline, opline->op1) + 1);
const zend_string *rtd_key = Z_STR_P(RT_CONSTANT(opline, opline->op1) + 1);
/* Skip early_binding entries that don't match, maybe their DECLARE_CLASS_DELAYED
* was optimized away. */
while (!zend_string_equals(early_binding->rtd_key, rtd_key)) {
@@ -310,7 +310,7 @@ void zend_accel_free_delayed_early_binding_list(zend_persistent_script *persiste
{
if (persistent_script->num_early_bindings) {
for (uint32_t i = 0; i < persistent_script->num_early_bindings; i++) {
zend_early_binding *early_binding = &persistent_script->early_bindings[i];
const zend_early_binding *early_binding = &persistent_script->early_bindings[i];
zend_string_release(early_binding->lcname);
zend_string_release(early_binding->rtd_key);
zend_string_release(early_binding->lc_parent_name);
@@ -322,7 +322,7 @@ void zend_accel_free_delayed_early_binding_list(zend_persistent_script *persiste
}
static void zend_accel_do_delayed_early_binding(
zend_persistent_script *persistent_script, zend_op_array *op_array)
const zend_persistent_script *persistent_script, zend_op_array *op_array)
{
ZEND_ASSERT(!ZEND_MAP_PTR(op_array->run_time_cache));
ZEND_ASSERT(op_array->fn_flags & ZEND_ACC_HEAP_RT_CACHE);
@@ -336,7 +336,7 @@ static void zend_accel_do_delayed_early_binding(
CG(compiled_filename) = persistent_script->script.filename;
CG(in_compilation) = 1;
for (uint32_t i = 0; i < persistent_script->num_early_bindings; i++) {
zend_early_binding *early_binding = &persistent_script->early_bindings[i];
const zend_early_binding *early_binding = &persistent_script->early_bindings[i];
zend_class_entry *ce = zend_hash_find_ex_ptr(EG(class_table), early_binding->lcname, 1);
if (!ce) {
zval *zv = zend_hash_find_known_hash(EG(class_table), early_binding->rtd_key);
@@ -448,7 +448,7 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script,
#define ADLER32_SCALAR_DO8(buf, i) ADLER32_SCALAR_DO4(buf, i); ADLER32_SCALAR_DO4(buf, i + 4);
#define ADLER32_SCALAR_DO16(buf) ADLER32_SCALAR_DO8(buf, 0); ADLER32_SCALAR_DO8(buf, 8);
static zend_always_inline void adler32_do16_loop(unsigned char *buf, unsigned char *end, unsigned int *s1_out, unsigned int *s2_out)
static zend_always_inline void adler32_do16_loop(unsigned char *buf, const unsigned char *end, unsigned int *s1_out, unsigned int *s2_out)
{
unsigned int s1 = *s1_out;
unsigned int s2 = *s2_out;

View File

@@ -33,7 +33,7 @@ void free_persistent_script(zend_persistent_script *persistent_script, int destr
void zend_accel_move_user_functions(HashTable *str, uint32_t count, zend_script *script);
void zend_accel_move_user_classes(HashTable *str, uint32_t count, zend_script *script);
void zend_accel_build_delayed_early_binding_list(zend_persistent_script *persistent_script);
void zend_accel_finalize_delayed_early_binding_list(zend_persistent_script *persistent_script);
void zend_accel_finalize_delayed_early_binding_list(const zend_persistent_script *persistent_script);
void zend_accel_free_delayed_early_binding_list(zend_persistent_script *persistent_script);
zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script, int from_shared_memory);

View File

@@ -732,7 +732,7 @@ static void zend_persist_op_array(zval *zv)
}
}
static zend_op_array *zend_persist_class_method(zend_op_array *op_array, zend_class_entry *ce)
static zend_op_array *zend_persist_class_method(zend_op_array *op_array, const zend_class_entry *ce)
{
zend_op_array *old_op_array;
@@ -834,7 +834,7 @@ static zend_property_info *zend_persist_property_info(zend_property_info *prop)
prop->attributes = zend_persist_attributes(prop->attributes);
}
if (prop->prototype) {
zend_property_info *new_prototype = (zend_property_info *) zend_shared_alloc_get_xlat_entry(prop->prototype);
const zend_property_info *new_prototype = (const zend_property_info *) zend_shared_alloc_get_xlat_entry(prop->prototype);
if (new_prototype) {
prop->prototype = new_prototype;
}
@@ -854,7 +854,7 @@ static zend_property_info *zend_persist_property_info(zend_property_info *prop)
}
}
#endif
zend_property_info *new_prop_info = (zend_property_info *) zend_shared_alloc_get_xlat_entry(hook->prop_info);
const zend_property_info *new_prop_info = (const zend_property_info *) zend_shared_alloc_get_xlat_entry(hook->prop_info);
if (new_prop_info) {
hook->prop_info = new_prop_info;
}
@@ -868,7 +868,7 @@ static zend_property_info *zend_persist_property_info(zend_property_info *prop)
static void zend_persist_class_constant(zval *zv)
{
zend_class_constant *orig_c = Z_PTR_P(zv);
const zend_class_constant *orig_c = Z_PTR_P(zv);
zend_class_constant *c = zend_shared_alloc_get_xlat_entry(orig_c);
zend_class_entry *ce;
@@ -1287,7 +1287,7 @@ void zend_update_parent_ce(zend_class_entry *ce)
}
#ifdef HAVE_JIT
static void zend_accel_persist_jit_op_array(zend_op_array *op_array, zend_class_entry *ce)
static void zend_accel_persist_jit_op_array(zend_op_array *op_array, const zend_class_entry *ce)
{
if (op_array->type == ZEND_USER_FUNCTION) {
if (op_array->scope == ce
@@ -1301,7 +1301,7 @@ static void zend_accel_persist_jit_op_array(zend_op_array *op_array, zend_class_
}
}
static void zend_accel_persist_link_func_info(zend_op_array *op_array, zend_class_entry *ce)
static void zend_accel_persist_link_func_info(zend_op_array *op_array, const zend_class_entry *ce)
{
if (op_array->type == ZEND_USER_FUNCTION
&& !(op_array->fn_flags & ZEND_ACC_ABSTRACT)) {

View File

@@ -47,9 +47,9 @@
} while (0)
static void zend_persist_zval_calc(zval *z);
static void zend_persist_op_array_calc(zval *zv);
static void zend_persist_op_array_calc(const zval *zv);
static void zend_hash_persist_calc(HashTable *ht)
static void zend_hash_persist_calc(const HashTable *ht)
{
if ((HT_FLAGS(ht) & HASH_FLAG_UNINITIALIZED) || ht->nNumUsed == 0) {
return;
@@ -79,7 +79,7 @@ static void zend_persist_ast_calc(zend_ast *ast)
ADD_SIZE(sizeof(zend_ast_zval));
zend_persist_zval_calc(&((zend_ast_zval*)(ast))->val);
} else if (zend_ast_is_list(ast)) {
zend_ast_list *list = zend_ast_get_list(ast);
const zend_ast_list *list = zend_ast_get_list(ast);
ADD_SIZE(sizeof(zend_ast_list) - sizeof(zend_ast *) + sizeof(zend_ast *) * list->children);
for (i = 0; i < list->children; i++) {
if (list->child[i]) {
@@ -125,7 +125,7 @@ static void zend_persist_zval_calc(zval *z)
}
size = zend_shared_memdup_size(Z_ARR_P(z), sizeof(zend_array));
if (size) {
HashTable *ht = Z_ARRVAL_P(z);
const HashTable *ht = Z_ARRVAL_P(z);
ADD_SIZE(size);
zend_hash_persist_calc(ht);
@@ -218,7 +218,7 @@ static void zend_persist_type_calc(zend_type *type)
static void zend_persist_op_array_calc_ex(zend_op_array *op_array)
{
if (op_array->function_name) {
zend_string *old_name = op_array->function_name;
const zend_string *old_name = op_array->function_name;
ADD_INTERNED_STRING(op_array->function_name);
/* Remember old function name, so it can be released multiple times if shared. */
if (op_array->function_name != old_name
@@ -258,7 +258,7 @@ static void zend_persist_op_array_calc_ex(zend_op_array *op_array)
if (op_array->literals) {
zval *p = op_array->literals;
zval *end = p + op_array->last_literal;
const zval *end = p + op_array->last_literal;
ADD_SIZE(sizeof(zval) * op_array->last_literal);
while (p < end) {
zend_persist_zval_calc(p);
@@ -272,7 +272,7 @@ static void zend_persist_op_array_calc_ex(zend_op_array *op_array)
/* ZEND_ACC_PTR_OPS and ZEND_ACC_OVERRIDE use the same value */
if ((op_array->fn_flags & ZEND_ACC_PTR_OPS) && !op_array->function_name) {
zend_op *op = op_array->opcodes;
zend_op *end = op + op_array->last;
const zend_op *end = op + op_array->last;
while (op < end) {
if (op->opcode == ZEND_DECLARE_ATTRIBUTED_CONST) {
HashTable *attributes = Z_PTR_P(RT_CONSTANT(op+1, (op+1)->op1));
@@ -344,7 +344,7 @@ static void zend_persist_op_array_calc_ex(zend_op_array *op_array)
ADD_SIZE(ZEND_ALIGNED_SIZE(zend_extensions_op_array_persist_calc(op_array)));
}
static void zend_persist_op_array_calc(zval *zv)
static void zend_persist_op_array_calc(const zval *zv)
{
zend_op_array *op_array = Z_PTR_P(zv);
ZEND_ASSERT(op_array->type == ZEND_USER_FUNCTION);
@@ -417,7 +417,7 @@ static void zend_persist_property_info_calc(zend_property_info *prop)
}
}
static void zend_persist_class_constant_calc(zval *zv)
static void zend_persist_class_constant_calc(const zval *zv)
{
zend_class_constant *c = Z_PTR_P(zv);
@@ -596,7 +596,7 @@ void zend_persist_class_entry_calc(zend_class_entry *ce)
}
}
static void zend_accel_persist_class_table_calc(HashTable *class_table)
static void zend_accel_persist_class_table_calc(const HashTable *class_table)
{
Bucket *p;