summaryrefslogtreecommitdiff
path: root/ext/opcache/zend_file_cache.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-09-20 17:01:19 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-11-08 15:15:48 +0100
commitac4e0f0852ce780e143013ceff45067a172e8a83 (patch)
treef39eebeb379b6f75e95a333ccec37c4af264d8ee /ext/opcache/zend_file_cache.c
parenta555cc0b3d4f745e6d0bb8c595de400a0c728827 (diff)
downloadphp-git-ac4e0f0852ce780e143013ceff45067a172e8a83.tar.gz
Make zend_type a 2-field struct
We now store the pointer payload and the type mask separately. This is in preparation for union types, where we will be using both at the same time. To avoid increasing the size of arginfo structures, the pass_by_reference and is_variadic fields are now stored as part of the type_mask (8-bit are reserved for custom use). Different types of pointer payloads are distinguished based on bits in the type_mask.
Diffstat (limited to 'ext/opcache/zend_file_cache.c')
-rw-r--r--ext/opcache/zend_file_cache.c51
1 files changed, 20 insertions, 31 deletions
diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c
index 697bb10b0d..6e4d52cee6 100644
--- a/ext/opcache/zend_file_cache.c
+++ b/ext/opcache/zend_file_cache.c
@@ -499,14 +499,9 @@ static void zend_file_cache_serialize_op_array(zend_op_array *op_arra
SERIALIZE_STR(p->name);
}
if (ZEND_TYPE_IS_CLASS(p->type)) {
- zend_bool allow_null = ZEND_TYPE_ALLOW_NULL(p->type);
zend_string *type_name = ZEND_TYPE_NAME(p->type);
-
SERIALIZE_STR(type_name);
- p->type =
- (Z_UL(1) << (sizeof(zend_type)*8-1)) | /* type is class */
- (allow_null ? (Z_UL(1) << (sizeof(zend_type)*8-2)) : Z_UL(0)) | /* type allow null */
- (zend_type)type_name;
+ ZEND_TYPE_SET_PTR(p->type, type_name);
}
p++;
}
@@ -577,16 +572,14 @@ static void zend_file_cache_serialize_prop_info(zval *zv,
SERIALIZE_STR(prop->doc_comment);
}
}
- if (prop->type) {
- if (ZEND_TYPE_IS_NAME(prop->type)) {
- zend_string *name = ZEND_TYPE_NAME(prop->type);
- SERIALIZE_STR(name);
- prop->type = ZEND_TYPE_ENCODE_CLASS(name, ZEND_TYPE_ALLOW_NULL(prop->type));
- } else if (ZEND_TYPE_IS_CE(prop->type)) {
- zend_class_entry *ce = ZEND_TYPE_CE(prop->type);
- SERIALIZE_PTR(ce);
- prop->type = ZEND_TYPE_ENCODE_CE(ce, ZEND_TYPE_ALLOW_NULL(prop->type));
- }
+ if (ZEND_TYPE_IS_NAME(prop->type)) {
+ zend_string *name = ZEND_TYPE_NAME(prop->type);
+ SERIALIZE_STR(name);
+ ZEND_TYPE_SET_PTR(prop->type, name);
+ } else if (ZEND_TYPE_IS_CE(prop->type)) {
+ zend_class_entry *ce = ZEND_TYPE_CE(prop->type);
+ SERIALIZE_PTR(ce);
+ ZEND_TYPE_SET_PTR(prop->type, ce);
}
}
}
@@ -1202,12 +1195,10 @@ static void zend_file_cache_unserialize_op_array(zend_op_array *op_arr
if (!IS_UNSERIALIZED(p->name)) {
UNSERIALIZE_STR(p->name);
}
- if (p->type & (Z_UL(1) << (sizeof(zend_type)*8-1))) { /* type is class */
- zend_bool allow_null = (p->type & (Z_UL(1) << (sizeof(zend_type)*8-2))) != 0; /* type allow null */
- zend_string *type_name = (zend_string*)(p->type & ~(((Z_UL(1) << (sizeof(zend_type)*8-1))) | ((Z_UL(1) << (sizeof(zend_type)*8-2)))));
-
+ if (ZEND_TYPE_IS_CLASS(p->type)) {
+ zend_string *type_name = ZEND_TYPE_NAME(p->type);
UNSERIALIZE_STR(type_name);
- p->type = ZEND_TYPE_ENCODE_CLASS(type_name, allow_null);
+ ZEND_TYPE_SET_PTR(p->type, type_name);
}
p++;
}
@@ -1278,16 +1269,14 @@ static void zend_file_cache_unserialize_prop_info(zval *zv,
UNSERIALIZE_STR(prop->doc_comment);
}
}
- if (prop->type) {
- if (ZEND_TYPE_IS_NAME(prop->type)) {
- zend_string *name = ZEND_TYPE_NAME(prop->type);
- UNSERIALIZE_STR(name);
- prop->type = ZEND_TYPE_ENCODE_CLASS(name, ZEND_TYPE_ALLOW_NULL(prop->type));
- } else if (ZEND_TYPE_IS_CE(prop->type)) {
- zend_class_entry *ce = ZEND_TYPE_CE(prop->type);
- UNSERIALIZE_PTR(ce);
- prop->type = ZEND_TYPE_ENCODE_CE(ce, ZEND_TYPE_ALLOW_NULL(prop->type));
- }
+ if (ZEND_TYPE_IS_NAME(prop->type)) {
+ zend_string *name = ZEND_TYPE_NAME(prop->type);
+ UNSERIALIZE_STR(name);
+ ZEND_TYPE_SET_PTR(prop->type, name);
+ } else if (ZEND_TYPE_IS_CE(prop->type)) {
+ zend_class_entry *ce = ZEND_TYPE_CE(prop->type);
+ UNSERIALIZE_PTR(ce);
+ ZEND_TYPE_SET_PTR(prop->type, ce);
}
}
}