Skip to content

Commit 00a2c30

Browse files
committed
Add extra VM operand specialization
For now RETVAL and OP_DATA= are supported
1 parent af66ad2 commit 00a2c30

File tree

5 files changed

+13259
-6007
lines changed

5 files changed

+13259
-6007
lines changed

Zend/zend_execute.c

Lines changed: 0 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,164 +1098,6 @@ static ZEND_COLD int zend_verify_missing_return_type(zend_function *zf, void **c
10981098
return 1;
10991099
}
11001100

1101-
static zend_always_inline void zend_assign_to_object(zval *retval, zval *object, uint32_t object_op_type, zval *property_name, uint32_t property_op_type, int value_type, znode_op value_op, const zend_execute_data *execute_data, void **cache_slot)
1102-
{
1103-
zend_free_op free_value;
1104-
zval *value = get_zval_ptr_r(value_type, value_op, execute_data, &free_value);
1105-
zval tmp;
1106-
1107-
if (object_op_type != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) {
1108-
do {
1109-
if (object_op_type == IS_VAR && UNEXPECTED(Z_ISERROR_P(object))) {
1110-
if (retval) {
1111-
ZVAL_NULL(retval);
1112-
}
1113-
FREE_OP(free_value);
1114-
return;
1115-
}
1116-
if (Z_ISREF_P(object)) {
1117-
object = Z_REFVAL_P(object);
1118-
if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) {
1119-
break;
1120-
}
1121-
}
1122-
if (EXPECTED(Z_TYPE_P(object) <= IS_FALSE ||
1123-
(Z_TYPE_P(object) == IS_STRING && Z_STRLEN_P(object) == 0))) {
1124-
zend_object *obj;
1125-
1126-
zval_ptr_dtor(object);
1127-
object_init(object);
1128-
Z_ADDREF_P(object);
1129-
obj = Z_OBJ_P(object);
1130-
zend_error(E_WARNING, "Creating default object from empty value");
1131-
if (GC_REFCOUNT(obj) == 1) {
1132-
/* the enclosing container was deleted, obj is unreferenced */
1133-
if (retval) {
1134-
ZVAL_NULL(retval);
1135-
}
1136-
FREE_OP(free_value);
1137-
OBJ_RELEASE(obj);
1138-
return;
1139-
}
1140-
Z_DELREF_P(object);
1141-
} else {
1142-
zend_error(E_WARNING, "Attempt to assign property of non-object");
1143-
if (retval) {
1144-
ZVAL_NULL(retval);
1145-
}
1146-
FREE_OP(free_value);
1147-
return;
1148-
}
1149-
} while (0);
1150-
}
1151-
1152-
if (property_op_type == IS_CONST &&
1153-
EXPECTED(Z_OBJCE_P(object) == CACHED_PTR_EX(cache_slot))) {
1154-
uint32_t prop_offset = (uint32_t)(intptr_t)CACHED_PTR_EX(cache_slot + 1);
1155-
zend_object *zobj = Z_OBJ_P(object);
1156-
zval *property;
1157-
1158-
if (EXPECTED(prop_offset != (uint32_t)ZEND_DYNAMIC_PROPERTY_OFFSET)) {
1159-
property = OBJ_PROP(zobj, prop_offset);
1160-
if (Z_TYPE_P(property) != IS_UNDEF) {
1161-
fast_assign:
1162-
value = zend_assign_to_variable(property, value, value_type);
1163-
if (retval && EXPECTED(!EG(exception))) {
1164-
ZVAL_COPY(retval, value);
1165-
}
1166-
return;
1167-
}
1168-
} else {
1169-
if (EXPECTED(zobj->properties != NULL)) {
1170-
if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) {
1171-
if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) {
1172-
GC_REFCOUNT(zobj->properties)--;
1173-
}
1174-
zobj->properties = zend_array_dup(zobj->properties);
1175-
}
1176-
property = zend_hash_find(zobj->properties, Z_STR_P(property_name));
1177-
if (property) {
1178-
goto fast_assign;
1179-
}
1180-
}
1181-
1182-
if (!zobj->ce->__set) {
1183-
1184-
if (EXPECTED(zobj->properties == NULL)) {
1185-
rebuild_object_properties(zobj);
1186-
}
1187-
/* separate our value if necessary */
1188-
if (value_type == IS_CONST) {
1189-
if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
1190-
ZVAL_COPY_VALUE(&tmp, value);
1191-
zval_copy_ctor_func(&tmp);
1192-
value = &tmp;
1193-
}
1194-
} else if (value_type != IS_TMP_VAR) {
1195-
if (Z_ISREF_P(value)) {
1196-
if (value_type == IS_VAR) {
1197-
zend_reference *ref = Z_REF_P(value);
1198-
if (--(GC_REFCOUNT(ref)) == 0) {
1199-
ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value));
1200-
efree_size(ref, sizeof(zend_reference));
1201-
value = &tmp;
1202-
} else {
1203-
value = Z_REFVAL_P(value);
1204-
if (Z_REFCOUNTED_P(value)) {
1205-
Z_ADDREF_P(value);
1206-
}
1207-
}
1208-
} else {
1209-
value = Z_REFVAL_P(value);
1210-
if (Z_REFCOUNTED_P(value)) {
1211-
Z_ADDREF_P(value);
1212-
}
1213-
}
1214-
} else if (value_type == IS_CV && Z_REFCOUNTED_P(value)) {
1215-
Z_ADDREF_P(value);
1216-
}
1217-
}
1218-
zend_hash_add_new(zobj->properties, Z_STR_P(property_name), value);
1219-
if (retval) {
1220-
ZVAL_COPY(retval, value);
1221-
}
1222-
return;
1223-
}
1224-
}
1225-
}
1226-
1227-
if (!Z_OBJ_HT_P(object)->write_property) {
1228-
zend_error(E_WARNING, "Attempt to assign property of non-object");
1229-
if (retval) {
1230-
ZVAL_NULL(retval);
1231-
}
1232-
FREE_OP(free_value);
1233-
return;
1234-
}
1235-
1236-
/* separate our value if necessary */
1237-
if (value_type == IS_CONST) {
1238-
if (UNEXPECTED(Z_OPT_COPYABLE_P(value))) {
1239-
ZVAL_COPY_VALUE(&tmp, value);
1240-
zval_copy_ctor_func(&tmp);
1241-
value = &tmp;
1242-
}
1243-
} else if (value_type != IS_TMP_VAR) {
1244-
ZVAL_DEREF(value);
1245-
}
1246-
1247-
Z_OBJ_HT_P(object)->write_property(object, property_name, value, cache_slot);
1248-
1249-
if (retval && EXPECTED(!EG(exception))) {
1250-
ZVAL_COPY(retval, value);
1251-
}
1252-
if (value_type == IS_CONST) {
1253-
zval_ptr_dtor_nogc(value);
1254-
} else {
1255-
FREE_OP(free_value);
1256-
}
1257-
}
1258-
12591101
static zend_never_inline void zend_assign_to_object_dim(zval *retval, zval *object, zval *property_name, int value_type, znode_op value_op, const zend_execute_data *execute_data)
12601102
{
12611103
zend_free_op free_value;

0 commit comments

Comments
 (0)