Skip to content

Better c zend api #6002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 65 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
9e58187
Voidify functions in zend.c
Girgias Aug 15, 2020
826c788
Boolify functions in zend.c
Girgias Aug 15, 2020
976f9b1
Voidify functions in zend_alloc.c
Girgias Aug 15, 2020
60019a9
Boolify functions in zend_alloc.c
Girgias Aug 15, 2020
3130976
Boolify functions in zend_API.c
Girgias Aug 15, 2020
26f0ad7
Boolify functions in zend_ast.c
Girgias Aug 15, 2020
06f1fba
Boolify functions in zend_attributes.c
Girgias Aug 15, 2020
76e6762
Boolify functions in zend_bitset.h
Girgias Aug 15, 2020
002c1f6
Boolify functions in zend_builtin_functions.c
Girgias Aug 15, 2020
a35d350
Boolify functions in zend_closure.c
Girgias Aug 15, 2020
640bb8b
boolify zend_constant.c
Girgias Aug 15, 2020
88efdd1
Boolify zend_exception.c
Girgias Aug 15, 2020
efef6f7
Voidify zend_execute.c
Girgias Aug 15, 2020
ef1fe77
Boolify zend_execute.c
Girgias Aug 15, 2020
9141257
Drop zend_handle_sigsegv() unused var
Girgias Aug 15, 2020
7f478fd
Boolify zend_extensions.c
Girgias Aug 15, 2020
700448c
Voidify zend_extensions.c
Girgias Aug 15, 2020
b7d5d01
Fix zend_extension
Girgias Aug 16, 2020
abcb59a
Boolify zend_gdb.c
Girgias Aug 15, 2020
5d70fe8
Boolify zend_generator.c
Girgias Aug 15, 2020
d70cbaf
Boolify zend_hash.c
Girgias Aug 15, 2020
2f7ed86
Boolify zend_highlight.c
Girgias Aug 15, 2020
71b5d1b
Boolify zend_inheritence.c
Girgias Aug 15, 2020
315d298
Boolify zend_ini.c
Girgias Aug 15, 2020
ce33408
Voidify zend_ini.c
Girgias Aug 15, 2020
801605f
Fix zend.c after voidification of zend_copy_ini_directives()
Girgias Aug 16, 2020
8d36546
Boolify zend_interface.c
Girgias Aug 15, 2020
34766d7
Boolify zend_language_scanner.l
Girgias Aug 15, 2020
c389890
Voidify language_scanner.l
Girgias Aug 16, 2020
b915d59
Voidify zend_list.c
Girgias Aug 15, 2020
1889901
Boolify zend_list.c
Girgias Aug 15, 2020
3542add
Boolify zend_multibyte.c
Girgias Aug 15, 2020
ba8a0a3
Boolify zend_multiply.h
Girgias Aug 15, 2020
b935df4
Boolify zend_object_handler.c
Girgias Aug 15, 2020
b73b448
Revert "Boolify zend_object_handler.c"
Girgias Aug 16, 2020
13b326e
Voidify zend_opcode.c
Girgias Aug 16, 2020
9d31dc9
Boolify zend_operators.c
Girgias Aug 16, 2020
3a6fc73
Boolify zend_signal.c
Girgias Aug 16, 2020
9fdb0dc
Voidify zend_signal.c
Girgias Aug 16, 2020
d476a97
Fix PCNTL Code due to zend_sigaction() voidification
Girgias Aug 16, 2020
22e5f71
Voidify zend_stack.c
Girgias Aug 16, 2020
efdf2d1
Boolify zend_stream.c
Girgias Aug 16, 2020
14e6f25
Boolify zend_string.c
Girgias Aug 16, 2020
d81edcb
Update FTP code after zend_list_close() voidification
Girgias Aug 16, 2020
73e6f4d
Fix streamfuncs.c due to zend_list_close() voidification
Girgias Aug 16, 2020
6d9a6c7
Fix ZIP after zend_list_close() voidification
Girgias Aug 16, 2020
f93e105
Fix Tokenizer extension after voidification of zend_prepare_string_fo…
Girgias Aug 16, 2020
f4e9196
Fix PHP_FUNCTION(highlight_string) after voidification of highlight_s…
Girgias Aug 16, 2020
36b9243
Boolify zend_virtual_cwd.c
Girgias Aug 16, 2020
bcfa1f9
Boolify zend_weakref.c
Girgias Aug 16, 2020
7f20490
Boolify zend_VM
Girgias Aug 16, 2020
ce59e42
Zend_API.h slight teak
Girgias Aug 16, 2020
32149e4
Fix zend_extension incompatible function pointer
Girgias Aug 16, 2020
0001c4b
Fix zend_stream function to be compatible for Zend LList
Girgias Aug 16, 2020
06c5779
Fix zend_module_entry enum due to zend_API changes
Girgias Aug 18, 2020
45aef0f
Fix incompatible pointer error for Zend object handlers.
Girgias Aug 20, 2020
4f8829a
Fix OpCache
Girgias Aug 20, 2020
d276dce
Shot in the dark to fix the JIT
Girgias Aug 21, 2020
39cc10b
Typedef ZEND_RESULT_CODE to zend_result
Girgias Aug 24, 2020
b548cdb
Use zend_result instead of ZEND_RESULT_CODE
Girgias Aug 24, 2020
bbc67c4
Attempt to fix some variable types in VM due to JIT failures
Girgias Aug 23, 2020
a953eaa
Partial revert of 'Shot in the dark to fix JIT'
Girgias Aug 24, 2020
3bc1ce8
Other change to see if this is root cause of JIT failure
Girgias Aug 24, 2020
85dc37f
Fix spurious change
Girgias Aug 25, 2020
9ffcda2
Update UPGRADING.INTERNALS
Girgias Aug 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 183 additions & 1 deletion UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,28 @@ PHP 8.0 INTERNALS UPGRADE NOTES
- zend_fcall_info_argp()
- zend_fcall_info_argv()
- zend_fcall_info_argn()
- zend_startup()
- zend_set_memory_limit()
- pass_two()
- zend_startup_constants()
- zend_shutdown_constants()
- zend_startup_extensions_mechanism()
- zend_startup_extensions()
- zend_register_extension()
- highlight_string()
- zend_ini_startup()
- zend_ini_shutdown()
- zend_ini_global_shutdown()
- zend_ini_deactivate()
- zend_copy_ini_directives()
- zend_prepare_string_for_scanning()
- zend_init_rsrc_list()
- zend_list_close()
- zend_signal()
- zend_sigaction()
- zend_stack_init()
- zend_stack_del_top()
- zend_stack_destroy()
2. Argument int to uint32_t in Zend Engine 4.0:
- _zend_get_parameters_array_ex()
- zend_copy_parameters_array()
Expand All @@ -169,8 +191,39 @@ PHP 8.0 INTERNALS UPGRADE NOTES
- zend_wrong_parameter*()
- zend_wrong_callback_error()
- zend_parse_arg_class()
3. Argument int to zend_bool in Zend Engine 4.0:
3. Argument int to bool in Zend Engine 4.0:
- add_next_index_bool()
- zend_register_class_alias_ex()
- add_assoc_bool_ex()
- add_index_bool()
- zend_fcall_info_args_clear()
- zend_set_local_var()
- zend_set_local_var_str()
- zend_parse_arg_*()
- shutdown_memory_manager()
- zend_memory_usage()
- zend_memory_peak_usage()
- zend_mm_shutdown()
- zend_eval_string*()
- zend_set_timeout()
- _zend_hash_append_ex()
- _zend_hash_append_ptr_ex()
- zend_alter_ini_entry_ex()
- (*zend_encoding_list_parser) typedef
- zend_multibyte_parse_encoding_list()
- zend_safe_address()
- zend_string_tolower_ex()
- zend_string_alloc()
- zend_string_safe_alloc()
- zend_string_init()
- zend_string_dup()
- zend_string_realloc()
- zend_string_extend()
- zend_string_truncate()
- zend_string_safe_realloc()
- zend_string_release_ex()
- zend_ts_hash_merge()
- zend_ts_hash_sort()
4. Argument int to size_t in Zend Engine 4.0:
- zend_set_hash_symbol()
5. Argument zval* to zend_object* in Zend Engine 4.0:
Expand All @@ -185,6 +238,135 @@ PHP 8.0 INTERNALS UPGRADE NOTES
- zend_get_exception_base()
6. Argument zval* to zend_long in Zend Engine 4.0:
- _php_math_longtobase()
7. Return type from int to zend_result in Zend Engine 4.0:
- (*stream_open_function) in _zend_utility_functions
- (*zend_post_startup_cb)
- (*zend_preload_autoload)
- zend_execute_scripts()
- zend_post_startup()
- _zend_get_parameters_array_ex()
- zend_copy_parameters_array()
- zend_parse_parameters()
- zend_parse_parameters_ex()
- zend_parse_method_parameters()
- zend_parse_method_parameters_ex()
- zend_parse_method_parameters()
- zend_register_functions()
- zend_startup_module()
- zend_startup_module_ex()
- zend_register_class_alias_ex()
- zend_disable_function()
- zend_disable_class()
- zend_update_class_constants()
- zend_update_static_property*()
- object_init_ex()
- object_and_properties_init()
- add_index_zval()
- add_next_index_long_*()
- array_set_zval_key()
- _call_user_function_impl()
- zend_fcall_info_*()
- zend_call_function()
- zend_set_hash_symbol()
- zend_delete_global_variable()
- zend_set_local_var()
- zend_set_local_var_str()
- zend_forbid_dynamic_call()
- zend_get_default_from_internal_arg_info()
- zend_try_assign_typed_ref*()
- zend_ast_evaluate()
- zend_startup_builtin_functions()
- do_bind_function()
- do_bind_class()
- zend_unmangle_property_name_ex()
- zend_register_auto_global()
- zend_register_constant()
- zend_exception_error()
- zend_eval_string*()
- zend_undefined_offset_write()
- zend_undefined_index_write()
- zval_update_constant(_ex)()
- zend_load_extension()
- zend_load_extension_handle()
- zend_hash_del(_ind)()
- zend_hash_str_del(_ind)()
- zend_hash_index_del()
- zend_hash_move_forward_ex()
- zend_hash_move_backward_ex()
- zend_hash_get_current_key_ex()
- zend_hash_get_current_key_type_ex()
- zend_symtable_del(_ind)()
- zend_symtable_str_del(_ind)()
- highlight_file()
- zend_do_link_class()
- zend_alter_ini_entry*()
- zend_restore_ini_entry()
- zend_ini_register_displayer()
- zend_ini_open_file_for_scanning()
- zend_ini_prepare_string_for_scanning()
- zend_user_it_valid()
- zend_create_internal_iterator_zval()
- zend_multibyte_set_filter()
- zend_lex_tstring()
- _zend_module_entry module_startup_func, module_shutdown_func,
request_startup_func, and request_shutdown_func function pointers
- (*zend_encoding_list_parser) typedef
- (*zend_encoding_internal_encoding_setter) typedef
- zend_multibyte_set_functions()
- zend_multibyte_set_script_encoding_by_string()
- add_function()
- sub_function()
- mul_function()
- pow_function()
- div_function()
- mod_function()
- boolean_xor_function()
- boolean_not_function()
- bitwise_not_function()
- bitwise_or_function()
- bitwise_and_function()
- bitwise_xor_function()
- shift_left_function()
- shift_right_function()
- concat_function()
- is_equal_function(
- is_identical_function()
- is_not_identical_function()
- is_not_equal_function()
- is_smaller_function()
- is_smaller_or_equal_function(zv
- increment_function()
- decrement_function()
- zend_stream_open()
- zend_stream_fixup()
- zend_ts_hash_del()
- zend_ts_hash_index_del()
8. Return type from int to bool in Zend Engine 4.0:
- zend_make_printable_zval()
- zend_parse_arg_*()
- is_zend_mm()
- is_zend_ptr()
- zend_mm_is_custom_heap()
- (*zend_mm_chunk_truncate_t)
- (*zend_mm_chunk_extend_t)
- zend_bitset_empty()
- zend_is_smart_branch()
- zend_check_arg_send_type()
- zend_verify_const_access()
- zend_gdb_register_code()
- zend_gdb_present()
- _zend_handle_numeric_str(_ex)()
- zend_hash_exists_ind()
- zend_hash_str_exists_ind()
- zend_symtable_exists(_ind)()
- zend_symtable_str_exists()
- (*zend_encoding_lexer_compatibility_checker)
- zend_object_is_true()
- i_zend_is_true()
- zendi_smart_streq()
- zend_stack_is_empty()
- zend_ts_hash_exists()
- zend_ts_hash_index_exists()

u. Instead of overwriting zend_error_cb extensions with debugging, monitoring
use-cases catching Errors/Exceptions are strongly encouraged to use
Expand Down
25 changes: 11 additions & 14 deletions Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ ZEND_API zend_class_entry *zend_standard_class_def = NULL;
ZEND_API size_t (*zend_printf)(const char *format, ...);
ZEND_API zend_write_func_t zend_write;
ZEND_API FILE *(*zend_fopen)(const char *filename, zend_string **opened_path);
ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle);
ZEND_API zend_result (*zend_stream_open_function)(const char *filename, zend_file_handle *handle);
ZEND_API void (*zend_ticks_function)(int ticks);
ZEND_API void (*zend_interrupt_function)(zend_execute_data *execute_data);
ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message);
void (*zend_printf_to_smart_string)(smart_string *buf, const char *format, va_list ap);
void (*zend_printf_to_smart_str)(smart_str *buf, const char *format, va_list ap);
ZEND_API char *(*zend_getenv)(const char *name, size_t name_len);
ZEND_API zend_string *(*zend_resolve_path)(const char *filename, size_t filename_len);
ZEND_API int (*zend_post_startup_cb)(void) = NULL;
ZEND_API zend_result (*zend_post_startup_cb)(void) = NULL;
ZEND_API void (*zend_post_shutdown_cb)(void) = NULL;
ZEND_API int (*zend_preload_autoload)(zend_string *filename) = NULL;
ZEND_API zend_result (*zend_preload_autoload)(zend_string *filename) = NULL;

/* This callback must be signal handler safe! */
void (*zend_on_timeout)(int seconds);
Expand Down Expand Up @@ -365,7 +365,7 @@ static void print_flat_hash(HashTable *ht) /* {{{ */
}
/* }}} */

ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy) /* {{{ */
ZEND_API bool zend_make_printable_zval(zval *expr, zval *expr_copy) /* {{{ */
{
if (Z_TYPE_P(expr) == IS_STRING) {
return 0;
Expand Down Expand Up @@ -757,9 +757,8 @@ static void executor_globals_dtor(zend_executor_globals *executor_globals) /* {{

static void zend_new_thread_end_handler(THREAD_T thread_id) /* {{{ */
{
if (zend_copy_ini_directives() == SUCCESS) {
zend_ini_refresh_caches(ZEND_INI_STAGE_STARTUP);
}
zend_copy_ini_directives();
zend_ini_refresh_caches(ZEND_INI_STAGE_STARTUP);
}
/* }}} */
#endif
Expand Down Expand Up @@ -803,7 +802,7 @@ static zend_bool php_auto_globals_create_globals(zend_string *name) /* {{{ */
}
/* }}} */

int zend_startup(zend_utility_functions *utility_functions) /* {{{ */
void zend_startup(zend_utility_functions *utility_functions) /* {{{ */
{
#ifdef ZTS
zend_compiler_globals *compiler_globals;
Expand Down Expand Up @@ -969,8 +968,6 @@ int zend_startup(zend_utility_functions *utility_functions) /* {{{ */
tsrm_set_new_thread_end_handler(zend_new_thread_end_handler);
tsrm_set_shutdown_handler(zend_interned_strings_dtor);
#endif

return SUCCESS;
}
/* }}} */

Expand Down Expand Up @@ -1021,7 +1018,7 @@ static void zend_resolve_property_types(void) /* {{{ */
/* Unlink the global (r/o) copies of the class, function and constant tables,
* and use a fresh r/w copy for the startup thread
*/
int zend_post_startup(void) /* {{{ */
zend_result zend_post_startup(void) /* {{{ */
{
#ifdef ZTS
zend_encoding **script_encoding_list;
Expand All @@ -1033,7 +1030,7 @@ int zend_post_startup(void) /* {{{ */
zend_resolve_property_types();

if (zend_post_startup_cb) {
int (*cb)(void) = zend_post_startup_cb;
zend_result (*cb)(void) = zend_post_startup_cb;

zend_post_startup_cb = NULL;
if (cb() != SUCCESS) {
Expand Down Expand Up @@ -1665,13 +1662,13 @@ ZEND_API ZEND_COLD void zend_user_exception_handler(void) /* {{{ */
}
} /* }}} */

ZEND_API int zend_execute_scripts(int type, zval *retval, int file_count, ...) /* {{{ */
ZEND_API zend_result zend_execute_scripts(int type, zval *retval, int file_count, ...) /* {{{ */
{
va_list files;
int i;
zend_file_handle *file_handle;
zend_op_array *op_array;
int ret = SUCCESS;
zend_result ret = SUCCESS;

va_start(files, file_count);
for (i = 0; i < file_count; i++) {
Expand Down
14 changes: 7 additions & 7 deletions Zend/zend.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ typedef struct _zend_utility_functions {
zval *(*get_configuration_directive)(zend_string *name);
void (*ticks_function)(int ticks);
void (*on_timeout)(int seconds);
int (*stream_open_function)(const char *filename, zend_file_handle *handle);
zend_result (*stream_open_function)(const char *filename, zend_file_handle *handle);
void (*printf_to_smart_string_function)(smart_string *buf, const char *format, va_list ap);
void (*printf_to_smart_str_function)(smart_str *buf, const char *format, va_list ap);
char *(*getenv_function)(const char *name, size_t name_len);
Expand Down Expand Up @@ -227,10 +227,10 @@ typedef size_t (*zend_write_func_t)(const char *str, size_t str_length);
#define zend_first_try EG(bailout)=NULL; zend_try

BEGIN_EXTERN_C()
int zend_startup(zend_utility_functions *utility_functions);
void zend_startup(zend_utility_functions *utility_functions);
void zend_shutdown(void);
void zend_register_standard_ini_entries(void);
int zend_post_startup(void);
zend_result zend_post_startup(void);
void zend_set_utility_values(zend_utility_values *utility_values);

ZEND_API ZEND_COLD ZEND_NORETURN void _zend_bailout(const char *filename, uint32_t lineno);
Expand All @@ -246,7 +246,7 @@ ZEND_API size_t zend_spprintf_unchecked(char **message, size_t max_len, const ch
ZEND_API zend_string *zend_strpprintf_unchecked(size_t max_len, const char *format, ...);

ZEND_API const char *get_zend_version(void);
ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy);
ZEND_API bool zend_make_printable_zval(zval *expr, zval *expr_copy);
ZEND_API size_t zend_print_zval(zval *expr, int indent);
ZEND_API void zend_print_zval_r(zval *expr, int indent);
ZEND_API zend_string *zend_print_zval_r_to_str(zval *expr, int indent);
Expand Down Expand Up @@ -283,18 +283,18 @@ extern ZEND_API void (*zend_ticks_function)(int ticks);
extern ZEND_API void (*zend_interrupt_function)(zend_execute_data *execute_data);
extern ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message);
extern ZEND_API void (*zend_on_timeout)(int seconds);
extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle);
extern ZEND_API zend_result (*zend_stream_open_function)(const char *filename, zend_file_handle *handle);
extern void (*zend_printf_to_smart_string)(smart_string *buf, const char *format, va_list ap);
extern void (*zend_printf_to_smart_str)(smart_str *buf, const char *format, va_list ap);
extern ZEND_API char *(*zend_getenv)(const char *name, size_t name_len);
extern ZEND_API zend_string *(*zend_resolve_path)(const char *filename, size_t filename_len);

/* These two callbacks are especially for opcache */
extern ZEND_API int (*zend_post_startup_cb)(void);
extern ZEND_API zend_result (*zend_post_startup_cb)(void);
extern ZEND_API void (*zend_post_shutdown_cb)(void);

/* Callback for loading of not preloaded part of the script */
extern ZEND_API int (*zend_preload_autoload)(zend_string *filename);
extern ZEND_API zend_result (*zend_preload_autoload)(zend_string *filename);

ZEND_API ZEND_COLD void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
Expand Down
Loading