Skip to content

Commit 657126f

Browse files
committed
Add [UN]EXPECTED hints
1 parent b4c3b85 commit 657126f

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

Zend/zend_execute.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3209,7 +3209,7 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
32093209
* to make sure no actual modification is possible. */
32103210
ZEND_ASSERT(type == BP_VAR_W || type == BP_VAR_RW || type == BP_VAR_UNSET);
32113211
if (Z_TYPE_P(ptr) == IS_OBJECT
3212-
&& !(Z_OBJCE_P(ptr)->ce_flags & ZEND_ACC_DATA_CLASS)) {
3212+
&& EXPECTED(!(Z_OBJCE_P(ptr)->ce_flags & ZEND_ACC_DATA_CLASS))) {
32133213
ZVAL_COPY(result, ptr);
32143214
} else if (Z_PROP_FLAG_P(ptr) & IS_PROP_REINITABLE) {
32153215
Z_PROP_FLAG_P(ptr) &= ~IS_PROP_REINITABLE;

Zend/zend_object_handlers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ ZEND_API zval *zend_std_read_property(zend_object *zobj, zend_string *name, int
624624
if (prop_info && UNEXPECTED(prop_info->flags & ZEND_ACC_READONLY)
625625
&& (type == BP_VAR_W || type == BP_VAR_RW || type == BP_VAR_UNSET)) {
626626
if (Z_TYPE_P(retval) == IS_OBJECT
627-
&& !(Z_OBJCE_P(retval)->ce_flags & ZEND_ACC_DATA_CLASS)) {
627+
&& EXPECTED(!(Z_OBJCE_P(retval)->ce_flags & ZEND_ACC_DATA_CLASS))) {
628628
/* For objects, W/RW/UNSET fetch modes might not actually modify object.
629629
* Similar as with magic __get() allow them, but return the value as a copy
630630
* to make sure no actual modification is possible. */

Zend/zend_operators.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2452,7 +2452,7 @@ ZEND_API bool ZEND_FASTCALL zend_is_identical(const zval *op1, const zval *op2)
24522452
if (Z_OBJ_P(op1) == Z_OBJ_P(op2)) {
24532453
return true;
24542454
}
2455-
if ((Z_OBJCE_P(op1)->ce_flags & ZEND_ACC_DATA_CLASS)
2455+
if (UNEXPECTED(Z_OBJCE_P(op1)->ce_flags & ZEND_ACC_DATA_CLASS)
24562456
&& Z_OBJCE_P(op1) == Z_OBJCE_P(op2)) {
24572457
return zend_is_identical_data_class(op1, op2);
24582458
}

Zend/zend_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,7 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) {
15301530
zval *_zv = (zv); \
15311531
ZEND_ASSERT(Z_TYPE_P(_zv) == IS_OBJECT); \
15321532
zend_object *obj = Z_OBJ_P(_zv); \
1533-
if ((obj->ce->ce_flags & ZEND_ACC_DATA_CLASS) \
1533+
if (UNEXPECTED(obj->ce->ce_flags & ZEND_ACC_DATA_CLASS) \
15341534
&& GC_REFCOUNT(obj) > 1) { \
15351535
zend_object_clone_obj_t clone_call = obj->handlers->clone_obj; \
15361536
ZEND_ASSERT(clone_call); \

Zend/zend_vm_def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9105,7 +9105,7 @@ ZEND_VM_HOT_HANDLER(184, ZEND_FETCH_THIS, UNUSED, UNUSED)
91059105
if (EXPECTED(Z_TYPE(EX(This)) == IS_OBJECT)) {
91069106
zval *result = EX_VAR(opline->result.var);
91079107

9108-
if (!(Z_OBJCE(EX(This))->ce_flags & ZEND_ACC_DATA_CLASS)) {
9108+
if (EXPECTED(!(Z_OBJCE(EX(This))->ce_flags & ZEND_ACC_DATA_CLASS))) {
91099109
ZVAL_OBJ(result, Z_OBJ(EX(This)));
91109110
Z_ADDREF_P(result);
91119111
} else {

ext/reflection/php_reflection.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3434,7 +3434,7 @@ static void reflection_method_invoke(INTERNAL_FUNCTION_PARAMETERS, int variadic)
34343434
RETURN_THROWS();
34353435
}
34363436

3437-
if (Z_OBJCE_P(object)->ce_flags & ZEND_ACC_DATA_CLASS) {
3437+
if (UNEXPECTED(Z_OBJCE_P(object)->ce_flags & ZEND_ACC_DATA_CLASS)) {
34383438
zend_throw_exception_ex(reflection_exception_ptr, 0,
34393439
"May not invoke mutating method \"%s::%s()\" through reflection",
34403440
ZSTR_VAL(Z_OBJCE_P(object)->name), ZSTR_VAL(mptr->common.function_name));
@@ -5775,7 +5775,7 @@ ZEND_METHOD(ReflectionProperty, setValue)
57755775
RETURN_THROWS();
57765776
}
57775777

5778-
if (Z_OBJCE_P(object)->ce_flags & ZEND_ACC_DATA_CLASS) {
5778+
if (UNEXPECTED(Z_OBJCE_P(object)->ce_flags & ZEND_ACC_DATA_CLASS)) {
57795779
zend_throw_exception_ex(reflection_exception_ptr, 0,
57805780
"May not set property value of data class \"%s\" through reflection",
57815781
ZSTR_VAL(Z_OBJCE_P(object)->name));

0 commit comments

Comments
 (0)