Skip to content

Commit

Permalink
Drop various unused macros/APIs
Browse files Browse the repository at this point in the history
Also convert_libmagic_pattern() to return a zend_string*

Closes GH-6029
  • Loading branch information
Girgias committed Aug 26, 2020
1 parent ebbe333 commit 1b2ec73
Show file tree
Hide file tree
Showing 26 changed files with 111 additions and 114 deletions.
12 changes: 12 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ PHP 8.0 INTERNALS UPGRADE NOTES
s. zend_fcall_info no_separation flag removed
t. Signature changes
u. Error Notification callbacks to replace zend_error_cb overwrite use-cases
v. Removed Zend APIs

2. Build system changes
a. Abstract
Expand Down Expand Up @@ -201,6 +202,17 @@ PHP 8.0 INTERNALS UPGRADE NOTES
}
zend_register_error_notify_callback(my_error_notify_cb);

v. The following APIs have been removed from the Zend Engine:
- zend_ts_hash_init_ex(), drop the last argument and use zend_ts_hash_init() instead
- zend_hash_init_ex(), drop the last argument and use zend_hash_init() instead
- zval_internal_dtor(), use zval_internal_ptr_dtor() instead
- zval_dtor_func(), use rc_dtor_func() instead
- zval_ptr_dtor_wrapper(), use zval_ptr_dtor() instead
- zval_internal_ptr_dtor_wrapper(), use zval_internal_ptr_dtor() instead

w. The following APIs have been renamed:
- _zend_ts_hash_init() to zend_ts_hash_init()

========================
2. Build system changes
========================
Expand Down
16 changes: 8 additions & 8 deletions Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,17 +650,17 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals) /* {{
compiler_globals->compiled_filename = NULL;

compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable));
zend_hash_init_ex(compiler_globals->function_table, 1024, NULL, ZEND_FUNCTION_DTOR, 1, 0);
zend_hash_init(compiler_globals->function_table, 1024, NULL, ZEND_FUNCTION_DTOR, 1);
zend_hash_copy(compiler_globals->function_table, global_function_table, function_copy_ctor);

compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable));
zend_hash_init_ex(compiler_globals->class_table, 64, NULL, ZEND_CLASS_DTOR, 1, 0);
zend_hash_init(compiler_globals->class_table, 64, NULL, ZEND_CLASS_DTOR, 1);
zend_hash_copy(compiler_globals->class_table, global_class_table, zend_class_add_ref);

zend_set_default_compile_time_values();

compiler_globals->auto_globals = (HashTable *) malloc(sizeof(HashTable));
zend_hash_init_ex(compiler_globals->auto_globals, 8, NULL, auto_global_dtor, 1, 0);
zend_hash_init(compiler_globals->auto_globals, 8, NULL, auto_global_dtor, 1);
zend_hash_copy(compiler_globals->auto_globals, global_auto_globals_table, auto_global_copy_ctor);

compiler_globals->script_encoding_list = NULL;
Expand Down Expand Up @@ -894,12 +894,12 @@ int zend_startup(zend_utility_functions *utility_functions) /* {{{ */
GLOBAL_AUTO_GLOBALS_TABLE = (HashTable *) malloc(sizeof(HashTable));
GLOBAL_CONSTANTS_TABLE = (HashTable *) malloc(sizeof(HashTable));

zend_hash_init_ex(GLOBAL_FUNCTION_TABLE, 1024, NULL, ZEND_FUNCTION_DTOR, 1, 0);
zend_hash_init_ex(GLOBAL_CLASS_TABLE, 64, NULL, ZEND_CLASS_DTOR, 1, 0);
zend_hash_init_ex(GLOBAL_AUTO_GLOBALS_TABLE, 8, NULL, auto_global_dtor, 1, 0);
zend_hash_init_ex(GLOBAL_CONSTANTS_TABLE, 128, NULL, ZEND_CONSTANT_DTOR, 1, 0);
zend_hash_init(GLOBAL_FUNCTION_TABLE, 1024, NULL, ZEND_FUNCTION_DTOR, 1);
zend_hash_init(GLOBAL_CLASS_TABLE, 64, NULL, ZEND_CLASS_DTOR, 1);
zend_hash_init(GLOBAL_AUTO_GLOBALS_TABLE, 8, NULL, auto_global_dtor, 1);
zend_hash_init(GLOBAL_CONSTANTS_TABLE, 128, NULL, ZEND_CONSTANT_DTOR, 1);

zend_hash_init_ex(&module_registry, 32, NULL, module_destructor_zval, 1, 0);
zend_hash_init(&module_registry, 32, NULL, module_destructor_zval, 1);
zend_init_rsrc_list_dtors();

#ifdef ZTS
Expand Down
6 changes: 3 additions & 3 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1810,9 +1810,9 @@ ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify

ce->default_properties_table = NULL;
ce->default_static_members_table = NULL;
zend_hash_init_ex(&ce->properties_info, 8, NULL, (persistent_hashes ? zend_destroy_property_info_internal : NULL), persistent_hashes, 0);
zend_hash_init_ex(&ce->constants_table, 8, NULL, NULL, persistent_hashes, 0);
zend_hash_init_ex(&ce->function_table, 8, NULL, ZEND_FUNCTION_DTOR, persistent_hashes, 0);
zend_hash_init(&ce->properties_info, 8, NULL, (persistent_hashes ? zend_destroy_property_info_internal : NULL), persistent_hashes);
zend_hash_init(&ce->constants_table, 8, NULL, NULL, persistent_hashes);
zend_hash_init(&ce->function_table, 8, NULL, ZEND_FUNCTION_DTOR, persistent_hashes);

if (ce->type == ZEND_INTERNAL_CLASS) {
ZEND_MAP_PTR_INIT(ce->static_members_table, NULL);
Expand Down
2 changes: 0 additions & 2 deletions Zend/zend_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ ZEND_API void ZEND_FASTCALL zend_hash_clean(HashTable *ht);

#define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent) \
_zend_hash_init((ht), (nSize), (pDestructor), (persistent))
#define zend_hash_init_ex(ht, nSize, pHashFunction, pDestructor, persistent, bApplyProtection) \
_zend_hash_init((ht), (nSize), (pDestructor), (persistent))

ZEND_API void ZEND_FASTCALL zend_hash_real_init(HashTable *ht, zend_bool packed);
ZEND_API void ZEND_FASTCALL zend_hash_real_init_packed(HashTable *ht);
Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ ZEND_API int zend_ini_startup(void) /* {{{ */
EG(ini_directives) = registered_zend_ini_directives;
EG(modified_ini_directives) = NULL;
EG(error_reporting_ini_entry) = NULL;
zend_hash_init_ex(registered_zend_ini_directives, 128, NULL, free_ini_entry, 1, 0);
zend_hash_init(registered_zend_ini_directives, 128, NULL, free_ini_entry, 1);
return SUCCESS;
}
/* }}} */
Expand Down Expand Up @@ -164,7 +164,7 @@ ZEND_API int zend_copy_ini_directives(void) /* {{{ */
EG(modified_ini_directives) = NULL;
EG(error_reporting_ini_entry) = NULL;
EG(ini_directives) = (HashTable *) malloc(sizeof(HashTable));
zend_hash_init_ex(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, free_ini_entry, 1, 0);
zend_hash_init(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, free_ini_entry, 1);
zend_hash_copy(EG(ini_directives), registered_zend_ini_directives, copy_ini_entry);
return SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_language_scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ ZEND_API zend_ast *zend_compile_string_to_ast(
zend_restore_lexical_state(&original_lex_state);
CG(in_compilation) = original_in_compilation;

zval_dtor(&code_zv);
zval_ptr_dtor_str(&code_zv);

return ast;
}
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ ZEND_API int zend_init_rsrc_list(void)

int zend_init_rsrc_plist(void)
{
zend_hash_init_ex(&EG(persistent_list), 8, NULL, plist_entry_destructor, 1, 0);
zend_hash_init(&EG(persistent_list), 8, NULL, plist_entry_destructor, 1);
return SUCCESS;
}

Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_ts_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static void end_write(TsHashTable *ht)
}

/* delegates */
ZEND_API void _zend_ts_hash_init(TsHashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent)
ZEND_API void zend_ts_hash_init(TsHashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent)
{
#ifdef ZTS
ht->mx_reader = tsrm_mutex_alloc();
Expand Down
7 changes: 1 addition & 6 deletions Zend/zend_ts_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,10 @@ BEGIN_EXTERN_C()
#define TS_HASH(table) (&(table->hash))

/* startup/shutdown */
ZEND_API void _zend_ts_hash_init(TsHashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent);
ZEND_API void zend_ts_hash_init(TsHashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent);
ZEND_API void zend_ts_hash_destroy(TsHashTable *ht);
ZEND_API void zend_ts_hash_clean(TsHashTable *ht);

#define zend_ts_hash_init(ht, nSize, pHashFunction, pDestructor, persistent) \
_zend_ts_hash_init(ht, nSize, pDestructor, persistent)
#define zend_ts_hash_init_ex(ht, nSize, pHashFunction, pDestructor, persistent, bApplyProtection) \
_zend_ts_hash_init(ht, nSize, pDestructor, persistent)


/* additions/updates/changes */
ZEND_API zval *zend_ts_hash_update(TsHashTable *ht, zend_string *key, zval *pData);
Expand Down
4 changes: 0 additions & 4 deletions Zend/zend_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ ZEND_API void zval_internal_ptr_dtor(zval *zvalue);

/* Kept for compatibility */
#define zval_dtor(zvalue) zval_ptr_dtor_nogc(zvalue)
#define zval_internal_dtor(zvalue) zval_internal_ptr_dtor(zvalue)
#define zval_dtor_func rc_dtor_func
#define zval_ptr_dtor_wrapper zval_ptr_dtor
#define zval_internal_ptr_dtor_wrapper zval_internal_ptr_dtor

ZEND_API void zval_add_ref(zval *p);

Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_vm_execute.h
Original file line number Diff line number Diff line change
Expand Up @@ -61625,7 +61625,7 @@ static void init_opcode_serialiser(void)
zval tmp;

zend_handlers_table = malloc(sizeof(HashTable));
zend_hash_init_ex(zend_handlers_table, zend_handlers_count, NULL, NULL, 1, 0);
zend_hash_init(zend_handlers_table, zend_handlers_count, NULL, NULL, 1);
zend_hash_real_init(zend_handlers_table, 0);
Z_TYPE_INFO(tmp) = IS_LONG;
for (i = 0; i < zend_handlers_count; i++) {
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_vm_execute.skl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static void init_opcode_serialiser(void)
zval tmp;

zend_handlers_table = malloc(sizeof(HashTable));
zend_hash_init_ex(zend_handlers_table, zend_handlers_count, NULL, NULL, 1, 0);
zend_hash_init(zend_handlers_table, zend_handlers_count, NULL, NULL, 1);
zend_hash_real_init(zend_handlers_table, 0);
Z_TYPE_INFO(tmp) = IS_LONG;
for (i = 0; i < zend_handlers_count; i++) {
Expand Down

0 comments on commit 1b2ec73

Please sign in to comment.