Skip to content

Commit 21e0beb

Browse files
committed
Merge branch 'immutable' into preload
* immutable: Added comment Added type cast Moved static class members initialization into the proper place. Removed redundand assertion Removed duplicate code Hide offset encoding magic in ZEND_MAP_PTR_IS_OFFSET(), ZEND_MAP_PTR_OFFSET2PTR() and ZEND_MAP_PTR_PTR2OFFSET() macros. typo Remove unused variable makefile_am_files Classify object handlers are required/optional Add support for getting SKIP_TAGSTART and SKIP_WHITE options Remove some obsolete config_vars.mk occurrences Remove bsd_converted from .gitignore Remove configuration parser and scanners ignores Remove obsolete buildconf.stamp from .gitignore [ci skip] Add magicdata.patch exception to .gitignore Remove outdated ext/spl/examples items from .gitignore Remove unused test.inc in ext/iconv/tests
2 parents c78277a + ad7a78b commit 21e0beb

32 files changed

+668
-1277
lines changed

.gitignore

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ _libs
3838
acconfig.h
3939
aclocal.m4
4040
autom4te.cache
41-
bsd_converted
42-
buildconf.stamp
4341
buildmk.stamp
4442
confdefs.h
4543
config.h
@@ -48,11 +46,6 @@ config.h.in
4846
config.log
4947
config.nice
5048
config.status
51-
config_vars.mk
52-
configuration-parser.c
53-
configuration-parser.h
54-
configuration-parser.output
55-
configuration-scanner.c
5649
configure
5750
conftest
5851
conftest.c
@@ -172,8 +165,6 @@ ext/phar/phar.phar
172165
ext/phar/phar.1
173166
ext/phar/phar.phar.1
174167
ext/phar/phar.php
175-
ext/spl/examples/.htaccess
176-
ext/spl/examples/*.phps
177168
ext/sqlite3/tests/phpsql*
178169

179170
# ------------------------------------------------------------------------------ Windows
@@ -205,5 +196,6 @@ ext/sqlite3/tests/phpsql*
205196

206197
# Special cases to invert previous ignore rules
207198
!ext/fileinfo/libmagic.patch
199+
!ext/fileinfo/magicdata.patch
208200
!ext/mbstring/oniguruma.patch
209201
!ext/pcre/pcre2lib/config.h

UPGRADING.INTERNALS

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ PHP 7.4 INTERNALS UPGRADE NOTES
77
d. Removed zend_check_private()
88
e. php_win32_error_to_msg() memory management
99
f. get_properties_for() handler / Z_OBJDEBUG_P
10-
g. Immutable classes and op_arrays
10+
g. Required object handlers
11+
h. Immutable classes and op_arrays
1112

1213
2. Build system changes
1314
a. Abstract
@@ -99,15 +100,37 @@ PHP 7.4 INTERNALS UPGRADE NOTES
99100
// ...
100101
zend_release_properties(ht);
101102

102-
g. Opcache may make classes and op_arrays immutable. Such classes are marked
103+
g. The following object handlers are now required (must be non-NULL):
104+
105+
* free_obj
106+
* dtor_obj
107+
* read_property
108+
* write_property
109+
* read_dimension
110+
* write_dimension
111+
* get_property_ptr_ptr
112+
* has_property
113+
* unset_property
114+
* has_dimension
115+
* unset_dimension
116+
* get_properties
117+
* get_method
118+
* get_constructor
119+
* get_class_name
120+
* get_gc
121+
122+
It is recommended to initialize object handler structures by copying the
123+
std object handlers and only overwriting those you want to change.
124+
125+
h. Opcache may make classes and op_arrays immutable. Such classes are marked
103126
by ZEND_ACC_IMMUTABLE flag, they are not going to be copied from opcache
104-
shard memory to process memory and must not be modified at all.
127+
shared memory to process memory and must not be modified at all.
105128
Few related data structures were changed to allow addressing mutable data
106129
structures from immutable ones. This access is implemented through
107130
ZEND_MAP_PTR... abstraction macros and, basically, uses additional level of
108131
indirection. op_array->run_time_cache, op_array->static_variables_ptr,
109132
class_entry->static_members_table and class_entry->iterator_funcs_ptr now
110-
have to be access through ZEND_MAP_PTR... macros.
133+
have to be accessed through ZEND_MAP_PTR... macros.
111134
It's also not allowed to change op_array->reserved[] handles of immutable
112135
op_arrays. Instead, now you have to reserve op_array handle using
113136
zend_get_op_array_extension_handle() during MINIT and access its value

Zend/zend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,7 @@ ZEND_API void *zend_map_ptr_new(void)
16761676
#if ZEND_MAP_PTR_KIND == ZEND_MAP_PTR_KIND_PTR
16771677
return ptr;
16781678
#elif ZEND_MAP_PTR_KIND == ZEND_MAP_PTR_KIND_PTR_OR_OFFSET
1679-
return (void*)((CG(map_ptr_last) * sizeof(void*)) - (sizeof(void*) - 1));
1679+
return ZEND_MAP_PTR_PTR2OFFSET(ptr);
16801680
#else
16811681
# error "Unknown ZEND_MAP_PTR_KIND"
16821682
#endif

Zend/zend_API.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3116,7 +3116,7 @@ static zend_always_inline int zend_is_callable_check_func(int check_flags, zval
31163116
fcc->function_handler = zend_get_call_trampoline_func(ce_org, mname, 0);
31173117
call_via_handler = 1;
31183118
retval = 1;
3119-
} else if (fcc->object->handlers->get_method) {
3119+
} else {
31203120
fcc->function_handler = fcc->object->handlers->get_method(&fcc->object, mname, NULL);
31213121
if (fcc->function_handler) {
31223122
if (strict_class &&
@@ -3933,9 +3933,6 @@ ZEND_API void zend_update_property_ex(zend_class_entry *scope, zval *object, zen
39333933

39343934
EG(fake_scope) = scope;
39353935

3936-
if (!Z_OBJ_HT_P(object)->write_property) {
3937-
zend_error_noreturn(E_CORE_ERROR, "Property %s of class %s cannot be updated", ZSTR_VAL(name), ZSTR_VAL(Z_OBJCE_P(object)->name));
3938-
}
39393936
ZVAL_STR(&property, name);
39403937
Z_OBJ_HT_P(object)->write_property(object, &property, value, NULL);
39413938

@@ -3950,9 +3947,6 @@ ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, const
39503947

39513948
EG(fake_scope) = scope;
39523949

3953-
if (!Z_OBJ_HT_P(object)->write_property) {
3954-
zend_error_noreturn(E_CORE_ERROR, "Property %s of class %s cannot be updated", name, ZSTR_VAL(Z_OBJCE_P(object)->name));
3955-
}
39563950
ZVAL_STRINGL(&property, name, name_length);
39573951
Z_OBJ_HT_P(object)->write_property(object, &property, value, NULL);
39583952
zval_ptr_dtor(&property);
@@ -3977,9 +3971,6 @@ ZEND_API void zend_unset_property(zend_class_entry *scope, zval *object, const c
39773971

39783972
EG(fake_scope) = scope;
39793973

3980-
if (!Z_OBJ_HT_P(object)->unset_property) {
3981-
zend_error_noreturn(E_CORE_ERROR, "Property %s of class %s cannot be unset", name, ZSTR_VAL(Z_OBJCE_P(object)->name));
3982-
}
39833974
ZVAL_STRINGL(&property, name, name_length);
39843975
Z_OBJ_HT_P(object)->unset_property(object, &property, 0);
39853976
zval_ptr_dtor(&property);
@@ -4141,10 +4132,6 @@ ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zval *object, zend
41414132

41424133
EG(fake_scope) = scope;
41434134

4144-
if (!Z_OBJ_HT_P(object)->read_property) {
4145-
zend_error_noreturn(E_CORE_ERROR, "Property %s of class %s cannot be read", ZSTR_VAL(name), ZSTR_VAL(Z_OBJCE_P(object)->name));
4146-
}
4147-
41484135
ZVAL_STR(&property, name);
41494136
value = Z_OBJ_HT_P(object)->read_property(object, &property, silent?BP_VAR_IS:BP_VAR_R, NULL, rv);
41504137

Zend/zend_builtin_functions.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ ZEND_FUNCTION(method_exists)
13381338
if (zend_hash_exists(&ce->function_table, lcname)) {
13391339
zend_string_release_ex(lcname, 0);
13401340
RETURN_TRUE;
1341-
} else if (Z_TYPE_P(klass) == IS_OBJECT && Z_OBJ_HT_P(klass)->get_method != NULL) {
1341+
} else if (Z_TYPE_P(klass) == IS_OBJECT) {
13421342
zend_object *obj = Z_OBJ_P(klass);
13431343
zend_function *func = Z_OBJ_HT_P(klass)->get_method(&obj, method_name, NULL);
13441344
if (func != NULL) {
@@ -1401,7 +1401,6 @@ ZEND_FUNCTION(property_exists)
14011401
ZVAL_STR(&property_z, property);
14021402

14031403
if (Z_TYPE_P(object) == IS_OBJECT &&
1404-
Z_OBJ_HANDLER_P(object, has_property) &&
14051404
Z_OBJ_HANDLER_P(object, has_property)(object, &property_z, 2, NULL)) {
14061405
RETURN_TRUE;
14071406
}

Zend/zend_compile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ struct _zend_execute_data {
668668
ZEND_MAP_PTR_GET((op_array)->run_time_cache)
669669

670670
#define ZEND_OP_ARRAY_EXTENSION(op_array, handle) \
671-
RUN_TIME_CACHE(op_array)[handle]
671+
((void**)RUN_TIME_CACHE(op_array))[handle]
672672

673673
#if ZEND_EX_USE_RUN_TIME_CACHE
674674

0 commit comments

Comments
 (0)