Skip to content

Commit c2c4302

Browse files
committed
Zend/zend_portability.h: add ZEND_ATTRIBUTE_PURE
Adding "pure" and "const" attributes to some functions allows the compiler to do more optimizations, e.g. cache certain values in registers across function calls because it has been given a guarantee that those values will not change from inside a "pure" function call. `pure` basically says two things: 1. the compiler gets a guarantee that the function's return value depends only on the parameter and global state (the latter not for `const`, that's the difference between the two); "global state" here includes the dereferenced values of `ex`, for example 2. the compiler gets a guarantee that the function does not modify global state The first guarantee allows the compiler to combine two function calls into one, by caching the return value. It will do that if it sees two function calls with the same parameters, and global state is not modified in between. The second guarantee is just "secondary" but the more important/powerful one for compiler optimizations: if the compiler knows that global state will not be modified, it will be able to cache memory accesses across this function call. For example: https://github.com/php/php-src/blob/d2cdfdbe44f3bdded4aed8f84ef9db740c7f8adb/Zend/zend_vm_def.h#L7946-L7957 Here, `Z_OBJ_P(fast_call)` is a shortcut for `fast_call->value.obj`, i.e. it reads a pointer from RAM. It does that RAM read in line 7946, but since the compiler cannot know that `zend_is_unwind_exit(ex) || zend_is_graceful_exit` will not modify those RAM portions, it will need to read the RAM again in lines 7950 and 7952. Enter `pure`: once those functions are marked as `pure`, the compiler gets this guarantee, and is allowed to cache `Z_OBJ_P(fast_call)` in a register; it is allowed to remember this value even across calls to these functions. In an expression/code section where only `pure` functions are called, the compiler is allowed to cache everything, but the first non-`pure` call forces the compiler to drop all cached RAM values. So the benefits of adding more `pure` (where appropriate) add up. (Often, you can gain a similar optimization by explicitly caching stuff in a local variable, because local variables are often in registers, and the compiler can reason whether they may be modified by a function call (it will never be, unless you passed a pointer to one somewhere, and in that case, it cannot be in a register anyway). The disadvantage of local variables is that they can spill to the stack if registers are exhausted.) (This is a continuation of commit db64c1c) See https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html for documentation.
1 parent f771ad7 commit c2c4302

35 files changed

+154
-148
lines changed

Zend/Optimizer/scdf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static inline void scdf_add_def_to_worklist(scdf_ctx *scdf, int var_num) {
7575
}
7676
}
7777

78-
static inline uint32_t scdf_edge(zend_cfg *cfg, int from, int to) {
78+
static inline ZEND_ATTRIBUTE_PURE uint32_t scdf_edge(zend_cfg *cfg, int from, int to) {
7979
zend_basic_block *to_block = cfg->blocks + to;
8080
int i;
8181

@@ -89,7 +89,7 @@ static inline uint32_t scdf_edge(zend_cfg *cfg, int from, int to) {
8989
ZEND_UNREACHABLE();
9090
}
9191

92-
static inline bool scdf_is_edge_feasible(scdf_ctx *scdf, int from, int to) {
92+
static inline ZEND_ATTRIBUTE_PURE bool scdf_is_edge_feasible(scdf_ctx *scdf, int from, int to) {
9393
uint32_t edge = scdf_edge(&scdf->ssa->cfg, from, to);
9494
return zend_bitset_in(scdf->feasible_edges, edge);
9595
}

Zend/Optimizer/zend_func_info.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ BEGIN_EXTERN_C()
5656

5757
extern ZEND_API int zend_func_info_rid;
5858

59-
uint32_t zend_get_internal_func_info(
59+
ZEND_ATTRIBUTE_PURE uint32_t zend_get_internal_func_info(
6060
const zend_function *callee_func, const zend_call_info *call_info, const zend_ssa *ssa);
6161
ZEND_API uint32_t zend_get_func_info(
6262
const zend_call_info *call_info, const zend_ssa *ssa,

Zend/Optimizer/zend_inference.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ ZEND_API void zend_ssa_find_false_dependencies(const zend_op_array *op_array, ze
219219
ZEND_API void zend_ssa_find_sccs(const zend_op_array *op_array, zend_ssa *ssa);
220220
ZEND_API int zend_ssa_inference(zend_arena **raena, const zend_op_array *op_array, const zend_script *script, zend_ssa *ssa, zend_long optimization_level);
221221

222-
ZEND_API uint32_t zend_array_element_type(uint32_t t1, zend_uchar op_type, int write, int insert);
222+
ZEND_API ZEND_ATTRIBUTE_CONST uint32_t zend_array_element_type(uint32_t t1, zend_uchar op_type, int write, int insert);
223223

224224
ZEND_API bool zend_inference_propagate_range(const zend_op_array *op_array, zend_ssa *ssa, zend_op *opline, zend_ssa_op* ssa_op, int var, zend_ssa_range *tmp);
225225

@@ -231,8 +231,8 @@ uint32_t zend_get_return_info_from_signature_only(
231231
const zend_function *func, const zend_script *script,
232232
zend_class_entry **ce, bool *ce_is_instanceof, bool use_tentative_return_info);
233233

234-
ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, zend_ssa *ssa, uint32_t t1, uint32_t t2);
235-
ZEND_API bool zend_may_throw(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, zend_ssa *ssa);
234+
ZEND_API ZEND_ATTRIBUTE_PURE bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, zend_ssa *ssa, uint32_t t1, uint32_t t2);
235+
ZEND_API ZEND_ATTRIBUTE_PURE bool zend_may_throw(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, zend_ssa *ssa);
236236

237237
ZEND_API zend_result zend_update_type_info(
238238
const zend_op_array *op_array, zend_ssa *ssa, const zend_script *script,

Zend/zend_alloc.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,15 @@ ZEND_API ZEND_ATTRIBUTE_MALLOC char * __zend_strdup(const char *s);
215215
#define pestrdup_rel(s, persistent) ((persistent)?strdup(s):estrdup_rel(s))
216216

217217
ZEND_API zend_result zend_set_memory_limit(size_t memory_limit);
218-
ZEND_API bool zend_alloc_in_memory_limit_error_reporting(void);
218+
ZEND_API ZEND_ATTRIBUTE_PURE bool zend_alloc_in_memory_limit_error_reporting(void);
219219

220220
ZEND_API void start_memory_manager(void);
221221
ZEND_API void shutdown_memory_manager(bool silent, bool full_shutdown);
222-
ZEND_API bool is_zend_mm(void);
223-
ZEND_API bool is_zend_ptr(const void *ptr);
222+
ZEND_API ZEND_ATTRIBUTE_CONST bool is_zend_mm(void);
223+
ZEND_API ZEND_ATTRIBUTE_PURE bool is_zend_ptr(const void *ptr);
224224

225-
ZEND_API size_t zend_memory_usage(bool real_usage);
226-
ZEND_API size_t zend_memory_peak_usage(bool real_usage);
225+
ZEND_API ZEND_ATTRIBUTE_PURE size_t zend_memory_usage(bool real_usage);
226+
ZEND_API ZEND_ATTRIBUTE_PURE size_t zend_memory_peak_usage(bool real_usage);
227227
ZEND_API void zend_memory_reset_peak_usage(void);
228228

229229
/* fast cache for HashTables */
@@ -248,7 +248,7 @@ ZEND_API ZEND_ATTRIBUTE_MALLOC void* ZEND_FASTCALL _zend_mm_alloc(zend_mm_heap
248248
ZEND_API void ZEND_FASTCALL _zend_mm_free(zend_mm_heap *heap, void *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
249249
ZEND_API void* ZEND_FASTCALL _zend_mm_realloc(zend_mm_heap *heap, void *p, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
250250
ZEND_API void* ZEND_FASTCALL _zend_mm_realloc2(zend_mm_heap *heap, void *p, size_t size, size_t copy_size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
251-
ZEND_API size_t ZEND_FASTCALL _zend_mm_block_size(zend_mm_heap *heap, void *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
251+
ZEND_API ZEND_ATTRIBUTE_PURE size_t ZEND_FASTCALL _zend_mm_block_size(zend_mm_heap *heap, void *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
252252

253253
#define zend_mm_alloc(heap, size) _zend_mm_alloc((heap), (size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
254254
#define zend_mm_free(heap, p) _zend_mm_free((heap), (p) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
@@ -263,15 +263,15 @@ ZEND_API size_t ZEND_FASTCALL _zend_mm_block_size(zend_mm_heap *heap, void *p ZE
263263
#define zend_mm_block_size_rel(heap, p) _zend_mm_block_size((heap), (p) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
264264

265265
ZEND_API zend_mm_heap *zend_mm_set_heap(zend_mm_heap *new_heap);
266-
ZEND_API zend_mm_heap *zend_mm_get_heap(void);
266+
ZEND_API ZEND_ATTRIBUTE_PURE zend_mm_heap *zend_mm_get_heap(void);
267267

268268
ZEND_API size_t zend_mm_gc(zend_mm_heap *heap);
269269

270270
#define ZEND_MM_CUSTOM_HEAP_NONE 0
271271
#define ZEND_MM_CUSTOM_HEAP_STD 1
272272
#define ZEND_MM_CUSTOM_HEAP_DEBUG 2
273273

274-
ZEND_API bool zend_mm_is_custom_heap(zend_mm_heap *new_heap);
274+
ZEND_API ZEND_ATTRIBUTE_PURE bool zend_mm_is_custom_heap(zend_mm_heap *new_heap);
275275
ZEND_API void zend_mm_set_custom_handlers(zend_mm_heap *heap,
276276
void* (*_malloc)(size_t),
277277
void (*_free)(void*),
@@ -307,7 +307,7 @@ struct _zend_mm_storage {
307307
void *data;
308308
};
309309

310-
ZEND_API zend_mm_storage *zend_mm_get_storage(zend_mm_heap *heap);
310+
ZEND_API ZEND_ATTRIBUTE_PURE zend_mm_storage *zend_mm_get_storage(zend_mm_heap *heap);
311311
ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_handlers *handlers, void *data, size_t data_size);
312312

313313
/*
@@ -396,7 +396,7 @@ static void apc_init_heap(void)
396396
*/
397397

398398
#ifdef ZTS
399-
size_t zend_mm_globals_size(void);
399+
ZEND_ATTRIBUTE_CONST size_t zend_mm_globals_size(void);
400400
#endif
401401

402402
END_EXTERN_C()

Zend/zend_bitset.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ typedef zend_ulong *zend_bitset;
3838
(zend_bitset)do_alloca((n) * ZEND_BITSET_ELM_SIZE, use_heap)
3939

4040
/* Number of trailing zero bits (0x01 -> 0; 0x40 -> 6; 0x00 -> LEN) */
41-
static zend_always_inline int zend_ulong_ntz(zend_ulong num)
41+
static zend_always_inline ZEND_ATTRIBUTE_CONST int zend_ulong_ntz(zend_ulong num)
4242
{
4343
#if (defined(__GNUC__) || __has_builtin(__builtin_ctzl)) \
4444
&& SIZEOF_ZEND_LONG == SIZEOF_LONG && defined(PHP_HAVE_BUILTIN_CTZL)
@@ -76,7 +76,7 @@ static zend_always_inline int zend_ulong_ntz(zend_ulong num)
7676
}
7777

7878
/* Number of leading zero bits (Undefined for zero) */
79-
static zend_always_inline int zend_ulong_nlz(zend_ulong num)
79+
static zend_always_inline ZEND_ATTRIBUTE_CONST int zend_ulong_nlz(zend_ulong num)
8080
{
8181
#if (defined(__GNUC__) || __has_builtin(__builtin_clzl)) \
8282
&& SIZEOF_ZEND_LONG == SIZEOF_LONG && defined(PHP_HAVE_BUILTIN_CLZL)
@@ -158,7 +158,7 @@ static inline void zend_bitset_fill(zend_bitset set, uint32_t len)
158158
memset(set, 0xff, len * ZEND_BITSET_ELM_SIZE);
159159
}
160160

161-
static inline bool zend_bitset_equal(zend_bitset set1, zend_bitset set2, uint32_t len)
161+
static inline ZEND_ATTRIBUTE_PURE bool zend_bitset_equal(zend_bitset set1, zend_bitset set2, uint32_t len)
162162
{
163163
return memcmp(set1, set2, len * ZEND_BITSET_ELM_SIZE) == 0;
164164
}
@@ -225,7 +225,7 @@ static inline bool zend_bitset_subset(zend_bitset set1, zend_bitset set2, uint32
225225
return 1;
226226
}
227227

228-
static inline int zend_bitset_first(zend_bitset set, uint32_t len)
228+
static inline ZEND_ATTRIBUTE_PURE int zend_bitset_first(zend_bitset set, uint32_t len)
229229
{
230230
uint32_t i;
231231

@@ -237,7 +237,7 @@ static inline int zend_bitset_first(zend_bitset set, uint32_t len)
237237
return -1; /* empty set */
238238
}
239239

240-
static inline int zend_bitset_last(zend_bitset set, uint32_t len)
240+
static inline ZEND_ATTRIBUTE_PURE int zend_bitset_last(zend_bitset set, uint32_t len)
241241
{
242242
uint32_t i = len;
243243

Zend/zend_compile.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,8 +1193,8 @@ END_EXTERN_C()
11931193
/* The default value for CG(compiler_options) during eval() */
11941194
#define ZEND_COMPILE_DEFAULT_FOR_EVAL 0
11951195

1196-
ZEND_API bool zend_is_op_long_compatible(zval *op);
1197-
ZEND_API bool zend_binary_op_produces_error(uint32_t opcode, zval *op1, zval *op2);
1198-
ZEND_API bool zend_unary_op_produces_error(uint32_t opcode, zval *op);
1196+
ZEND_API ZEND_ATTRIBUTE_PURE bool zend_is_op_long_compatible(zval *op);
1197+
ZEND_API ZEND_ATTRIBUTE_PURE bool zend_binary_op_produces_error(uint32_t opcode, zval *op1, zval *op2);
1198+
ZEND_API ZEND_ATTRIBUTE_PURE bool zend_unary_op_produces_error(uint32_t opcode, zval *op);
11991199

12001200
#endif /* ZEND_COMPILE_H */

Zend/zend_constants.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ void free_zend_constant(zval *zv);
7373
void zend_startup_constants(void);
7474
void zend_shutdown_constants(void);
7575
void zend_register_standard_constants(void);
76-
ZEND_API bool zend_verify_const_access(zend_class_constant *c, zend_class_entry *ce);
77-
ZEND_API zval *zend_get_constant(zend_string *name);
78-
ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len);
79-
ZEND_API zval *zend_get_constant_ex(zend_string *name, zend_class_entry *scope, uint32_t flags);
80-
ZEND_API zval *zend_get_class_constant_ex(zend_string *class_name, zend_string *constant_name, zend_class_entry *scope, uint32_t flags);
76+
ZEND_API ZEND_ATTRIBUTE_PURE bool zend_verify_const_access(zend_class_constant *c, zend_class_entry *ce);
77+
ZEND_API ZEND_ATTRIBUTE_PURE zval *zend_get_constant(zend_string *name);
78+
ZEND_API ZEND_ATTRIBUTE_PURE zval *zend_get_constant_str(const char *name, size_t name_len);
79+
ZEND_API ZEND_ATTRIBUTE_PURE zval *zend_get_constant_ex(zend_string *name, zend_class_entry *scope, uint32_t flags);
80+
ZEND_API ZEND_ATTRIBUTE_PURE zval *zend_get_class_constant_ex(zend_string *class_name, zend_string *constant_name, zend_class_entry *scope, uint32_t flags);
8181
ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, bool bval, int flags, int module_number);
8282
ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number);
8383
ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number);
@@ -89,9 +89,9 @@ ZEND_API zend_result zend_register_constant(zend_constant *c);
8989
void zend_copy_constants(HashTable *target, HashTable *source);
9090
#endif
9191

92-
ZEND_API zend_constant *_zend_get_special_const(const char *name, size_t name_len);
92+
ZEND_API ZEND_ATTRIBUTE_PURE zend_constant *_zend_get_special_const(const char *name, size_t name_len);
9393

94-
static zend_always_inline zend_constant *zend_get_special_const(
94+
static zend_always_inline ZEND_ATTRIBUTE_PURE zend_constant *zend_get_special_const(
9595
const char *name, size_t name_len) {
9696
if (name_len == 4 || name_len == 5) {
9797
return _zend_get_special_const(name, name_len);

Zend/zend_exceptions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static int zend_implement_throwable(zend_class_entry *interface, zend_class_entr
8080
}
8181
/* }}} */
8282

83-
static inline zend_class_entry *i_get_exception_base(zend_object *object) /* {{{ */
83+
static inline ZEND_ATTRIBUTE_PURE zend_class_entry *i_get_exception_base(zend_object *object) /* {{{ */
8484
{
8585
return instanceof_function(object->ce, zend_ce_exception) ? zend_ce_exception : zend_ce_error;
8686
}

Zend/zend_exceptions.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ ZEND_API ZEND_COLD void zend_throw_exception_internal(zend_object *exception);
4545

4646
void zend_register_default_exception(void);
4747

48-
ZEND_API zend_class_entry *zend_get_exception_base(zend_object *object);
48+
ZEND_API ZEND_ATTRIBUTE_PURE zend_class_entry *zend_get_exception_base(zend_object *object);
4949

5050
/* Deprecated - Use zend_ce_exception directly instead */
51-
ZEND_API zend_class_entry *zend_exception_get_default(void);
51+
ZEND_API ZEND_ATTRIBUTE_CONST zend_class_entry *zend_exception_get_default(void);
5252

5353
/* Deprecated - Use zend_ce_error_exception directly instead */
54-
ZEND_API zend_class_entry *zend_get_error_exception(void);
54+
ZEND_API ZEND_ATTRIBUTE_CONST zend_class_entry *zend_get_error_exception(void);
5555

5656
ZEND_API void zend_register_default_classes(void);
5757

@@ -75,8 +75,8 @@ ZEND_API ZEND_COLD zend_object *zend_create_unwind_exit(void);
7575
ZEND_API ZEND_COLD zend_object *zend_create_graceful_exit(void);
7676
ZEND_API ZEND_COLD void zend_throw_unwind_exit(void);
7777
ZEND_API ZEND_COLD void zend_throw_graceful_exit(void);
78-
ZEND_API bool zend_is_unwind_exit(const zend_object *ex);
79-
ZEND_API bool zend_is_graceful_exit(const zend_object *ex);
78+
ZEND_API ZEND_ATTRIBUTE_PURE bool zend_is_unwind_exit(const zend_object *ex);
79+
ZEND_API ZEND_ATTRIBUTE_PURE bool zend_is_graceful_exit(const zend_object *ex);
8080

8181
#include "zend_globals.h"
8282

Zend/zend_hash.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ ZEND_API void ZEND_FASTCALL zend_hash_del_bucket(HashTable *ht, Bucket *p);
174174
ZEND_API void ZEND_FASTCALL zend_hash_packed_del_val(HashTable *ht, zval *zv);
175175

176176
/* Data retrieval */
177-
ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key);
178-
ZEND_API zval* ZEND_FASTCALL zend_hash_str_find(const HashTable *ht, const char *key, size_t len);
179-
ZEND_API zval* ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h);
180-
ZEND_API zval* ZEND_FASTCALL _zend_hash_index_find(const HashTable *ht, zend_ulong h);
177+
ZEND_API ZEND_ATTRIBUTE_PURE zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key);
178+
ZEND_API ZEND_ATTRIBUTE_PURE zval* ZEND_FASTCALL zend_hash_str_find(const HashTable *ht, const char *key, size_t len);
179+
ZEND_API ZEND_ATTRIBUTE_PURE zval* ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h);
180+
ZEND_API ZEND_ATTRIBUTE_PURE zval* ZEND_FASTCALL _zend_hash_index_find(const HashTable *ht, zend_ulong h);
181181

182182
/* The same as zend_hash_find(), but hash value of the key must be already calculated. */
183-
ZEND_API zval* ZEND_FASTCALL zend_hash_find_known_hash(const HashTable *ht, const zend_string *key);
183+
ZEND_API ZEND_ATTRIBUTE_PURE zval* ZEND_FASTCALL zend_hash_find_known_hash(const HashTable *ht, const zend_string *key);
184184

185-
static zend_always_inline zval *zend_hash_find_ex(const HashTable *ht, zend_string *key, bool known_hash)
185+
static ZEND_ATTRIBUTE_PURE zend_always_inline zval *zend_hash_find_ex(const HashTable *ht, zend_string *key, bool known_hash)
186186
{
187187
if (known_hash) {
188188
return zend_hash_find_known_hash(ht, key);
@@ -211,8 +211,8 @@ static zend_always_inline zval *zend_hash_find_ex(const HashTable *ht, zend_stri
211211

212212

213213
/* Find or add NULL, if doesn't exist */
214-
ZEND_API zval* ZEND_FASTCALL zend_hash_lookup(HashTable *ht, zend_string *key);
215-
ZEND_API zval* ZEND_FASTCALL zend_hash_index_lookup(HashTable *ht, zend_ulong h);
214+
ZEND_API ZEND_ATTRIBUTE_PURE zval* ZEND_FASTCALL zend_hash_lookup(HashTable *ht, zend_string *key);
215+
ZEND_API ZEND_ATTRIBUTE_PURE zval* ZEND_FASTCALL zend_hash_index_lookup(HashTable *ht, zend_ulong h);
216216

217217
#define ZEND_HASH_INDEX_LOOKUP(_ht, _h, _ret) do { \
218218
if (EXPECTED(HT_FLAGS(_ht) & HASH_FLAG_PACKED)) { \
@@ -294,7 +294,7 @@ ZEND_API void zend_hash_bucket_renum_swap(Bucket *p, Bucket *q);
294294
ZEND_API void zend_hash_bucket_packed_swap(Bucket *p, Bucket *q);
295295

296296
typedef int (*bucket_compare_func_t)(Bucket *a, Bucket *b);
297-
ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, bool ordered);
297+
ZEND_API ZEND_ATTRIBUTE_PURE int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, bool ordered);
298298
ZEND_API void ZEND_FASTCALL zend_hash_sort_ex(HashTable *ht, sort_func_t sort_func, bucket_compare_func_t compare_func, bool renumber);
299299
void ZEND_FASTCALL zend_array_sort_ex(HashTable *ht, sort_func_t sort_func, bucket_compare_func_t compare_func, bool renumber);
300300
ZEND_API zval* ZEND_FASTCALL zend_hash_minmax(const HashTable *ht, compare_func_t compar, uint32_t flag);

Zend/zend_multibyte.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf8;
5959
/* multibyte utility functions */
6060
ZEND_API zend_result zend_multibyte_set_functions(const zend_multibyte_functions *functions);
6161
ZEND_API void zend_multibyte_restore_functions(void);
62-
ZEND_API const zend_multibyte_functions *zend_multibyte_get_functions(void);
62+
ZEND_API ZEND_ATTRIBUTE_PURE const zend_multibyte_functions *zend_multibyte_get_functions(void);
6363

64-
ZEND_API const zend_encoding *zend_multibyte_fetch_encoding(const char *name);
65-
ZEND_API const char *zend_multibyte_get_encoding_name(const zend_encoding *encoding);
66-
ZEND_API int zend_multibyte_check_lexer_compatibility(const zend_encoding *encoding);
64+
ZEND_API ZEND_ATTRIBUTE_PURE const zend_encoding *zend_multibyte_fetch_encoding(const char *name);
65+
ZEND_API ZEND_ATTRIBUTE_PURE const char *zend_multibyte_get_encoding_name(const zend_encoding *encoding);
66+
ZEND_API ZEND_ATTRIBUTE_PURE int zend_multibyte_check_lexer_compatibility(const zend_encoding *encoding);
6767
ZEND_API const zend_encoding *zend_multibyte_encoding_detector(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size);
6868
ZEND_API size_t zend_multibyte_encoding_converter(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from);
6969
ZEND_API int zend_multibyte_parse_encoding_list(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent);
7070

71-
ZEND_API const zend_encoding *zend_multibyte_get_internal_encoding(void);
72-
ZEND_API const zend_encoding *zend_multibyte_get_script_encoding(void);
71+
ZEND_API ZEND_ATTRIBUTE_PURE const zend_encoding *zend_multibyte_get_internal_encoding(void);
72+
ZEND_API ZEND_ATTRIBUTE_PURE const zend_encoding *zend_multibyte_get_script_encoding(void);
7373
ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_list, size_t encoding_list_size);
7474
ZEND_API int zend_multibyte_set_internal_encoding(const zend_encoding *encoding);
7575
ZEND_API zend_result zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length);

Zend/zend_objects_API.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static zend_always_inline void *zend_object_alloc(size_t obj_size, zend_class_en
9494
return obj;
9595
}
9696

97-
static inline zend_property_info *zend_get_property_info_for_slot(zend_object *obj, zval *slot)
97+
static inline ZEND_ATTRIBUTE_PURE zend_property_info *zend_get_property_info_for_slot(zend_object *obj, zval *slot)
9898
{
9999
zend_property_info **table = obj->ce->properties_info_table;
100100
intptr_t prop_num = slot - obj->properties_table;
@@ -103,7 +103,7 @@ static inline zend_property_info *zend_get_property_info_for_slot(zend_object *o
103103
}
104104

105105
/* Helper for cases where we're only interested in property info of typed properties. */
106-
static inline zend_property_info *zend_get_typed_property_info_for_slot(zend_object *obj, zval *slot)
106+
static inline ZEND_ATTRIBUTE_PURE zend_property_info *zend_get_typed_property_info_for_slot(zend_object *obj, zval *slot)
107107
{
108108
zend_property_info *prop_info = zend_get_property_info_for_slot(obj, slot);
109109
if (prop_info && ZEND_TYPE_IS_SET(prop_info->type)) {

0 commit comments

Comments
 (0)