diff --git a/NEWS b/NEWS index c0d14769a227f..8d81c0cd5cc5a 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,23 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -?? ??? ????, PHP 8.0.0beta2 +?? ??? ????, PHP 8.0.0beta3 +- Calendar: + . Fixed bug #80007 (Potential type confusion in unixtojd() parameter parsing). + (Andy Postnikov) + +- COM: + . Fixed bug #55847 (DOTNET .NET 4.0 GAC new location). (cmb) + +- DOM: + . Fixed bug #79968 (DOMChildNode API crash on unattached nodes). (Benjamin) + + +20 Aug 2020, PHP 8.0.0beta2 + +- SPL: + . Fixed bug #79987 (Memory leak in SplFileInfo because of missing + zend_restore_error_handling()). (Dmitry) 06 Aug 2020, PHP 8.0.0beta1 diff --git a/UPGRADING b/UPGRADING index c74fc585ad3c4..2412b60865f5e 100644 --- a/UPGRADING +++ b/UPGRADING @@ -21,6 +21,7 @@ PHP 8.0 UPGRADE NOTES ======================================== - Core: + . `match` is now a reserved keyword. . Assertion failures now throw by default. If the old behavior is desired, then set `assert.exception=0` in INI settings. . Methods with the same name as the class are no longer interpreted as @@ -148,7 +149,7 @@ PHP 8.0 UPGRADE NOTES new class {}; // -> class@anonymous - The name shown above is still followed by a null byte and and a unique + The name shown above is still followed by a null byte and a unique suffix. . Non-absolute trait method references in trait alias adaptations are now required to be unambiguous: @@ -380,6 +381,9 @@ PHP 8.0 UPGRADE NOTES removed. - OCI8: + . The OCI-Lob class is now called OCILob, and the OCI-Collection class is now + called OCICollection for name compliance enforced by PHP 8 arginfo + type annotation tooling. . Several alias functions have been marked as deprecated. . oci_internal_debug() and its alias ociinternaldebug() have been removed. @@ -1044,6 +1048,10 @@ PHP 8.0 UPGRADE NOTES . New INI directive to set the maximum string length in an argument of a stringified stack strace. +- com.dotnet_version + . New INI directive to choose the version of the .NET framework to use for + dotnet objects. + ======================================== 12. Windows Support ======================================== diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 711ba47604c0a..301faf16cdcff 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -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 @@ -157,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() @@ -168,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: @@ -184,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 @@ -201,6 +384,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 ======================== diff --git a/Zend/tests/bug79979.phpt b/Zend/tests/bug79979.phpt new file mode 100644 index 0000000000000..d655a0edce577 --- /dev/null +++ b/Zend/tests/bug79979.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #79979 (passing value to by-ref param via CUF(A) crashes) +--FILE-- + new \stdClass]); + +\call_user_func_array("str_replace", ["a", "b", "c", new \stdClass]); +\call_user_func_array("str_replace", ["a", "b", "c", "replace_count" => new \stdClass]); + +?> +--EXPECTF-- +Warning: str_replace(): Argument #4 ($replace_count) must be passed by reference, value given in %s on line %d + +Warning: str_replace(): Argument #4 ($replace_count) must be passed by reference, value given in %s on line %d + +Warning: str_replace(): Argument #4 ($replace_count) must be passed by reference, value given in %s on line %d + +Warning: str_replace(): Argument #4 ($replace_count) must be passed by reference, value given in %s on line %d diff --git a/Zend/tests/exception_during_by_reference_magic_get.phpt b/Zend/tests/exception_during_by_reference_magic_get.phpt new file mode 100644 index 0000000000000..5732e8cc5af79 --- /dev/null +++ b/Zend/tests/exception_during_by_reference_magic_get.phpt @@ -0,0 +1,23 @@ +--TEST-- +Exception thrown by __get() during =& assignment +--FILE-- +x =& $y; +} catch (Exception $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +Foobar diff --git a/Zend/tests/generators/yield_from_non_iterable.phpt b/Zend/tests/generators/yield_from_non_iterable.phpt new file mode 100644 index 0000000000000..705bcaec3511e --- /dev/null +++ b/Zend/tests/generators/yield_from_non_iterable.phpt @@ -0,0 +1,18 @@ +--TEST-- +Yield from non-iterable +--FILE-- +current(); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +Can use "yield from" only with arrays and Traversables diff --git a/Zend/tests/named_params/cannot_pass_by_ref.phpt b/Zend/tests/named_params/cannot_pass_by_ref.phpt new file mode 100644 index 0000000000000..395ee8fa5aa71 --- /dev/null +++ b/Zend/tests/named_params/cannot_pass_by_ref.phpt @@ -0,0 +1,13 @@ +--TEST-- +Cannot pass by reference error with named parameters +--FILE-- +getMessage(), "\n"; +} +?> +--EXPECT-- +Cannot pass parameter 2 by reference diff --git a/Zend/tests/named_params/undef_var.phpt b/Zend/tests/named_params/undef_var.phpt new file mode 100644 index 0000000000000..b1d5682434067 --- /dev/null +++ b/Zend/tests/named_params/undef_var.phpt @@ -0,0 +1,17 @@ +--TEST-- +Passing undefined variabled to named arg +--FILE-- + +--EXPECTF-- +Warning: Undefined variable $undef in %s on line %d +NULL + +Warning: Undefined variable $undef in %s on line %d +NULL diff --git a/Zend/tests/named_params/unknown_named_param.phpt b/Zend/tests/named_params/unknown_named_param.phpt index f43a40c69ca62..5a18932ffd174 100644 --- a/Zend/tests/named_params/unknown_named_param.phpt +++ b/Zend/tests/named_params/unknown_named_param.phpt @@ -15,6 +15,24 @@ try { echo $e->getMessage(), "\n"; } +try { + test(b: new stdClass); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + +try { + test(b: 2, a: 1); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + +try { + test(...new ArrayIterator(['unknown' => 42])); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + try { test2(a: 42); } catch (Error $e) { @@ -24,3 +42,6 @@ try { ?> --EXPECT-- Unknown named parameter $b +Unknown named parameter $b +Unknown named parameter $b +Unknown named parameter $unknown diff --git a/Zend/zend.c b/Zend/zend.c index 2aa37b0536acc..2e2ff032136bc 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -74,7 +74,7 @@ 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); @@ -82,9 +82,9 @@ void (*zend_printf_to_smart_string)(smart_string *buf, const char *format, va_li 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); @@ -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; @@ -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; @@ -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 @@ -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; @@ -894,12 +893,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 @@ -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; } /* }}} */ @@ -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; @@ -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) { @@ -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++) { diff --git a/Zend/zend.h b/Zend/zend.h index 5963ca7d9a7ac..0a0506f9158a1 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -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); @@ -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); @@ -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); @@ -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); diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 03b65779da2c8..1e5dfe57b038d 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -42,7 +42,7 @@ static zend_module_entry **module_post_deactivate_handlers; static zend_class_entry **class_cleanup_handlers; -ZEND_API int _zend_get_parameters_array_ex(uint32_t param_count, zval *argument_array) /* {{{ */ +ZEND_API zend_result _zend_get_parameters_array_ex(uint32_t param_count, zval *argument_array) /* {{{ */ { zval *param_ptr; uint32_t arg_count; @@ -64,7 +64,7 @@ ZEND_API int _zend_get_parameters_array_ex(uint32_t param_count, zval *argument_ } /* }}} */ -ZEND_API int zend_copy_parameters_array(uint32_t param_count, zval *argument_array) /* {{{ */ +ZEND_API zend_result zend_copy_parameters_array(uint32_t param_count, zval *argument_array) /* {{{ */ { zval *param_ptr; uint32_t arg_count; @@ -369,7 +369,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_value_error(uint32_t arg_num } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pce, uint32_t num, int check_null) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pce, uint32_t num, bool check_null) /* {{{ */ { zend_class_entry *ce_base = *pce; @@ -398,7 +398,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pc } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, zend_bool *dest) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, zend_bool *dest) /* {{{ */ { if (EXPECTED(Z_TYPE_P(arg) <= IS_STRING)) { *dest = zend_is_true(arg); @@ -409,7 +409,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, zend_bool *dest) } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_bool_slow(zval *arg, zend_bool *dest) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_slow(zval *arg, zend_bool *dest) /* {{{ */ { if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) { return 0; @@ -418,7 +418,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_bool_slow(zval *arg, zend_bool *dest) } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest) /* {{{ */ { if (EXPECTED(Z_TYPE_P(arg) == IS_DOUBLE)) { if (UNEXPECTED(zend_isnan(Z_DVAL_P(arg)))) { @@ -461,7 +461,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest) } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest) /* {{{ */ { if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) { return 0; @@ -470,7 +470,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest) } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest) /* {{{ */ { if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) { *dest = (double)Z_LVAL_P(arg); @@ -499,7 +499,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest) / } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest) /* {{{ */ { if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) { /* SSTH Exception: IS_LONG may be accepted instead as IS_DOUBLE */ @@ -511,7 +511,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest) / } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest) /* {{{ */ { if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) { return 0; @@ -541,7 +541,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest) /* } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest) /* {{{ */ { if (EXPECTED(Z_TYPE_P(arg) < IS_STRING)) { convert_to_string(arg); @@ -563,7 +563,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest) /* {{{ */ { if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) { return 0; @@ -572,7 +572,7 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_str_or_long_slow(zval *arg, zend_string **dest_str, zend_long *dest_long) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_or_long_slow(zval *arg, zend_string **dest_str, zend_long *dest_long) /* {{{ */ { if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) { return 0; @@ -593,8 +593,8 @@ static const char *zend_parse_arg_impl(zval *arg, va_list *va, const char **spec { const char *spec_walk = *spec; char c = *spec_walk++; - int check_null = 0; - int separate = 0; + bool check_null = 0; + bool separate = 0; zval *real_arg = arg; /* scan through modifiers */ @@ -858,7 +858,7 @@ static const char *zend_parse_arg_impl(zval *arg, va_list *va, const char **spec } /* }}} */ -static int zend_parse_arg(uint32_t arg_num, zval *arg, va_list *va, const char **spec, int flags) /* {{{ */ +static zend_result zend_parse_arg(uint32_t arg_num, zval *arg, va_list *va, const char **spec, int flags) /* {{{ */ { const char *expected_type = NULL; char *error = NULL; @@ -886,10 +886,10 @@ static int zend_parse_arg(uint32_t arg_num, zval *arg, va_list *va, const char * } /* }}} */ -ZEND_API int zend_parse_parameter(int flags, uint32_t arg_num, zval *arg, const char *spec, ...) +ZEND_API zend_result zend_parse_parameter(int flags, uint32_t arg_num, zval *arg, const char *spec, ...) { va_list va; - int ret; + zend_result ret; va_start(va, spec); ret = zend_parse_arg(arg_num, arg, &va, &spec, flags); @@ -907,7 +907,7 @@ static ZEND_COLD void zend_parse_parameters_debug_error(const char *msg) { ZSTR_VAL(active_function->common.function_name), msg); } -static int zend_parse_va_args(uint32_t num_args, const char *type_spec, va_list *va, int flags) /* {{{ */ +static zend_result zend_parse_va_args(uint32_t num_args, const char *type_spec, va_list *va, int flags) /* {{{ */ { const char *spec_walk; char c; @@ -1049,10 +1049,10 @@ static int zend_parse_va_args(uint32_t num_args, const char *type_spec, va_list } /* }}} */ -ZEND_API int zend_parse_parameters_ex(int flags, uint32_t num_args, const char *type_spec, ...) /* {{{ */ +ZEND_API zend_result zend_parse_parameters_ex(int flags, uint32_t num_args, const char *type_spec, ...) /* {{{ */ { va_list va; - int retval; + zend_result retval; va_start(va, type_spec); retval = zend_parse_va_args(num_args, type_spec, &va, flags); @@ -1062,10 +1062,10 @@ ZEND_API int zend_parse_parameters_ex(int flags, uint32_t num_args, const char * } /* }}} */ -ZEND_API int zend_parse_parameters(uint32_t num_args, const char *type_spec, ...) /* {{{ */ +ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec, ...) /* {{{ */ { va_list va; - int retval; + zend_result retval; int flags = 0; va_start(va, type_spec); @@ -1076,10 +1076,10 @@ ZEND_API int zend_parse_parameters(uint32_t num_args, const char *type_spec, ... } /* }}} */ -ZEND_API int zend_parse_method_parameters(uint32_t num_args, zval *this_ptr, const char *type_spec, ...) /* {{{ */ +ZEND_API zend_result zend_parse_method_parameters(uint32_t num_args, zval *this_ptr, const char *type_spec, ...) /* {{{ */ { va_list va; - int retval; + zend_result retval; int flags = 0; const char *p = type_spec; zval **object; @@ -1116,10 +1116,10 @@ ZEND_API int zend_parse_method_parameters(uint32_t num_args, zval *this_ptr, con } /* }}} */ -ZEND_API int zend_parse_method_parameters_ex(int flags, uint32_t num_args, zval *this_ptr, const char *type_spec, ...) /* {{{ */ +ZEND_API zend_result zend_parse_method_parameters_ex(int flags, uint32_t num_args, zval *this_ptr, const char *type_spec, ...) /* {{{ */ { va_list va; - int retval; + zend_result retval; const char *p = type_spec; zval **object; zend_class_entry *ce; @@ -1172,7 +1172,7 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties) /* {{{ */ } /* }}} */ -ZEND_API int zend_update_class_constants(zend_class_entry *class_type) /* {{{ */ +ZEND_API zend_result zend_update_class_constants(zend_class_entry *class_type) /* {{{ */ { if (!(class_type->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) { zend_class_constant *c; @@ -1361,7 +1361,7 @@ ZEND_API void object_properties_load(zend_object *object, HashTable *properties) * class and all props being public. If only a subset is given or the class * has protected members then you need to merge the properties separately by * calling zend_merge_properties(). */ -static zend_always_inline int _object_and_properties_init(zval *arg, zend_class_entry *class_type, HashTable *properties) /* {{{ */ +static zend_always_inline zend_result _object_and_properties_init(zval *arg, zend_class_entry *class_type, HashTable *properties) /* {{{ */ { if (UNEXPECTED(class_type->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_TRAIT|ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS))) { if (class_type->ce_flags & ZEND_ACC_INTERFACE) { @@ -1400,13 +1400,13 @@ static zend_always_inline int _object_and_properties_init(zval *arg, zend_class_ } /* }}} */ -ZEND_API int object_and_properties_init(zval *arg, zend_class_entry *class_type, HashTable *properties) /* {{{ */ +ZEND_API zend_result object_and_properties_init(zval *arg, zend_class_entry *class_type, HashTable *properties) /* {{{ */ { return _object_and_properties_init(arg, class_type, properties); } /* }}} */ -ZEND_API int object_init_ex(zval *arg, zend_class_entry *class_type) /* {{{ */ +ZEND_API zend_result object_init_ex(zval *arg, zend_class_entry *class_type) /* {{{ */ { return _object_and_properties_init(arg, class_type, NULL); } @@ -1436,7 +1436,7 @@ ZEND_API void add_assoc_null_ex(zval *arg, const char *key, size_t key_len) /* { } /* }}} */ -ZEND_API void add_assoc_bool_ex(zval *arg, const char *key, size_t key_len, int b) /* {{{ */ +ZEND_API void add_assoc_bool_ex(zval *arg, const char *key, size_t key_len, bool b) /* {{{ */ { zval tmp; @@ -1514,7 +1514,7 @@ ZEND_API void add_index_null(zval *arg, zend_ulong index) /* {{{ */ } /* }}} */ -ZEND_API void add_index_bool(zval *arg, zend_ulong index, int b) /* {{{ */ +ZEND_API void add_index_bool(zval *arg, zend_ulong index, bool b) /* {{{ */ { zval tmp; @@ -1568,7 +1568,7 @@ ZEND_API void add_index_stringl(zval *arg, zend_ulong index, const char *str, si } /* }}} */ -ZEND_API int add_next_index_long(zval *arg, zend_long n) /* {{{ */ +ZEND_API zend_result add_next_index_long(zval *arg, zend_long n) /* {{{ */ { zval tmp; @@ -1577,7 +1577,7 @@ ZEND_API int add_next_index_long(zval *arg, zend_long n) /* {{{ */ } /* }}} */ -ZEND_API int add_next_index_null(zval *arg) /* {{{ */ +ZEND_API zend_result add_next_index_null(zval *arg) /* {{{ */ { zval tmp; @@ -1586,7 +1586,7 @@ ZEND_API int add_next_index_null(zval *arg) /* {{{ */ } /* }}} */ -ZEND_API int add_next_index_bool(zval *arg, zend_bool b) /* {{{ */ +ZEND_API zend_result add_next_index_bool(zval *arg, zend_bool b) /* {{{ */ { zval tmp; @@ -1595,7 +1595,7 @@ ZEND_API int add_next_index_bool(zval *arg, zend_bool b) /* {{{ */ } /* }}} */ -ZEND_API int add_next_index_resource(zval *arg, zend_resource *r) /* {{{ */ +ZEND_API zend_result add_next_index_resource(zval *arg, zend_resource *r) /* {{{ */ { zval tmp; @@ -1604,7 +1604,7 @@ ZEND_API int add_next_index_resource(zval *arg, zend_resource *r) /* {{{ */ } /* }}} */ -ZEND_API int add_next_index_double(zval *arg, double d) /* {{{ */ +ZEND_API zend_result add_next_index_double(zval *arg, double d) /* {{{ */ { zval tmp; @@ -1613,7 +1613,7 @@ ZEND_API int add_next_index_double(zval *arg, double d) /* {{{ */ } /* }}} */ -ZEND_API int add_next_index_str(zval *arg, zend_string *str) /* {{{ */ +ZEND_API zend_result add_next_index_str(zval *arg, zend_string *str) /* {{{ */ { zval tmp; @@ -1622,7 +1622,7 @@ ZEND_API int add_next_index_str(zval *arg, zend_string *str) /* {{{ */ } /* }}} */ -ZEND_API int add_next_index_string(zval *arg, const char *str) /* {{{ */ +ZEND_API zend_result add_next_index_string(zval *arg, const char *str) /* {{{ */ { zval tmp; @@ -1631,7 +1631,7 @@ ZEND_API int add_next_index_string(zval *arg, const char *str) /* {{{ */ } /* }}} */ -ZEND_API int add_next_index_stringl(zval *arg, const char *str, size_t length) /* {{{ */ +ZEND_API zend_result add_next_index_stringl(zval *arg, const char *str, size_t length) /* {{{ */ { zval tmp; @@ -1640,7 +1640,7 @@ ZEND_API int add_next_index_stringl(zval *arg, const char *str, size_t length) / } /* }}} */ -ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value) /* {{{ */ +ZEND_API zend_result array_set_zval_key(HashTable *ht, zval *key, zval *value) /* {{{ */ { zval *result; @@ -1767,7 +1767,7 @@ ZEND_API void add_property_zval_ex(zval *arg, const char *key, size_t key_len, z } /* }}} */ -ZEND_API int zend_startup_module_ex(zend_module_entry *module) /* {{{ */ +ZEND_API zend_result zend_startup_module_ex(zend_module_entry *module) /* {{{ */ { size_t name_len; zend_string *lcname; @@ -2254,7 +2254,7 @@ ZEND_API void zend_add_magic_method(zend_class_entry *ce, zend_function *fptr, z } /* registers all functions in *library_functions in the function hash */ -ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type) /* {{{ */ +ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type) /* {{{ */ { const zend_function_entry *ptr = functions; zend_function function, *reg_function; @@ -2371,10 +2371,16 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio break; } + /* Get parameter count including variadic parameter. */ + uint32_t num_args = reg_function->common.num_args; + if (reg_function->common.fn_flags & ZEND_ACC_VARIADIC) { + num_args++; + } + /* If types of arguments have to be checked */ - if (reg_function->common.arg_info && reg_function->common.num_args) { + if (reg_function->common.arg_info && num_args) { uint32_t i; - for (i = 0; i < reg_function->common.num_args; i++) { + for (i = 0; i < num_args; i++) { zend_internal_arg_info *arg_info = ®_function->internal_function.arg_info[i]; ZEND_ASSERT(arg_info->name && "Parameter must have a name"); if (ZEND_TYPE_IS_SET(arg_info->type)) { @@ -2396,13 +2402,11 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio (reg_function->common.fn_flags & (ZEND_ACC_HAS_RETURN_TYPE|ZEND_ACC_HAS_TYPE_HINTS))) { /* convert "const char*" class type names into "zend_string*" */ uint32_t i; - uint32_t num_args = reg_function->common.num_args + 1; zend_arg_info *arg_info = reg_function->common.arg_info - 1; zend_arg_info *new_arg_info; - if (reg_function->common.fn_flags & ZEND_ACC_VARIADIC) { - num_args++; - } + /* Treat return type as an extra argument */ + num_args++; new_arg_info = malloc(sizeof(zend_arg_info) * num_args); memcpy(new_arg_info, arg_info, sizeof(zend_arg_info) * num_args); reg_function->common.arg_info = new_arg_info + 1; @@ -2473,7 +2477,7 @@ ZEND_API void zend_unregister_functions(const zend_function_entry *functions, in } /* }}} */ -ZEND_API int zend_startup_module(zend_module_entry *module) /* {{{ */ +ZEND_API zend_result zend_startup_module(zend_module_entry *module) /* {{{ */ { if ((module = zend_register_internal_module(module)) != NULL && zend_startup_module_ex(module) == SUCCESS) { return SUCCESS; @@ -2482,7 +2486,7 @@ ZEND_API int zend_startup_module(zend_module_entry *module) /* {{{ */ } /* }}} */ -ZEND_API int zend_get_module_started(const char *module_name) /* {{{ */ +ZEND_API zend_result zend_get_module_started(const char *module_name) /* {{{ */ { zend_module_entry *module; @@ -2726,7 +2730,7 @@ ZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *or } /* }}} */ -ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce, int persistent) /* {{{ */ +ZEND_API zend_result zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce, bool persistent) /* {{{ */ { zend_string *lcname; zval zv, *ret; @@ -2761,7 +2765,8 @@ ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zen } /* }}} */ -ZEND_API int zend_set_hash_symbol(zval *symbol, const char *name, size_t name_length, zend_bool is_ref, int num_symbol_tables, ...) /* {{{ */ +// TODO num_symbol_tables as unsigned int? +ZEND_API zend_result zend_set_hash_symbol(zval *symbol, const char *name, size_t name_length, zend_bool is_ref, int num_symbol_tables, ...) /* {{{ */ { HashTable *symbol_table; va_list symbol_table_list; @@ -2785,7 +2790,7 @@ ZEND_API int zend_set_hash_symbol(zval *symbol, const char *name, size_t name_le /* Disabled functions support */ -ZEND_API int zend_disable_function(const char *function_name, size_t function_name_length) /* {{{ */ +ZEND_API zend_result zend_disable_function(const char *function_name, size_t function_name_length) /* {{{ */ { return zend_hash_str_del(CG(function_table), function_name, function_name_length); } @@ -2822,7 +2827,7 @@ static const zend_function_entry disabled_class_new[] = { ZEND_FE_END }; -ZEND_API int zend_disable_class(const char *class_name, size_t class_name_length) /* {{{ */ +ZEND_API zend_result zend_disable_class(const char *class_name, size_t class_name_length) /* {{{ */ { zend_class_entry *disabled_class; zend_string *key; @@ -2855,9 +2860,9 @@ static zend_always_inline zend_class_entry *get_scope(zend_execute_data *frame) return frame && frame->func ? frame->func->common.scope : NULL; } -static int zend_is_callable_check_class(zend_string *name, zend_class_entry *scope, zend_execute_data *frame, zend_fcall_info_cache *fcc, int *strict_class, char **error) /* {{{ */ +static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *scope, zend_execute_data *frame, zend_fcall_info_cache *fcc, bool *strict_class, char **error) /* {{{ */ { - int ret = 0; + bool ret = 0; zend_class_entry *ce; size_t name_len = ZSTR_LEN(name); zend_string *lcname; @@ -2944,10 +2949,10 @@ ZEND_API void zend_release_fcall_info_cache(zend_fcall_info_cache *fcc) { fcc->function_handler = NULL; } -static zend_always_inline int zend_is_callable_check_func(int check_flags, zval *callable, zend_execute_data *frame, zend_fcall_info_cache *fcc, int strict_class, char **error) /* {{{ */ +static zend_always_inline bool zend_is_callable_check_func(int check_flags, zval *callable, zend_execute_data *frame, zend_fcall_info_cache *fcc, bool strict_class, char **error) /* {{{ */ { zend_class_entry *ce_org = fcc->calling_scope; - int retval = 0; + bool retval = 0; zend_string *mname, *cname; zend_string *lmname; const char *colon; @@ -3232,7 +3237,7 @@ static zend_always_inline zend_bool zend_is_callable_impl( { zend_bool ret; zend_fcall_info_cache fcc_local; - int strict_class = 0; + bool strict_class = 0; if (fcc == NULL) { fcc = &fcc_local; @@ -3386,7 +3391,7 @@ ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_nam } /* }}} */ -ZEND_API int zend_fcall_info_init(zval *callable, uint32_t check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error) /* {{{ */ +ZEND_API zend_result zend_fcall_info_init(zval *callable, uint32_t check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error) /* {{{ */ { if (!zend_is_callable_ex(callable, NULL, check_flags, callable_name, fcc, error)) { return FAILURE; @@ -3404,7 +3409,7 @@ ZEND_API int zend_fcall_info_init(zval *callable, uint32_t check_flags, zend_fca } /* }}} */ -ZEND_API void zend_fcall_info_args_clear(zend_fcall_info *fci, int free_mem) /* {{{ */ +ZEND_API void zend_fcall_info_args_clear(zend_fcall_info *fci, bool free_mem) /* {{{ */ { if (fci->params) { zval *p = fci->params; @@ -3440,7 +3445,7 @@ ZEND_API void zend_fcall_info_args_restore(zend_fcall_info *fci, uint32_t param_ } /* }}} */ -ZEND_API int zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, zval *args) /* {{{ */ +ZEND_API zend_result zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, zval *args) /* {{{ */ { zval *arg, *params; uint32_t n = 1; @@ -3473,7 +3478,7 @@ ZEND_API int zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, } /* }}} */ -ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args) /* {{{ */ +ZEND_API zend_result zend_fcall_info_args(zend_fcall_info *fci, zval *args) /* {{{ */ { return zend_fcall_info_args_ex(fci, NULL, args); } @@ -3521,11 +3526,11 @@ ZEND_API void zend_fcall_info_argn(zend_fcall_info *fci, uint32_t argc, ...) /* } /* }}} */ -ZEND_API int zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *fcc, zval *retval_ptr, zval *args) /* {{{ */ +ZEND_API zend_result zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *fcc, zval *retval_ptr, zval *args) /* {{{ */ { zval retval, *org_params = NULL; uint32_t org_count = 0; - int result; + zend_result result; fci->retval = retval_ptr ? retval_ptr : &retval; if (args) { @@ -3676,7 +3681,7 @@ ZEND_API zend_property_info *zend_declare_typed_property(zend_class_entry *ce, z } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_ex(zend_reference *ref, zval *val, zend_bool strict) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_ex(zend_reference *ref, zval *val, zend_bool strict) /* {{{ */ { if (UNEXPECTED(!zend_verify_ref_assignable_zval(ref, val, strict))) { zval_ptr_dtor(val); @@ -3689,13 +3694,13 @@ ZEND_API int zend_try_assign_typed_ref_ex(zend_reference *ref, zval *val, zend_b } /* }}} */ -ZEND_API int zend_try_assign_typed_ref(zend_reference *ref, zval *val) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref(zend_reference *ref, zval *val) /* {{{ */ { return zend_try_assign_typed_ref_ex(ref, val, ZEND_ARG_USES_STRICT_TYPES()); } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_null(zend_reference *ref) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_null(zend_reference *ref) /* {{{ */ { zval tmp; @@ -3704,7 +3709,7 @@ ZEND_API int zend_try_assign_typed_ref_null(zend_reference *ref) /* {{{ */ } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_bool(zend_reference *ref, zend_bool val) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_bool(zend_reference *ref, zend_bool val) /* {{{ */ { zval tmp; @@ -3713,7 +3718,7 @@ ZEND_API int zend_try_assign_typed_ref_bool(zend_reference *ref, zend_bool val) } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_long(zend_reference *ref, zend_long lval) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_long(zend_reference *ref, zend_long lval) /* {{{ */ { zval tmp; @@ -3722,7 +3727,7 @@ ZEND_API int zend_try_assign_typed_ref_long(zend_reference *ref, zend_long lval) } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_double(zend_reference *ref, double dval) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_double(zend_reference *ref, double dval) /* {{{ */ { zval tmp; @@ -3731,7 +3736,7 @@ ZEND_API int zend_try_assign_typed_ref_double(zend_reference *ref, double dval) } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_empty_string(zend_reference *ref) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_empty_string(zend_reference *ref) /* {{{ */ { zval tmp; @@ -3740,7 +3745,7 @@ ZEND_API int zend_try_assign_typed_ref_empty_string(zend_reference *ref) /* {{{ } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_str(zend_reference *ref, zend_string *str) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_str(zend_reference *ref, zend_string *str) /* {{{ */ { zval tmp; @@ -3749,7 +3754,7 @@ ZEND_API int zend_try_assign_typed_ref_str(zend_reference *ref, zend_string *str } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_string(zend_reference *ref, const char *string) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_string(zend_reference *ref, const char *string) /* {{{ */ { zval tmp; @@ -3758,7 +3763,7 @@ ZEND_API int zend_try_assign_typed_ref_string(zend_reference *ref, const char *s } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_stringl(zend_reference *ref, const char *string, size_t len) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_stringl(zend_reference *ref, const char *string, size_t len) /* {{{ */ { zval tmp; @@ -3767,7 +3772,7 @@ ZEND_API int zend_try_assign_typed_ref_stringl(zend_reference *ref, const char * } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_arr(zend_reference *ref, zend_array *arr) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_arr(zend_reference *ref, zend_array *arr) /* {{{ */ { zval tmp; @@ -3776,7 +3781,7 @@ ZEND_API int zend_try_assign_typed_ref_arr(zend_reference *ref, zend_array *arr) } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_res(zend_reference *ref, zend_resource *res) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_res(zend_reference *ref, zend_resource *res) /* {{{ */ { zval tmp; @@ -3785,7 +3790,7 @@ ZEND_API int zend_try_assign_typed_ref_res(zend_reference *ref, zend_resource *r } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_zval(zend_reference *ref, zval *zv) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_zval(zend_reference *ref, zval *zv) /* {{{ */ { zval tmp; @@ -3794,7 +3799,7 @@ ZEND_API int zend_try_assign_typed_ref_zval(zend_reference *ref, zval *zv) /* {{ } /* }}} */ -ZEND_API int zend_try_assign_typed_ref_zval_ex(zend_reference *ref, zval *zv, zend_bool strict) /* {{{ */ +ZEND_API zend_result zend_try_assign_typed_ref_zval_ex(zend_reference *ref, zval *zv, zend_bool strict) /* {{{ */ { zval tmp; @@ -4085,7 +4090,7 @@ ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zend_object } /* }}} */ -ZEND_API int zend_update_static_property_ex(zend_class_entry *scope, zend_string *name, zval *value) /* {{{ */ +ZEND_API zend_result zend_update_static_property_ex(zend_class_entry *scope, zend_string *name, zval *value) /* {{{ */ { zval *property, tmp; zend_property_info *prop_info; @@ -4121,16 +4126,16 @@ ZEND_API int zend_update_static_property_ex(zend_class_entry *scope, zend_string } /* }}} */ -ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value) /* {{{ */ +ZEND_API zend_result zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value) /* {{{ */ { zend_string *key = zend_string_init(name, name_length, 0); - int retval = zend_update_static_property_ex(scope, key, value); + bool retval = zend_update_static_property_ex(scope, key, value); zend_string_efree(key); return retval; } /* }}} */ -ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length) /* {{{ */ +ZEND_API zend_result zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length) /* {{{ */ { zval tmp; @@ -4139,7 +4144,7 @@ ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const cha } /* }}} */ -ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value) /* {{{ */ +ZEND_API zend_result zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value) /* {{{ */ { zval tmp; @@ -4148,7 +4153,7 @@ ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const cha } /* }}} */ -ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, size_t name_length, zend_long value) /* {{{ */ +ZEND_API zend_result zend_update_static_property_long(zend_class_entry *scope, const char *name, size_t name_length, zend_long value) /* {{{ */ { zval tmp; @@ -4157,7 +4162,7 @@ ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const cha } /* }}} */ -ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value) /* {{{ */ +ZEND_API zend_result zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value) /* {{{ */ { zval tmp; @@ -4166,7 +4171,7 @@ ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const c } /* }}} */ -ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value) /* {{{ */ +ZEND_API zend_result zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value) /* {{{ */ { zval tmp; @@ -4176,7 +4181,7 @@ ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const c } /* }}} */ -ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_len) /* {{{ */ +ZEND_API zend_result zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_len) /* {{{ */ { zval tmp; @@ -4256,44 +4261,15 @@ ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, } /* }}} */ -static int same_zval(zval *zv1, zval *zv2) /* {{{ */ -{ - if (Z_TYPE_P(zv1) != Z_TYPE_P(zv2)) { - return 0; - } - switch (Z_TYPE_P(zv1)) { - case IS_UNDEF: - case IS_NULL: - case IS_FALSE: - case IS_TRUE: - return 1; - case IS_LONG: - return Z_LVAL_P(zv1) == Z_LVAL_P(zv2); - case IS_DOUBLE: - return Z_LVAL_P(zv1) == Z_LVAL_P(zv2); - case IS_STRING: - case IS_ARRAY: - case IS_OBJECT: - case IS_RESOURCE: - return Z_COUNTED_P(zv1) == Z_COUNTED_P(zv2); - default: - return 0; - } -} -/* }}} */ - ZEND_API void zend_restore_error_handling(zend_error_handling *saved) /* {{{ */ { EG(error_handling) = saved->handling; EG(exception_class) = saved->handling == EH_THROW ? saved->exception : NULL; - if (Z_TYPE(saved->user_handler) != IS_UNDEF - && !same_zval(&saved->user_handler, &EG(user_error_handler))) { + if (Z_TYPE(saved->user_handler) != IS_UNDEF) { zval_ptr_dtor(&EG(user_error_handler)); ZVAL_COPY_VALUE(&EG(user_error_handler), &saved->user_handler); - } else if (Z_TYPE(saved->user_handler)) { - zval_ptr_dtor(&saved->user_handler); + ZVAL_UNDEF(&saved->user_handler); } - ZVAL_UNDEF(&saved->user_handler); } /* }}} */ @@ -4339,7 +4315,7 @@ ZEND_API zend_bool zend_is_countable(zval *countable) /* {{{ */ } /* }}} */ -static int get_default_via_ast(zval *default_value_zval, const char *default_value) { +static zend_result get_default_via_ast(zval *default_value_zval, const char *default_value) { zend_ast *ast; zend_arena *ast_arena; @@ -4387,7 +4363,7 @@ static zend_string *try_parse_string(const char *str, size_t len, char quote) { return zend_string_init(str, len, 0); } -ZEND_API int zend_get_default_from_internal_arg_info( +ZEND_API zend_result zend_get_default_from_internal_arg_info( zval *default_value_zval, zend_internal_arg_info *arg_info) { const char *default_value = arg_info->default_value; diff --git a/Zend/zend_API.h b/Zend/zend_API.h index adf84affd284f..6d588cc90075d 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -182,11 +182,11 @@ typedef struct _zend_fcall_info_cache { #define ZEND_MODULE_GLOBALS_DTOR_N(module) zm_globals_dtor_##module /* Declaration macros */ -#define ZEND_MODULE_STARTUP_D(module) int ZEND_MODULE_STARTUP_N(module)(INIT_FUNC_ARGS) -#define ZEND_MODULE_SHUTDOWN_D(module) int ZEND_MODULE_SHUTDOWN_N(module)(SHUTDOWN_FUNC_ARGS) -#define ZEND_MODULE_ACTIVATE_D(module) int ZEND_MODULE_ACTIVATE_N(module)(INIT_FUNC_ARGS) -#define ZEND_MODULE_DEACTIVATE_D(module) int ZEND_MODULE_DEACTIVATE_N(module)(SHUTDOWN_FUNC_ARGS) -#define ZEND_MODULE_POST_ZEND_DEACTIVATE_D(module) int ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module)(void) +#define ZEND_MODULE_STARTUP_D(module) zend_result ZEND_MODULE_STARTUP_N(module)(INIT_FUNC_ARGS) +#define ZEND_MODULE_SHUTDOWN_D(module) zend_result ZEND_MODULE_SHUTDOWN_N(module)(SHUTDOWN_FUNC_ARGS) +#define ZEND_MODULE_ACTIVATE_D(module) zend_result ZEND_MODULE_ACTIVATE_N(module)(INIT_FUNC_ARGS) +#define ZEND_MODULE_DEACTIVATE_D(module) zend_result ZEND_MODULE_DEACTIVATE_N(module)(SHUTDOWN_FUNC_ARGS) +#define ZEND_MODULE_POST_ZEND_DEACTIVATE_D(module) zend_result ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module)(void) #define ZEND_MODULE_INFO_D(module) ZEND_COLD void ZEND_MODULE_INFO_N(module)(ZEND_MODULE_INFO_FUNC_ARGS) #define ZEND_MODULE_GLOBALS_CTOR_D(module) void ZEND_MODULE_GLOBALS_CTOR_N(module)(zend_##module##_globals *module##_globals) #define ZEND_MODULE_GLOBALS_DTOR_D(module) void ZEND_MODULE_GLOBALS_DTOR_N(module)(zend_##module##_globals *module##_globals) @@ -283,10 +283,10 @@ typedef struct _zend_fcall_info_cache { ZEND_API int zend_next_free_module(void); BEGIN_EXTERN_C() -ZEND_API int _zend_get_parameters_array_ex(uint32_t param_count, zval *argument_array); +ZEND_API zend_result _zend_get_parameters_array_ex(uint32_t param_count, zval *argument_array); /* internal function to efficiently copy parameters when executing __call() */ -ZEND_API int zend_copy_parameters_array(uint32_t param_count, zval *argument_array); +ZEND_API zend_result zend_copy_parameters_array(uint32_t param_count, zval *argument_array); #define zend_get_parameters_array(ht, param_count, argument_array) \ _zend_get_parameters_array_ex(param_count, argument_array) @@ -301,27 +301,27 @@ ZEND_API int zend_copy_parameters_array(uint32_t param_count, zval *argument_arr #define ZEND_PARSE_PARAMS_THROW 0 /* No longer used, zpp always uses exceptions */ #define ZEND_PARSE_PARAMS_QUIET (1<<1) -ZEND_API int zend_parse_parameters(uint32_t num_args, const char *type_spec, ...); -ZEND_API int zend_parse_parameters_ex(int flags, uint32_t num_args, const char *type_spec, ...); +ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec, ...); +ZEND_API zend_result zend_parse_parameters_ex(int flags, uint32_t num_args, const char *type_spec, ...); /* NOTE: This must have at least one value in __VA_ARGS__ for the expression to be valid */ #define zend_parse_parameters_throw(num_args, ...) \ zend_parse_parameters(num_args, __VA_ARGS__) ZEND_API const char *zend_zval_type_name(const zval *arg); ZEND_API zend_string *zend_zval_get_legacy_type(const zval *arg); -ZEND_API int zend_parse_method_parameters(uint32_t num_args, zval *this_ptr, const char *type_spec, ...); -ZEND_API int zend_parse_method_parameters_ex(int flags, uint32_t num_args, zval *this_ptr, const char *type_spec, ...); +ZEND_API zend_result zend_parse_method_parameters(uint32_t num_args, zval *this_ptr, const char *type_spec, ...); +ZEND_API zend_result zend_parse_method_parameters_ex(int flags, uint32_t num_args, zval *this_ptr, const char *type_spec, ...); -ZEND_API int zend_parse_parameter(int flags, uint32_t arg_num, zval *arg, const char *spec, ...); +ZEND_API zend_result zend_parse_parameter(int flags, uint32_t arg_num, zval *arg, const char *spec, ...); /* End of parameter parsing API -- andrei */ -ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type); +ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type); ZEND_API void zend_unregister_functions(const zend_function_entry *functions, int count, HashTable *function_table); -ZEND_API int zend_startup_module(zend_module_entry *module_entry); +ZEND_API zend_result zend_startup_module(zend_module_entry *module_entry); ZEND_API zend_module_entry* zend_register_internal_module(zend_module_entry *module_entry); ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module); -ZEND_API int zend_startup_module_ex(zend_module_entry *module); +ZEND_API zend_result zend_startup_module_ex(zend_module_entry *module); ZEND_API void zend_startup_modules(void); ZEND_API void zend_collect_module_handlers(void); ZEND_API void zend_destroy_modules(void); @@ -334,15 +334,15 @@ ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *cla ZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *orig_class_entry); ZEND_API void zend_class_implements(zend_class_entry *class_entry, int num_interfaces, ...); -ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce, int persistent); +ZEND_API zend_result zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce, bool persistent); #define zend_register_class_alias(name, ce) \ zend_register_class_alias_ex(name, sizeof(name)-1, ce, 1) #define zend_register_ns_class_alias(ns, name, ce) \ zend_register_class_alias_ex(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, ce, 1) -ZEND_API int zend_disable_function(const char *function_name, size_t function_name_length); -ZEND_API int zend_disable_class(const char *class_name, size_t class_name_length); +ZEND_API zend_result zend_disable_function(const char *function_name, size_t function_name_length); +ZEND_API zend_result zend_disable_class(const char *class_name, size_t class_name_length); ZEND_API ZEND_COLD void zend_wrong_param_count(void); @@ -378,7 +378,7 @@ ZEND_API void zend_declare_class_constant_double(zend_class_entry *ce, const cha ZEND_API void zend_declare_class_constant_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_length); ZEND_API void zend_declare_class_constant_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value); -ZEND_API int zend_update_class_constants(zend_class_entry *class_type); +ZEND_API zend_result zend_update_class_constants(zend_class_entry *class_type); ZEND_API void zend_update_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, zval *value); ZEND_API void zend_update_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zval *value); @@ -391,14 +391,14 @@ ZEND_API void zend_update_property_string(zend_class_entry *scope, zend_object * ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, const char *value, size_t value_length); ZEND_API void zend_unset_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length); -ZEND_API int zend_update_static_property_ex(zend_class_entry *scope, zend_string *name, zval *value); -ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value); -ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length); -ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value); -ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, size_t name_length, zend_long value); -ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value); -ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value); -ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_length); +ZEND_API zend_result zend_update_static_property_ex(zend_class_entry *scope, zend_string *name, zval *value); +ZEND_API zend_result zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value); +ZEND_API zend_result zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length); +ZEND_API zend_result zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value); +ZEND_API zend_result zend_update_static_property_long(zend_class_entry *scope, const char *name, size_t name_length, zend_long value); +ZEND_API zend_result zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value); +ZEND_API zend_result zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value); +ZEND_API zend_result zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_length); ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, zend_bool silent, zval *rv); ZEND_API zval *zend_read_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zend_bool silent, zval *rv); @@ -426,8 +426,8 @@ ZEND_API const char *zend_get_type_by_const(int type); #define array_init(arg) ZVAL_ARR((arg), zend_new_array(0)) #define array_init_size(arg, size) ZVAL_ARR((arg), zend_new_array(size)) ZEND_API void object_init(zval *arg); -ZEND_API int object_init_ex(zval *arg, zend_class_entry *ce); -ZEND_API int object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties); +ZEND_API zend_result object_init_ex(zval *arg, zend_class_entry *ce); +ZEND_API zend_result object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties); ZEND_API void object_properties_init(zend_object *object, zend_class_entry *class_type); ZEND_API void object_properties_init_ex(zend_object *object, HashTable *properties); ZEND_API void object_properties_load(zend_object *object, HashTable *properties); @@ -436,7 +436,7 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties); ZEND_API void add_assoc_long_ex(zval *arg, const char *key, size_t key_len, zend_long n); ZEND_API void add_assoc_null_ex(zval *arg, const char *key, size_t key_len); -ZEND_API void add_assoc_bool_ex(zval *arg, const char *key, size_t key_len, int b); +ZEND_API void add_assoc_bool_ex(zval *arg, const char *key, size_t key_len, bool b); ZEND_API void add_assoc_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r); ZEND_API void add_assoc_double_ex(zval *arg, const char *key, size_t key_len, double d); ZEND_API void add_assoc_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str); @@ -456,33 +456,33 @@ ZEND_API void add_assoc_zval_ex(zval *arg, const char *key, size_t key_len, zval ZEND_API void add_index_long(zval *arg, zend_ulong index, zend_long n); ZEND_API void add_index_null(zval *arg, zend_ulong index); -ZEND_API void add_index_bool(zval *arg, zend_ulong index, int b); +ZEND_API void add_index_bool(zval *arg, zend_ulong index, bool b); ZEND_API void add_index_resource(zval *arg, zend_ulong index, zend_resource *r); ZEND_API void add_index_double(zval *arg, zend_ulong index, double d); ZEND_API void add_index_str(zval *arg, zend_ulong index, zend_string *str); ZEND_API void add_index_string(zval *arg, zend_ulong index, const char *str); ZEND_API void add_index_stringl(zval *arg, zend_ulong index, const char *str, size_t length); -static zend_always_inline int add_index_zval(zval *arg, zend_ulong index, zval *value) +static zend_always_inline zend_result add_index_zval(zval *arg, zend_ulong index, zval *value) { return zend_hash_index_update(Z_ARRVAL_P(arg), index, value) ? SUCCESS : FAILURE; } -ZEND_API int add_next_index_long(zval *arg, zend_long n); -ZEND_API int add_next_index_null(zval *arg); -ZEND_API int add_next_index_bool(zval *arg, zend_bool b); -ZEND_API int add_next_index_resource(zval *arg, zend_resource *r); -ZEND_API int add_next_index_double(zval *arg, double d); -ZEND_API int add_next_index_str(zval *arg, zend_string *str); -ZEND_API int add_next_index_string(zval *arg, const char *str); -ZEND_API int add_next_index_stringl(zval *arg, const char *str, size_t length); +ZEND_API zend_result add_next_index_long(zval *arg, zend_long n); +ZEND_API zend_result add_next_index_null(zval *arg); +ZEND_API zend_result add_next_index_bool(zval *arg, zend_bool b); +ZEND_API zend_result add_next_index_resource(zval *arg, zend_resource *r); +ZEND_API zend_result add_next_index_double(zval *arg, double d); +ZEND_API zend_result add_next_index_str(zval *arg, zend_string *str); +ZEND_API zend_result add_next_index_string(zval *arg, const char *str); +ZEND_API zend_result add_next_index_stringl(zval *arg, const char *str, size_t length); -static zend_always_inline int add_next_index_zval(zval *arg, zval *value) +static zend_always_inline zend_result add_next_index_zval(zval *arg, zval *value) { return zend_hash_next_index_insert(Z_ARRVAL_P(arg), value) ? SUCCESS : FAILURE; } -ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value); +ZEND_API zend_result array_set_zval_key(HashTable *ht, zval *key, zval *value); ZEND_API void add_property_long_ex(zval *arg, const char *key, size_t key_len, zend_long l); ZEND_API void add_property_null_ex(zval *arg, const char *key, size_t key_len); @@ -505,7 +505,7 @@ ZEND_API void add_property_zval_ex(zval *arg, const char *key, size_t key_len, z #define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key), __value) -ZEND_API int _call_user_function_impl(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], HashTable *named_params); +ZEND_API zend_result _call_user_function_impl(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], HashTable *named_params); #define call_user_function(function_table, object, function_name, retval_ptr, param_count, params) \ _call_user_function_impl(object, function_name, retval_ptr, param_count, params, NULL) @@ -524,12 +524,12 @@ ZEND_API extern const zend_fcall_info_cache empty_fcall_info_cache; * fci->params = NULL; * The callable_name argument may be NULL. */ -ZEND_API int zend_fcall_info_init(zval *callable, uint32_t check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error); +ZEND_API zend_result zend_fcall_info_init(zval *callable, uint32_t check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error); /** Clear arguments connected with zend_fcall_info *fci * If free_mem is not zero then the params array gets free'd as well */ -ZEND_API void zend_fcall_info_args_clear(zend_fcall_info *fci, int free_mem); +ZEND_API void zend_fcall_info_args_clear(zend_fcall_info *fci, bool free_mem); /** Save current arguments from zend_fcall_info *fci * params array will be set to NULL @@ -543,8 +543,8 @@ ZEND_API void zend_fcall_info_args_restore(zend_fcall_info *fci, uint32_t param_ /** Set or clear the arguments in the zend_call_info struct taking care of * refcount. If args is NULL and arguments are set then those are cleared. */ -ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args); -ZEND_API int zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, zval *args); +ZEND_API zend_result zend_fcall_info_args(zend_fcall_info *fci, zval *args); +ZEND_API zend_result zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, zval *args); /** Set arguments in the zend_fcall_info struct taking care of refcount. * If argc is 0 the arguments which are set will be cleared, else pass @@ -567,9 +567,9 @@ ZEND_API void zend_fcall_info_argn(zend_fcall_info *fci, uint32_t argc, ...); /** Call a function using information created by zend_fcall_info_init()/args(). * If args is given then those replace the argument info in fci is temporarily. */ -ZEND_API int zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *fcc, zval *retval, zval *args); +ZEND_API zend_result zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *fcc, zval *retval, zval *args); -ZEND_API int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache); +ZEND_API zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache); /* Call the provided zend_function with the given params. * If retval_ptr is NULL, the return value is discarded. @@ -602,17 +602,17 @@ static zend_always_inline void zend_call_known_instance_method_with_1_params( ZEND_API void zend_call_known_instance_method_with_2_params( zend_function *fn, zend_object *object, zval *retval_ptr, zval *param1, zval *param2); -ZEND_API int zend_set_hash_symbol(zval *symbol, const char *name, size_t name_length, zend_bool is_ref, int num_symbol_tables, ...); +ZEND_API zend_result zend_set_hash_symbol(zval *symbol, const char *name, size_t name_length, zend_bool is_ref, int num_symbol_tables, ...); -ZEND_API int zend_delete_global_variable(zend_string *name); +ZEND_API zend_result zend_delete_global_variable(zend_string *name); ZEND_API zend_array *zend_rebuild_symbol_table(void); ZEND_API void zend_attach_symbol_table(zend_execute_data *execute_data); ZEND_API void zend_detach_symbol_table(zend_execute_data *execute_data); -ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force); -ZEND_API int zend_set_local_var_str(const char *name, size_t len, zval *value, int force); +ZEND_API zend_result zend_set_local_var(zend_string *name, zval *value, bool force); +ZEND_API zend_result zend_set_local_var_str(const char *name, size_t len, zval *value, bool force); -static zend_always_inline int zend_forbid_dynamic_call(const char *func_name) +static zend_always_inline zend_result zend_forbid_dynamic_call(const char *func_name) { zend_execute_data *ex = EG(current_execute_data); ZEND_ASSERT(ex != NULL && ex->func != NULL); @@ -631,7 +631,7 @@ ZEND_API zend_bool zend_is_iterable(zval *iterable); ZEND_API zend_bool zend_is_countable(zval *countable); -ZEND_API int zend_get_default_from_internal_arg_info( +ZEND_API zend_result zend_get_default_from_internal_arg_info( zval *default_value_zval, zend_internal_arg_info *arg_info); END_EXTERN_C() @@ -779,21 +779,21 @@ END_EXTERN_C() /* May modify arg in-place. Will free arg in failure case (and take ownership in success case). * Prefer using the ZEND_TRY_ASSIGN_* macros over these APIs. */ -ZEND_API int zend_try_assign_typed_ref_ex(zend_reference *ref, zval *zv, zend_bool strict); -ZEND_API int zend_try_assign_typed_ref(zend_reference *ref, zval *zv); - -ZEND_API int zend_try_assign_typed_ref_null(zend_reference *ref); -ZEND_API int zend_try_assign_typed_ref_bool(zend_reference *ref, zend_bool val); -ZEND_API int zend_try_assign_typed_ref_long(zend_reference *ref, zend_long lval); -ZEND_API int zend_try_assign_typed_ref_double(zend_reference *ref, double dval); -ZEND_API int zend_try_assign_typed_ref_empty_string(zend_reference *ref); -ZEND_API int zend_try_assign_typed_ref_str(zend_reference *ref, zend_string *str); -ZEND_API int zend_try_assign_typed_ref_string(zend_reference *ref, const char *string); -ZEND_API int zend_try_assign_typed_ref_stringl(zend_reference *ref, const char *string, size_t len); -ZEND_API int zend_try_assign_typed_ref_arr(zend_reference *ref, zend_array *arr); -ZEND_API int zend_try_assign_typed_ref_res(zend_reference *ref, zend_resource *res); -ZEND_API int zend_try_assign_typed_ref_zval(zend_reference *ref, zval *zv); -ZEND_API int zend_try_assign_typed_ref_zval_ex(zend_reference *ref, zval *zv, zend_bool strict); +ZEND_API zend_result zend_try_assign_typed_ref_ex(zend_reference *ref, zval *zv, zend_bool strict); +ZEND_API zend_result zend_try_assign_typed_ref(zend_reference *ref, zval *zv); + +ZEND_API zend_result zend_try_assign_typed_ref_null(zend_reference *ref); +ZEND_API zend_result zend_try_assign_typed_ref_bool(zend_reference *ref, zend_bool val); +ZEND_API zend_result zend_try_assign_typed_ref_long(zend_reference *ref, zend_long lval); +ZEND_API zend_result zend_try_assign_typed_ref_double(zend_reference *ref, double dval); +ZEND_API zend_result zend_try_assign_typed_ref_empty_string(zend_reference *ref); +ZEND_API zend_result zend_try_assign_typed_ref_str(zend_reference *ref, zend_string *str); +ZEND_API zend_result zend_try_assign_typed_ref_string(zend_reference *ref, const char *string); +ZEND_API zend_result zend_try_assign_typed_ref_stringl(zend_reference *ref, const char *string, size_t len); +ZEND_API zend_result zend_try_assign_typed_ref_arr(zend_reference *ref, zend_array *arr); +ZEND_API zend_result zend_try_assign_typed_ref_res(zend_reference *ref, zend_resource *res); +ZEND_API zend_result zend_try_assign_typed_ref_zval(zend_reference *ref, zval *zv); +ZEND_API zend_result zend_try_assign_typed_ref_zval_ex(zend_reference *ref, zval *zv, zend_bool strict); #define _ZEND_TRY_ASSIGN_NULL(zv, is_ref) do { \ zval *_zv = zv; \ @@ -1176,7 +1176,7 @@ static zend_always_inline zval *zend_try_array_init_size(zval *zv, uint32_t size if (EXPECTED(Z_ISREF_P(zv))) { zend_reference *ref = Z_REF_P(zv); if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) { - if (zend_try_assign_typed_ref_arr(ref, arr) != SUCCESS) { + if (zend_try_assign_typed_ref_arr(ref, arr) == FAILURE) { return NULL; } return &ref->val; @@ -1771,19 +1771,19 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_value_error(uint32_t arg_num /* Inlined implementations shared by new and old parameter parsing APIs */ -ZEND_API int ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pce, uint32_t num, int check_null); -ZEND_API int ZEND_FASTCALL zend_parse_arg_bool_slow(zval *arg, zend_bool *dest); -ZEND_API int ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, zend_bool *dest); -ZEND_API int ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest); -ZEND_API int ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest); -ZEND_API int ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest); -ZEND_API int ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest); -ZEND_API int ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest); -ZEND_API int ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest); -ZEND_API int ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest); -ZEND_API int ZEND_FASTCALL zend_parse_arg_str_or_long_slow(zval *arg, zend_string **dest_str, zend_long *dest_long); - -static zend_always_inline int zend_parse_arg_bool(zval *arg, zend_bool *dest, zend_bool *is_null, int check_null) +ZEND_API bool ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pce, uint32_t num, bool check_null); +ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_slow(zval *arg, zend_bool *dest); +ZEND_API bool ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, zend_bool *dest); +ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest); +ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest); +ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest); +ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest); +ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest); +ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest); +ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest); +ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_or_long_slow(zval *arg, zend_string **dest_str, zend_long *dest_long); + +static zend_always_inline bool zend_parse_arg_bool(zval *arg, zend_bool *dest, zend_bool *is_null, bool check_null) { if (check_null) { *is_null = 0; @@ -1801,7 +1801,7 @@ static zend_always_inline int zend_parse_arg_bool(zval *arg, zend_bool *dest, ze return 1; } -static zend_always_inline int zend_parse_arg_long(zval *arg, zend_long *dest, zend_bool *is_null, int check_null) +static zend_always_inline bool zend_parse_arg_long(zval *arg, zend_long *dest, zend_bool *is_null, bool check_null) { if (check_null) { *is_null = 0; @@ -1817,7 +1817,7 @@ static zend_always_inline int zend_parse_arg_long(zval *arg, zend_long *dest, ze return 1; } -static zend_always_inline int zend_parse_arg_double(zval *arg, double *dest, zend_bool *is_null, int check_null) +static zend_always_inline bool zend_parse_arg_double(zval *arg, double *dest, zend_bool *is_null, bool check_null) { if (check_null) { *is_null = 0; @@ -1833,7 +1833,7 @@ static zend_always_inline int zend_parse_arg_double(zval *arg, double *dest, zen return 1; } -static zend_always_inline int zend_parse_arg_number(zval *arg, zval **dest, int check_null) +static zend_always_inline bool zend_parse_arg_number(zval *arg, zval **dest, bool check_null) { if (EXPECTED(Z_TYPE_P(arg) == IS_LONG || Z_TYPE_P(arg) == IS_DOUBLE)) { *dest = arg; @@ -1845,7 +1845,7 @@ static zend_always_inline int zend_parse_arg_number(zval *arg, zval **dest, int return 1; } -static zend_always_inline int zend_parse_arg_str(zval *arg, zend_string **dest, int check_null) +static zend_always_inline bool zend_parse_arg_str(zval *arg, zend_string **dest, bool check_null) { if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) { *dest = Z_STR_P(arg); @@ -1857,7 +1857,7 @@ static zend_always_inline int zend_parse_arg_str(zval *arg, zend_string **dest, return 1; } -static zend_always_inline int zend_parse_arg_string(zval *arg, char **dest, size_t *dest_len, int check_null) +static zend_always_inline bool zend_parse_arg_string(zval *arg, char **dest, size_t *dest_len, bool check_null) { zend_string *str; @@ -1874,7 +1874,7 @@ static zend_always_inline int zend_parse_arg_string(zval *arg, char **dest, size return 1; } -static zend_always_inline int zend_parse_arg_path_str(zval *arg, zend_string **dest, int check_null) +static zend_always_inline bool zend_parse_arg_path_str(zval *arg, zend_string **dest, bool check_null) { if (!zend_parse_arg_str(arg, dest, check_null) || (*dest && UNEXPECTED(CHECK_NULL_PATH(ZSTR_VAL(*dest), ZSTR_LEN(*dest))))) { @@ -1883,7 +1883,7 @@ static zend_always_inline int zend_parse_arg_path_str(zval *arg, zend_string **d return 1; } -static zend_always_inline int zend_parse_arg_path(zval *arg, char **dest, size_t *dest_len, int check_null) +static zend_always_inline bool zend_parse_arg_path(zval *arg, char **dest, size_t *dest_len, bool check_null) { zend_string *str; @@ -1900,7 +1900,7 @@ static zend_always_inline int zend_parse_arg_path(zval *arg, char **dest, size_t return 1; } -static zend_always_inline int zend_parse_arg_array(zval *arg, zval **dest, int check_null, int or_object) +static zend_always_inline bool zend_parse_arg_array(zval *arg, zval **dest, bool check_null, bool or_object) { if (EXPECTED(Z_TYPE_P(arg) == IS_ARRAY) || (or_object && EXPECTED(Z_TYPE_P(arg) == IS_OBJECT))) { @@ -1913,7 +1913,7 @@ static zend_always_inline int zend_parse_arg_array(zval *arg, zval **dest, int c return 1; } -static zend_always_inline int zend_parse_arg_array_ht(zval *arg, HashTable **dest, int check_null, int or_object, int separate) +static zend_always_inline bool zend_parse_arg_array_ht(zval *arg, HashTable **dest, bool check_null, bool or_object, bool separate) { if (EXPECTED(Z_TYPE_P(arg) == IS_ARRAY)) { *dest = Z_ARRVAL_P(arg); @@ -1936,7 +1936,7 @@ static zend_always_inline int zend_parse_arg_array_ht(zval *arg, HashTable **des return 1; } -static zend_always_inline int zend_parse_arg_object(zval *arg, zval **dest, zend_class_entry *ce, int check_null) +static zend_always_inline bool zend_parse_arg_object(zval *arg, zval **dest, zend_class_entry *ce, bool check_null) { if (EXPECTED(Z_TYPE_P(arg) == IS_OBJECT) && (!ce || EXPECTED(instanceof_function(Z_OBJCE_P(arg), ce) != 0))) { @@ -1949,7 +1949,7 @@ static zend_always_inline int zend_parse_arg_object(zval *arg, zval **dest, zend return 1; } -static zend_always_inline int zend_parse_arg_resource(zval *arg, zval **dest, int check_null) +static zend_always_inline bool zend_parse_arg_resource(zval *arg, zval **dest, bool check_null) { if (EXPECTED(Z_TYPE_P(arg) == IS_RESOURCE)) { *dest = arg; @@ -1961,7 +1961,7 @@ static zend_always_inline int zend_parse_arg_resource(zval *arg, zval **dest, in return 1; } -static zend_always_inline int zend_parse_arg_func(zval *arg, zend_fcall_info *dest_fci, zend_fcall_info_cache *dest_fcc, int check_null, char **error) +static zend_always_inline bool zend_parse_arg_func(zval *arg, zend_fcall_info *dest_fci, zend_fcall_info_cache *dest_fcc, bool check_null, char **error) { if (check_null && UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) { dest_fci->size = 0; @@ -1973,7 +1973,7 @@ static zend_always_inline int zend_parse_arg_func(zval *arg, zend_fcall_info *de return 1; } -static zend_always_inline void zend_parse_arg_zval(zval *arg, zval **dest, int check_null) +static zend_always_inline void zend_parse_arg_zval(zval *arg, zval **dest, bool check_null) { *dest = (check_null && (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) || @@ -1981,13 +1981,13 @@ static zend_always_inline void zend_parse_arg_zval(zval *arg, zval **dest, int c UNEXPECTED(Z_TYPE_P(Z_REFVAL_P(arg)) == IS_NULL)))) ? NULL : arg; } -static zend_always_inline void zend_parse_arg_zval_deref(zval *arg, zval **dest, int check_null) +static zend_always_inline void zend_parse_arg_zval_deref(zval *arg, zval **dest, bool check_null) { *dest = (check_null && UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) ? NULL : arg; } -static zend_always_inline int zend_parse_arg_str_or_array_ht( - zval *arg, zend_string **dest_str, HashTable **dest_ht, int allow_null) +static zend_always_inline bool zend_parse_arg_str_or_array_ht( + zval *arg, zend_string **dest_str, HashTable **dest_ht, bool allow_null) { if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) { *dest_str = Z_STR_P(arg); @@ -2005,8 +2005,8 @@ static zend_always_inline int zend_parse_arg_str_or_array_ht( return 1; } -static zend_always_inline int zend_parse_arg_str_or_long(zval *arg, zend_string **dest_str, zend_long *dest_long, - zend_bool *is_null, int allow_null) +static zend_always_inline bool zend_parse_arg_str_or_long(zval *arg, zend_string **dest_str, zend_long *dest_long, + zend_bool *is_null, bool allow_null) { if (allow_null) { *is_null = 0; @@ -2025,8 +2025,8 @@ static zend_always_inline int zend_parse_arg_str_or_long(zval *arg, zend_string return 1; } -static zend_always_inline int zend_parse_arg_class_name_or_obj( - zval *arg, zend_class_entry **destination, int allow_null +static zend_always_inline bool zend_parse_arg_class_name_or_obj( + zval *arg, zend_class_entry **destination, bool allow_null ) { if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) { *destination = zend_lookup_class(Z_STR_P(arg)); @@ -2043,8 +2043,8 @@ static zend_always_inline int zend_parse_arg_class_name_or_obj( return 1; } -static zend_always_inline int zend_parse_arg_str_or_obj( - zval *arg, zend_string **destination_string, zend_object **destination_object, zend_class_entry *base_ce, int allow_null +static zend_always_inline bool zend_parse_arg_str_or_obj( + zval *arg, zend_string **destination_string, zend_object **destination_object, zend_class_entry *base_ce, bool allow_null ) { if (EXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) { if (!base_ce || EXPECTED(instanceof_function(Z_OBJCE_P(arg), base_ce))) { diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 2236cf0dbb037..b6c89eff3007f 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -2203,7 +2203,7 @@ static void *tracked_malloc(size_t size); static void tracked_free_all(); #endif -void zend_mm_shutdown(zend_mm_heap *heap, int full, int silent) +void zend_mm_shutdown(zend_mm_heap *heap, bool full, bool silent) { zend_mm_chunk *p; zend_mm_huge_list *list; @@ -2364,7 +2364,7 @@ static size_t alloc_globals_offset; static zend_alloc_globals alloc_globals; #endif -ZEND_API int is_zend_mm(void) +ZEND_API bool is_zend_mm(void) { #if ZEND_MM_CUSTOM return !AG(mm_heap)->use_custom_heap; @@ -2373,7 +2373,7 @@ ZEND_API int is_zend_mm(void) #endif } -ZEND_API int is_zend_ptr(const void *ptr) +ZEND_API bool is_zend_ptr(const void *ptr) { #if ZEND_MM_CUSTOM if (AG(mm_heap)->use_custom_heap) { @@ -2657,15 +2657,14 @@ ZEND_API char* ZEND_FASTCALL zend_strndup(const char *s, size_t length) } -ZEND_API int zend_set_memory_limit(size_t memory_limit) +ZEND_API void zend_set_memory_limit(size_t memory_limit) { #if ZEND_MM_LIMIT AG(mm_heap)->limit = (memory_limit >= ZEND_MM_CHUNK_SIZE) ? memory_limit : ZEND_MM_CHUNK_SIZE; #endif - return SUCCESS; } -ZEND_API size_t zend_memory_usage(int real_usage) +ZEND_API size_t zend_memory_usage(bool real_usage) { #if ZEND_MM_STAT if (real_usage) { @@ -2678,7 +2677,7 @@ ZEND_API size_t zend_memory_usage(int real_usage) return 0; } -ZEND_API size_t zend_memory_peak_usage(int real_usage) +ZEND_API size_t zend_memory_peak_usage(bool real_usage) { #if ZEND_MM_STAT if (real_usage) { @@ -2690,7 +2689,7 @@ ZEND_API size_t zend_memory_peak_usage(int real_usage) return 0; } -ZEND_API void shutdown_memory_manager(int silent, int full_shutdown) +ZEND_API void shutdown_memory_manager(bool silent, bool full_shutdown) { zend_mm_shutdown(AG(mm_heap), full_shutdown, silent); } @@ -2819,7 +2818,7 @@ ZEND_API zend_mm_heap *zend_mm_get_heap(void) return AG(mm_heap); } -ZEND_API int zend_mm_is_custom_heap(zend_mm_heap *new_heap) +ZEND_API bool zend_mm_is_custom_heap(zend_mm_heap *new_heap) { #if ZEND_MM_CUSTOM return AG(mm_heap)->use_custom_heap; diff --git a/Zend/zend_alloc.h b/Zend/zend_alloc.h index 8bb854328dbdd..ef97766eb5372 100644 --- a/Zend/zend_alloc.h +++ b/Zend/zend_alloc.h @@ -219,15 +219,15 @@ ZEND_API void * __zend_realloc(void *p, size_t len) ZEND_ATTRIBUTE_ALLOC_SIZE(2) #define perealloc2_recoverable_rel(ptr, size, copy_size, persistent) ((persistent)?realloc((ptr), (size)):erealloc2_recoverable_rel((ptr), (size), (copy_size))) #define pestrdup_rel(s, persistent) ((persistent)?strdup(s):estrdup_rel(s)) -ZEND_API int zend_set_memory_limit(size_t memory_limit); +ZEND_API void zend_set_memory_limit(size_t memory_limit); ZEND_API void start_memory_manager(void); -ZEND_API void shutdown_memory_manager(int silent, int full_shutdown); -ZEND_API int is_zend_mm(void); -ZEND_API int is_zend_ptr(const void *ptr); +ZEND_API void shutdown_memory_manager(bool silent, bool full_shutdown); +ZEND_API bool is_zend_mm(void); +ZEND_API bool is_zend_ptr(const void *ptr); -ZEND_API size_t zend_memory_usage(int real_usage); -ZEND_API size_t zend_memory_peak_usage(int real_usage); +ZEND_API size_t zend_memory_usage(bool real_usage); +ZEND_API size_t zend_memory_peak_usage(bool real_usage); /* fast cache for HashTables */ #define ALLOC_HASHTABLE(ht) \ @@ -246,7 +246,7 @@ ZEND_API size_t zend_memory_peak_usage(int real_usage); typedef struct _zend_mm_heap zend_mm_heap; ZEND_API zend_mm_heap *zend_mm_startup(void); -ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, int full_shutdown, int silent); +ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, bool full_shutdown, bool silent); ZEND_API void* ZEND_FASTCALL _zend_mm_alloc(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC; ZEND_API void ZEND_FASTCALL _zend_mm_free(zend_mm_heap *heap, void *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); ZEND_API void* ZEND_FASTCALL _zend_mm_realloc(zend_mm_heap *heap, void *p, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); @@ -274,7 +274,7 @@ ZEND_API size_t zend_mm_gc(zend_mm_heap *heap); #define ZEND_MM_CUSTOM_HEAP_STD 1 #define ZEND_MM_CUSTOM_HEAP_DEBUG 2 -ZEND_API int zend_mm_is_custom_heap(zend_mm_heap *new_heap); +ZEND_API bool zend_mm_is_custom_heap(zend_mm_heap *new_heap); ZEND_API void zend_mm_set_custom_handlers(zend_mm_heap *heap, void* (*_malloc)(size_t), void (*_free)(void*), @@ -295,8 +295,8 @@ typedef struct _zend_mm_storage zend_mm_storage; typedef void* (*zend_mm_chunk_alloc_t)(zend_mm_storage *storage, size_t size, size_t alignment); typedef void (*zend_mm_chunk_free_t)(zend_mm_storage *storage, void *chunk, size_t size); -typedef int (*zend_mm_chunk_truncate_t)(zend_mm_storage *storage, void *chunk, size_t old_size, size_t new_size); -typedef int (*zend_mm_chunk_extend_t)(zend_mm_storage *storage, void *chunk, size_t old_size, size_t new_size); +typedef bool (*zend_mm_chunk_truncate_t)(zend_mm_storage *storage, void *chunk, size_t old_size, size_t new_size); +typedef bool (*zend_mm_chunk_extend_t)(zend_mm_storage *storage, void *chunk, size_t old_size, size_t new_size); typedef struct _zend_mm_handlers { zend_mm_chunk_alloc_t chunk_alloc; diff --git a/Zend/zend_arena.h b/Zend/zend_arena.h index 6ecc1fc85fb46..ff2d0a5fe60df 100644 --- a/Zend/zend_arena.h +++ b/Zend/zend_arena.h @@ -78,7 +78,7 @@ static zend_always_inline void* zend_arena_alloc(zend_arena **arena_ptr, size_t static zend_always_inline void* zend_arena_calloc(zend_arena **arena_ptr, size_t count, size_t unit_size) { - int overflow; + bool overflow; size_t size; void *ret; @@ -174,7 +174,7 @@ static zend_always_inline void *zend_arena_alloc(zend_arena **arena_ptr, size_t static zend_always_inline void* zend_arena_calloc(zend_arena **arena_ptr, size_t count, size_t unit_size) { - int overflow; + bool overflow; size_t size; void *ret; diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index e2a2aca698d48..f746b408a1f84 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -438,7 +438,7 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_list_add(zend_ast *ast, zend_ast *op) return (zend_ast *) list; } -static int zend_ast_add_array_element(zval *result, zval *offset, zval *expr) +static zend_result zend_ast_add_array_element(zval *result, zval *offset, zval *expr) { switch (Z_TYPE_P(offset)) { case IS_UNDEF: @@ -478,7 +478,7 @@ static int zend_ast_add_array_element(zval *result, zval *offset, zval *expr) return SUCCESS; } -static int zend_ast_add_unpacked_element(zval *result, zval *expr) { +static zend_result zend_ast_add_unpacked_element(zval *result, zval *expr) { if (EXPECTED(Z_TYPE_P(expr) == IS_ARRAY)) { HashTable *ht = Z_ARRVAL_P(expr); zval *val; @@ -505,10 +505,10 @@ static int zend_ast_add_unpacked_element(zval *result, zval *expr) { return FAILURE; } -ZEND_API int ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope) +ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope) { zval op1, op2; - int ret = SUCCESS; + zend_result ret = SUCCESS; switch (ast->kind) { case ZEND_AST_BINARY_OP: @@ -1059,7 +1059,7 @@ static ZEND_COLD void zend_ast_export_ns_name(smart_str *str, zend_ast *ast, int zend_ast_export_ex(str, ast, priority, indent); } -static ZEND_COLD int zend_ast_valid_var_char(char ch) +static ZEND_COLD bool zend_ast_valid_var_char(char ch) { unsigned char c = (unsigned char)ch; @@ -1072,7 +1072,7 @@ static ZEND_COLD int zend_ast_valid_var_char(char ch) return 1; } -static ZEND_COLD int zend_ast_valid_var_name(const char *s, size_t len) +static ZEND_COLD bool zend_ast_valid_var_name(const char *s, size_t len) { unsigned char c; size_t i; @@ -1098,7 +1098,7 @@ static ZEND_COLD int zend_ast_valid_var_name(const char *s, size_t len) return 1; } -static ZEND_COLD int zend_ast_var_needs_braces(char ch) +static ZEND_COLD bool zend_ast_var_needs_braces(char ch) { return ch == '[' || zend_ast_valid_var_char(ch); } @@ -1121,7 +1121,7 @@ static ZEND_COLD void zend_ast_export_var(smart_str *str, zend_ast *ast, int pri smart_str_appendc(str, '}'); } -static ZEND_COLD void zend_ast_export_list(smart_str *str, zend_ast_list *list, int separator, int priority, int indent) +static ZEND_COLD void zend_ast_export_list(smart_str *str, zend_ast_list *list, bool separator, int priority, int indent) { uint32_t i = 0; diff --git a/Zend/zend_ast.h b/Zend/zend_ast.h index 97236c5560c07..2d72759c392a4 100644 --- a/Zend/zend_ast.h +++ b/Zend/zend_ast.h @@ -290,7 +290,7 @@ ZEND_API zend_ast *zend_ast_create_decl( zend_string *name, zend_ast *child0, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4 ); -ZEND_API int ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope); +ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *scope); ZEND_API zend_string *zend_ast_export(const char *prefix, zend_ast *ast, const char *suffix); ZEND_API zend_ast_ref * ZEND_FASTCALL zend_ast_copy(zend_ast *ast); diff --git a/Zend/zend_attributes.c b/Zend/zend_attributes.c index e55f27f84a889..af5baa6ce07d1 100644 --- a/Zend/zend_attributes.c +++ b/Zend/zend_attributes.c @@ -116,7 +116,7 @@ ZEND_API zend_attribute *zend_get_parameter_attribute_str(HashTable *attributes, return get_attribute_str(attributes, str, len, offset + 1); } -ZEND_API int zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope) +ZEND_API zend_result zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope) { if (i >= attr->argc) { return FAILURE; @@ -175,7 +175,7 @@ ZEND_API zend_bool zend_is_attribute_repeated(HashTable *attributes, zend_attrib return 0; } -static zend_always_inline void free_attribute(zend_attribute *attr, int persistent) +static zend_always_inline void free_attribute(zend_attribute *attr, bool persistent) { uint32_t i; diff --git a/Zend/zend_attributes.h b/Zend/zend_attributes.h index 6b7150a363dd9..6a60b06665a8f 100644 --- a/Zend/zend_attributes.h +++ b/Zend/zend_attributes.h @@ -63,7 +63,7 @@ ZEND_API zend_attribute *zend_get_attribute_str(HashTable *attributes, const cha ZEND_API zend_attribute *zend_get_parameter_attribute(HashTable *attributes, zend_string *lcname, uint32_t offset); ZEND_API zend_attribute *zend_get_parameter_attribute_str(HashTable *attributes, const char *str, size_t len, uint32_t offset); -ZEND_API int zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope); +ZEND_API zend_result zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope); ZEND_API zend_string *zend_get_attribute_target_names(uint32_t targets); ZEND_API zend_bool zend_is_attribute_repeated(HashTable *attributes, zend_attribute *attr); diff --git a/Zend/zend_bitset.h b/Zend/zend_bitset.h index 2a227e482277b..9e196713f06fe 100644 --- a/Zend/zend_bitset.h +++ b/Zend/zend_bitset.h @@ -102,7 +102,7 @@ static inline void zend_bitset_clear(zend_bitset set, uint32_t len) memset(set, 0, len * ZEND_BITSET_ELM_SIZE); } -static inline int zend_bitset_empty(zend_bitset set, uint32_t len) +static inline bool zend_bitset_empty(zend_bitset set, uint32_t len) { uint32_t i; for (i = 0; i < len; i++) { diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 588c3c33d7f71..c3a2a1b63f331 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -57,7 +57,7 @@ zend_module_entry zend_builtin_module = { /* {{{ */ }; /* }}} */ -int zend_startup_builtin_functions(void) /* {{{ */ +zend_result zend_startup_builtin_functions(void) /* {{{ */ { zend_builtin_module.module_number = 0; zend_builtin_module.type = MODULE_PERSISTENT; @@ -420,9 +420,9 @@ ZEND_FUNCTION(error_reporting) } /* }}} */ -static int validate_constant_array_argument(HashTable *ht, int argument_number) /* {{{ */ +static bool validate_constant_array_argument(HashTable *ht, int argument_number) /* {{{ */ { - int ret = 1; + bool ret = 1; zval *val; GC_PROTECT_RECURSION(ht); @@ -698,7 +698,7 @@ ZEND_FUNCTION(is_a) /* }}} */ /* {{{ add_class_vars */ -static void add_class_vars(zend_class_entry *scope, zend_class_entry *ce, int statics, zval *return_value) +static void add_class_vars(zend_class_entry *scope, zend_class_entry *ce, bool statics, zval *return_value) { zend_property_info *prop_info; zval *prop, prop_copy; @@ -865,10 +865,10 @@ ZEND_FUNCTION(get_mangled_object_vars) } /* }}} */ -static int same_name(zend_string *key, zend_string *name) /* {{{ */ +static bool same_name(zend_string *key, zend_string *name) /* {{{ */ { zend_string *lcname; - int ret; + bool ret; if (key == name) { return 1; @@ -2112,7 +2112,7 @@ ZEND_FUNCTION(get_extension_funcs) { zend_string *extension_name; zend_string *lcname; - int array; + bool array; zend_module_entry *module; zend_function *zif; diff --git a/Zend/zend_builtin_functions.h b/Zend/zend_builtin_functions.h index cfc347ed41ffc..a49dab1b46838 100644 --- a/Zend/zend_builtin_functions.h +++ b/Zend/zend_builtin_functions.h @@ -20,7 +20,7 @@ #ifndef ZEND_BUILTIN_FUNCTIONS_H #define ZEND_BUILTIN_FUNCTIONS_H -int zend_startup_builtin_functions(void); +zend_result zend_startup_builtin_functions(void); BEGIN_EXTERN_C() ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int options, int limit); diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 6b36bede37cbe..630857f26c1df 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -273,7 +273,7 @@ static ZEND_NAMED_FUNCTION(zend_closure_call_magic) /* {{{ */ { } /* }}} */ -static int zend_create_closure_from_callable(zval *return_value, zval *callable, char **error) /* {{{ */ { +static zend_result zend_create_closure_from_callable(zval *return_value, zval *callable, char **error) /* {{{ */ { zend_fcall_info_cache fcc; zend_function *mptr; zval instance; @@ -361,6 +361,7 @@ static ZEND_COLD zend_function *zend_closure_get_constructor(zend_object *object } /* }}} */ +/* int return due to Object Handler API */ static int zend_closure_compare(zval *o1, zval *o2) /* {{{ */ { ZEND_COMPARE_OBJECTS_FALLBACK(o1, o2); @@ -513,6 +514,7 @@ int zend_closure_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_f } /* }}} */ +/* *is_temp is int due to Object Handler API */ static HashTable *zend_closure_get_debug_info(zend_object *object, int *is_temp) /* {{{ */ { zend_closure *closure = (zend_closure *)object; diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 9c4853ae4eb11..b54b435ae9f62 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1076,7 +1076,7 @@ static zend_never_inline ZEND_COLD ZEND_NORETURN void do_bind_function_error(zen } } -ZEND_API int do_bind_function(zval *lcname) /* {{{ */ +ZEND_API zend_result do_bind_function(zval *lcname) /* {{{ */ { zend_function *function; zval *rtd_key, *zv; @@ -1097,7 +1097,7 @@ ZEND_API int do_bind_function(zval *lcname) /* {{{ */ } /* }}} */ -ZEND_API int do_bind_class(zval *lcname, zend_string *lc_parent_name) /* {{{ */ +ZEND_API zend_result do_bind_class(zval *lcname, zend_string *lc_parent_name) /* {{{ */ { zend_class_entry *ce; zval *rtd_key, *zv; @@ -1356,7 +1356,7 @@ ZEND_API void zend_do_delayed_early_binding(zend_op_array *op_array, uint32_t fi } /* }}} */ -ZEND_API zend_string *zend_mangle_property_name(const char *src1, size_t src1_length, const char *src2, size_t src2_length, int internal) /* {{{ */ +ZEND_API zend_string *zend_mangle_property_name(const char *src1, size_t src1_length, const char *src2, size_t src2_length, bool internal) /* {{{ */ { size_t prop_name_length = 1 + src1_length + 1 + src2_length; zend_string *prop_name = zend_string_alloc(prop_name_length, internal); @@ -1376,7 +1376,7 @@ static zend_always_inline size_t zend_strnlen(const char* s, size_t maxlen) /* { } /* }}} */ -ZEND_API int zend_unmangle_property_name_ex(const zend_string *name, const char **class_name, const char **prop_name, size_t *prop_len) /* {{{ */ +ZEND_API zend_result zend_unmangle_property_name_ex(const zend_string *name, const char **class_name, const char **prop_name, size_t *prop_len) /* {{{ */ { size_t class_name_len; size_t anonclass_src_len; @@ -1749,10 +1749,10 @@ zend_bool zend_is_auto_global(zend_string *name) /* {{{ */ } /* }}} */ -int zend_register_auto_global(zend_string *name, zend_bool jit, zend_auto_global_callback auto_global_callback) /* {{{ */ +zend_result zend_register_auto_global(zend_string *name, zend_bool jit, zend_auto_global_callback auto_global_callback) /* {{{ */ { zend_auto_global auto_global; - int retval; + zend_result retval; auto_global.name = name; auto_global.auto_global_callback = auto_global_callback; @@ -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); @@ -2105,7 +2105,7 @@ static inline uint32_t zend_emit_jump(uint32_t opnum_target) /* {{{ */ } /* }}} */ -ZEND_API int zend_is_smart_branch(const zend_op *opline) /* {{{ */ +ZEND_API bool zend_is_smart_branch(const zend_op *opline) /* {{{ */ { switch (opline->opcode) { case ZEND_IS_IDENTICAL: @@ -2419,7 +2419,7 @@ static void zend_emit_return_type_check( } /* }}} */ -void zend_emit_final_return(int return_one) /* {{{ */ +void zend_emit_final_return(bool return_one) /* {{{ */ { znode zn; zend_op *ret; @@ -2597,7 +2597,7 @@ static void zend_compile_class_ref(znode *result, zend_ast *name_ast, uint32_t f } /* }}} */ -static int zend_try_compile_cv(znode *result, zend_ast *ast) /* {{{ */ +static zend_result zend_try_compile_cv(znode *result, zend_ast *ast) /* {{{ */ { zend_ast *name_ast = ast->child[0]; if (name_ast->kind == ZEND_AST_ZVAL) { @@ -2628,7 +2628,7 @@ static int zend_try_compile_cv(znode *result, zend_ast *ast) /* {{{ */ } /* }}} */ -static zend_op *zend_compile_simple_var_no_cv(znode *result, zend_ast *ast, uint32_t type, int delayed) /* {{{ */ +static zend_op *zend_compile_simple_var_no_cv(znode *result, zend_ast *ast, uint32_t type, bool delayed) /* {{{ */ { zend_ast *name_ast = ast->child[0]; znode name_node; @@ -2679,7 +2679,7 @@ static zend_bool this_guaranteed_exists() /* {{{ */ } /* }}} */ -static zend_op *zend_compile_simple_var(znode *result, zend_ast *ast, uint32_t type, int delayed) /* {{{ */ +static zend_op *zend_compile_simple_var(znode *result, zend_ast *ast, uint32_t type, bool delayed) /* {{{ */ { if (is_this_fetch(ast)) { zend_op *opline = zend_emit_op(result, ZEND_FETCH_THIS, NULL, NULL); @@ -2814,7 +2814,7 @@ static zend_op *zend_delayed_compile_prop(znode *result, zend_ast *ast, uint32_t } /* }}} */ -static zend_op *zend_compile_prop(znode *result, zend_ast *ast, uint32_t type, int by_ref) /* {{{ */ +static zend_op *zend_compile_prop(znode *result, zend_ast *ast, uint32_t type, bool by_ref) /* {{{ */ { uint32_t offset = zend_delayed_compile_begin(); zend_op *opline = zend_delayed_compile_prop(result, ast, type); @@ -2825,7 +2825,7 @@ static zend_op *zend_compile_prop(znode *result, zend_ast *ast, uint32_t type, i } /* }}} */ -zend_op *zend_compile_static_prop(znode *result, zend_ast *ast, uint32_t type, int by_ref, int delayed) /* {{{ */ +zend_op *zend_compile_static_prop(znode *result, zend_ast *ast, uint32_t type, bool by_ref, bool delayed) /* {{{ */ { zend_ast *class_ast = ast->child[0]; zend_ast *prop_ast = ast->child[1]; @@ -3369,7 +3369,7 @@ uint32_t zend_compile_args( if (fbc) { arg_num = zend_get_arg_num(fbc, arg_name); - if (arg_num == arg_count + 1) { + if (arg_num == arg_count + 1 && !may_have_undef) { /* Using named arguments, but passing in order. */ arg_name = NULL; arg_count++; @@ -3637,7 +3637,7 @@ static inline zend_bool zend_args_contain_unpack_or_named(zend_ast_list *args) / } /* }}} */ -int zend_compile_func_strlen(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_strlen(znode *result, zend_ast_list *args) /* {{{ */ { znode arg_node; @@ -3657,7 +3657,7 @@ int zend_compile_func_strlen(znode *result, zend_ast_list *args) /* {{{ */ } /* }}} */ -int zend_compile_func_typecheck(znode *result, zend_ast_list *args, uint32_t type) /* {{{ */ +zend_result zend_compile_func_typecheck(znode *result, zend_ast_list *args, uint32_t type) /* {{{ */ { znode arg_node; zend_op *opline; @@ -3677,7 +3677,7 @@ int zend_compile_func_typecheck(znode *result, zend_ast_list *args, uint32_t typ } /* }}} */ -static int zend_compile_func_is_scalar(znode *result, zend_ast_list *args) /* {{{ */ +static zend_result zend_compile_func_is_scalar(znode *result, zend_ast_list *args) /* {{{ */ { znode arg_node; zend_op *opline; @@ -3692,7 +3692,7 @@ static int zend_compile_func_is_scalar(znode *result, zend_ast_list *args) /* {{ return SUCCESS; } -int zend_compile_func_cast(znode *result, zend_ast_list *args, uint32_t type) /* {{{ */ +zend_result zend_compile_func_cast(znode *result, zend_ast_list *args, uint32_t type) /* {{{ */ { znode arg_node; zend_op *opline; @@ -3712,7 +3712,7 @@ int zend_compile_func_cast(znode *result, zend_ast_list *args, uint32_t type) /* } /* }}} */ -int zend_compile_func_defined(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_defined(znode *result, zend_ast_list *args) /* {{{ */ { zend_string *name; zend_op *opline; @@ -3744,7 +3744,7 @@ int zend_compile_func_defined(znode *result, zend_ast_list *args) /* {{{ */ } /* }}} */ -int zend_compile_func_chr(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_chr(znode *result, zend_ast_list *args) /* {{{ */ { if (args->children == 1 && @@ -3762,7 +3762,7 @@ int zend_compile_func_chr(znode *result, zend_ast_list *args) /* {{{ */ } /* }}} */ -int zend_compile_func_ord(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_ord(znode *result, zend_ast_list *args) /* {{{ */ { if (args->children == 1 && args->child[0]->kind == ZEND_AST_ZVAL && @@ -3784,7 +3784,7 @@ static zend_bool fbc_is_finalized(zend_function *fbc) { return !ZEND_USER_CODE(fbc->type) || (fbc->common.fn_flags & ZEND_ACC_DONE_PASS_TWO); } -static int zend_try_compile_ct_bound_init_user_func(zend_ast *name_ast, uint32_t num_args) /* {{{ */ +static zend_result zend_try_compile_ct_bound_init_user_func(zend_ast *name_ast, uint32_t num_args) /* {{{ */ { zend_string *name, *lcname; zend_function *fbc; @@ -3837,7 +3837,7 @@ static void zend_compile_init_user_func(zend_ast *name_ast, uint32_t num_args, z /* }}} */ /* cufa = call_user_func_array */ -int zend_compile_func_cufa(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ +zend_result zend_compile_func_cufa(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ { znode arg_node; @@ -3887,7 +3887,7 @@ int zend_compile_func_cufa(znode *result, zend_ast_list *args, zend_string *lcna /* }}} */ /* cuf = call_user_func */ -int zend_compile_func_cuf(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ +zend_result zend_compile_func_cuf(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ { uint32_t i; @@ -3958,7 +3958,7 @@ static void zend_compile_assert(znode *result, zend_ast_list *args, zend_string } /* }}} */ -static int zend_compile_func_in_array(znode *result, zend_ast_list *args) /* {{{ */ +static zend_result zend_compile_func_in_array(znode *result, zend_ast_list *args) /* {{{ */ { zend_bool strict = 0; znode array, needly; @@ -4043,7 +4043,7 @@ static int zend_compile_func_in_array(znode *result, zend_ast_list *args) /* {{{ } /* }}} */ -int zend_compile_func_count(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ +zend_result zend_compile_func_count(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ { znode arg_node; zend_op *opline; @@ -4060,7 +4060,7 @@ int zend_compile_func_count(znode *result, zend_ast_list *args, zend_string *lcn } /* }}} */ -int zend_compile_func_get_class(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_get_class(znode *result, zend_ast_list *args) /* {{{ */ { if (args->children == 0) { zend_emit_op_tmp(result, ZEND_GET_CLASS, NULL, NULL); @@ -4078,7 +4078,7 @@ int zend_compile_func_get_class(znode *result, zend_ast_list *args) /* {{{ */ } /* }}} */ -int zend_compile_func_get_called_class(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_get_called_class(znode *result, zend_ast_list *args) /* {{{ */ { if (args->children != 0) { return FAILURE; @@ -4089,7 +4089,7 @@ int zend_compile_func_get_called_class(znode *result, zend_ast_list *args) /* {{ } /* }}} */ -int zend_compile_func_gettype(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_gettype(znode *result, zend_ast_list *args) /* {{{ */ { znode arg_node; @@ -4103,7 +4103,7 @@ int zend_compile_func_gettype(znode *result, zend_ast_list *args) /* {{{ */ } /* }}} */ -int zend_compile_func_num_args(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_num_args(znode *result, zend_ast_list *args) /* {{{ */ { if (CG(active_op_array)->function_name && args->children == 0) { zend_emit_op_tmp(result, ZEND_FUNC_NUM_ARGS, NULL, NULL); @@ -4114,7 +4114,7 @@ int zend_compile_func_num_args(znode *result, zend_ast_list *args) /* {{{ */ } /* }}} */ -int zend_compile_func_get_args(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_get_args(znode *result, zend_ast_list *args) /* {{{ */ { if (CG(active_op_array)->function_name && args->children == 0) { zend_emit_op_tmp(result, ZEND_FUNC_GET_ARGS, NULL, NULL); @@ -4125,7 +4125,7 @@ int zend_compile_func_get_args(znode *result, zend_ast_list *args) /* {{{ */ } /* }}} */ -int zend_compile_func_array_key_exists(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_array_key_exists(znode *result, zend_ast_list *args) /* {{{ */ { znode subject, needle; @@ -4141,7 +4141,7 @@ int zend_compile_func_array_key_exists(znode *result, zend_ast_list *args) /* {{ } /* }}} */ -int zend_compile_func_array_slice(znode *result, zend_ast_list *args) /* {{{ */ +zend_result zend_compile_func_array_slice(znode *result, zend_ast_list *args) /* {{{ */ { if (CG(active_op_array)->function_name && args->children == 2 @@ -4174,7 +4174,7 @@ int zend_compile_func_array_slice(znode *result, zend_ast_list *args) /* {{{ */ } /* }}} */ -int zend_try_compile_special_func(znode *result, zend_string *lcname, zend_ast_list *args, zend_function *fbc, uint32_t type) /* {{{ */ +zend_result zend_try_compile_special_func(znode *result, zend_string *lcname, zend_ast_list *args, zend_function *fbc, uint32_t type) /* {{{ */ { if (CG(compiler_options) & ZEND_COMPILE_NO_BUILTINS) { return FAILURE; @@ -4641,7 +4641,7 @@ void zend_compile_unset(zend_ast *ast) /* {{{ */ } /* }}} */ -static int zend_handle_loops_and_finally_ex(zend_long depth, znode *return_value) /* {{{ */ +static bool zend_handle_loops_and_finally_ex(zend_long depth, znode *return_value) /* {{{ */ { zend_loop_var *base; zend_loop_var *loop_var = zend_stack_top(&CG(loop_var_stack)); @@ -4690,13 +4690,13 @@ static int zend_handle_loops_and_finally_ex(zend_long depth, znode *return_value } /* }}} */ -static int zend_handle_loops_and_finally(znode *return_value) /* {{{ */ +static bool zend_handle_loops_and_finally(znode *return_value) /* {{{ */ { return zend_handle_loops_and_finally_ex(zend_stack_count(&CG(loop_var_stack)) + 1, return_value); } /* }}} */ -static int zend_has_finally_ex(zend_long depth) /* {{{ */ +static bool zend_has_finally_ex(zend_long depth) /* {{{ */ { zend_loop_var *base; zend_loop_var *loop_var = zend_stack_top(&CG(loop_var_stack)); @@ -4722,7 +4722,7 @@ static int zend_has_finally_ex(zend_long depth) /* {{{ */ } /* }}} */ -static int zend_has_finally(void) /* {{{ */ +static bool zend_has_finally(void) /* {{{ */ { return zend_has_finally_ex(zend_stack_count(&CG(loop_var_stack)) + 1); } @@ -5859,7 +5859,7 @@ zend_bool zend_handle_encoding_declaration(zend_ast *ast) /* {{{ */ } /* }}} */ -static int zend_declare_is_first_statement(zend_ast *ast) /* {{{ */ +static zend_result zend_declare_is_first_statement(zend_ast *ast) /* {{{ */ { uint32_t i = 0; zend_ast_list *file_ast = zend_ast_get_list(CG(ast)); @@ -9603,7 +9603,7 @@ void zend_compile_expr(znode *result, zend_ast *ast) zend_short_circuiting_commit(checkpoint, result, ast); } -static zend_op *zend_compile_var_inner(znode *result, zend_ast *ast, uint32_t type, int by_ref) +static zend_op *zend_compile_var_inner(znode *result, zend_ast *ast, uint32_t type, bool by_ref) { CG(zend_lineno) = zend_ast_get_lineno(ast); @@ -9641,7 +9641,7 @@ static zend_op *zend_compile_var_inner(znode *result, zend_ast *ast, uint32_t ty } } -zend_op *zend_compile_var(znode *result, zend_ast *ast, uint32_t type, int by_ref) /* {{{ */ +zend_op *zend_compile_var(znode *result, zend_ast *ast, uint32_t type, bool by_ref) /* {{{ */ { uint32_t checkpoint = zend_short_circuiting_checkpoint(); zend_op *opcode = zend_compile_var_inner(result, ast, type, by_ref); diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index df3171f76d1ef..e50f620ed4078 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -133,7 +133,7 @@ typedef union _zend_parser_stack_elem { void zend_compile_top_stmt(zend_ast *ast); void zend_compile_stmt(zend_ast *ast); void zend_compile_expr(znode *node, zend_ast *ast); -zend_op *zend_compile_var(znode *node, zend_ast *ast, uint32_t type, int by_ref); +zend_op *zend_compile_var(znode *node, zend_ast *ast, uint32_t type, bool by_ref); void zend_eval_const_expr(zend_ast **ast_ptr); void zend_const_expr_to_zval(zval *result, zend_ast *ast); @@ -751,14 +751,14 @@ const char *zend_get_zendtext(void); int zend_get_zendleng(void); #endif -typedef int (ZEND_FASTCALL *unary_op_type)(zval *, zval *); -typedef int (ZEND_FASTCALL *binary_op_type)(zval *, zval *, zval *); +typedef zend_result (ZEND_FASTCALL *unary_op_type)(zval *, zval *); +typedef zend_result (ZEND_FASTCALL *binary_op_type)(zval *, zval *, zval *); ZEND_API unary_op_type get_unary_op(int opcode); ZEND_API binary_op_type get_binary_op(int opcode); void zend_stop_lexing(void); -void zend_emit_final_return(int return_one); +void zend_emit_final_return(bool return_one); /* Used during AST construction */ zend_ast *zend_ast_append_str(zend_ast *left, zend_ast *right); @@ -770,8 +770,8 @@ zend_bool zend_handle_encoding_declaration(zend_ast *ast); /* parser-driven code generators */ void zend_do_free(znode *op1); -ZEND_API int do_bind_function(zval *lcname); -ZEND_API int do_bind_class(zval *lcname, zend_string *lc_parent_name); +ZEND_API zend_result do_bind_function(zval *lcname); +ZEND_API zend_result do_bind_class(zval *lcname, zend_string *lc_parent_name); ZEND_API uint32_t zend_build_delayed_early_binding_list(const zend_op_array *op_array); ZEND_API void zend_do_delayed_early_binding(zend_op_array *op_array, uint32_t first_early_binding_opline); @@ -823,10 +823,10 @@ ZEND_API void zend_function_dtor(zval *zv); ZEND_API void destroy_zend_class(zval *zv); void zend_class_add_ref(zval *zv); -ZEND_API zend_string *zend_mangle_property_name(const char *src1, size_t src1_length, const char *src2, size_t src2_length, int internal); +ZEND_API zend_string *zend_mangle_property_name(const char *src1, size_t src1_length, const char *src2, size_t src2_length, bool internal); #define zend_unmangle_property_name(mangled_property, class_name, prop_name) \ zend_unmangle_property_name_ex(mangled_property, class_name, prop_name, NULL) -ZEND_API int zend_unmangle_property_name_ex(const zend_string *name, const char **class_name, const char **prop_name, size_t *prop_len); +ZEND_API zend_result zend_unmangle_property_name_ex(const zend_string *name, const char **class_name, const char **prop_name, size_t *prop_len); static zend_always_inline const char *zend_get_unmangled_property_name(const zend_string *mangled_prop) { const char *class_name, *prop_name; @@ -841,13 +841,13 @@ typedef zend_bool (*zend_needs_live_range_cb)(zend_op_array *op_array, zend_op * ZEND_API void zend_recalc_live_ranges( zend_op_array *op_array, zend_needs_live_range_cb needs_live_range); -ZEND_API int pass_two(zend_op_array *op_array); +ZEND_API void pass_two(zend_op_array *op_array); ZEND_API zend_bool zend_is_compiling(void); ZEND_API char *zend_make_compiled_string_description(const char *name); ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify_handlers); uint32_t zend_get_class_fetch_type(zend_string *name); ZEND_API zend_uchar zend_get_call_op(const zend_op *init_op, zend_function *fbc); -ZEND_API int zend_is_smart_branch(const zend_op *opline); +ZEND_API bool zend_is_smart_branch(const zend_op *opline); typedef zend_bool (*zend_auto_global_callback)(zend_string *name); typedef struct _zend_auto_global { @@ -857,7 +857,7 @@ typedef struct _zend_auto_global { zend_bool armed; } zend_auto_global; -ZEND_API int zend_register_auto_global(zend_string *name, zend_bool jit, zend_auto_global_callback auto_global_callback); +ZEND_API zend_result zend_register_auto_global(zend_string *name, zend_bool jit, zend_auto_global_callback auto_global_callback); ZEND_API void zend_activate_auto_globals(void); ZEND_API zend_bool zend_is_auto_global(zend_string *name); ZEND_API zend_bool zend_is_auto_global_str(const char *name, size_t len); @@ -974,7 +974,7 @@ ZEND_API zend_string *zend_type_to_string(zend_type type); #define IS_CONSTANT_CLASS 0x400 /* __CLASS__ in trait */ #define IS_CONSTANT_UNQUALIFIED_IN_NAMESPACE 0x800 -static zend_always_inline int zend_check_arg_send_type(const zend_function *zf, uint32_t arg_num, uint32_t mask) +static zend_always_inline bool zend_check_arg_send_type(const zend_function *zf, uint32_t arg_num, uint32_t mask) { arg_num--; if (UNEXPECTED(arg_num >= zf->common.num_args)) { diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index fe37e3fbd0454..3ad32446ff56c 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -98,12 +98,10 @@ void clean_module_constants(int module_number) zend_hash_apply_with_argument(EG(zend_constants), clean_module_constant, (void *) &module_number); } - -int zend_startup_constants(void) +void zend_startup_constants(void) { EG(zend_constants) = (HashTable *) malloc(sizeof(HashTable)); zend_hash_init(EG(zend_constants), 128, NULL, ZEND_CONSTANT_DTOR, 1); - return SUCCESS; } @@ -144,11 +142,10 @@ void zend_register_standard_constants(void) } -int zend_shutdown_constants(void) +void zend_shutdown_constants(void) { zend_hash_destroy(EG(zend_constants)); free(EG(zend_constants)); - return SUCCESS; } ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number) @@ -266,7 +263,7 @@ ZEND_API zend_constant *_zend_get_special_const(const char *name, size_t len) /* } /* }}} */ -ZEND_API int zend_verify_const_access(zend_class_constant *c, zend_class_entry *scope) /* {{{ */ +ZEND_API bool zend_verify_const_access(zend_class_constant *c, zend_class_entry *scope) /* {{{ */ { if (Z_ACCESS_FLAGS(c->value) & ZEND_ACC_PUBLIC) { return 1; @@ -396,7 +393,7 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope, } if (ret_constant && Z_TYPE_P(ret_constant) == IS_CONSTANT_AST) { - int ret; + zend_result ret; if (IS_CONSTANT_VISITED(ret_constant)) { zend_throw_error(NULL, "Cannot declare self-referencing constant %s::%s", ZSTR_VAL(class_name), ZSTR_VAL(constant_name)); @@ -480,11 +477,11 @@ static void* zend_hash_add_constant(HashTable *ht, zend_string *key, zend_consta return ret; } -ZEND_API int zend_register_constant(zend_constant *c) +ZEND_API zend_result zend_register_constant(zend_constant *c) { zend_string *lowercase_name = NULL; zend_string *name; - int ret = SUCCESS; + zend_result ret = SUCCESS; zend_bool persistent = (ZEND_CONSTANT_FLAGS(c) & CONST_PERSISTENT) != 0; #if 0 diff --git a/Zend/zend_constants.h b/Zend/zend_constants.h index 9b5a63a0260d9..0a3c5a737760c 100644 --- a/Zend/zend_constants.h +++ b/Zend/zend_constants.h @@ -69,10 +69,10 @@ typedef struct _zend_constant { BEGIN_EXTERN_C() void clean_module_constants(int module_number); void free_zend_constant(zval *zv); -int zend_startup_constants(void); -int zend_shutdown_constants(void); +void zend_startup_constants(void); +void zend_shutdown_constants(void); void zend_register_standard_constants(void); -ZEND_API int zend_verify_const_access(zend_class_constant *c, zend_class_entry *ce); +ZEND_API bool zend_verify_const_access(zend_class_constant *c, zend_class_entry *ce); ZEND_API zval *zend_get_constant(zend_string *name); ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len); ZEND_API zval *zend_get_constant_ex(zend_string *name, zend_class_entry *scope, uint32_t flags); @@ -82,7 +82,7 @@ ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zen ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number); ZEND_API void zend_register_string_constant(const char *name, size_t name_len, const char *strval, int flags, int module_number); ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, const char *strval, size_t strlen, int flags, int module_number); -ZEND_API int zend_register_constant(zend_constant *c); +ZEND_API zend_result zend_register_constant(zend_constant *c); #ifdef ZTS void zend_copy_constants(HashTable *target, HashTable *sourc); #endif diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 2923165e56651..7184f5bf68c6b 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -213,7 +213,7 @@ ZEND_API void zend_clear_exception(void) /* {{{ */ } /* }}} */ -static zend_object *zend_default_exception_new_ex(zend_class_entry *class_type, int skip_top_traces) /* {{{ */ +static zend_object *zend_default_exception_new_ex(zend_class_entry *class_type, bool skip_top_traces) /* {{{ */ { zval tmp; zval trace; @@ -908,11 +908,11 @@ static void zend_error_va(int type, const char *file, uint32_t lineno, const cha /* }}} */ /* This function doesn't return if it uses E_ERROR */ -ZEND_API ZEND_COLD int zend_exception_error(zend_object *ex, int severity) /* {{{ */ +ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severity) /* {{{ */ { zval exception, rv; zend_class_entry *ce_exception; - int result = FAILURE; + zend_result result = FAILURE; ZVAL_OBJ(&exception, ex); ce_exception = ex->ce; diff --git a/Zend/zend_exceptions.h b/Zend/zend_exceptions.h index 7e8c73b1e920a..9d0c18a6dada5 100644 --- a/Zend/zend_exceptions.h +++ b/Zend/zend_exceptions.h @@ -67,7 +67,7 @@ ZEND_API zend_object *zend_throw_error_exception(zend_class_entry *exception_ce, extern ZEND_API void (*zend_throw_exception_hook)(zend_object *ex); /* show an exception using zend_error(severity,...), severity should be E_ERROR */ -ZEND_API ZEND_COLD int zend_exception_error(zend_object *exception, int severity); +ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *exception, int severity); ZEND_API ZEND_COLD void zend_throw_unwind_exit(void); ZEND_API zend_bool zend_is_unwind_exit(zend_object *ex); diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 9a267987db3d7..c0e6adf79b840 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -568,7 +568,7 @@ static zend_never_inline zval* zend_assign_to_typed_property_reference(zend_prop return prop; } -static zend_never_inline ZEND_COLD int zend_wrong_assign_to_variable_reference(zval *variable_ptr, zval *value_ptr OPLINE_DC EXECUTE_DATA_DC) +static zend_never_inline ZEND_COLD bool zend_wrong_assign_to_variable_reference(zval *variable_ptr, zval *value_ptr OPLINE_DC EXECUTE_DATA_DC) { zend_error(E_NOTICE, "Only variables should be assigned by reference"); if (UNEXPECTED(EG(exception) != NULL)) { @@ -1035,7 +1035,7 @@ static zend_always_inline zend_bool zend_check_type( return zend_check_type_slow(type, arg, ref, cache_slot, scope, is_return_type, is_internal); } -static zend_always_inline int zend_verify_recv_arg_type(zend_function *zf, uint32_t arg_num, zval *arg, void **cache_slot) +static zend_always_inline bool zend_verify_recv_arg_type(zend_function *zf, uint32_t arg_num, zval *arg, void **cache_slot) { zend_arg_info *cur_arg_info; @@ -1051,7 +1051,7 @@ static zend_always_inline int zend_verify_recv_arg_type(zend_function *zf, uint3 return 1; } -static zend_always_inline int zend_verify_variadic_arg_type( +static zend_always_inline bool zend_verify_variadic_arg_type( zend_function *zf, zend_arg_info *arg_info, uint32_t arg_num, zval *arg, void **cache_slot) { ZEND_ASSERT(ZEND_TYPE_IS_SET(arg_info->type)); @@ -1063,7 +1063,7 @@ static zend_always_inline int zend_verify_variadic_arg_type( return 1; } -static zend_never_inline ZEND_ATTRIBUTE_UNUSED int zend_verify_internal_arg_types(zend_function *fbc, zend_execute_data *call) +static zend_never_inline ZEND_ATTRIBUTE_UNUSED bool zend_verify_internal_arg_types(zend_function *fbc, zend_execute_data *call) { uint32_t i; uint32_t num_args = ZEND_CALL_NUM_ARGS(call); @@ -1203,7 +1203,7 @@ static ZEND_COLD void zend_verify_void_return_error(const zend_function *zf, con fclass, fsep, fname, returned_msg, returned_kind); } -static int zend_verify_internal_return_type(zend_function *zf, zval *ret) +static bool zend_verify_internal_return_type(zend_function *zf, zval *ret) { zend_internal_arg_info *ret_info = zf->internal_function.arg_info - 1; void *dummy_cache_slot = NULL; @@ -1225,11 +1225,10 @@ static int zend_verify_internal_return_type(zend_function *zf, zval *ret) } #endif -static ZEND_COLD int zend_verify_missing_return_type(const zend_function *zf, void **cache_slot) +static ZEND_COLD void zend_verify_missing_return_type(const zend_function *zf, void **cache_slot) { /* VERIFY_RETURN_TYPE is not emitted for "void" functions, so this is always an error. */ zend_verify_return_error(zf, cache_slot, NULL); - return 0; } static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_object_as_array(void) @@ -1900,7 +1899,7 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_undefined_index(const zend_error(E_WARNING, "Undefined array key \"%s\"", ZSTR_VAL(offset)); } -ZEND_API ZEND_COLD int ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval) +ZEND_API ZEND_COLD zend_result ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval) { /* The array may be destroyed while throwing the notice. * Temporarily increase the refcount to detect this situation. */ @@ -1918,7 +1917,7 @@ ZEND_API ZEND_COLD int ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, return SUCCESS; } -ZEND_API ZEND_COLD int ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset) +ZEND_API ZEND_COLD zend_result ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset) { /* The array may be destroyed while throwing the notice. * Temporarily increase the refcount to detect this situation. */ @@ -2307,7 +2306,7 @@ static zend_never_inline void ZEND_FASTCALL zend_fetch_dimension_address_UNSET(z zend_fetch_dimension_address(result, container_ptr, dim, dim_type, BP_VAR_UNSET EXECUTE_DATA_CC); } -static zend_always_inline void zend_fetch_dimension_address_read(zval *result, zval *container, zval *dim, int dim_type, int type, int is_list, int slow EXECUTE_DATA_DC) +static zend_always_inline void zend_fetch_dimension_address_read(zval *result, zval *container, zval *dim, int dim_type, int type, bool is_list, int slow EXECUTE_DATA_DC) { zval *retval; @@ -2482,7 +2481,7 @@ static zend_never_inline zval* ZEND_FASTCALL zend_find_array_dim_slow(HashTable } } -static zend_never_inline int ZEND_FASTCALL zend_isset_dim_slow(zval *container, zval *offset EXECUTE_DATA_DC) +static zend_never_inline bool ZEND_FASTCALL zend_isset_dim_slow(zval *container, zval *offset EXECUTE_DATA_DC) { if (/*OP2_TYPE == IS_CV &&*/ UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) { offset = ZVAL_UNDEFINED_OP2(); @@ -2521,7 +2520,7 @@ static zend_never_inline int ZEND_FASTCALL zend_isset_dim_slow(zval *container, } } -static zend_never_inline int ZEND_FASTCALL zend_isempty_dim_slow(zval *container, zval *offset EXECUTE_DATA_DC) +static zend_never_inline bool ZEND_FASTCALL zend_isempty_dim_slow(zval *container, zval *offset EXECUTE_DATA_DC) { if (/*OP2_TYPE == IS_CV &&*/ UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) { offset = ZVAL_UNDEFINED_OP2(); @@ -2783,6 +2782,10 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c } goto end; } + if (UNEXPECTED(EG(exception))) { + ZVAL_ERROR(result); + goto end; + } } else if (UNEXPECTED(Z_ISERROR_P(ptr))) { ZVAL_ERROR(result); goto end; @@ -2886,7 +2889,7 @@ static zend_never_inline void zend_assign_to_property_reference_var_var(zval *co OPLINE_CC EXECUTE_DATA_CC); } -static zend_never_inline int zend_fetch_static_property_address_ex(zval **retval, zend_property_info **prop_info, uint32_t cache_slot, int fetch_type OPLINE_DC EXECUTE_DATA_DC) { +static zend_never_inline zend_result zend_fetch_static_property_address_ex(zval **retval, zend_property_info **prop_info, uint32_t cache_slot, int fetch_type OPLINE_DC EXECUTE_DATA_DC) { zend_string *name; zend_class_entry *ce; zend_property_info *property_info; @@ -2964,8 +2967,7 @@ static zend_never_inline int zend_fetch_static_property_address_ex(zval **retval } -static zend_always_inline int zend_fetch_static_property_address(zval **retval, zend_property_info **prop_info, uint32_t cache_slot, int fetch_type, int flags OPLINE_DC EXECUTE_DATA_DC) { - int success; +static zend_always_inline zend_result zend_fetch_static_property_address(zval **retval, zend_property_info **prop_info, uint32_t cache_slot, int fetch_type, int flags OPLINE_DC EXECUTE_DATA_DC) { zend_property_info *property_info; if (opline->op1_type == IS_CONST && (opline->op2_type == IS_CONST || (opline->op2_type == IS_UNUSED && (opline->op2.num == ZEND_FETCH_CLASS_SELF || opline->op2.num == ZEND_FETCH_CLASS_PARENT))) && EXPECTED(CACHED_PTR(cache_slot) != NULL)) { @@ -2981,6 +2983,7 @@ static zend_always_inline int zend_fetch_static_property_address(zval **retval, return FAILURE; } } else { + zend_result success; success = zend_fetch_static_property_address_ex(retval, &property_info, cache_slot, fetch_type OPLINE_CC EXECUTE_DATA_CC); if (UNEXPECTED(success != SUCCESS)) { return FAILURE; @@ -3343,7 +3346,7 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_wrong_clone_call(zend zend_hash_apply(EX(symbol_table), zend_check_symbol); \ } -static int zend_check_symbol(zval *pz) +static void zend_check_symbol(zval *pz) { if (Z_TYPE_P(pz) == IS_INDIRECT) { pz = Z_INDIRECT_P(pz); @@ -3360,8 +3363,6 @@ static int zend_check_symbol(zval *pz) /* OBJ-TBI - doesn't support new object model! */ zend_hash_apply(Z_OBJPROP_P(pz), zend_check_symbol); } - - return 0; } @@ -4281,8 +4282,8 @@ static zend_never_inline zend_bool ZEND_FASTCALL zend_fe_reset_iterator(zval *ar } /* }}} */ -static zend_always_inline int _zend_quick_get_constant( - const zval *key, uint32_t flags, int check_defined_only OPLINE_DC EXECUTE_DATA_DC) /* {{{ */ +static zend_always_inline zend_result _zend_quick_get_constant( + const zval *key, uint32_t flags, bool check_defined_only OPLINE_DC EXECUTE_DATA_DC) /* {{{ */ { zval *zv; zend_constant *c = NULL; @@ -4326,7 +4327,7 @@ static zend_never_inline void ZEND_FASTCALL zend_quick_get_constant( _zend_quick_get_constant(key, flags, 0 OPLINE_CC EXECUTE_DATA_CC); } /* }}} */ -static zend_never_inline int ZEND_FASTCALL zend_quick_check_constant( +static zend_never_inline zend_result ZEND_FASTCALL zend_quick_check_constant( const zval *key OPLINE_DC EXECUTE_DATA_DC) /* {{{ */ { return _zend_quick_get_constant(key, 0, 1 OPLINE_CC EXECUTE_DATA_CC); @@ -4449,7 +4450,7 @@ static void end_fake_frame(zend_execute_data *call) { } } -ZEND_API int ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *call) { +ZEND_API zend_result ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *call) { zend_function *fbc = call->func; if (fbc->type == ZEND_USER_FUNCTION) { uint32_t num_args = ZEND_CALL_NUM_ARGS(call); @@ -4477,7 +4478,7 @@ ZEND_API int ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *call) { zval tmp; ZVAL_COPY(&tmp, default_value); start_fake_frame(call, opline); - int ret = zval_update_constant_ex(&tmp, fbc->op_array.scope); + zend_result ret = zval_update_constant_ex(&tmp, fbc->op_array.scope); end_fake_frame(call); if (UNEXPECTED(ret == FAILURE)) { zval_ptr_dtor_nogc(&tmp); @@ -4532,7 +4533,7 @@ ZEND_API int ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *call) { if (Z_TYPE(default_value) == IS_CONSTANT_AST) { start_fake_frame(call, NULL); - int ret = zval_update_constant_ex(&default_value, fbc->common.scope); + zend_result ret = zval_update_constant_ex(&default_value, fbc->common.scope); end_fake_frame(call); if (ret == FAILURE) { return FAILURE; @@ -4749,7 +4750,7 @@ static zend_always_inline zend_execute_data *_zend_vm_stack_push_call_frame(uint #include "zend_vm_execute.h" -ZEND_API int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler) +ZEND_API zend_result zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler) { if (opcode != ZEND_USER_OPCODE) { if (handler == NULL) { diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index f93a9f5e0e86a..fb1a39898ca70 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -47,10 +47,10 @@ ZEND_API zend_class_entry *zend_lookup_class(zend_string *name); ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *lcname, uint32_t flags); ZEND_API zend_class_entry *zend_get_called_scope(zend_execute_data *ex); ZEND_API zend_object *zend_get_this_object(zend_execute_data *ex); -ZEND_API int zend_eval_string(const char *str, zval *retval_ptr, const char *string_name); -ZEND_API int zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name); -ZEND_API int zend_eval_string_ex(const char *str, zval *retval_ptr, const char *string_name, int handle_exceptions); -ZEND_API int zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ptr, const char *string_name, int handle_exceptions); +ZEND_API zend_result zend_eval_string(const char *str, zval *retval_ptr, const char *string_name); +ZEND_API zend_result zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name); +ZEND_API zend_result zend_eval_string_ex(const char *str, zval *retval_ptr, const char *string_name, bool handle_exceptions); +ZEND_API zend_result zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ptr, const char *string_name, bool handle_exceptions); /* export zend_pass_function to allow comparisons against it */ extern ZEND_API const zend_internal_function zend_pass_function; @@ -64,8 +64,8 @@ ZEND_API zend_bool ZEND_FASTCALL zend_verify_prop_assignable_by_ref(zend_propert ZEND_API ZEND_COLD void zend_throw_ref_type_error_zval(zend_property_info *prop, zval *zv); ZEND_API ZEND_COLD void zend_throw_ref_type_error_type(zend_property_info *prop1, zend_property_info *prop2, zval *zv); -ZEND_API ZEND_COLD int ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval); -ZEND_API ZEND_COLD int ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset); +ZEND_API ZEND_COLD zend_result ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval); +ZEND_API ZEND_COLD zend_result ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset); ZEND_API zend_bool zend_verify_scalar_type_hint(uint32_t type_mask, zval *arg, zend_bool strict, zend_bool is_internal_arg); ZEND_API ZEND_COLD void zend_verify_arg_error( @@ -155,8 +155,8 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval return variable_ptr; } -ZEND_API int zval_update_constant(zval *pp); -ZEND_API int zval_update_constant_ex(zval *pp, zend_class_entry *scope); +ZEND_API zend_result zval_update_constant(zval *pp); +ZEND_API zend_result zval_update_constant_ex(zval *pp, zend_class_entry *scope); /* dedicated Zend executor functions - do not use! */ struct _zend_vm_stack { @@ -317,7 +317,7 @@ ZEND_API uint32_t zend_get_executed_lineno(void); ZEND_API zend_class_entry *zend_get_executed_scope(void); ZEND_API zend_bool zend_is_executing(void); -ZEND_API void zend_set_timeout(zend_long seconds, int reset_signals); +ZEND_API void zend_set_timeout(zend_long seconds, bool reset_signals); ZEND_API void zend_unset_timeout(void); ZEND_API ZEND_NORETURN void ZEND_FASTCALL zend_timeout(void); ZEND_API zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_type); diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index b3d6319560dc2..77964e546b0f0 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -56,7 +56,7 @@ ZEND_TLS HANDLE tq_timer = NULL; #if 0&&ZEND_DEBUG static void (*original_sigsegv_handler)(int); -static void zend_handle_sigsegv(int dummy) /* {{{ */ +static void zend_handle_sigsegv(void) /* {{{ */ { fflush(stdout); fflush(stderr); @@ -585,7 +585,7 @@ ZEND_API zend_bool zend_is_executing(void) /* {{{ */ } /* }}} */ -ZEND_API int zval_update_constant_ex(zval *p, zend_class_entry *scope) /* {{{ */ +ZEND_API zend_result zval_update_constant_ex(zval *p, zend_class_entry *scope) /* {{{ */ { if (Z_TYPE_P(p) == IS_CONSTANT_AST) { zend_ast *ast = Z_ASTVAL_P(p); @@ -613,13 +613,13 @@ ZEND_API int zval_update_constant_ex(zval *p, zend_class_entry *scope) /* {{{ */ } /* }}} */ -ZEND_API int zval_update_constant(zval *pp) /* {{{ */ +ZEND_API zend_result zval_update_constant(zval *pp) /* {{{ */ { return zval_update_constant_ex(pp, EG(current_execute_data) ? zend_get_executed_scope() : CG(active_class_entry)); } /* }}} */ -int _call_user_function_impl(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], HashTable *named_params) /* {{{ */ +zend_result _call_user_function_impl(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], HashTable *named_params) /* {{{ */ { zend_fcall_info fci; @@ -635,7 +635,7 @@ int _call_user_function_impl(zval *object, zval *function_name, zval *retval_ptr } /* }}} */ -int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /* {{{ */ +zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /* {{{ */ { uint32_t i; zend_execute_data *call, dummy_execute_data; @@ -734,6 +734,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / for (i=0; iparam_count; i++) { zval *param = ZEND_CALL_ARG(call, i+1); zval *arg = &fci->params[i]; + zend_bool must_wrap = 0; if (UNEXPECTED(Z_ISUNDEF_P(arg))) { /* Allow forwarding undef slots. This is only used by Closure::__invoke(). */ ZVAL_UNDEF(param); @@ -745,8 +746,9 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / if (UNEXPECTED(!Z_ISREF_P(arg))) { if (!ARG_MAY_BE_SENT_BY_REF(func, i + 1)) { /* By-value send is not allowed -- emit a warning, - * but still perform the call with a by-value send. */ + * and perform the call with the value wrapped in a reference. */ zend_param_must_be_ref(func, i + 1); + must_wrap = 1; if (UNEXPECTED(EG(exception))) { ZEND_CALL_NUM_ARGS(call) = i; cleanup_args: @@ -767,7 +769,12 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / } } - ZVAL_COPY(param, arg); + if (EXPECTED(!must_wrap)) { + ZVAL_COPY(param, arg); + } else { + Z_TRY_ADDREF_P(arg); + ZVAL_NEW_REF(param, arg); + } } if (fci->named_params) { @@ -775,6 +782,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / zval *arg; uint32_t arg_num = ZEND_CALL_NUM_ARGS(call) + 1; zend_bool have_named_params = 0; + zend_bool must_wrap = 0; ZEND_HASH_FOREACH_STR_KEY_VAL(fci->named_params, name, arg) { zval *target; if (name) { @@ -799,8 +807,9 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / if (UNEXPECTED(!Z_ISREF_P(arg))) { if (!ARG_MAY_BE_SENT_BY_REF(func, arg_num)) { /* By-value send is not allowed -- emit a warning, - * but still perform the call with a by-value send. */ + * and perform the call with the value wrapped in a reference. */ zend_param_must_be_ref(func, arg_num); + must_wrap = 1; if (UNEXPECTED(EG(exception))) { goto cleanup_args; } @@ -814,7 +823,12 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / } } - ZVAL_COPY(target, arg); + if (EXPECTED(!must_wrap)) { + ZVAL_COPY(target, arg); + } else { + Z_TRY_ADDREF_P(arg); + ZVAL_NEW_REF(target, arg); + } if (!name) { ZEND_CALL_NUM_ARGS(call)++; arg_num++; @@ -942,7 +956,7 @@ ZEND_API void zend_call_known_function( fcic.object = object; fcic.called_scope = called_scope; - int result = zend_call_function(&fci, &fcic); + zend_result result = zend_call_function(&fci, &fcic); if (UNEXPECTED(result == FAILURE)) { if (!EG(exception)) { zend_error_noreturn(E_CORE_ERROR, "Couldn't execute method %s%s%s", @@ -1120,12 +1134,12 @@ ZEND_API zend_object *zend_get_this_object(zend_execute_data *ex) /* {{{ */ } /* }}} */ -ZEND_API int zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name) /* {{{ */ +ZEND_API zend_result zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name) /* {{{ */ { zval pv; zend_op_array *new_op_array; uint32_t original_compiler_options; - int retval; + zend_result retval; if (retval_ptr) { ZVAL_NEW_STR(&pv, zend_string_alloc(str_len + sizeof("return ;")-1, 0)); @@ -1184,15 +1198,15 @@ ZEND_API int zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr } /* }}} */ -ZEND_API int zend_eval_string(const char *str, zval *retval_ptr, const char *string_name) /* {{{ */ +ZEND_API zend_result zend_eval_string(const char *str, zval *retval_ptr, const char *string_name) /* {{{ */ { return zend_eval_stringl(str, strlen(str), retval_ptr, string_name); } /* }}} */ -ZEND_API int zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ptr, const char *string_name, int handle_exceptions) /* {{{ */ +ZEND_API zend_result zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ptr, const char *string_name, bool handle_exceptions) /* {{{ */ { - int result; + zend_result result; result = zend_eval_stringl(str, str_len, retval_ptr, string_name); if (handle_exceptions && EG(exception)) { @@ -1202,13 +1216,13 @@ ZEND_API int zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ } /* }}} */ -ZEND_API int zend_eval_string_ex(const char *str, zval *retval_ptr, const char *string_name, int handle_exceptions) /* {{{ */ +ZEND_API zend_result zend_eval_string_ex(const char *str, zval *retval_ptr, const char *string_name, bool handle_exceptions) /* {{{ */ { return zend_eval_stringl_ex(str, strlen(str), retval_ptr, string_name, handle_exceptions); } /* }}} */ -static void zend_set_timeout_ex(zend_long seconds, int reset_signals); +static void zend_set_timeout_ex(zend_long seconds, bool reset_signals); ZEND_API ZEND_NORETURN void ZEND_FASTCALL zend_timeout(void) /* {{{ */ { @@ -1308,7 +1322,7 @@ VOID CALLBACK tq_timer_cb(PVOID arg, BOOLEAN timed_out) #define SIGPROF 27 #endif -static void zend_set_timeout_ex(zend_long seconds, int reset_signals) /* {{{ */ +static void zend_set_timeout_ex(zend_long seconds, bool reset_signals) /* {{{ */ { #ifdef ZEND_WIN32 zend_executor_globals *eg; @@ -1380,7 +1394,7 @@ static void zend_set_timeout_ex(zend_long seconds, int reset_signals) /* {{{ */ } /* }}} */ -void zend_set_timeout(zend_long seconds, int reset_signals) /* {{{ */ +void zend_set_timeout(zend_long seconds, bool reset_signals) /* {{{ */ { EG(timeout_seconds) = seconds; @@ -1511,7 +1525,7 @@ zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, zend_string } /* }}} */ -ZEND_API int zend_delete_global_variable(zend_string *name) /* {{{ */ +ZEND_API zend_result zend_delete_global_variable(zend_string *name) /* {{{ */ { return zend_hash_del_ind(&EG(symbol_table), name); } @@ -1624,7 +1638,7 @@ ZEND_API void zend_detach_symbol_table(zend_execute_data *execute_data) /* {{{ * } /* }}} */ -ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force) /* {{{ */ +ZEND_API zend_result zend_set_local_var(zend_string *name, zval *value, bool force) /* {{{ */ { zend_execute_data *execute_data = EG(current_execute_data); @@ -1667,7 +1681,7 @@ ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force) /* {{ } /* }}} */ -ZEND_API int zend_set_local_var_str(const char *name, size_t len, zval *value, int force) /* {{{ */ +ZEND_API zend_result zend_set_local_var_str(const char *name, size_t len, zval *value, bool force) /* {{{ */ { zend_execute_data *execute_data = EG(current_execute_data); diff --git a/Zend/zend_extensions.c b/Zend/zend_extensions.c index 2509daf3180c5..c44a2f3093752 100644 --- a/Zend/zend_extensions.c +++ b/Zend/zend_extensions.c @@ -24,7 +24,7 @@ ZEND_API uint32_t zend_extension_flags = 0; ZEND_API int zend_op_array_extension_handles = 0; static int last_resource_number; -int zend_load_extension(const char *path) +zend_result zend_load_extension(const char *path) { #if ZEND_EXTENSIONS_SUPPORT DL_HANDLE handle; @@ -51,7 +51,7 @@ int zend_load_extension(const char *path) #endif } -int zend_load_extension_handle(DL_HANDLE handle, const char *path) +zend_result zend_load_extension_handle(DL_HANDLE handle, const char *path) { #if ZEND_EXTENSIONS_SUPPORT zend_extension *new_extension; @@ -126,7 +126,8 @@ int zend_load_extension_handle(DL_HANDLE handle, const char *path) return FAILURE; } - return zend_register_extension(new_extension, handle); + zend_register_extension(new_extension, handle); + return SUCCESS; #else fprintf(stderr, "Extensions are not supported on this platform.\n"); /* See http://support.microsoft.com/kb/190351 */ @@ -138,7 +139,7 @@ int zend_load_extension_handle(DL_HANDLE handle, const char *path) } -int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle) +void zend_register_extension(zend_extension *new_extension, DL_HANDLE handle) { #if ZEND_EXTENSIONS_SUPPORT zend_extension extension; @@ -167,8 +168,6 @@ int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle) } /*fprintf(stderr, "Loaded %s, version %s\n", extension.name, extension.version);*/ #endif - - return SUCCESS; } @@ -181,6 +180,7 @@ static void zend_extension_shutdown(zend_extension *extension) #endif } +/* int return due to zend linked list API */ static int zend_extension_startup(zend_extension *extension) { #if ZEND_EXTENSIONS_SUPPORT @@ -195,20 +195,18 @@ static int zend_extension_startup(zend_extension *extension) } -int zend_startup_extensions_mechanism() +void zend_startup_extensions_mechanism() { /* Startup extensions mechanism */ zend_llist_init(&zend_extensions, sizeof(zend_extension), (void (*)(void *)) zend_extension_dtor, 1); zend_op_array_extension_handles = 0; last_resource_number = 0; - return SUCCESS; } -int zend_startup_extensions() +void zend_startup_extensions() { zend_llist_apply_with_del(&zend_extensions, (int (*)(void *)) zend_extension_startup); - return SUCCESS; } diff --git a/Zend/zend_extensions.h b/Zend/zend_extensions.h index 59cd970b3a063..a26a6f9fc7e25 100644 --- a/Zend/zend_extensions.h +++ b/Zend/zend_extensions.h @@ -140,14 +140,14 @@ ZEND_API extern uint32_t zend_extension_flags; void zend_extension_dtor(zend_extension *extension); ZEND_API void zend_append_version_info(const zend_extension *extension); -int zend_startup_extensions_mechanism(void); -int zend_startup_extensions(void); +void zend_startup_extensions_mechanism(void); +void zend_startup_extensions(void); void zend_shutdown_extensions(void); BEGIN_EXTERN_C() -ZEND_API int zend_load_extension(const char *path); -ZEND_API int zend_load_extension_handle(DL_HANDLE handle, const char *path); -ZEND_API int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle); +ZEND_API zend_result zend_load_extension(const char *path); +ZEND_API zend_result zend_load_extension_handle(DL_HANDLE handle, const char *path); +ZEND_API void zend_register_extension(zend_extension *new_extension, DL_HANDLE handle); ZEND_API zend_extension *zend_get_extension(const char *extension_name); ZEND_API size_t zend_extensions_op_array_persist_calc(zend_op_array *op_array); ZEND_API size_t zend_extensions_op_array_persist(zend_op_array *op_array, void *mem); diff --git a/Zend/zend_gdb.c b/Zend/zend_gdb.c index 0fff7420486ff..ce6dc6a7850f9 100644 --- a/Zend/zend_gdb.c +++ b/Zend/zend_gdb.c @@ -54,7 +54,7 @@ ZEND_API zend_never_inline void __jit_debug_register_code() __asm__ __volatile__(""); } -ZEND_API int zend_gdb_register_code(const void *object, size_t size) +ZEND_API bool zend_gdb_register_code(const void *object, size_t size) { zend_gdbjit_code_entry *entry; @@ -102,9 +102,9 @@ ZEND_API void zend_gdb_unregister_all(void) } } -ZEND_API int zend_gdb_present(void) +ZEND_API bool zend_gdb_present(void) { - int ret = 0; + bool ret = 0; int fd = open("/proc/self/status", O_RDONLY); if (fd > 0) { diff --git a/Zend/zend_gdb.h b/Zend/zend_gdb.h index 220b70888fc80..aad0fefb097b9 100644 --- a/Zend/zend_gdb.h +++ b/Zend/zend_gdb.h @@ -20,8 +20,8 @@ #ifndef ZEND_GDB #define ZEND_GDB -ZEND_API int zend_gdb_register_code(const void *object, size_t size); +ZEND_API bool zend_gdb_register_code(const void *object, size_t size); ZEND_API void zend_gdb_unregister_all(void); -ZEND_API int zend_gdb_present(void); +ZEND_API bool zend_gdb_present(void); #endif diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 040a213ce7491..4f35b727aece3 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -629,7 +629,7 @@ ZEND_API zend_generator *zend_generator_update_current(zend_generator *generator return root; } -static int zend_generator_get_next_delegated_value(zend_generator *generator) /* {{{ */ +static zend_result zend_generator_get_next_delegated_value(zend_generator *generator) /* {{{ */ { zval *value; if (Z_TYPE(generator->values) == IS_ARRAY) { @@ -1106,6 +1106,7 @@ static const zend_object_iterator_funcs zend_generator_iterator_functions = { zend_generator_iterator_get_gc, }; +/* by_ref is int due to Iterator API */ zend_object_iterator *zend_generator_get_iterator(zend_class_entry *ce, zval *object, int by_ref) /* {{{ */ { zend_object_iterator *iterator; diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 365cf892beed8..abda03edf631e 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -218,7 +218,7 @@ static zend_always_inline void zend_hash_real_init_mixed_ex(HashTable *ht) HT_HASH_RESET(ht); } -static zend_always_inline void zend_hash_real_init_ex(HashTable *ht, int packed) +static zend_always_inline void zend_hash_real_init_ex(HashTable *ht, bool packed) { HT_ASSERT_RC1(ht); ZEND_ASSERT(HT_FLAGS(ht) & HASH_FLAG_UNINITIALIZED); @@ -1360,7 +1360,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_del_bucket(HashTable *ht, Bucket *p) _zend_hash_del_el(ht, HT_IDX_TO_HASH(p - ht->arData), p); } -ZEND_API int ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key) +ZEND_API zend_result ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key) { zend_ulong h; uint32_t nIndex; @@ -1390,7 +1390,7 @@ ZEND_API int ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key) return FAILURE; } -ZEND_API int ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key) +ZEND_API zend_result ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key) { zend_ulong h; uint32_t nIndex; @@ -1438,7 +1438,7 @@ ZEND_API int ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key) return FAILURE; } -ZEND_API int ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *str, size_t len) +ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *str, size_t len) { zend_ulong h; uint32_t nIndex; @@ -1482,7 +1482,7 @@ ZEND_API int ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *str, return FAILURE; } -ZEND_API int ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *str, size_t len) +ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *str, size_t len) { zend_ulong h; uint32_t nIndex; @@ -1512,7 +1512,7 @@ ZEND_API int ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *str, siz return FAILURE; } -ZEND_API int ZEND_FASTCALL zend_hash_index_del(HashTable *ht, zend_ulong h) +ZEND_API zend_result ZEND_FASTCALL zend_hash_index_del(HashTable *ht, zend_ulong h) { uint32_t nIndex; uint32_t idx; @@ -1964,7 +1964,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_copy(HashTable *target, HashTable *source, } -static zend_always_inline int zend_array_dup_element(HashTable *source, HashTable *target, uint32_t idx, Bucket *p, Bucket *q, int packed, int static_keys, int with_holes) +static zend_always_inline bool zend_array_dup_element(HashTable *source, HashTable *target, uint32_t idx, Bucket *p, Bucket *q, bool packed, bool static_keys, bool with_holes) { zval *data = &p->val; @@ -2018,7 +2018,7 @@ static zend_always_inline int zend_array_dup_element(HashTable *source, HashTabl return 1; } -static zend_always_inline void zend_array_dup_packed_elements(HashTable *source, HashTable *target, int with_holes) +static zend_always_inline void zend_array_dup_packed_elements(HashTable *source, HashTable *target, bool with_holes) { Bucket *p = source->arData; Bucket *q = target->arData; @@ -2034,7 +2034,7 @@ static zend_always_inline void zend_array_dup_packed_elements(HashTable *source, } while (p != end); } -static zend_always_inline uint32_t zend_array_dup_elements(HashTable *source, HashTable *target, int static_keys, int with_holes) +static zend_always_inline uint32_t zend_array_dup_elements(HashTable *source, HashTable *target, bool static_keys, bool with_holes) { uint32_t idx = 0; Bucket *p = source->arData; @@ -2325,7 +2325,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_end_ex(HashTable *ht, Has } -ZEND_API int ZEND_FASTCALL zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos) +ZEND_API zend_result ZEND_FASTCALL zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos) { uint32_t idx; @@ -2350,7 +2350,7 @@ ZEND_API int ZEND_FASTCALL zend_hash_move_forward_ex(HashTable *ht, HashPosition } } -ZEND_API int ZEND_FASTCALL zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos) +ZEND_API zend_result ZEND_FASTCALL zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos) { uint32_t idx = *pos; @@ -2707,7 +2707,7 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_minmax(const HashTable *ht, bucket_compar return &res->val; } -ZEND_API int ZEND_FASTCALL _zend_handle_numeric_str_ex(const char *key, size_t length, zend_ulong *idx) +ZEND_API bool ZEND_FASTCALL _zend_handle_numeric_str_ex(const char *key, size_t length, zend_ulong *idx) { register const char *tmp = key; diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index 294a9c2c26389..fb11c4a9e321e 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -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); @@ -164,11 +162,11 @@ ZEND_API void ZEND_FASTCALL zend_hash_reverse_apply(HashTable *ht, apply_func_t /* Deletes */ -ZEND_API int ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key); -ZEND_API int ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key); -ZEND_API int ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *key, size_t len); -ZEND_API int ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *key, size_t len); -ZEND_API int ZEND_FASTCALL zend_hash_index_del(HashTable *ht, zend_ulong h); +ZEND_API zend_result ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key); +ZEND_API zend_result ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key); +ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *key, size_t len); +ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *key, size_t len); +ZEND_API zend_result ZEND_FASTCALL zend_hash_index_del(HashTable *ht, zend_ulong h); ZEND_API void ZEND_FASTCALL zend_hash_del_bucket(HashTable *ht, Bucket *p); /* Data retrieval */ @@ -229,11 +227,11 @@ ZEND_API HashPosition ZEND_FASTCALL zend_hash_get_current_pos(const HashTable *h #define zend_hash_has_more_elements_ex(ht, pos) \ (zend_hash_get_current_key_type_ex(ht, pos) == HASH_KEY_NON_EXISTENT ? FAILURE : SUCCESS) -ZEND_API int ZEND_FASTCALL zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos); -ZEND_API int ZEND_FASTCALL zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos); -ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, HashPosition *pos); +ZEND_API zend_result ZEND_FASTCALL zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos); +ZEND_API zend_result ZEND_FASTCALL zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos); +ZEND_API zend_result ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, HashPosition *pos); ZEND_API void ZEND_FASTCALL zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, HashPosition *pos); -ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_type_ex(HashTable *ht, HashPosition *pos); +ZEND_API zend_result ZEND_FASTCALL zend_hash_get_current_key_type_ex(HashTable *ht, HashPosition *pos); ZEND_API zval* ZEND_FASTCALL zend_hash_get_current_data_ex(HashTable *ht, HashPosition *pos); ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_reset_ex(HashTable *ht, HashPosition *pos); ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_end_ex(HashTable *ht, HashPosition *pos); @@ -307,7 +305,7 @@ ZEND_API void ZEND_FASTCALL zend_symtable_clean(HashTable *ht); ZEND_API HashTable* ZEND_FASTCALL zend_symtable_to_proptable(HashTable *ht); ZEND_API HashTable* ZEND_FASTCALL zend_proptable_to_symtable(HashTable *ht, zend_bool always_duplicate); -ZEND_API int ZEND_FASTCALL _zend_handle_numeric_str_ex(const char *key, size_t length, zend_ulong *idx); +ZEND_API bool ZEND_FASTCALL _zend_handle_numeric_str_ex(const char *key, size_t length, zend_ulong *idx); ZEND_API uint32_t ZEND_FASTCALL zend_hash_iterator_add(HashTable *ht, HashPosition pos); ZEND_API HashPosition ZEND_FASTCALL zend_hash_iterator_pos(uint32_t idx, HashTable *ht); @@ -353,7 +351,7 @@ END_EXTERN_C() #define ZEND_INIT_SYMTABLE_EX(ht, n, persistent) \ zend_hash_init(ht, n, NULL, ZVAL_PTR_DTOR, persistent) -static zend_always_inline int _zend_handle_numeric_str(const char *key, size_t length, zend_ulong *idx) +static zend_always_inline bool _zend_handle_numeric_str(const char *key, size_t length, zend_ulong *idx) { const char *tmp = key; @@ -398,7 +396,7 @@ static zend_always_inline zval *zend_hash_find_ex_ind(const HashTable *ht, zend_ } -static zend_always_inline int zend_hash_exists_ind(const HashTable *ht, zend_string *key) +static zend_always_inline bool zend_hash_exists_ind(const HashTable *ht, zend_string *key) { zval *zv; @@ -418,7 +416,7 @@ static zend_always_inline zval *zend_hash_str_find_ind(const HashTable *ht, cons } -static zend_always_inline int zend_hash_str_exists_ind(const HashTable *ht, const char *str, size_t len) +static zend_always_inline bool zend_hash_str_exists_ind(const HashTable *ht, const char *str, size_t len) { zval *zv; @@ -462,7 +460,7 @@ static zend_always_inline zval *zend_symtable_update_ind(HashTable *ht, zend_str } -static zend_always_inline int zend_symtable_del(HashTable *ht, zend_string *key) +static zend_always_inline zend_result zend_symtable_del(HashTable *ht, zend_string *key) { zend_ulong idx; @@ -474,7 +472,7 @@ static zend_always_inline int zend_symtable_del(HashTable *ht, zend_string *key) } -static zend_always_inline int zend_symtable_del_ind(HashTable *ht, zend_string *key) +static zend_always_inline zend_result zend_symtable_del_ind(HashTable *ht, zend_string *key) { zend_ulong idx; @@ -510,7 +508,7 @@ static zend_always_inline zval *zend_symtable_find_ind(const HashTable *ht, zend } -static zend_always_inline int zend_symtable_exists(HashTable *ht, zend_string *key) +static zend_always_inline bool zend_symtable_exists(HashTable *ht, zend_string *key) { zend_ulong idx; @@ -522,7 +520,7 @@ static zend_always_inline int zend_symtable_exists(HashTable *ht, zend_string *k } -static zend_always_inline int zend_symtable_exists_ind(HashTable *ht, zend_string *key) +static zend_always_inline bool zend_symtable_exists_ind(HashTable *ht, zend_string *key) { zend_ulong idx; @@ -558,7 +556,7 @@ static zend_always_inline zval *zend_symtable_str_update_ind(HashTable *ht, cons } -static zend_always_inline int zend_symtable_str_del(HashTable *ht, const char *str, size_t len) +static zend_always_inline zend_result zend_symtable_str_del(HashTable *ht, const char *str, size_t len) { zend_ulong idx; @@ -570,7 +568,7 @@ static zend_always_inline int zend_symtable_str_del(HashTable *ht, const char *s } -static zend_always_inline int zend_symtable_str_del_ind(HashTable *ht, const char *str, size_t len) +static zend_always_inline zend_result zend_symtable_str_del_ind(HashTable *ht, const char *str, size_t len) { zend_ulong idx; @@ -594,7 +592,7 @@ static zend_always_inline zval *zend_symtable_str_find(HashTable *ht, const char } -static zend_always_inline int zend_symtable_str_exists(HashTable *ht, const char *str, size_t len) +static zend_always_inline bool zend_symtable_str_exists(HashTable *ht, const char *str, size_t len) { zend_ulong idx; @@ -1151,7 +1149,7 @@ static zend_always_inline void *zend_hash_get_current_data_ptr_ex(HashTable *ht, ZEND_HASH_FILL_FINISH(); \ } while (0) -static zend_always_inline zval *_zend_hash_append_ex(HashTable *ht, zend_string *key, zval *zv, int interned) +static zend_always_inline zval *_zend_hash_append_ex(HashTable *ht, zend_string *key, zval *zv, bool interned) { uint32_t idx = ht->nNumUsed++; uint32_t nIndex; @@ -1177,7 +1175,7 @@ static zend_always_inline zval *_zend_hash_append(HashTable *ht, zend_string *ke return _zend_hash_append_ex(ht, key, zv, 0); } -static zend_always_inline zval *_zend_hash_append_ptr_ex(HashTable *ht, zend_string *key, void *ptr, int interned) +static zend_always_inline zval *_zend_hash_append_ptr_ex(HashTable *ht, zend_string *key, void *ptr, bool interned) { uint32_t idx = ht->nNumUsed++; uint32_t nIndex; diff --git a/Zend/zend_highlight.h b/Zend/zend_highlight.h index 8ea1518ca662f..c4f819d508c1e 100644 --- a/Zend/zend_highlight.h +++ b/Zend/zend_highlight.h @@ -39,8 +39,8 @@ typedef struct _zend_syntax_highlighter_ini { BEGIN_EXTERN_C() ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini); ZEND_API void zend_strip(void); -ZEND_API int highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini); -ZEND_API int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, const char *str_name); +ZEND_API zend_result highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini); +ZEND_API void highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, const char *str_name); ZEND_API void zend_html_putc(char c); ZEND_API void zend_html_puts(const char *s, size_t len); END_EXTERN_C() diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 158b67ce38007..4d2e2d540074c 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -633,7 +633,7 @@ static inheritance_status zend_do_perform_implementation_check( /* }}} */ static ZEND_COLD void zend_append_type_hint( - smart_str *str, zend_class_entry *scope, zend_arg_info *arg_info, int return_hint) /* {{{ */ + smart_str *str, zend_class_entry *scope, zend_arg_info *arg_info, bool return_hint) /* {{{ */ { if (ZEND_TYPE_IS_SET(arg_info->type)) { zend_string *type_str = zend_type_to_string_resolved(arg_info->type, scope); @@ -2390,7 +2390,7 @@ static void check_unrecoverable_load_failure(zend_class_entry *ce) { } } -ZEND_API int zend_do_link_class(zend_class_entry *ce, zend_string *lc_parent_name) /* {{{ */ +ZEND_API zend_result zend_do_link_class(zend_class_entry *ce, zend_string *lc_parent_name) /* {{{ */ { /* Load parent/interface dependencies first, so we can still gracefully abort linking * with an exception and remove the class from the class table. This is only possible diff --git a/Zend/zend_inheritance.h b/Zend/zend_inheritance.h index 6cf2d1b78d874..e49ec49b6f958 100644 --- a/Zend/zend_inheritance.h +++ b/Zend/zend_inheritance.h @@ -30,7 +30,7 @@ ZEND_API void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *par #define zend_do_inheritance(ce, parent_ce) \ zend_do_inheritance_ex(ce, parent_ce, 0) -ZEND_API int zend_do_link_class(zend_class_entry *ce, zend_string *lc_parent_name); +ZEND_API zend_result zend_do_link_class(zend_class_entry *ce, zend_string *lc_parent_name); void zend_verify_abstract_class(zend_class_entry *ce); void zend_build_properties_info_table(zend_class_entry *ce); diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c index 279dcae03c931..75c7faf4c014e 100644 --- a/Zend/zend_ini.c +++ b/Zend/zend_ini.c @@ -41,9 +41,9 @@ static int zend_remove_ini_entries(zval *el, void *arg) /* {{{ */ } /* }}} */ -static int zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stage) /* {{{ */ +static zend_result zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stage) /* {{{ */ { - int result = FAILURE; + zend_result result = FAILURE; if (ini_entry->modified) { if (ini_entry->on_modify) { @@ -89,22 +89,20 @@ static void free_ini_entry(zval *zv) /* {{{ */ /* * Startup / shutdown */ -ZEND_API int zend_ini_startup(void) /* {{{ */ +ZEND_API void zend_ini_startup(void) /* {{{ */ { registered_zend_ini_directives = (HashTable *) malloc(sizeof(HashTable)); 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); - return SUCCESS; + zend_hash_init(registered_zend_ini_directives, 128, NULL, free_ini_entry, 1); } /* }}} */ -ZEND_API int zend_ini_shutdown(void) /* {{{ */ +ZEND_API void zend_ini_shutdown(void) /* {{{ */ { zend_ini_dtor(EG(ini_directives)); - return SUCCESS; } /* }}} */ @@ -115,15 +113,14 @@ ZEND_API void zend_ini_dtor(HashTable *ini_directives) /* {{{ */ } /* }}} */ -ZEND_API int zend_ini_global_shutdown(void) /* {{{ */ +ZEND_API void zend_ini_global_shutdown(void) /* {{{ */ { zend_hash_destroy(registered_zend_ini_directives); free(registered_zend_ini_directives); - return SUCCESS; } /* }}} */ -ZEND_API int zend_ini_deactivate(void) /* {{{ */ +ZEND_API void zend_ini_deactivate(void) /* {{{ */ { if (EG(modified_ini_directives)) { zend_ini_entry *ini_entry; @@ -135,7 +132,6 @@ ZEND_API int zend_ini_deactivate(void) /* {{{ */ FREE_HASHTABLE(EG(modified_ini_directives)); EG(modified_ini_directives) = NULL; } - return SUCCESS; } /* }}} */ @@ -159,14 +155,13 @@ static void copy_ini_entry(zval *zv) /* {{{ */ } /* }}} */ -ZEND_API int zend_copy_ini_directives(void) /* {{{ */ +ZEND_API void 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; } /* }}} */ #endif @@ -199,7 +194,7 @@ ZEND_API void zend_ini_sort_entries(void) /* {{{ */ /* * Registration / unregistration */ -ZEND_API int zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number) /* {{{ */ +ZEND_API zend_result zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number) /* {{{ */ { zend_ini_entry *p; zval *default_value; @@ -280,16 +275,16 @@ ZEND_API void zend_ini_refresh_caches(int stage) /* {{{ */ /* }}} */ #endif -ZEND_API int zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage) /* {{{ */ +ZEND_API zend_result zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage) /* {{{ */ { return zend_alter_ini_entry_ex(name, new_value, modify_type, stage, 0); } /* }}} */ -ZEND_API int zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage) /* {{{ */ +ZEND_API zend_result zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage) /* {{{ */ { - int ret; + zend_result ret; zend_string *new_value; new_value = zend_string_init(value, value_length, !(stage & ZEND_INI_STAGE_IN_REQUEST)); @@ -299,9 +294,9 @@ ZEND_API int zend_alter_ini_entry_chars(zend_string *name, const char *value, si } /* }}} */ -ZEND_API int zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change) /* {{{ */ +ZEND_API zend_result zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change) /* {{{ */ { - int ret; + zend_result ret; zend_string *new_value; new_value = zend_string_init(value, value_length, !(stage & ZEND_INI_STAGE_IN_REQUEST)); @@ -311,11 +306,11 @@ ZEND_API int zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, } /* }}} */ -ZEND_API int zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, int force_change) /* {{{ */ +ZEND_API zend_result zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, bool force_change) /* {{{ */ { zend_ini_entry *ini_entry; zend_string *duplicate; - zend_bool modifiable; + uint8_t modifiable; zend_bool modified; if ((ini_entry = zend_hash_find_ptr(EG(ini_directives), name)) == NULL) { @@ -363,7 +358,7 @@ ZEND_API int zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, } /* }}} */ -ZEND_API int zend_restore_ini_entry(zend_string *name, int stage) /* {{{ */ +ZEND_API zend_result zend_restore_ini_entry(zend_string *name, int stage) /* {{{ */ { zend_ini_entry *ini_entry; @@ -384,7 +379,7 @@ ZEND_API int zend_restore_ini_entry(zend_string *name, int stage) /* {{{ */ } /* }}} */ -ZEND_API int zend_ini_register_displayer(const char *name, uint32_t name_length, void (*displayer)(zend_ini_entry *ini_entry, int type)) /* {{{ */ +ZEND_API zend_result zend_ini_register_displayer(const char *name, uint32_t name_length, void (*displayer)(zend_ini_entry *ini_entry, int type)) /* {{{ */ { zend_ini_entry *ini_entry; diff --git a/Zend/zend_ini.h b/Zend/zend_ini.h index 0289b322be1a2..d227f3779d990 100644 --- a/Zend/zend_ini.h +++ b/Zend/zend_ini.h @@ -61,24 +61,24 @@ struct _zend_ini_entry { }; BEGIN_EXTERN_C() -ZEND_API int zend_ini_startup(void); -ZEND_API int zend_ini_shutdown(void); -ZEND_API int zend_ini_global_shutdown(void); -ZEND_API int zend_ini_deactivate(void); +ZEND_API void zend_ini_startup(void); +ZEND_API void zend_ini_shutdown(void); +ZEND_API void zend_ini_global_shutdown(void); +ZEND_API void zend_ini_deactivate(void); ZEND_API void zend_ini_dtor(HashTable *ini_directives); -ZEND_API int zend_copy_ini_directives(void); +ZEND_API void zend_copy_ini_directives(void); ZEND_API void zend_ini_sort_entries(void); -ZEND_API int zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number); +ZEND_API zend_result zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number); ZEND_API void zend_unregister_ini_entries(int module_number); ZEND_API void zend_ini_refresh_caches(int stage); -ZEND_API int zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage); -ZEND_API int zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, int force_change); -ZEND_API int zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage); -ZEND_API int zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change); -ZEND_API int zend_restore_ini_entry(zend_string *name, int stage); +ZEND_API zend_result zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage); +ZEND_API zend_result zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, bool force_change); +ZEND_API zend_result zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage); +ZEND_API zend_result zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change); +ZEND_API zend_result zend_restore_ini_entry(zend_string *name, int stage); ZEND_API void display_ini_entries(zend_module_entry *module); ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, int orig); @@ -88,7 +88,7 @@ ZEND_API char *zend_ini_string_ex(const char *name, size_t name_length, int orig ZEND_API zend_string *zend_ini_get_value(zend_string *name); ZEND_API zend_bool zend_ini_parse_bool(zend_string *str); -ZEND_API int zend_ini_register_displayer(const char *name, uint32_t name_length, void (*displayer)(zend_ini_entry *ini_entry, int type)); +ZEND_API zend_result zend_ini_register_displayer(const char *name, uint32_t name_length, void (*displayer)(zend_ini_entry *ini_entry, int type)); ZEND_API ZEND_INI_DISP(zend_ini_boolean_displayer_cb); ZEND_API ZEND_INI_DISP(zend_ini_color_displayer_cb); diff --git a/Zend/zend_ini_parser.y b/Zend/zend_ini_parser.y index 373dee7aeb16d..f9170d9ecc024 100644 --- a/Zend/zend_ini_parser.y +++ b/Zend/zend_ini_parser.y @@ -212,7 +212,7 @@ static ZEND_COLD void ini_error(const char *msg) /* }}} */ /* {{{ zend_parse_ini_file() */ -ZEND_API int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg) +ZEND_API zend_result zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg) { int retval; zend_ini_parser_param ini_parser_param; @@ -240,7 +240,7 @@ ZEND_API int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_erro /* }}} */ /* {{{ zend_parse_ini_string() */ -ZEND_API int zend_parse_ini_string(char *str, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg) +ZEND_API zend_result zend_parse_ini_string(char *str, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg) { int retval; zend_ini_parser_param ini_parser_param; diff --git a/Zend/zend_ini_scanner.h b/Zend/zend_ini_scanner.h index ddb9247d3721d..f3d7f1a82b271 100644 --- a/Zend/zend_ini_scanner.h +++ b/Zend/zend_ini_scanner.h @@ -28,8 +28,8 @@ BEGIN_EXTERN_C() ZEND_COLD int zend_ini_scanner_get_lineno(void); ZEND_COLD char *zend_ini_scanner_get_filename(void); -int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode); -int zend_ini_prepare_string_for_scanning(char *str, int scanner_mode); +zend_result zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode); +zend_result zend_ini_prepare_string_for_scanning(char *str, int scanner_mode); int ini_lex(zval *ini_lval); void shutdown_ini_scanner(void); END_EXTERN_C() diff --git a/Zend/zend_ini_scanner.l b/Zend/zend_ini_scanner.l index c8efb1f144d95..1d689f3748a5d 100644 --- a/Zend/zend_ini_scanner.l +++ b/Zend/zend_ini_scanner.l @@ -151,7 +151,7 @@ ZEND_API zend_ini_scanner_globals ini_scanner_globals; return type; \ } -static inline int convert_to_number(zval *retval, const char *str, const int str_len) +static inline zend_result convert_to_number(zval *retval, const char *str, const int str_len) { zend_uchar type; int overflow; @@ -218,7 +218,7 @@ static void yy_scan_buffer(char *str, unsigned int len) #define ini_filename SCNG(filename) /* {{{ init_ini_scanner() */ -static int init_ini_scanner(int scanner_mode, zend_file_handle *fh) +static zend_result init_ini_scanner(int scanner_mode, zend_file_handle *fh) { /* Sanity check */ if (scanner_mode != ZEND_INI_SCANNER_NORMAL && scanner_mode != ZEND_INI_SCANNER_RAW && scanner_mode != ZEND_INI_SCANNER_TYPED) { @@ -268,7 +268,7 @@ ZEND_COLD char *zend_ini_scanner_get_filename(void) /* }}} */ /* {{{ zend_ini_open_file_for_scanning() */ -int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode) +zend_result zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode) { char *buf; size_t size; @@ -289,7 +289,7 @@ int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode) /* }}} */ /* {{{ zend_ini_prepare_string_for_scanning() */ -int zend_ini_prepare_string_for_scanning(char *str, int scanner_mode) +zend_result zend_ini_prepare_string_for_scanning(char *str, int scanner_mode) { int len = (int)strlen(str); diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index 16c193e42060e..1278f08209d67 100644 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -53,7 +53,7 @@ ZEND_API zval* zend_call_method(zend_object *object, zend_class_entry *obj_ce, z } if (!fn_proxy || !*fn_proxy) { if (EXPECTED(obj_ce)) { - fn = zend_hash_str_find_ptr( + fn = zend_hash_str_find_ptr_lc( &obj_ce->function_table, function_name, function_name_len); if (UNEXPECTED(fn == NULL)) { /* error at c-level */ @@ -124,7 +124,7 @@ ZEND_API int zend_user_it_valid(zend_object_iterator *_iter) zend_user_iterator *iter = (zend_user_iterator*)_iter; zval *object = &iter->it.data; zval more; - int result; + bool result; zend_call_method_with_0_params(Z_OBJ_P(object), iter->ce, &iter->ce->iterator_funcs_ptr->zf_valid, "valid", &more); result = i_zend_is_true(&more); @@ -203,6 +203,7 @@ static const zend_object_iterator_funcs zend_interface_iterator_funcs_iterator = }; /* {{{ zend_user_it_get_iterator */ +/* by_ref is int due to Iterator API */ static zend_object_iterator *zend_user_it_get_iterator(zend_class_entry *ce, zval *object, int by_ref) { zend_user_iterator *iterator; @@ -225,6 +226,7 @@ static zend_object_iterator *zend_user_it_get_iterator(zend_class_entry *ce, zva /* }}} */ /* {{{ zend_user_it_get_new_iterator */ +/* by_ref is int due to Iterator API */ ZEND_API zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *ce, zval *object, int by_ref) { zval iterator; @@ -356,7 +358,7 @@ ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, size_t *b { zend_class_entry * ce = Z_OBJCE_P(object); zval retval; - int result; + zend_result result; zend_call_method_with_0_params( Z_OBJ_P(object), Z_OBJCE_P(object), NULL, "serialize", &retval); @@ -458,7 +460,7 @@ static zend_object *zend_internal_iterator_create(zend_class_entry *ce) { return &intern->std; } -ZEND_API int zend_create_internal_iterator_zval(zval *return_value, zval *obj) { +ZEND_API zend_result zend_create_internal_iterator_zval(zval *return_value, zval *obj) { zend_class_entry *scope = EG(current_execute_data)->func->common.scope; ZEND_ASSERT(scope->get_iterator != zend_user_it_get_new_iterator); zend_object_iterator *iter = scope->get_iterator(Z_OBJCE_P(obj), obj, /* by_ref */ 0); @@ -492,7 +494,7 @@ static zend_internal_iterator *zend_internal_iterator_fetch(zval *This) { } /* Many iterators will not behave correctly if rewind() is not called, make sure it happens. */ -static int zend_internal_iterator_ensure_rewound(zend_internal_iterator *intern) { +static zend_result zend_internal_iterator_ensure_rewound(zend_internal_iterator *intern) { if (!intern->rewind_called) { zend_object_iterator *iter = intern->iter; intern->rewind_called = 1; diff --git a/Zend/zend_interfaces.h b/Zend/zend_interfaces.h index 3f3f39b0877f4..ecdc9b0e1b278 100644 --- a/Zend/zend_interfaces.h +++ b/Zend/zend_interfaces.h @@ -61,7 +61,7 @@ ZEND_API zval* zend_call_method(zend_object *object, zend_class_entry *obj_ce, z zend_class_implements(zend_ce_ ## class_name, 1, zend_ce_ ## interface_name) ZEND_API void zend_user_it_rewind(zend_object_iterator *_iter); -ZEND_API int zend_user_it_valid(zend_object_iterator *_iter); +ZEND_API zend_result zend_user_it_valid(zend_object_iterator *_iter); ZEND_API void zend_user_it_get_current_key(zend_object_iterator *_iter, zval *key); ZEND_API zval *zend_user_it_get_current_data(zend_object_iterator *_iter); ZEND_API void zend_user_it_move_forward(zend_object_iterator *_iter); @@ -78,7 +78,7 @@ ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const uns ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data); ZEND_API int zend_class_unserialize_deny(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data); -ZEND_API int zend_create_internal_iterator_zval(zval *return_value, zval *obj); +ZEND_API zend_result zend_create_internal_iterator_zval(zval *return_value, zval *obj); END_EXTERN_C() diff --git a/Zend/zend_language_scanner.h b/Zend/zend_language_scanner.h index c15f11af2e51b..f08dbb4ea91d8 100644 --- a/Zend/zend_language_scanner.h +++ b/Zend/zend_language_scanner.h @@ -75,10 +75,10 @@ typedef struct _zend_nest_location { BEGIN_EXTERN_C() ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state); ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state); -ZEND_API int zend_prepare_string_for_scanning(zval *str, const char *filename); +ZEND_API void zend_prepare_string_for_scanning(zval *str, const char *filename); ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, const zend_encoding *old_encoding); -ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding); -ZEND_API int zend_lex_tstring(zval *zv, zend_lexer_ident_ref ident_ref); +ZEND_API zend_result zend_multibyte_set_filter(const zend_encoding *onetime_encoding); +ZEND_API zend_result zend_lex_tstring(zval *zv, zend_lexer_ident_ref ident_ref); END_EXTERN_C() diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index deee3ae3cf759..ee88282fd5176 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -306,7 +306,7 @@ ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle) } } -ZEND_API int zend_lex_tstring(zval *zv, zend_lexer_ident_ref ident_ref) +ZEND_API zend_result zend_lex_tstring(zval *zv, zend_lexer_ident_ref ident_ref) { char *ident = (char *) SCNG(yy_start) + ident_ref.offset; size_t length = ident_ref.len; @@ -486,7 +486,7 @@ static const zend_encoding* zend_multibyte_find_script_encoding(void) return CG(script_encoding_list)[0]; } -ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding) +ZEND_API zend_result zend_multibyte_set_filter(const zend_encoding *onetime_encoding) { const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding(); const zend_encoding *script_encoding = onetime_encoding ? onetime_encoding: zend_multibyte_find_script_encoding(); @@ -524,10 +524,10 @@ ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding) LANG_SCNG(output_filter) = encoding_filter_intermediate_to_internal; } - return 0; + return SUCCESS; } -ZEND_API int open_file_for_scanning(zend_file_handle *file_handle) +ZEND_API zend_result open_file_for_scanning(zend_file_handle *file_handle) { char *buf; size_t size; @@ -680,16 +680,15 @@ ZEND_API zend_ast *zend_compile_string_to_ast( CG(in_compilation) = 1; zend_save_lexical_state(&original_lex_state); - if (zend_prepare_string_for_scanning(&code_zv, filename) == SUCCESS) { - CG(ast) = NULL; - CG(ast_arena) = zend_arena_create(1024 * 32); - LANG_SCNG(yy_state) = yycINITIAL; + zend_prepare_string_for_scanning(&code_zv, filename); + CG(ast) = NULL; + CG(ast_arena) = zend_arena_create(1024 * 32); + LANG_SCNG(yy_state) = yycINITIAL; - if (zendparse() != 0) { - zend_ast_destroy(CG(ast)); - zend_arena_destroy(CG(ast_arena)); - CG(ast) = NULL; - } + if (zendparse() != 0) { + zend_ast_destroy(CG(ast)); + zend_arena_destroy(CG(ast_arena)); + CG(ast) = NULL; } /* restore_lexical_state changes CG(ast) and CG(ast_arena) */ @@ -699,7 +698,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; } @@ -737,7 +736,7 @@ zend_op_array *compile_filename(int type, zval *filename) return retval; } -ZEND_API int zend_prepare_string_for_scanning(zval *str, const char *filename) +ZEND_API void zend_prepare_string_for_scanning(zval *str, const char *filename) { char *buf; size_t size, old_len; @@ -780,7 +779,6 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, const char *filename) CG(zend_lineno) = 1; CG(increment_lineno) = 0; RESET_DOC_COMMENT(); - return SUCCESS; } @@ -823,10 +821,9 @@ zend_op_array *compile_string(zval *source_string, const char *filename) } zend_save_lexical_state(&original_lex_state); - if (zend_prepare_string_for_scanning(&tmp, filename) == SUCCESS) { - BEGIN(ST_IN_SCRIPTING); - op_array = zend_compile(ZEND_EVAL_CODE); - } + zend_prepare_string_for_scanning(&tmp, filename); + BEGIN(ST_IN_SCRIPTING); + op_array = zend_compile(ZEND_EVAL_CODE); zend_restore_lexical_state(&original_lex_state); zval_ptr_dtor(&tmp); @@ -836,7 +833,7 @@ zend_op_array *compile_string(zval *source_string, const char *filename) BEGIN_EXTERN_C() -int highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini) +zend_result highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini) { zend_lex_state original_lex_state; zend_file_handle file_handle; @@ -858,7 +855,7 @@ int highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_hig return SUCCESS; } -int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, const char *str_name) +void highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, const char *str_name) { zend_lex_state original_lex_state; zval tmp; @@ -868,13 +865,7 @@ int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ str = &tmp; } zend_save_lexical_state(&original_lex_state); - if (zend_prepare_string_for_scanning(str, str_name)==FAILURE) { - zend_restore_lexical_state(&original_lex_state); - if (UNEXPECTED(str == &tmp)) { - zval_ptr_dtor(&tmp); - } - return FAILURE; - } + zend_prepare_string_for_scanning(str, str_name); BEGIN(INITIAL); zend_highlight(syntax_highlighter_ini); if (SCNG(script_filtered)) { @@ -885,7 +876,6 @@ int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ if (UNEXPECTED(str == &tmp)) { zval_ptr_dtor(&tmp); } - return SUCCESS; } ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, const zend_encoding *old_encoding) @@ -937,7 +927,7 @@ ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter ZVAL_STRINGL(zendlval, yytext, yyleng); \ } -static int zend_scan_escape_string(zval *zendlval, char *str, int len, char quote_type) +static zend_result zend_scan_escape_string(zval *zendlval, char *str, int len, char quote_type) { register char *s, *t; char *end; @@ -1290,11 +1280,11 @@ static void enter_nesting(char opening) zend_stack_push(&SCNG(nest_location_stack), &nest_loc); } -static int exit_nesting(char closing) +static zend_result exit_nesting(char closing) { if (zend_stack_is_empty(&SCNG(nest_location_stack))) { zend_throw_exception_ex(zend_ce_parse_error, 0, "Unmatched '%c'", closing); - return -1; + return FAILURE; } zend_nest_location *nest_loc = zend_stack_top(&SCNG(nest_location_stack)); @@ -1304,22 +1294,22 @@ static int exit_nesting(char closing) (opening == '[' && closing != ']') || (opening == '(' && closing != ')')) { report_bad_nesting(opening, nest_loc->lineno, closing); - return -1; + return FAILURE; } zend_stack_del_top(&SCNG(nest_location_stack)); - return 0; + return SUCCESS; } -static int check_nesting_at_end() +static zend_result check_nesting_at_end() { if (!zend_stack_is_empty(&SCNG(nest_location_stack))) { zend_nest_location *nest_loc = zend_stack_top(&SCNG(nest_location_stack)); report_bad_nesting(nest_loc->text, nest_loc->lineno, 0); - return -1; + return FAILURE; } - return 0; + return SUCCESS; } #define PARSER_MODE() \ diff --git a/Zend/zend_list.c b/Zend/zend_list.c index 3464ca27d524d..45ff950b6bfec 100644 --- a/Zend/zend_list.c +++ b/Zend/zend_list.c @@ -42,7 +42,7 @@ ZEND_API zval* ZEND_FASTCALL zend_list_insert(void *ptr, int type) return zend_hash_index_add_new(&EG(regular_list), index, &zv); } -ZEND_API int ZEND_FASTCALL zend_list_delete(zend_resource *res) +ZEND_API zend_result ZEND_FASTCALL zend_list_delete(zend_resource *res) { if (GC_DELREF(res) <= 0) { return zend_hash_index_del(&EG(regular_list), res->handle); @@ -76,14 +76,13 @@ static void zend_resource_dtor(zend_resource *res) } -ZEND_API int ZEND_FASTCALL zend_list_close(zend_resource *res) +ZEND_API void ZEND_FASTCALL zend_list_close(zend_resource *res) { if (GC_REFCOUNT(res) <= 0) { zend_list_free(res); } else if (res->type >= 0) { zend_resource_dtor(res); } - return SUCCESS; } ZEND_API zend_resource* zend_register_resource(void *rsrc_pointer, int rsrc_type) @@ -203,18 +202,16 @@ void plist_entry_destructor(zval *zv) free(res); } -ZEND_API int zend_init_rsrc_list(void) +ZEND_API void zend_init_rsrc_list(void) { zend_hash_init(&EG(regular_list), 8, NULL, list_entry_destructor, 0); EG(regular_list).nNextFreeElement = 0; - return SUCCESS; } -int zend_init_rsrc_plist(void) +void zend_init_rsrc_plist(void) { - zend_hash_init_ex(&EG(persistent_list), 8, NULL, plist_entry_destructor, 1, 0); - return SUCCESS; + zend_hash_init(&EG(persistent_list), 8, NULL, plist_entry_destructor, 1); } @@ -235,6 +232,7 @@ void zend_destroy_rsrc_list(HashTable *ht) zend_hash_graceful_reverse_destroy(ht); } +/* int return due to HashTable API */ static int clean_module_resource(zval *zv, void *arg) { int resource_id = *(int *)arg; @@ -242,7 +240,7 @@ static int clean_module_resource(zval *zv, void *arg) return Z_RES_TYPE_P(zv) == resource_id; } - +/* int return due to HashTable API */ static int zend_clean_module_rsrc_dtors_cb(zval *zv, void *arg) { zend_rsrc_list_dtors_entry *ld = (zend_rsrc_list_dtors_entry *)Z_PTR_P(zv); @@ -299,11 +297,10 @@ static void list_destructors_dtor(zval *zv) free(Z_PTR_P(zv)); } -int zend_init_rsrc_list_dtors(void) +void zend_init_rsrc_list_dtors(void) { zend_hash_init(&list_destructors, 64, NULL, list_destructors_dtor, 1); list_destructors.nNextFreeElement=1; /* we don't want resource type 0 */ - return SUCCESS; } diff --git a/Zend/zend_list.h b/Zend/zend_list.h index 92fdd3d4178f3..680915121e2a6 100644 --- a/Zend/zend_list.h +++ b/Zend/zend_list.h @@ -45,17 +45,17 @@ void list_entry_destructor(zval *ptr); void plist_entry_destructor(zval *ptr); void zend_clean_module_rsrc_dtors(int module_number); -ZEND_API int zend_init_rsrc_list(void); /* Exported for phar hack */ -int zend_init_rsrc_plist(void); +ZEND_API void zend_init_rsrc_list(void); /* Exported for phar hack */ +void zend_init_rsrc_plist(void); void zend_close_rsrc_list(HashTable *ht); void zend_destroy_rsrc_list(HashTable *ht); -int zend_init_rsrc_list_dtors(void); +void zend_init_rsrc_list_dtors(void); void zend_destroy_rsrc_list_dtors(void); ZEND_API zval* ZEND_FASTCALL zend_list_insert(void *ptr, int type); ZEND_API void ZEND_FASTCALL zend_list_free(zend_resource *res); ZEND_API int ZEND_FASTCALL zend_list_delete(zend_resource *res); -ZEND_API int ZEND_FASTCALL zend_list_close(zend_resource *res); +ZEND_API void ZEND_FASTCALL zend_list_close(zend_resource *res); ZEND_API zend_resource *zend_register_resource(void *rsrc_pointer, int rsrc_type); ZEND_API void *zend_fetch_resource(zend_resource *res, const char *resource_type_name, int resource_type); diff --git a/Zend/zend_modules.h b/Zend/zend_modules.h index c7e279a40849d..cb64324d38bc7 100644 --- a/Zend/zend_modules.h +++ b/Zend/zend_modules.h @@ -77,10 +77,10 @@ struct _zend_module_entry { const struct _zend_module_dep *deps; const char *name; const struct _zend_function_entry *functions; - int (*module_startup_func)(INIT_FUNC_ARGS); - int (*module_shutdown_func)(SHUTDOWN_FUNC_ARGS); - int (*request_startup_func)(INIT_FUNC_ARGS); - int (*request_shutdown_func)(SHUTDOWN_FUNC_ARGS); + zend_result (*module_startup_func)(INIT_FUNC_ARGS); + zend_result (*module_shutdown_func)(SHUTDOWN_FUNC_ARGS); + zend_result (*request_startup_func)(INIT_FUNC_ARGS); + zend_result (*request_shutdown_func)(SHUTDOWN_FUNC_ARGS); void (*info_func)(ZEND_MODULE_INFO_FUNC_ARGS); const char *version; size_t globals_size; diff --git a/Zend/zend_multibyte.c b/Zend/zend_multibyte.c index 956ffbb74f841..f8dab668751a1 100644 --- a/Zend/zend_multibyte.c +++ b/Zend/zend_multibyte.c @@ -33,7 +33,7 @@ static const char *dummy_encoding_name_getter(const zend_encoding *encoding) return (const char*)encoding; } -static int dummy_encoding_lexer_compatibility_checker(const zend_encoding *encoding) +static bool dummy_encoding_lexer_compatibility_checker(const zend_encoding *encoding) { return 0; } @@ -48,7 +48,7 @@ static size_t dummy_encoding_converter(unsigned char **to, size_t *to_length, co return (size_t)-1; } -static int dummy_encoding_list_parser(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent) +static zend_result dummy_encoding_list_parser(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent) { *return_list = pemalloc(0, persistent); *return_size = 0; @@ -60,7 +60,7 @@ static const zend_encoding *dummy_internal_encoding_getter(void) return NULL; } -static int dummy_internal_encoding_setter(const zend_encoding *encoding) +static zend_result dummy_internal_encoding_setter(const zend_encoding *encoding) { return FAILURE; } @@ -84,7 +84,7 @@ ZEND_API const zend_encoding *zend_multibyte_encoding_utf16be = (const zend_enco ZEND_API const zend_encoding *zend_multibyte_encoding_utf16le = (const zend_encoding*)"UTF-32LE"; ZEND_API const zend_encoding *zend_multibyte_encoding_utf8 = (const zend_encoding*)"UTF-8"; -ZEND_API int zend_multibyte_set_functions(const zend_multibyte_functions *functions) +ZEND_API zend_result zend_multibyte_set_functions(const zend_multibyte_functions *functions) { zend_multibyte_encoding_utf32be = functions->encoding_fetcher("UTF-32BE"); if (!zend_multibyte_encoding_utf32be) { @@ -155,7 +155,7 @@ ZEND_API size_t zend_multibyte_encoding_converter(unsigned char **to, size_t *to return multibyte_functions.encoding_converter(to, to_length, from, from_length, encoding_to, encoding_from); } -ZEND_API int zend_multibyte_parse_encoding_list(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent) +ZEND_API zend_result zend_multibyte_parse_encoding_list(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent) { return multibyte_functions.encoding_list_parser(encoding_list, encoding_list_len, return_list, return_size, persistent); } @@ -180,12 +180,12 @@ ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_l return SUCCESS; } -ZEND_API int zend_multibyte_set_internal_encoding(const zend_encoding *encoding) +ZEND_API zend_result zend_multibyte_set_internal_encoding(const zend_encoding *encoding) { return multibyte_functions.internal_encoding_setter(encoding); } -ZEND_API int zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length) +ZEND_API zend_result zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length) { const zend_encoding **list = 0; size_t size = 0; diff --git a/Zend/zend_multibyte.h b/Zend/zend_multibyte.h index 19444eda83592..5466840cd900a 100644 --- a/Zend/zend_multibyte.h +++ b/Zend/zend_multibyte.h @@ -26,12 +26,12 @@ typedef size_t (*zend_encoding_filter)(unsigned char **str, size_t *str_length, typedef const zend_encoding* (*zend_encoding_fetcher)(const char *encoding_name); typedef const char* (*zend_encoding_name_getter)(const zend_encoding *encoding); -typedef int (*zend_encoding_lexer_compatibility_checker)(const zend_encoding *encoding); +typedef bool (*zend_encoding_lexer_compatibility_checker)(const zend_encoding *encoding); typedef const zend_encoding *(*zend_encoding_detector)(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size); typedef size_t (*zend_encoding_converter)(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from); -typedef int (*zend_encoding_list_parser)(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent); +typedef zend_result (*zend_encoding_list_parser)(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent); typedef const zend_encoding *(*zend_encoding_internal_encoding_getter)(void); -typedef int (*zend_encoding_internal_encoding_setter)(const zend_encoding *encoding); +typedef zend_result (*zend_encoding_internal_encoding_setter)(const zend_encoding *encoding); typedef struct _zend_multibyte_functions { const char *provider_name; @@ -57,7 +57,7 @@ ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf16le; ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf8; /* multibyte utility functions */ -ZEND_API int zend_multibyte_set_functions(const zend_multibyte_functions *functions); +ZEND_API zend_result zend_multibyte_set_functions(const zend_multibyte_functions *functions); ZEND_API void zend_multibyte_restore_functions(void); ZEND_API const zend_multibyte_functions *zend_multibyte_get_functions(void); @@ -66,13 +66,13 @@ ZEND_API const char *zend_multibyte_get_encoding_name(const zend_encoding *encod ZEND_API int zend_multibyte_check_lexer_compatibility(const zend_encoding *encoding); ZEND_API const zend_encoding *zend_multibyte_encoding_detector(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size); ZEND_API size_t zend_multibyte_encoding_converter(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from); -ZEND_API int zend_multibyte_parse_encoding_list(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent); +ZEND_API int zend_multibyte_parse_encoding_list(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent); ZEND_API const zend_encoding *zend_multibyte_get_internal_encoding(void); ZEND_API const zend_encoding *zend_multibyte_get_script_encoding(void); ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_list, size_t encoding_list_size); ZEND_API int zend_multibyte_set_internal_encoding(const zend_encoding *encoding); -ZEND_API int zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length); +ZEND_API zend_result zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length); END_EXTERN_C() diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h index a3827d25d128d..c6cd472a237b1 100644 --- a/Zend/zend_multiply.h +++ b/Zend/zend_multiply.h @@ -154,7 +154,7 @@ #if defined(__GNUC__) && (defined(__native_client__) || defined(i386)) -static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, int *overflow) +static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow) { size_t res = nmemb; size_t m_overflow = 0; @@ -182,7 +182,7 @@ static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, si #elif defined(__GNUC__) && defined(__x86_64__) -static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, int *overflow) +static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow) { size_t res = nmemb; zend_ulong m_overflow = 0; @@ -219,7 +219,7 @@ static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, si #elif defined(__GNUC__) && defined(__arm__) -static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, int *overflow) +static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow) { size_t res; zend_ulong m_overflow; @@ -241,7 +241,7 @@ static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, si #elif defined(__GNUC__) && defined(__aarch64__) -static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, int *overflow) +static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow) { size_t res; zend_ulong m_overflow; @@ -262,7 +262,7 @@ static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, si #elif defined(__GNUC__) && defined(__powerpc64__) -static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, int *overflow) +static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow) { size_t res; unsigned long m_overflow; @@ -286,7 +286,7 @@ static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, si #elif SIZEOF_SIZE_T == 4 -static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, int *overflow) +static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow) { uint64_t res = (uint64_t) nmemb * (uint64_t) size + (uint64_t) offset; @@ -300,7 +300,7 @@ static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, si #else -static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, int *overflow) +static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, bool *overflow) { size_t res = nmemb * size + offset; double _d = (double)nmemb * (double)size + (double)offset; @@ -317,7 +317,7 @@ static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, si static zend_always_inline size_t zend_safe_address_guarded(size_t nmemb, size_t size, size_t offset) { - int overflow; + bool overflow; size_t ret = zend_safe_address(nmemb, size, offset, &overflow); if (UNEXPECTED(overflow)) { @@ -330,7 +330,7 @@ static zend_always_inline size_t zend_safe_address_guarded(size_t nmemb, size_t /* A bit more generic version of the same */ static zend_always_inline size_t zend_safe_addmult(size_t nmemb, size_t size, size_t offset, const char *message) { - int overflow; + bool overflow; size_t ret = zend_safe_address(nmemb, size, offset, &overflow); if (UNEXPECTED(overflow)) { diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h index b401d72ca294a..fedc70cc80997 100644 --- a/Zend/zend_object_handlers.h +++ b/Zend/zend_object_handlers.h @@ -60,7 +60,13 @@ typedef zval *(*zend_object_write_property_t)(zend_object *object, zend_string * typedef void (*zend_object_write_dimension_t)(zend_object *object, zval *offset, zval *value); -/* Used to create pointer to the property of the object, for future direct r/w access */ +/* Used to create pointer to the property of the object, for future direct r/w access. + * May return one of: + * * A zval pointer, without incrementing the reference count. + * * &EG(error_zval), if an exception has been thrown. + * * NULL, if acquiring a direct pointer is not possible. + * In this case, the VM will fall back to using read_property and write_property. + */ typedef zval *(*zend_object_get_property_ptr_ptr_t)(zend_object *object, zend_string *member, int type, void **cache_slot); /* Used to check if a property of the object exists */ diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index 14dd6e46db27d..a9236faf6a68c 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -907,12 +907,12 @@ ZEND_API void zend_recalc_live_ranges( zend_calc_live_ranges(op_array, needs_live_range); } -ZEND_API int pass_two(zend_op_array *op_array) +ZEND_API void pass_two(zend_op_array *op_array) { zend_op *opline, *end; if (!ZEND_USER_CODE(op_array->type)) { - return 0; + return; } if (CG(compiler_options) & ZEND_COMPILE_EXTENDED_STMT) { zend_update_extended_stmts(op_array); @@ -1074,7 +1074,7 @@ ZEND_API int pass_two(zend_op_array *op_array) zend_calc_live_ranges(op_array, NULL); - return 0; + return; } ZEND_API unary_op_type get_unary_op(int opcode) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index fba6c6337a7eb..7de4cd8ad7ad1 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -232,7 +232,7 @@ static zend_never_inline zval* ZEND_FASTCALL _zendi_convert_scalar_to_number_sil } /* }}} */ -static zend_never_inline int ZEND_FASTCALL _zendi_try_convert_scalar_to_number(zval *op, zval *holder) /* {{{ */ +static zend_never_inline zend_result ZEND_FASTCALL _zendi_try_convert_scalar_to_number(zval *op, zval *holder) /* {{{ */ { switch (Z_TYPE_P(op)) { case IS_NULL: @@ -274,7 +274,7 @@ static zend_never_inline int ZEND_FASTCALL _zendi_try_convert_scalar_to_number(z } /* }}} */ -static zend_always_inline int zendi_try_convert_scalar_to_number(zval *op, zval *holder) /* {{{ */ +static zend_always_inline zend_result zendi_try_convert_scalar_to_number(zval *op, zval *holder) /* {{{ */ { if (Z_TYPE_P(op) == IS_LONG || Z_TYPE_P(op) == IS_DOUBLE) { ZVAL_COPY_VALUE(holder, op); @@ -559,7 +559,7 @@ ZEND_API void ZEND_FASTCALL convert_to_null(zval *op) /* {{{ */ ZEND_API void ZEND_FASTCALL convert_to_boolean(zval *op) /* {{{ */ { - int tmp; + bool tmp; try_again: switch (Z_TYPE_P(op)) { @@ -963,7 +963,7 @@ static zend_never_inline void ZEND_FASTCALL add_function_array(zval *result, zva } /* }}} */ -static zend_always_inline int add_function_fast(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_always_inline zend_result add_function_fast(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_uchar type_pair = TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2)); @@ -987,7 +987,7 @@ static zend_always_inline int add_function_fast(zval *result, zval *op1, zval *o } } /* }}} */ -static zend_never_inline int ZEND_FASTCALL add_function_slow(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_never_inline zend_result ZEND_FASTCALL add_function_slow(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_DEREF(op1); ZVAL_DEREF(op2); @@ -1019,7 +1019,7 @@ static zend_never_inline int ZEND_FASTCALL add_function_slow(zval *result, zval return FAILURE; } /* }}} */ -ZEND_API int ZEND_FASTCALL add_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL add_function(zval *result, zval *op1, zval *op2) /* {{{ */ { if (add_function_fast(result, op1, op2) == SUCCESS) { return SUCCESS; @@ -1029,7 +1029,7 @@ ZEND_API int ZEND_FASTCALL add_function(zval *result, zval *op1, zval *op2) /* { } /* }}} */ -static zend_always_inline int sub_function_fast(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_always_inline zend_result sub_function_fast(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_uchar type_pair = TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2)); @@ -1051,7 +1051,7 @@ static zend_always_inline int sub_function_fast(zval *result, zval *op1, zval *o } /* }}} */ -static zend_never_inline int ZEND_FASTCALL sub_function_slow(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_never_inline zend_result ZEND_FASTCALL sub_function_slow(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_DEREF(op1); ZVAL_DEREF(op2); @@ -1084,7 +1084,7 @@ static zend_never_inline int ZEND_FASTCALL sub_function_slow(zval *result, zval } /* }}} */ -ZEND_API int ZEND_FASTCALL sub_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL sub_function(zval *result, zval *op1, zval *op2) /* {{{ */ { if (sub_function_fast(result, op1, op2) == SUCCESS) { return SUCCESS; @@ -1094,7 +1094,7 @@ ZEND_API int ZEND_FASTCALL sub_function(zval *result, zval *op1, zval *op2) /* { } /* }}} */ -static zend_always_inline int mul_function_fast(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_always_inline zend_result mul_function_fast(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_uchar type_pair = TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2)); @@ -1120,7 +1120,7 @@ static zend_always_inline int mul_function_fast(zval *result, zval *op1, zval *o } /* }}} */ -static zend_never_inline int ZEND_FASTCALL mul_function_slow(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_never_inline zend_result ZEND_FASTCALL mul_function_slow(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_DEREF(op1); ZVAL_DEREF(op2); @@ -1153,7 +1153,7 @@ static zend_never_inline int ZEND_FASTCALL mul_function_slow(zval *result, zval } /* }}} */ -ZEND_API int ZEND_FASTCALL mul_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL mul_function(zval *result, zval *op1, zval *op2) /* {{{ */ { if (mul_function_fast(result, op1, op2) == SUCCESS) { return SUCCESS; @@ -1163,7 +1163,7 @@ ZEND_API int ZEND_FASTCALL mul_function(zval *result, zval *op1, zval *op2) /* { } /* }}} */ -static int ZEND_FASTCALL pow_function_base(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_result ZEND_FASTCALL pow_function_base(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_uchar type_pair = TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2)); @@ -1220,7 +1220,7 @@ static int ZEND_FASTCALL pow_function_base(zval *result, zval *op1, zval *op2) / } /* }}} */ -ZEND_API int ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_DEREF(op1); ZVAL_DEREF(op2); @@ -1256,7 +1256,7 @@ ZEND_API int ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2) /* { #ifdef __clang__ __attribute__((no_sanitize("float-divide-by-zero"))) #endif -static int ZEND_FASTCALL div_function_base(zval *result, zval *op1, zval *op2) /* {{{ */ +static zend_result ZEND_FASTCALL div_function_base(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_uchar type_pair = TYPE_PAIR(Z_TYPE_P(op1), Z_TYPE_P(op2)); @@ -1300,7 +1300,7 @@ static int ZEND_FASTCALL div_function_base(zval *result, zval *op1, zval *op2) / } /* }}} */ -ZEND_API int ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_DEREF(op1); ZVAL_DEREF(op2); @@ -1333,7 +1333,7 @@ ZEND_API int ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2) /* { } /* }}} */ -ZEND_API int ZEND_FASTCALL mod_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL mod_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_long op1_lval, op2_lval; @@ -1367,7 +1367,7 @@ ZEND_API int ZEND_FASTCALL mod_function(zval *result, zval *op1, zval *op2) /* { } /* }}} */ -ZEND_API int ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, zval *op2) /* {{{ */ { int op1_val, op2_val; @@ -1417,7 +1417,7 @@ ZEND_API int ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, zval *o } /* }}} */ -ZEND_API int ZEND_FASTCALL boolean_not_function(zval *result, zval *op1) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL boolean_not_function(zval *result, zval *op1) /* {{{ */ { if (Z_TYPE_P(op1) < IS_TRUE) { ZVAL_TRUE(result); @@ -1442,7 +1442,7 @@ ZEND_API int ZEND_FASTCALL boolean_not_function(zval *result, zval *op1) /* {{{ } /* }}} */ -ZEND_API int ZEND_FASTCALL bitwise_not_function(zval *result, zval *op1) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL bitwise_not_function(zval *result, zval *op1) /* {{{ */ { try_again: switch (Z_TYPE_P(op1)) { @@ -1482,7 +1482,7 @@ ZEND_API int ZEND_FASTCALL bitwise_not_function(zval *result, zval *op1) /* {{{ } /* }}} */ -ZEND_API int ZEND_FASTCALL bitwise_or_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL bitwise_or_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_long op1_lval, op2_lval; @@ -1564,7 +1564,7 @@ ZEND_API int ZEND_FASTCALL bitwise_or_function(zval *result, zval *op1, zval *op } /* }}} */ -ZEND_API int ZEND_FASTCALL bitwise_and_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL bitwise_and_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_long op1_lval, op2_lval; @@ -1646,7 +1646,7 @@ ZEND_API int ZEND_FASTCALL bitwise_and_function(zval *result, zval *op1, zval *o } /* }}} */ -ZEND_API int ZEND_FASTCALL bitwise_xor_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL bitwise_xor_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_long op1_lval, op2_lval; @@ -1728,7 +1728,7 @@ ZEND_API int ZEND_FASTCALL bitwise_xor_function(zval *result, zval *op1, zval *o } /* }}} */ -ZEND_API int ZEND_FASTCALL shift_left_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL shift_left_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_long op1_lval, op2_lval; @@ -1765,7 +1765,7 @@ ZEND_API int ZEND_FASTCALL shift_left_function(zval *result, zval *op1, zval *op } /* }}} */ -ZEND_API int ZEND_FASTCALL shift_right_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL shift_right_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zend_long op1_lval, op2_lval; @@ -1801,7 +1801,7 @@ ZEND_API int ZEND_FASTCALL shift_right_function(zval *result, zval *op1, zval *o } /* }}} */ -ZEND_API int ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zval *orig_op1 = op1; zval op1_copy, op2_copy; @@ -1992,7 +1992,7 @@ ZEND_API int ZEND_FASTCALL numeric_compare_function(zval *op1, zval *op2) /* {{{ } /* }}} */ -ZEND_API int ZEND_FASTCALL compare_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL compare_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_LONG(result, zend_compare(op1, op2)); return SUCCESS; @@ -2175,6 +2175,7 @@ ZEND_API int ZEND_FASTCALL zend_compare(zval *op1, zval *op2) /* {{{ */ } /* }}} */ +/* return int to be compatible with compare_func_t */ static int hash_zval_identical_function(zval *z1, zval *z2) /* {{{ */ { /* is_identical_function() returns 1 in case of identity and 0 in case @@ -2217,42 +2218,42 @@ ZEND_API zend_bool ZEND_FASTCALL zend_is_identical(zval *op1, zval *op2) /* {{{ } /* }}} */ -ZEND_API int ZEND_FASTCALL is_identical_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL is_identical_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_BOOL(result, zend_is_identical(op1, op2)); return SUCCESS; } /* }}} */ -ZEND_API int ZEND_FASTCALL is_not_identical_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL is_not_identical_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_BOOL(result, !zend_is_identical(op1, op2)); return SUCCESS; } /* }}} */ -ZEND_API int ZEND_FASTCALL is_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL is_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_BOOL(result, zend_compare(op1, op2) == 0); return SUCCESS; } /* }}} */ -ZEND_API int ZEND_FASTCALL is_not_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL is_not_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_BOOL(result, (zend_compare(op1, op2) != 0)); return SUCCESS; } /* }}} */ -ZEND_API int ZEND_FASTCALL is_smaller_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL is_smaller_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_BOOL(result, (zend_compare(op1, op2) < 0)); return SUCCESS; } /* }}} */ -ZEND_API int ZEND_FASTCALL is_smaller_or_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL is_smaller_or_equal_function(zval *result, zval *op1, zval *op2) /* {{{ */ { ZVAL_BOOL(result, (zend_compare(op1, op2) <= 0)); return SUCCESS; @@ -2395,7 +2396,7 @@ static void ZEND_FASTCALL increment_string(zval *str) /* {{{ */ } /* }}} */ -ZEND_API int ZEND_FASTCALL increment_function(zval *op1) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL increment_function(zval *op1) /* {{{ */ { try_again: switch (Z_TYPE_P(op1)) { @@ -2460,7 +2461,7 @@ ZEND_API int ZEND_FASTCALL increment_function(zval *op1) /* {{{ */ } /* }}} */ -ZEND_API int ZEND_FASTCALL decrement_function(zval *op1) /* {{{ */ +ZEND_API zend_result ZEND_FASTCALL decrement_function(zval *op1) /* {{{ */ { zend_long lval; double dval; @@ -2525,11 +2526,11 @@ ZEND_API int ZEND_FASTCALL decrement_function(zval *op1) /* {{{ */ ZEND_API int ZEND_FASTCALL zend_is_true(zval *op) /* {{{ */ { - return i_zend_is_true(op); + return (int) i_zend_is_true(op); } /* }}} */ -ZEND_API int ZEND_FASTCALL zend_object_is_true(zval *op) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zend_object_is_true(zval *op) /* {{{ */ { zend_object *zobj = Z_OBJ_P(op); zval tmp; @@ -2537,7 +2538,7 @@ ZEND_API int ZEND_FASTCALL zend_object_is_true(zval *op) /* {{{ */ return Z_TYPE(tmp) == IS_TRUE; } zend_error(E_RECOVERABLE_ERROR, "Object of class %s could not be converted to bool", ZSTR_VAL(zobj->ce->name)); - return 1; + return false; } /* }}} */ @@ -2621,7 +2622,7 @@ ZEND_API char* ZEND_FASTCALL zend_str_tolower_dup_ex(const char *source, size_t } /* }}} */ -ZEND_API zend_string* ZEND_FASTCALL zend_string_tolower_ex(zend_string *str, int persistent) /* {{{ */ +ZEND_API zend_string* ZEND_FASTCALL zend_string_tolower_ex(zend_string *str, bool persistent) /* {{{ */ { size_t length = ZSTR_LEN(str); unsigned char *p = (unsigned char *) ZSTR_VAL(str); @@ -2817,9 +2818,9 @@ ZEND_API int ZEND_FASTCALL zend_binary_zval_strncasecmp(zval *s1, zval *s2, zval } /* }}} */ -ZEND_API int ZEND_FASTCALL zendi_smart_streq(zend_string *s1, zend_string *s2) /* {{{ */ +ZEND_API bool ZEND_FASTCALL zendi_smart_streq(zend_string *s1, zend_string *s2) /* {{{ */ { - int ret1, ret2; + zend_uchar ret1, ret2; int oflow1, oflow2; zend_long lval1 = 0, lval2 = 0; double dval1 = 0.0, dval2 = 0.0; @@ -2867,7 +2868,7 @@ ZEND_API int ZEND_FASTCALL zendi_smart_streq(zend_string *s1, zend_string *s2) / ZEND_API int ZEND_FASTCALL zendi_smart_strcmp(zend_string *s1, zend_string *s2) /* {{{ */ { - int ret1, ret2; + zend_uchar ret1, ret2; int oflow1, oflow2; zend_long lval1 = 0, lval2 = 0; double dval1 = 0.0, dval2 = 0.0; diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 9eb064b125d7a..d543b7b03c2bb 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -38,30 +38,30 @@ #define LONG_SIGN_MASK ZEND_LONG_MIN BEGIN_EXTERN_C() -ZEND_API int ZEND_FASTCALL add_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL sub_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL mul_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL mod_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL boolean_not_function(zval *result, zval *op1); -ZEND_API int ZEND_FASTCALL bitwise_not_function(zval *result, zval *op1); -ZEND_API int ZEND_FASTCALL bitwise_or_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL bitwise_and_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL bitwise_xor_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL shift_left_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL shift_right_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL add_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL sub_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL mul_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL mod_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL boolean_not_function(zval *result, zval *op1); +ZEND_API zend_result ZEND_FASTCALL bitwise_not_function(zval *result, zval *op1); +ZEND_API zend_result ZEND_FASTCALL bitwise_or_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL bitwise_and_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL bitwise_xor_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL shift_left_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL shift_right_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2); ZEND_API zend_bool ZEND_FASTCALL zend_is_identical(zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL is_equal_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL is_identical_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL is_not_identical_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL is_not_equal_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL is_smaller_function(zval *result, zval *op1, zval *op2); -ZEND_API int ZEND_FASTCALL is_smaller_or_equal_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL is_equal_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL is_identical_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL is_not_identical_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL is_not_equal_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL is_smaller_function(zval *result, zval *op1, zval *op2); +ZEND_API zend_result ZEND_FASTCALL is_smaller_or_equal_function(zval *result, zval *op1, zval *op2); ZEND_API zend_bool ZEND_FASTCALL zend_class_implements_interface(const zend_class_entry *class_ce, const zend_class_entry *interface_ce); ZEND_API zend_bool ZEND_FASTCALL instanceof_function_slow(const zend_class_entry *instance_ce, const zend_class_entry *ce); @@ -255,8 +255,8 @@ zend_memnrstr(const char *haystack, const char *needle, size_t needle_len, const } } -ZEND_API int ZEND_FASTCALL increment_function(zval *op1); -ZEND_API int ZEND_FASTCALL decrement_function(zval *op2); +ZEND_API zend_result ZEND_FASTCALL increment_function(zval *op1); +ZEND_API zend_result ZEND_FASTCALL decrement_function(zval *op2); ZEND_API void ZEND_FASTCALL convert_scalar_to_number(zval *op); ZEND_API void ZEND_FASTCALL _convert_to_string(zval *op); @@ -342,14 +342,14 @@ static zend_always_inline zend_bool try_convert_to_string(zval *op) { ZEND_API int ZEND_FASTCALL zend_is_true(zval *op); -ZEND_API int ZEND_FASTCALL zend_object_is_true(zval *op); +ZEND_API bool ZEND_FASTCALL zend_object_is_true(zval *op); #define zval_is_true(op) \ zend_is_true(op) -static zend_always_inline int i_zend_is_true(zval *op) +static zend_always_inline bool i_zend_is_true(zval *op) { - int result = 0; + bool result = 0; again: switch (Z_TYPE_P(op)) { @@ -418,7 +418,7 @@ ZEND_API void ZEND_FASTCALL zend_str_tolower(char *str, size_t length); ZEND_API char* ZEND_FASTCALL zend_str_tolower_copy(char *dest, const char *source, size_t length); ZEND_API char* ZEND_FASTCALL zend_str_tolower_dup(const char *source, size_t length); ZEND_API char* ZEND_FASTCALL zend_str_tolower_dup_ex(const char *source, size_t length); -ZEND_API zend_string* ZEND_FASTCALL zend_string_tolower_ex(zend_string *str, int persistent); +ZEND_API zend_string* ZEND_FASTCALL zend_string_tolower_ex(zend_string *str, bool persistent); #define zend_string_tolower(str) zend_string_tolower_ex(str, 0) @@ -433,7 +433,7 @@ ZEND_API int ZEND_FASTCALL zend_binary_strncasecmp(const char *s1, size_t len1, ZEND_API int ZEND_FASTCALL zend_binary_strcasecmp_l(const char *s1, size_t len1, const char *s2, size_t len2); ZEND_API int ZEND_FASTCALL zend_binary_strncasecmp_l(const char *s1, size_t len1, const char *s2, size_t len2, size_t length); -ZEND_API int ZEND_FASTCALL zendi_smart_streq(zend_string *s1, zend_string *s2); +ZEND_API bool ZEND_FASTCALL zendi_smart_streq(zend_string *s1, zend_string *s2); ZEND_API int ZEND_FASTCALL zendi_smart_strcmp(zend_string *s1, zend_string *s2); ZEND_API int ZEND_FASTCALL zend_compare_symbol_tables(HashTable *ht1, HashTable *ht2); ZEND_API int ZEND_FASTCALL zend_compare_arrays(zval *a1, zval *a2); @@ -738,7 +738,7 @@ overflow: ZEND_ATTRIBUTE_COLD_LABEL #endif } -static zend_always_inline int fast_add_function(zval *result, zval *op1, zval *op2) +static zend_always_inline zend_result fast_add_function(zval *result, zval *op1, zval *op2) { if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { @@ -842,12 +842,12 @@ overflow: ZEND_ATTRIBUTE_COLD_LABEL #endif } -static zend_always_inline int fast_div_function(zval *result, zval *op1, zval *op2) +static zend_always_inline zend_result fast_div_function(zval *result, zval *op1, zval *op2) { return div_function(result, op1, op2); } -static zend_always_inline int zend_fast_equal_strings(zend_string *s1, zend_string *s2) +static zend_always_inline bool zend_fast_equal_strings(zend_string *s1, zend_string *s2) { if (s1 == s2) { return 1; @@ -858,7 +858,7 @@ static zend_always_inline int zend_fast_equal_strings(zend_string *s1, zend_stri } } -static zend_always_inline int fast_equal_check_function(zval *op1, zval *op2) +static zend_always_inline bool fast_equal_check_function(zval *op1, zval *op2) { if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { @@ -880,7 +880,7 @@ static zend_always_inline int fast_equal_check_function(zval *op1, zval *op2) return zend_compare(op1, op2) == 0; } -static zend_always_inline int fast_equal_check_long(zval *op1, zval *op2) +static zend_always_inline bool fast_equal_check_long(zval *op1, zval *op2) { if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { return Z_LVAL_P(op1) == Z_LVAL_P(op2); @@ -888,7 +888,7 @@ static zend_always_inline int fast_equal_check_long(zval *op1, zval *op2) return zend_compare(op1, op2) == 0; } -static zend_always_inline int fast_equal_check_string(zval *op1, zval *op2) +static zend_always_inline bool fast_equal_check_string(zval *op1, zval *op2) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { return zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); diff --git a/Zend/zend_signal.c b/Zend/zend_signal.c index 2086f03dd881c..80feecd98ff3a 100644 --- a/Zend/zend_signal.c +++ b/Zend/zend_signal.c @@ -223,7 +223,7 @@ static void zend_signal_handler(int signo, siginfo_t *siginfo, void *context) /* {{{ zend_sigaction * Register a signal handler that will be deferred in critical sections */ -ZEND_API int zend_sigaction(int signo, const struct sigaction *act, struct sigaction *oldact) +ZEND_API void zend_sigaction(int signo, const struct sigaction *act, struct sigaction *oldact) { struct sigaction sa; sigset_t sigset; @@ -259,14 +259,12 @@ ZEND_API int zend_sigaction(int signo, const struct sigaction *act, struct sigac sigaddset(&sigset, signo); zend_sigprocmask(SIG_UNBLOCK, &sigset, NULL); } - - return SUCCESS; } /* }}} */ /* {{{ zend_signal * Register a signal handler that will be deferred in critical sections */ -ZEND_API int zend_signal(int signo, void (*handler)(int)) +ZEND_API void zend_signal(int signo, void (*handler)(int)) { struct sigaction sa; @@ -275,7 +273,7 @@ ZEND_API int zend_signal(int signo, void (*handler)(int)) sa.sa_handler = handler; sa.sa_mask = global_sigmask; - return zend_sigaction(signo, &sa, NULL); + zend_sigaction(signo, &sa, NULL); } /* }}} */ @@ -283,7 +281,7 @@ ZEND_API int zend_signal(int signo, void (*handler)(int)) * Set a handler for a signal we want to defer. * Previously set handler must have been saved before. */ -static int zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void*)) +static zend_result zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void*)) { struct sigaction sa; diff --git a/Zend/zend_signal.h b/Zend/zend_signal.h index 0bb191db73245..08c9de20c76c3 100644 --- a/Zend/zend_signal.h +++ b/Zend/zend_signal.h @@ -91,8 +91,8 @@ ZEND_API void zend_signal_startup(void); END_EXTERN_C() void zend_signal_init(void); -ZEND_API int zend_signal(int signo, void (*handler)(int)); -ZEND_API int zend_sigaction(int signo, const struct sigaction *act, struct sigaction *oldact); +ZEND_API void zend_signal(int signo, void (*handler)(int)); +ZEND_API void zend_sigaction(int signo, const struct sigaction *act, struct sigaction *oldact); #else /* ZEND_SIGNALS */ diff --git a/Zend/zend_stack.c b/Zend/zend_stack.c index 51f68b5c9a2c9..1255c941a03d6 100644 --- a/Zend/zend_stack.c +++ b/Zend/zend_stack.c @@ -22,13 +22,12 @@ #define ZEND_STACK_ELEMENT(stack, n) ((void *)((char *) (stack)->elements + (stack)->size * (n))) -ZEND_API int zend_stack_init(zend_stack *stack, int size) +ZEND_API void zend_stack_init(zend_stack *stack, int size) { stack->size = size; stack->top = 0; stack->max = 0; stack->elements = NULL; - return SUCCESS; } ZEND_API int zend_stack_push(zend_stack *stack, const void *element) @@ -53,10 +52,9 @@ ZEND_API void *zend_stack_top(const zend_stack *stack) } -ZEND_API int zend_stack_del_top(zend_stack *stack) +ZEND_API void zend_stack_del_top(zend_stack *stack) { --stack->top; - return SUCCESS; } @@ -71,20 +69,18 @@ ZEND_API int zend_stack_int_top(const zend_stack *stack) } -ZEND_API int zend_stack_is_empty(const zend_stack *stack) +ZEND_API bool zend_stack_is_empty(const zend_stack *stack) { return stack->top == 0; } -ZEND_API int zend_stack_destroy(zend_stack *stack) +ZEND_API void zend_stack_destroy(zend_stack *stack) { if (stack->elements) { efree(stack->elements); stack->elements = NULL; } - - return SUCCESS; } diff --git a/Zend/zend_stack.h b/Zend/zend_stack.h index 912850a25e4c6..a5aa9622268b2 100644 --- a/Zend/zend_stack.h +++ b/Zend/zend_stack.h @@ -29,13 +29,13 @@ typedef struct _zend_stack { #define STACK_BLOCK_SIZE 16 BEGIN_EXTERN_C() -ZEND_API int zend_stack_init(zend_stack *stack, int size); +ZEND_API void zend_stack_init(zend_stack *stack, int size); ZEND_API int zend_stack_push(zend_stack *stack, const void *element); ZEND_API void *zend_stack_top(const zend_stack *stack); -ZEND_API int zend_stack_del_top(zend_stack *stack); +ZEND_API void zend_stack_del_top(zend_stack *stack); ZEND_API int zend_stack_int_top(const zend_stack *stack); -ZEND_API int zend_stack_is_empty(const zend_stack *stack); -ZEND_API int zend_stack_destroy(zend_stack *stack); +ZEND_API bool zend_stack_is_empty(const zend_stack *stack); +ZEND_API void zend_stack_destroy(zend_stack *stack); ZEND_API void *zend_stack_base(const zend_stack *stack); ZEND_API int zend_stack_count(const zend_stack *stack); ZEND_API void zend_stack_apply(zend_stack *stack, int type, int (*apply_function)(void *element)); diff --git a/Zend/zend_stream.c b/Zend/zend_stream.c index 38b145736bea2..1dfc5b1bc1e89 100644 --- a/Zend/zend_stream.c +++ b/Zend/zend_stream.c @@ -73,7 +73,7 @@ ZEND_API void zend_stream_init_filename(zend_file_handle *handle, const char *fi handle->filename = filename; } -ZEND_API int zend_stream_open(const char *filename, zend_file_handle *handle) /* {{{ */ +ZEND_API zend_result zend_stream_open(const char *filename, zend_file_handle *handle) /* {{{ */ { zend_string *opened_path; if (zend_stream_open_function) { @@ -113,7 +113,7 @@ static ssize_t zend_stream_read(zend_file_handle *file_handle, char *buf, size_t return file_handle->handle.stream.reader(file_handle->handle.stream.handle, buf, len); } /* }}} */ -ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len) /* {{{ */ +ZEND_API zend_result zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len) /* {{{ */ { size_t file_size; @@ -232,6 +232,7 @@ ZEND_API void zend_file_handle_dtor(zend_file_handle *fh) /* {{{ */ } /* }}} */ +/* return int to be compatible with Zend linked list API */ ZEND_API int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2) /* {{{ */ { if (fh1->type != fh2->type) { diff --git a/Zend/zend_stream.h b/Zend/zend_stream.h index 51651add38278..023e2d0555a4d 100644 --- a/Zend/zend_stream.h +++ b/Zend/zend_stream.h @@ -66,8 +66,8 @@ typedef struct _zend_file_handle { BEGIN_EXTERN_C() ZEND_API void zend_stream_init_fp(zend_file_handle *handle, FILE *fp, const char *filename); ZEND_API void zend_stream_init_filename(zend_file_handle *handle, const char *filename); -ZEND_API int zend_stream_open(const char *filename, zend_file_handle *handle); -ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len); +ZEND_API zend_result zend_stream_open(const char *filename, zend_file_handle *handle); +ZEND_API zend_result zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t *len); ZEND_API void zend_file_handle_dtor(zend_file_handle *fh); ZEND_API int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2); END_EXTERN_C() diff --git a/Zend/zend_string.c b/Zend/zend_string.c index 7eae674f08a21..570aeece61e22 100644 --- a/Zend/zend_string.c +++ b/Zend/zend_string.c @@ -28,8 +28,8 @@ ZEND_API zend_string_init_interned_func_t zend_string_init_interned; static zend_string* ZEND_FASTCALL zend_new_interned_string_permanent(zend_string *str); static zend_string* ZEND_FASTCALL zend_new_interned_string_request(zend_string *str); -static zend_string* ZEND_FASTCALL zend_string_init_interned_permanent(const char *str, size_t size, int permanent); -static zend_string* ZEND_FASTCALL zend_string_init_interned_request(const char *str, size_t size, int permanent); +static zend_string* ZEND_FASTCALL zend_string_init_interned_permanent(const char *str, size_t size, bool permanent); +static zend_string* ZEND_FASTCALL zend_string_init_interned_request(const char *str, size_t size, bool permanent); /* Any strings interned in the startup phase. Common to all the threads, won't be free'd until process exit. If we want an ability to @@ -67,7 +67,7 @@ ZEND_KNOWN_STRINGS(_ZEND_STR_DSC) NULL }; -static zend_always_inline void zend_init_interned_strings_ht(HashTable *interned_strings, int permanent) +static zend_always_inline void zend_init_interned_strings_ht(HashTable *interned_strings, bool permanent) { zend_hash_init(interned_strings, 1024, NULL, _str_dtor, permanent); if (permanent) { @@ -251,7 +251,7 @@ static zend_string* ZEND_FASTCALL zend_new_interned_string_request(zend_string * return ret; } -static zend_string* ZEND_FASTCALL zend_string_init_interned_permanent(const char *str, size_t size, int permanent) +static zend_string* ZEND_FASTCALL zend_string_init_interned_permanent(const char *str, size_t size, bool permanent) { zend_string *ret; zend_ulong h = zend_inline_hash_func(str, size); @@ -267,7 +267,7 @@ static zend_string* ZEND_FASTCALL zend_string_init_interned_permanent(const char return zend_add_interned_string(ret, &interned_strings_permanent, IS_STR_PERMANENT); } -static zend_string* ZEND_FASTCALL zend_string_init_interned_request(const char *str, size_t size, int permanent) +static zend_string* ZEND_FASTCALL zend_string_init_interned_request(const char *str, size_t size, bool permanent) { zend_string *ret; zend_ulong h = zend_inline_hash_func(str, size); diff --git a/Zend/zend_string.h b/Zend/zend_string.h index 98bd735976487..316d022e647a7 100644 --- a/Zend/zend_string.h +++ b/Zend/zend_string.h @@ -25,7 +25,7 @@ BEGIN_EXTERN_C() typedef void (*zend_string_copy_storage_func_t)(void); typedef zend_string *(ZEND_FASTCALL *zend_new_interned_string_func_t)(zend_string *str); -typedef zend_string *(ZEND_FASTCALL *zend_string_init_interned_func_t)(const char *str, size_t size, int permanent); +typedef zend_string *(ZEND_FASTCALL *zend_string_init_interned_func_t)(const char *str, size_t size, bool permanent); ZEND_API extern zend_new_interned_string_func_t zend_new_interned_string; ZEND_API extern zend_string_init_interned_func_t zend_string_init_interned; @@ -136,7 +136,7 @@ static zend_always_inline uint32_t zend_string_delref(zend_string *s) return 1; } -static zend_always_inline zend_string *zend_string_alloc(size_t len, int persistent) +static zend_always_inline zend_string *zend_string_alloc(size_t len, bool persistent) { zend_string *ret = (zend_string *)pemalloc(ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent); @@ -147,7 +147,7 @@ static zend_always_inline zend_string *zend_string_alloc(size_t len, int persist return ret; } -static zend_always_inline zend_string *zend_string_safe_alloc(size_t n, size_t m, size_t l, int persistent) +static zend_always_inline zend_string *zend_string_safe_alloc(size_t n, size_t m, size_t l, bool persistent) { zend_string *ret = (zend_string *)safe_pemalloc(n, m, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(l)), persistent); @@ -158,7 +158,7 @@ static zend_always_inline zend_string *zend_string_safe_alloc(size_t n, size_t m return ret; } -static zend_always_inline zend_string *zend_string_init(const char *str, size_t len, int persistent) +static zend_always_inline zend_string *zend_string_init(const char *str, size_t len, bool persistent) { zend_string *ret = zend_string_alloc(len, persistent); @@ -186,7 +186,7 @@ static zend_always_inline zend_string *zend_string_copy(zend_string *s) return s; } -static zend_always_inline zend_string *zend_string_dup(zend_string *s, int persistent) +static zend_always_inline zend_string *zend_string_dup(zend_string *s, bool persistent) { if (ZSTR_IS_INTERNED(s)) { return s; @@ -195,7 +195,7 @@ static zend_always_inline zend_string *zend_string_dup(zend_string *s, int persi } } -static zend_always_inline zend_string *zend_string_realloc(zend_string *s, size_t len, int persistent) +static zend_always_inline zend_string *zend_string_realloc(zend_string *s, size_t len, bool persistent) { zend_string *ret; @@ -214,7 +214,7 @@ static zend_always_inline zend_string *zend_string_realloc(zend_string *s, size_ return ret; } -static zend_always_inline zend_string *zend_string_extend(zend_string *s, size_t len, int persistent) +static zend_always_inline zend_string *zend_string_extend(zend_string *s, size_t len, bool persistent) { zend_string *ret; @@ -234,7 +234,7 @@ static zend_always_inline zend_string *zend_string_extend(zend_string *s, size_t return ret; } -static zend_always_inline zend_string *zend_string_truncate(zend_string *s, size_t len, int persistent) +static zend_always_inline zend_string *zend_string_truncate(zend_string *s, size_t len, bool persistent) { zend_string *ret; @@ -254,7 +254,7 @@ static zend_always_inline zend_string *zend_string_truncate(zend_string *s, size return ret; } -static zend_always_inline zend_string *zend_string_safe_realloc(zend_string *s, size_t n, size_t m, size_t l, int persistent) +static zend_always_inline zend_string *zend_string_safe_realloc(zend_string *s, size_t n, size_t m, size_t l, bool persistent) { zend_string *ret; @@ -298,7 +298,7 @@ static zend_always_inline void zend_string_release(zend_string *s) } } -static zend_always_inline void zend_string_release_ex(zend_string *s, int persistent) +static zend_always_inline void zend_string_release_ex(zend_string *s, bool persistent) { if (!ZSTR_IS_INTERNED(s)) { if (GC_DELREF(s) == 0) { diff --git a/Zend/zend_ts_hash.c b/Zend/zend_ts_hash.c index 34cc7419a841b..d4e972d0e3e5d 100644 --- a/Zend/zend_ts_hash.c +++ b/Zend/zend_ts_hash.c @@ -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(); @@ -186,9 +186,9 @@ ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_fun end_write(ht); } -ZEND_API int zend_ts_hash_del(TsHashTable *ht, zend_string *key) +ZEND_API zend_result zend_ts_hash_del(TsHashTable *ht, zend_string *key) { - int retval; + zend_result retval; begin_write(ht); retval = zend_hash_del(TS_HASH(ht), key); @@ -197,9 +197,9 @@ ZEND_API int zend_ts_hash_del(TsHashTable *ht, zend_string *key) return retval; } -ZEND_API int zend_ts_hash_index_del(TsHashTable *ht, zend_ulong h) +ZEND_API zend_result zend_ts_hash_index_del(TsHashTable *ht, zend_ulong h) { - int retval; + zend_result retval; begin_write(ht); retval = zend_hash_index_del(TS_HASH(ht), h); @@ -246,7 +246,7 @@ ZEND_API void zend_ts_hash_copy_to_hash(HashTable *target, TsHashTable *source, end_read(source); } -ZEND_API void zend_ts_hash_merge(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, int overwrite) +ZEND_API void zend_ts_hash_merge(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, bool overwrite) { begin_read(source); begin_write(target); @@ -264,7 +264,7 @@ ZEND_API void zend_ts_hash_merge_ex(TsHashTable *target, TsHashTable *source, co end_read(source); } -ZEND_API void zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, bucket_compare_func_t compare_func, int renumber) +ZEND_API void zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, bucket_compare_func_t compare_func, bool renumber) { begin_write(ht); zend_hash_sort_ex(TS_HASH(ht), sort_func, compare_func, renumber); diff --git a/Zend/zend_ts_hash.h b/Zend/zend_ts_hash.h index e224d0217c7e9..51801e4e05f17 100644 --- a/Zend/zend_ts_hash.h +++ b/Zend/zend_ts_hash.h @@ -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); @@ -61,8 +56,8 @@ ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_fun /* Deletes */ -ZEND_API int zend_ts_hash_del(TsHashTable *ht, zend_string *key); -ZEND_API int zend_ts_hash_index_del(TsHashTable *ht, zend_ulong h); +ZEND_API zend_result zend_ts_hash_del(TsHashTable *ht, zend_string *key); +ZEND_API zend_result zend_ts_hash_index_del(TsHashTable *ht, zend_ulong h); /* Data retrieval */ ZEND_API zval *zend_ts_hash_find(TsHashTable *ht, zend_string *key); @@ -71,10 +66,10 @@ ZEND_API zval *zend_ts_hash_index_find(TsHashTable *ht, zend_ulong); /* Copying, merging and sorting */ ZEND_API void zend_ts_hash_copy(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor); ZEND_API void zend_ts_hash_copy_to_hash(HashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor); -ZEND_API void zend_ts_hash_merge(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, int overwrite); +ZEND_API void zend_ts_hash_merge(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, bool overwrite); ZEND_API void zend_ts_hash_merge_ex(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, merge_checker_func_t pMergeSource, void *pParam); -ZEND_API void zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, bucket_compare_func_t compare_func, int renumber); -ZEND_API int zend_ts_hash_compare(TsHashTable *ht1, TsHashTable *ht2, compare_func_t compar, zend_bool ordered); +ZEND_API void zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, bucket_compare_func_t compare_func, bool renumber); +ZEND_API int zend_ts_hash_compare(TsHashTable *ht1, TsHashTable *ht2, compare_func_t compar, zend_bool ordered); ZEND_API zval *zend_ts_hash_minmax(TsHashTable *ht, bucket_compare_func_t compar, int flag); ZEND_API int zend_ts_hash_num_elements(TsHashTable *ht); @@ -117,12 +112,12 @@ static zend_always_inline void *zend_ts_hash_str_add_ptr(TsHashTable *ht, const return zv ? Z_PTR_P(zv) : NULL; } -static zend_always_inline int zend_ts_hash_exists(TsHashTable *ht, zend_string *key) +static zend_always_inline bool zend_ts_hash_exists(TsHashTable *ht, zend_string *key) { return zend_ts_hash_find(ht, key) != NULL; } -static zend_always_inline int zend_ts_hash_index_exists(TsHashTable *ht, zend_ulong h) +static zend_always_inline bool zend_ts_hash_index_exists(TsHashTable *ht, zend_ulong h) { return zend_ts_hash_index_find(ht, h) != NULL; } diff --git a/Zend/zend_type_info.h b/Zend/zend_type_info.h index 9dc90d142b4ed..a0fc698ebe5ee 100644 --- a/Zend/zend_type_info.h +++ b/Zend/zend_type_info.h @@ -56,11 +56,18 @@ #define MAY_BE_ARRAY_OF_ANY (MAY_BE_ANY << MAY_BE_ARRAY_SHIFT) #define MAY_BE_ARRAY_OF_REF (MAY_BE_REF << MAY_BE_ARRAY_SHIFT) -#define MAY_BE_ARRAY_KEY_LONG (1<<21) -#define MAY_BE_ARRAY_KEY_STRING (1<<22) +#define MAY_BE_ARRAY_PACKED (1<<21) +#define MAY_BE_ARRAY_HASH (1<<22) /* hash with numeric keys */ + +#define MAY_BE_ARRAY_KEY_LONG (MAY_BE_ARRAY_PACKED | MAY_BE_ARRAY_HASH) +#define MAY_BE_ARRAY_KEY_STRING (1<<23) #define MAY_BE_ARRAY_KEY_ANY (MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_KEY_STRING) -#define MAY_BE_CLASS (1<<23) -#define MAY_BE_INDIRECT (1<<24) +#define MAY_BE_CLASS (1<<24) +#define MAY_BE_INDIRECT (1<<25) + + +#define MAY_BE_ANY_ARRAY \ + (MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_ANY|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF) #endif /* ZEND_TYPE_INFO_H */ diff --git a/Zend/zend_types.h b/Zend/zend_types.h index 7796979ed842f..745be6e93830c 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -55,6 +55,8 @@ typedef enum { FAILURE = -1, /* this MUST stay a negative number, or it may affect functions! */ } ZEND_RESULT_CODE; +typedef ZEND_RESULT_CODE zend_result; + #ifdef ZEND_ENABLE_ZVAL_LONG64 # ifdef ZEND_WIN32 # define ZEND_SIZE_MAX _UI64_MAX diff --git a/Zend/zend_variables.h b/Zend/zend_variables.h index bdee8b1879d5b..ea3fd9c5efcb8 100644 --- a/Zend/zend_variables.h +++ b/Zend/zend_variables.h @@ -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); diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c index 61542bfce200e..250d1704dcf19 100644 --- a/Zend/zend_virtual_cwd.c +++ b/Zend/zend_virtual_cwd.c @@ -483,7 +483,7 @@ CWD_API realpath_cache_bucket** realpath_cache_get_buckets(void) #undef LINK_MAX #define LINK_MAX 32 -static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, time_t *t, int use_realpath, int is_dir, int *link_is_dir) /* {{{ */ +static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, time_t *t, int use_realpath, bool is_dir, int *link_is_dir) /* {{{ */ { size_t i, j; int directory = 0, save; @@ -996,7 +996,7 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim /* }}} */ /* Resolve path relatively to state and put the real path into state */ -/* returns 0 for ok, 1 for error */ +/* returns 0 for ok, 1 for error, -1 if (path_length >= MAXPATHLEN-1) */ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath) /* {{{ */ { size_t path_length = strlen(path); @@ -1005,7 +1005,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func int ll = 0; time_t t; int ret; - int add_slash; + bool add_slash; void *tmp; if (!path_length || path_length >= MAXPATHLEN-1) { @@ -1178,12 +1178,14 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func } /* }}} */ -CWD_API int virtual_chdir(const char *path) /* {{{ */ +CWD_API zend_result virtual_chdir(const char *path) /* {{{ */ { - return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok, CWD_REALPATH)?-1:0; + return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok, CWD_REALPATH) ? FAILURE : SUCCESS; } /* }}} */ + +/* returns 0 for ok, 1 for empty string, -1 on error */ CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path)) /* {{{ */ { size_t length = strlen(path); @@ -1255,6 +1257,7 @@ CWD_API char *virtual_realpath(const char *path, char *real_path) /* {{{ */ } /* }}} */ +/* returns 0 for ok, 1 for error, -1 if (path_length >= MAXPATHLEN-1) */ CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_func verify_path) /* {{{ */ { cwd_state new_state; @@ -1270,6 +1273,7 @@ CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_f } /* }}} */ +/* returns 0 for ok, 1 for error, -1 if (path_length >= MAXPATHLEN-1) */ CWD_API int virtual_filepath(const char *path, char **filepath) /* {{{ */ { return virtual_filepath_ex(path, filepath, php_is_file_ok); diff --git a/Zend/zend_virtual_cwd.h b/Zend/zend_virtual_cwd.h index 84a1562c7789f..dfaa95932c3b6 100644 --- a/Zend/zend_virtual_cwd.h +++ b/Zend/zend_virtual_cwd.h @@ -189,6 +189,7 @@ CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group, int li /* One of the following constants must be used as the last argument in virtual_file_ex() call. */ +// TODO Make this into an enum #define CWD_EXPAND 0 /* expand "." and ".." but don't resolve symlinks */ #define CWD_FILEPATH 1 /* resolve symlinks if file is exist otherwise expand */ #define CWD_REALPATH 2 /* call realpath(), resolve symlinks. File must exist */ diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index f06713d5ac8ab..00bb179561f0f 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -549,7 +549,7 @@ ZEND_VM_C_LABEL(is_equal_double): } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (OP1_TYPE & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -629,7 +629,7 @@ ZEND_VM_C_LABEL(is_not_equal_double): } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (OP1_TYPE & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -2993,7 +2993,7 @@ ZEND_VM_COLD_CONST_HANDLER(46, ZEND_JMPZ_EX, CONST|TMPVAR|CV, JMP_ADDR) { USE_OPLINE zval *val; - int ret; + bool ret; val = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -3029,7 +3029,7 @@ ZEND_VM_COLD_CONST_HANDLER(47, ZEND_JMPNZ_EX, CONST|TMPVAR|CV, JMP_ADDR) { USE_OPLINE zval *val; - int ret; + bool ret; val = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -3424,12 +3424,26 @@ ZEND_VM_HOT_OBJ_HANDLER(112, ZEND_INIT_METHOD_CALL, CONST|TMPVAR|UNUSED|THIS|CV, } while (0); } - if (OP1_TYPE != IS_UNUSED) { + if (OP1_TYPE == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if (OP1_TYPE == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if (OP1_TYPE != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if ((OP1_TYPE & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + if (OP1_TYPE & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -3453,7 +3467,6 @@ ZEND_VM_HOT_OBJ_HANDLER(112, ZEND_INIT_METHOD_CALL, CONST|TMPVAR|UNUSED|THIS|CV, } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if (OP2_TYPE == IS_CONST && @@ -3473,7 +3486,9 @@ ZEND_VM_HOT_OBJ_HANDLER(112, ZEND_INIT_METHOD_CALL, CONST|TMPVAR|UNUSED|THIS|CV, zend_undefined_method(obj->ce, Z_STR_P(function_name)); } FREE_OP2(); - FREE_OP1(); + if ((OP1_TYPE & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if (OP2_TYPE == IS_CONST && @@ -3482,8 +3497,10 @@ ZEND_VM_HOT_OBJ_HANDLER(112, ZEND_INIT_METHOD_CALL, CONST|TMPVAR|UNUSED|THIS|CV, CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if ((OP1_TYPE & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -3496,10 +3513,11 @@ ZEND_VM_HOT_OBJ_HANDLER(112, ZEND_INIT_METHOD_CALL, CONST|TMPVAR|UNUSED|THIS|CV, call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - FREE_OP1(); - - if ((OP1_TYPE & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if ((OP1_TYPE & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -3507,12 +3525,6 @@ ZEND_VM_HOT_OBJ_HANDLER(112, ZEND_INIT_METHOD_CALL, CONST|TMPVAR|UNUSED|THIS|CV, } else if (OP1_TYPE & (IS_VAR|IS_TMP_VAR|IS_CV)) { if (OP1_TYPE == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -4558,6 +4570,7 @@ ZEND_VM_HOT_HANDLER(65, ZEND_SEND_VAL, CONST|TMPVAR, CONST|UNUSED|NUM) uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + FREE_OP1(); HANDLE_EXCEPTION(); } } else { @@ -4574,17 +4587,14 @@ ZEND_VM_HOT_HANDLER(65, ZEND_SEND_VAL, CONST|TMPVAR, CONST|UNUSED|NUM) ZEND_VM_NEXT_OPCODE(); } -ZEND_VM_COLD_HELPER(zend_cannot_pass_by_ref_helper, ANY, ANY) +ZEND_VM_COLD_HELPER(zend_cannot_pass_by_ref_helper, ANY, ANY, uint32_t _arg_num, zval *_arg) { USE_OPLINE - zval *arg; - uint32_t arg_num = opline->op2.num; SAVE_OPLINE(); - zend_throw_error(NULL, "Cannot pass parameter %d by reference", arg_num); + zend_throw_error(NULL, "Cannot pass parameter %d by reference", _arg_num); FREE_OP1(); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); - ZVAL_UNDEF(arg); + ZVAL_UNDEF(_arg); HANDLE_EXCEPTION(); } @@ -4599,6 +4609,7 @@ ZEND_VM_HOT_SEND_HANDLER(116, ZEND_SEND_VAL_EX, CONST|TMP, CONST|UNUSED|NUM, SPE zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + FREE_OP1(); HANDLE_EXCEPTION(); } } else { @@ -4612,7 +4623,7 @@ ZEND_VM_HOT_SEND_HANDLER(116, ZEND_SEND_VAL_EX, CONST|TMP, CONST|UNUSED|NUM, SPE } } else if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) { ZEND_VM_C_LABEL(send_val_by_ref): - ZEND_VM_DISPATCH_TO_HELPER(zend_cannot_pass_by_ref_helper); + ZEND_VM_DISPATCH_TO_HELPER(zend_cannot_pass_by_ref_helper, _arg_num, arg_num, _arg, arg); } value = GET_OP1_ZVAL_PTR(BP_VAR_R); ZVAL_COPY_VALUE(arg, value); @@ -4635,6 +4646,7 @@ ZEND_VM_HOT_HANDLER(117, ZEND_SEND_VAR, VAR|CV, CONST|UNUSED|NUM) uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + FREE_OP1(); HANDLE_EXCEPTION(); } } else { @@ -4681,6 +4693,7 @@ ZEND_VM_HANDLER(106, ZEND_SEND_VAR_NO_REF, VAR, CONST|UNUSED|NUM) uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + FREE_OP1(); HANDLE_EXCEPTION(); } } else { @@ -4711,6 +4724,7 @@ ZEND_VM_HOT_SEND_HANDLER(50, ZEND_SEND_VAR_NO_REF_EX, VAR, CONST|UNUSED|NUM, SPE zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + FREE_OP1(); HANDLE_EXCEPTION(); } } else { @@ -4778,6 +4792,7 @@ ZEND_VM_HANDLER(67, ZEND_SEND_REF, VAR|CV, CONST|UNUSED|NUM) uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + FREE_OP1(); HANDLE_EXCEPTION(); } } else { @@ -4807,6 +4822,7 @@ ZEND_VM_HOT_SEND_HANDLER(66, ZEND_SEND_VAR_EX, VAR|CV, CONST|UNUSED|NUM, SPEC(QU zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + FREE_OP1(); HANDLE_EXCEPTION(); } } else { @@ -4836,7 +4852,6 @@ ZEND_VM_C_LABEL(send_var_by_ref): if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(varptr) == IS_UNDEF)) { SAVE_OPLINE(); ZVAL_UNDEFINED_OP1(); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); ZVAL_NULL(arg); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -4906,6 +4921,7 @@ ZEND_VM_HOT_HANDLER(185, ZEND_SEND_FUNC_ARG, VAR, CONST|UNUSED|NUM) uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + FREE_OP1(); HANDLE_EXCEPTION(); } } else { @@ -4966,7 +4982,7 @@ ZEND_VM_C_LABEL(send_again): // TODO: Speed this up using a flag that specifies whether there are any ref parameters. if ((OP1_TYPE & (IS_VAR|IS_CV)) && Z_REFCOUNT_P(args) > 1) { uint32_t tmp_arg_num = arg_num; - int separate = 0; + bool separate = 0; /* check if any of arguments are going to be passed by reference */ ZEND_HASH_FOREACH_STR_KEY_VAL(ht, name, arg) { @@ -5088,6 +5104,7 @@ ZEND_VM_C_LABEL(send_again): have_named_params = 1; top = zend_handle_named_arg(&EX(call), name, &arg_num, cache_slot); if (UNEXPECTED(!top)) { + zend_string_release(name); break; } @@ -5191,6 +5208,7 @@ ZEND_VM_C_LABEL(send_array): arg_num = 1; param = ZEND_CALL_ARG(EX(call), 1); ZEND_HASH_FOREACH_VAL(ht, arg) { + zend_bool must_wrap = 0; if (skip > 0) { skip--; continue; @@ -5202,6 +5220,7 @@ ZEND_VM_C_LABEL(send_array): /* By-value send is not allowed -- emit a warning, * but still perform the call. */ zend_param_must_be_ref(EX(call)->func, arg_num); + must_wrap = 1; } } } else { @@ -5211,7 +5230,12 @@ ZEND_VM_C_LABEL(send_array): arg = Z_REFVAL_P(arg); } } - ZVAL_COPY(param, arg); + if (EXPECTED(!must_wrap)) { + ZVAL_COPY(param, arg); + } else { + Z_TRY_ADDREF_P(arg); + ZVAL_NEW_REF(param, arg); + } ZEND_CALL_NUM_ARGS(EX(call))++; arg_num++; param++; @@ -5241,12 +5265,14 @@ ZEND_VM_C_LABEL(send_array): HANDLE_EXCEPTION(); } + zend_bool must_wrap = 0; if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) { if (UNEXPECTED(!Z_ISREF_P(arg))) { if (!ARG_MAY_BE_SENT_BY_REF(EX(call)->func, arg_num)) { /* By-value send is not allowed -- emit a warning, * but still perform the call. */ zend_param_must_be_ref(EX(call)->func, arg_num); + must_wrap = 1; } } } else { @@ -5257,7 +5283,12 @@ ZEND_VM_C_LABEL(send_array): } } - ZVAL_COPY(param, arg); + if (EXPECTED(!must_wrap)) { + ZVAL_COPY(param, arg); + } else { + Z_TRY_ADDREF_P(arg); + ZVAL_NEW_REF(param, arg); + } if (!name) { ZEND_CALL_NUM_ARGS(EX(call))++; arg_num++; @@ -5560,7 +5591,7 @@ ZEND_VM_C_LABEL(case_double): } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); FREE_OP2(); if (result) { ZEND_VM_C_GOTO(case_true); @@ -6919,7 +6950,7 @@ ZEND_VM_HOT_HANDLER(154, ZEND_ISSET_ISEMPTY_CV, CV, UNUSED, ISSET, SPEC(ISSET)) ZEND_VM_SMART_BRANCH_FALSE(); } } else { - int result; + bool result; SAVE_OPLINE(); result = !i_zend_is_true(value); @@ -6931,6 +6962,7 @@ ZEND_VM_HANDLER(114, ZEND_ISSET_ISEMPTY_VAR, CONST|TMPVAR|CV, UNUSED, VAR_FETCH| { USE_OPLINE zval *value; + /* Should be bool result? as below got: result = (opline->extended_value & ZEND_ISEMPTY) */ int result; zval *varname; zend_string *name, *tmp_name; @@ -6976,17 +7008,18 @@ ZEND_VM_HANDLER(180, ZEND_ISSET_ISEMPTY_STATIC_PROP, ANY, CLASS_FETCH, ISSET|CAC { USE_OPLINE zval *value; - int result; + zend_result fetch_result; + bool result; SAVE_OPLINE(); - result = zend_fetch_static_property_address(&value, NULL, opline->extended_value & ~ZEND_ISEMPTY, BP_VAR_IS, 0 OPLINE_CC EXECUTE_DATA_CC); + fetch_result = zend_fetch_static_property_address(&value, NULL, opline->extended_value & ~ZEND_ISEMPTY, BP_VAR_IS, 0 OPLINE_CC EXECUTE_DATA_CC); if (!(opline->extended_value & ZEND_ISEMPTY)) { - result = result == SUCCESS && Z_TYPE_P(value) > IS_NULL && + result = fetch_result == SUCCESS && Z_TYPE_P(value) > IS_NULL && (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL); } else { - result = result != SUCCESS || !i_zend_is_true(value); + result = fetch_result != SUCCESS || !i_zend_is_true(value); } ZEND_VM_SMART_BRANCH(result, 1); @@ -6996,7 +7029,7 @@ ZEND_VM_COLD_CONSTCONST_HANDLER(115, ZEND_ISSET_ISEMPTY_DIM_OBJ, CONST|TMPVAR|CV { USE_OPLINE zval *container; - int result; + bool result; zend_ulong hval; zval *offset; @@ -7236,7 +7269,7 @@ ZEND_VM_COLD_CONST_HANDLER(152, ZEND_JMP_SET, CONST|TMP|VAR|CV, JMP_ADDR) USE_OPLINE zval *value; zval *ref = NULL; - int ret; + bool ret; SAVE_OPLINE(); value = GET_OP1_ZVAL_PTR(BP_VAR_R); @@ -8041,6 +8074,7 @@ ZEND_VM_C_LABEL(yield_from_try_again): ZEND_VM_C_GOTO(yield_from_try_again); } else { zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables"); + FREE_OP1(); UNDEF_RESULT(); HANDLE_EXCEPTION(); } @@ -9174,7 +9208,7 @@ ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_IS_EQUAL|ZEND_IS_IDENTICAL, (op1_info == MAY_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -9186,7 +9220,7 @@ ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_IS_EQUAL|ZEND_IS_IDENTICAL, (op1_info == MAY_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -9198,7 +9232,7 @@ ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_IS_NOT_EQUAL|ZEND_IS_NOT_IDENTICAL, (op1_info { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -9210,7 +9244,7 @@ ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_IS_NOT_EQUAL|ZEND_IS_NOT_IDENTICAL, (op1_info { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -9251,7 +9285,7 @@ ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_IS_SMALLER, (op1_info == MAY_BE_LONG && op2_i { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -9263,7 +9297,7 @@ ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_IS_SMALLER, (op1_info == MAY_BE_DOUBLE && op2 { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -9275,7 +9309,7 @@ ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_IS_SMALLER_OR_EQUAL, (op1_info == MAY_BE_LONG { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -9287,7 +9321,7 @@ ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_IS_SMALLER_OR_EQUAL, (op1_info == MAY_BE_DOUB { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R); @@ -9529,11 +9563,11 @@ ZEND_VM_HOT_TYPE_SPEC_HANDLER(ZEND_SEND_VAL_EX, op->op2_type == IS_UNUSED && op- zval *value, *arg; uint32_t arg_num = opline->op2.num; + arg = ZEND_CALL_VAR(EX(call), opline->result.var); if (QUICK_ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) { - ZEND_VM_DISPATCH_TO_HELPER(zend_cannot_pass_by_ref_helper); + ZEND_VM_DISPATCH_TO_HELPER(zend_cannot_pass_by_ref_helper, _arg_num, arg_num, _arg, arg); } value = GET_OP1_ZVAL_PTR(BP_VAR_R); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); ZVAL_COPY_VALUE(arg, value); ZEND_VM_NEXT_OPCODE(); } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index f103e91d331a5..e6712b86afbca 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1837,17 +1837,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_GENERATOR_CREATE_SPEC_HANDLER( } } -static zend_never_inline ZEND_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_cannot_pass_by_ref_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) +static zend_never_inline ZEND_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_cannot_pass_by_ref_helper_SPEC(uint32_t _arg_num, zval *_arg ZEND_OPCODE_HANDLER_ARGS_DC) { USE_OPLINE - zval *arg; - uint32_t arg_num = opline->op2.num; SAVE_OPLINE(); - zend_throw_error(NULL, "Cannot pass parameter %d by reference", arg_num); + zend_throw_error(NULL, "Cannot pass parameter %d by reference", _arg_num); FREE_OP(opline->op1_type, opline->op1.var); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); - ZVAL_UNDEF(arg); + ZVAL_UNDEF(_arg); HANDLE_EXCEPTION(); } @@ -1873,7 +1870,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_UNPACK_SPEC_HANDLER(ZEND_ // TODO: Speed this up using a flag that specifies whether there are any ref parameters. if ((opline->op1_type & (IS_VAR|IS_CV)) && Z_REFCOUNT_P(args) > 1) { uint32_t tmp_arg_num = arg_num; - int separate = 0; + bool separate = 0; /* check if any of arguments are going to be passed by reference */ ZEND_HASH_FOREACH_STR_KEY_VAL(ht, name, arg) { @@ -1995,6 +1992,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_UNPACK_SPEC_HANDLER(ZEND_ have_named_params = 1; top = zend_handle_named_arg(&EX(call), name, &arg_num, cache_slot); if (UNEXPECTED(!top)) { + zend_string_release(name); break; } @@ -2098,6 +2096,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_O arg_num = 1; param = ZEND_CALL_ARG(EX(call), 1); ZEND_HASH_FOREACH_VAL(ht, arg) { + zend_bool must_wrap = 0; if (skip > 0) { skip--; continue; @@ -2109,6 +2108,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_O /* By-value send is not allowed -- emit a warning, * but still perform the call. */ zend_param_must_be_ref(EX(call)->func, arg_num); + must_wrap = 1; } } } else { @@ -2118,7 +2118,12 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_O arg = Z_REFVAL_P(arg); } } - ZVAL_COPY(param, arg); + if (EXPECTED(!must_wrap)) { + ZVAL_COPY(param, arg); + } else { + Z_TRY_ADDREF_P(arg); + ZVAL_NEW_REF(param, arg); + } ZEND_CALL_NUM_ARGS(EX(call))++; arg_num++; param++; @@ -2148,12 +2153,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_O HANDLE_EXCEPTION(); } + zend_bool must_wrap = 0; if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) { if (UNEXPECTED(!Z_ISREF_P(arg))) { if (!ARG_MAY_BE_SENT_BY_REF(EX(call)->func, arg_num)) { /* By-value send is not allowed -- emit a warning, * but still perform the call. */ zend_param_must_be_ref(EX(call)->func, arg_num); + must_wrap = 1; } } } else { @@ -2164,7 +2171,12 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_O } } - ZVAL_COPY(param, arg); + if (EXPECTED(!must_wrap)) { + ZVAL_COPY(param, arg); + } else { + Z_TRY_ADDREF_P(arg); + ZVAL_NEW_REF(param, arg); + } if (!name) { ZEND_CALL_NUM_ARGS(EX(call))++; arg_num++; @@ -2393,17 +2405,18 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_STATIC_PROP_SPEC { USE_OPLINE zval *value; - int result; + zend_result fetch_result; + bool result; SAVE_OPLINE(); - result = zend_fetch_static_property_address(&value, NULL, opline->extended_value & ~ZEND_ISEMPTY, BP_VAR_IS, 0 OPLINE_CC EXECUTE_DATA_CC); + fetch_result = zend_fetch_static_property_address(&value, NULL, opline->extended_value & ~ZEND_ISEMPTY, BP_VAR_IS, 0 OPLINE_CC EXECUTE_DATA_CC); if (!(opline->extended_value & ZEND_ISEMPTY)) { - result = result == SUCCESS && Z_TYPE_P(value) > IS_NULL && + result = fetch_result == SUCCESS && Z_TYPE_P(value) > IS_NULL && (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL); } else { - result = result != SUCCESS || !i_zend_is_true(value); + result = fetch_result != SUCCESS || !i_zend_is_true(value); } ZEND_VM_SMART_BRANCH(result, 1); @@ -3542,7 +3555,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMPZ_EX_SPEC_CONS { USE_OPLINE zval *val; - int ret; + bool ret; val = RT_CONSTANT(opline, opline->op1); @@ -3578,7 +3591,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMPNZ_EX_SPEC_CON { USE_OPLINE zval *val; - int ret; + bool ret; val = RT_CONSTANT(opline, opline->op1); @@ -4288,7 +4301,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMP_SET_SPEC_CONS USE_OPLINE zval *value; zval *ref = NULL; - int ret; + bool ret; SAVE_OPLINE(); value = RT_CONSTANT(opline, opline->op1); @@ -4531,6 +4544,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_YIELD_FROM_SPEC_CONST_HANDLER( goto yield_from_try_again; } else { zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables"); + UNDEF_RESULT(); HANDLE_EXCEPTION(); } @@ -4711,11 +4725,11 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SIMPLE zval *value, *arg; uint32_t arg_num = opline->op2.num; + arg = ZEND_CALL_VAR(EX(call), opline->result.var); if (QUICK_ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) { - ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)); + ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(arg_num, arg ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC)); } value = RT_CONSTANT(opline, opline->op1); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); ZVAL_COPY_VALUE(arg, value); ZEND_VM_NEXT_OPCODE(); } @@ -5003,7 +5017,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CON } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CONST & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -5061,7 +5075,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CONST & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -5739,12 +5753,26 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ } while (0); } - if (IS_CONST != IS_UNUSED) { + if (IS_CONST == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if (IS_CONST == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if (IS_CONST != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if ((IS_CONST & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + if (IS_CONST & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -5768,7 +5796,6 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if (IS_CONST == IS_CONST && @@ -5788,7 +5815,9 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ zend_undefined_method(obj->ce, Z_STR_P(function_name)); } - + if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if (IS_CONST == IS_CONST && @@ -5797,8 +5826,10 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -5811,9 +5842,11 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - - if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -5821,12 +5854,6 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ } else if (IS_CONST & (IS_VAR|IS_TMP_VAR|IS_CV)) { if (IS_CONST == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -6044,6 +6071,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_SPEC_CONS uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -6071,6 +6099,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_CONST_CONST_H zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -6084,7 +6113,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_CONST_CONST_H } } else if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) { send_val_by_ref: - ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)); + ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(arg_num, arg ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC)); } value = RT_CONSTANT(opline, opline->op1); ZVAL_COPY_VALUE(arg, value); @@ -6287,7 +6316,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM { USE_OPLINE zval *container; - int result; + bool result; zend_ulong hval; zval *offset; @@ -7220,7 +7249,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_LONG_SPEC_CONST_TMP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7232,7 +7261,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_LONG_SP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7244,7 +7273,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_LONG_SP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7256,7 +7285,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_DOUBLE_SPEC_CONST_T { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7268,7 +7297,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_DOUBLE_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7280,7 +7309,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_DOUBLE_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7292,7 +7321,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_LONG_SPEC_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7304,7 +7333,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7316,7 +7345,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7328,7 +7357,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_DOUBLE_SPE { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7340,7 +7369,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -7352,7 +7381,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = RT_CONSTANT(opline, opline->op1); op2 = EX_VAR(opline->op2.var); @@ -8014,12 +8043,26 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ } while (0); } - if (IS_CONST != IS_UNUSED) { + if (IS_CONST == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if (IS_CONST == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if (IS_CONST != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if ((IS_CONST & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + if (IS_CONST & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -8043,7 +8086,6 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if ((IS_TMP_VAR|IS_VAR) == IS_CONST && @@ -8063,7 +8105,9 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ zend_undefined_method(obj->ce, Z_STR_P(function_name)); } zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); - + if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if ((IS_TMP_VAR|IS_VAR) == IS_CONST && @@ -8072,8 +8116,10 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -8086,9 +8132,11 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - - if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -8096,12 +8144,6 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ } else if (IS_CONST & (IS_VAR|IS_TMP_VAR|IS_CV)) { if (IS_CONST == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -8430,7 +8472,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CON { USE_OPLINE zval *container; - int result; + bool result; zend_ulong hval; zval *offset; @@ -9065,6 +9107,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_SPEC_CONS uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -9092,6 +9135,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_CONST_UNUSED_ zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -9105,7 +9149,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_CONST_UNUSED_ } } else if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) { send_val_by_ref: - ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)); + ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(arg_num, arg ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC)); } value = RT_CONSTANT(opline, opline->op1); ZVAL_COPY_VALUE(arg, value); @@ -9128,6 +9172,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_C zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -9141,7 +9186,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_C } } else if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) { send_val_by_ref: - ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)); + ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(arg_num, arg ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC)); } value = RT_CONSTANT(opline, opline->op1); ZVAL_COPY_VALUE(arg, value); @@ -9381,6 +9426,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_CONST_U { USE_OPLINE zval *value; + /* Should be bool result? as below got: result = (opline->extended_value & ZEND_ISEMPTY) */ int result; zval *varname; zend_string *name, *tmp_name; @@ -10382,12 +10428,26 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ } while (0); } - if (IS_CONST != IS_UNUSED) { + if (IS_CONST == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if (IS_CONST == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if (IS_CONST != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if ((IS_CONST & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + if (IS_CONST & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -10411,7 +10471,6 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if (IS_CV == IS_CONST && @@ -10431,7 +10490,9 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ zend_undefined_method(obj->ce, Z_STR_P(function_name)); } - + if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if (IS_CV == IS_CONST && @@ -10440,8 +10501,10 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -10454,9 +10517,11 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - - if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -10464,12 +10529,6 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ } else if (IS_CONST & (IS_VAR|IS_TMP_VAR|IS_CV)) { if (IS_CONST == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -10797,7 +10856,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CON { USE_OPLINE zval *container; - int result; + bool result; zend_ulong hval; zval *offset; @@ -11894,7 +11953,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_LONG_SPEC_TMPVARCV_CO { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -11906,7 +11965,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_LONG_SPEC { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -11918,7 +11977,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_LONG_SPEC { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -11930,7 +11989,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_DOUBLE_SPEC_TMPVARCV_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -11942,7 +12001,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_DOUBLE_SP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -11954,7 +12013,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_DOUBLE_SP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -11966,7 +12025,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_LONG_SPEC_TMPVARC { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -11978,7 +12037,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_LONG_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -11990,7 +12049,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_LONG_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12002,7 +12061,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_DOUBLE_SPEC_TMPVA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12014,7 +12073,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_DOUBL { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12026,7 +12085,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_DOUBL { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12038,7 +12097,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_LONG_SPEC_TMPVARCV_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12050,7 +12109,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_LONG_SP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12062,7 +12121,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_LONG_SP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12074,7 +12133,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_DOUBLE_SPEC_TMPVARC { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12086,7 +12145,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_DOUBLE_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12098,7 +12157,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_DOUBLE_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12110,7 +12169,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_LONG_SPEC_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12122,7 +12181,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12134,7 +12193,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12146,7 +12205,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_DOUBLE_SPE { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12158,7 +12217,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12170,7 +12229,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = RT_CONSTANT(opline, opline->op2); @@ -12800,7 +12859,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_LONG_SPEC_TMPVARCV_TM { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12812,7 +12871,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_LONG_SPEC { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12824,7 +12883,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_LONG_SPEC { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12836,7 +12895,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_DOUBLE_SPEC_TMPVARCV_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12848,7 +12907,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_DOUBLE_SP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12860,7 +12919,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_DOUBLE_SP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12872,7 +12931,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_LONG_SPEC_TMPVARC { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12884,7 +12943,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_LONG_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12896,7 +12955,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_LONG_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12908,7 +12967,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_DOUBLE_SPEC_TMPVA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12920,7 +12979,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_DOUBL { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12932,7 +12991,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_DOUBL { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12944,7 +13003,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_LONG_SPEC_TMPVARCV_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12956,7 +13015,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_LONG_SP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12968,7 +13027,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_LONG_SP { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12980,7 +13039,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_DOUBLE_SPEC_TMPVARC { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -12992,7 +13051,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_DOUBLE_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13004,7 +13063,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_DOUBLE_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13016,7 +13075,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_LONG_SPEC_ { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13028,7 +13087,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13040,7 +13099,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13052,7 +13111,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUAL_DOUBLE_SPE { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13064,7 +13123,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13076,7 +13135,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_SMALLER_OR_EQUA { USE_OPLINE zval *op1, *op2; - int result; + bool result; op1 = EX_VAR(opline->op1.var); op2 = EX_VAR(opline->op2.var); @@ -13281,7 +13340,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMPZ_EX_SPEC_TMPVAR_HANDLER(ZE { USE_OPLINE zval *val; - int ret; + bool ret; val = _get_zval_ptr_var(opline->op1.var EXECUTE_DATA_CC); @@ -13317,7 +13376,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMPNZ_EX_SPEC_TMPVAR_HANDLER(Z { USE_OPLINE zval *val; - int ret; + bool ret; val = _get_zval_ptr_var(opline->op1.var EXECUTE_DATA_CC); @@ -13654,6 +13713,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_YIELD_FROM_SPEC_TMPVAR_HANDLER goto yield_from_try_again; } else { zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables"); + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); UNDEF_RESULT(); HANDLE_EXCEPTION(); } @@ -13966,7 +14026,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_TMPVAR_CONST_HAN } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -14024,7 +14084,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_TMPVAR_CONST_JMP } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -14082,7 +14142,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_TMPVAR_CONST_JMP } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -14140,7 +14200,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_TMPVAR_CONST } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -14198,7 +14258,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_TMPVAR_CONST } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -14256,7 +14316,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_TMPVAR_CONST } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -14742,12 +14802,26 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C } while (0); } - if ((IS_TMP_VAR|IS_VAR) != IS_UNUSED) { + if ((IS_TMP_VAR|IS_VAR) == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if ((IS_TMP_VAR|IS_VAR) == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if ((IS_TMP_VAR|IS_VAR) != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + if ((IS_TMP_VAR|IS_VAR) & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -14771,7 +14845,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if (IS_CONST == IS_CONST && @@ -14791,7 +14864,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C zend_undefined_method(obj->ce, Z_STR_P(function_name)); } - zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); + if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if (IS_CONST == IS_CONST && @@ -14800,8 +14875,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -14814,10 +14891,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); - - if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -14825,12 +14903,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C } else if ((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR|IS_CV)) { if ((IS_TMP_VAR|IS_VAR) == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -14855,6 +14927,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_SPEC_TMPV uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -14910,7 +14983,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CASE_SPEC_TMPVAR_CONST_HANDLER } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (result) { goto case_true; @@ -14926,7 +14999,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_TMP { USE_OPLINE zval *container; - int result; + bool result; zend_ulong hval; zval *offset; @@ -15373,7 +15446,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_TMPVAR_TMPVAR_HA } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -15431,7 +15504,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_TMPVAR_TMPVAR_JM } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -15489,7 +15562,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_TMPVAR_TMPVAR_JM } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -15547,7 +15620,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_TMPVAR_TMPVA } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -15605,7 +15678,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_TMPVAR_TMPVA } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -15663,7 +15736,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_TMPVAR_TMPVA } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if ((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -16149,12 +16222,26 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_T } while (0); } - if ((IS_TMP_VAR|IS_VAR) != IS_UNUSED) { + if ((IS_TMP_VAR|IS_VAR) == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if ((IS_TMP_VAR|IS_VAR) == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if ((IS_TMP_VAR|IS_VAR) != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + if ((IS_TMP_VAR|IS_VAR) & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -16178,7 +16265,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_T } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if ((IS_TMP_VAR|IS_VAR) == IS_CONST && @@ -16198,7 +16284,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_T zend_undefined_method(obj->ce, Z_STR_P(function_name)); } zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); - zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); + if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if ((IS_TMP_VAR|IS_VAR) == IS_CONST && @@ -16207,8 +16295,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_T CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -16221,10 +16311,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_T call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); - - if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -16232,12 +16323,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_T } else if ((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR|IS_CV)) { if ((IS_TMP_VAR|IS_VAR) == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -16290,7 +16375,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CASE_SPEC_TMPVAR_TMPVAR_HANDLE } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); if (result) { goto case_true; @@ -16306,7 +16391,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_TMP { USE_OPLINE zval *container; - int result; + bool result; zend_ulong hval; zval *offset; @@ -16645,6 +16730,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_SPEC_TMPV uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -16703,6 +16789,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_TMPVAR_ { USE_OPLINE zval *value; + /* Should be bool result? as below got: result = (opline->extended_value & ZEND_ISEMPTY) */ int result; zval *varname; zend_string *name, *tmp_name; @@ -17449,12 +17536,26 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C } while (0); } - if ((IS_TMP_VAR|IS_VAR) != IS_UNUSED) { + if ((IS_TMP_VAR|IS_VAR) == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if ((IS_TMP_VAR|IS_VAR) == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if ((IS_TMP_VAR|IS_VAR) != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + if ((IS_TMP_VAR|IS_VAR) & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -17478,7 +17579,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if (IS_CV == IS_CONST && @@ -17498,7 +17598,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C zend_undefined_method(obj->ce, Z_STR_P(function_name)); } - zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); + if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if (IS_CV == IS_CONST && @@ -17507,8 +17609,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -17521,10 +17625,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); - - if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -17532,12 +17637,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C } else if ((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR|IS_CV)) { if ((IS_TMP_VAR|IS_VAR) == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -17590,7 +17689,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CASE_SPEC_TMPVAR_CV_HANDLER(ZE } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (result) { goto case_true; @@ -17606,7 +17705,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_TMP { USE_OPLINE zval *container; - int result; + bool result; zend_ulong hval; zval *offset; @@ -18215,7 +18314,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMP_SET_SPEC_TMP_HANDLER(ZEND_ USE_OPLINE zval *value; zval *ref = NULL; - int ret; + bool ret; SAVE_OPLINE(); value = _get_zval_ptr_tmp(opline->op1.var EXECUTE_DATA_CC); @@ -18518,6 +18617,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_TMP_CONST_HAN zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -18531,7 +18631,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_TMP_CONST_HAN } } else if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) { send_val_by_ref: - ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)); + ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(arg_num, arg ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC)); } value = _get_zval_ptr_tmp(opline->op1.var EXECUTE_DATA_CC); ZVAL_COPY_VALUE(arg, value); @@ -19341,6 +19441,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_TMP_UNUSED_HA zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -19354,7 +19455,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_TMP_UNUSED_HA } } else if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) { send_val_by_ref: - ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)); + ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(arg_num, arg ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC)); } value = _get_zval_ptr_tmp(opline->op1.var EXECUTE_DATA_CC); ZVAL_COPY_VALUE(arg, value); @@ -19377,6 +19478,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_T zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -19390,7 +19492,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAL_EX_SPEC_T } } else if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) { send_val_by_ref: - ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)); + ZEND_VM_TAIL_CALL(zend_cannot_pass_by_ref_helper_SPEC(arg_num, arg ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC)); } value = _get_zval_ptr_tmp(opline->op1.var EXECUTE_DATA_CC); ZVAL_COPY_VALUE(arg, value); @@ -21085,7 +21187,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMP_SET_SPEC_VAR_HANDLER(ZEND_ USE_OPLINE zval *value; zval *ref = NULL; - int ret; + bool ret; SAVE_OPLINE(); value = _get_zval_ptr_var(opline->op1.var EXECUTE_DATA_CC); @@ -23056,6 +23158,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_SPEC_VAR_ uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -23102,6 +23205,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_SPEC_VAR_CONST uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -23132,6 +23236,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_EX_SPEC_VAR_CO zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -23199,6 +23304,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_REF_SPEC_VAR_CONST_HANDLE uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -23228,6 +23334,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_VAR_CONST_HAN zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -23257,7 +23364,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_VAR_CONST_HAN if (IS_VAR == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(varptr) == IS_UNDEF)) { SAVE_OPLINE(); ZVAL_UNDEFINED_OP1(); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); ZVAL_NULL(arg); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -23295,6 +23401,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_FUNC_ARG_SPEC uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -26928,6 +27035,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_SPEC_VAR_ uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -26974,6 +27082,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_SPEC_VAR_UNUSE uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -27004,6 +27113,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_EX_SPEC_VAR_UN zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -27071,6 +27181,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_NO_REF_EX zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -27138,6 +27249,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_REF_SPEC_VAR_UNUSED_HANDL uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -27167,6 +27279,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_VAR_UNUSED_HA zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -27196,7 +27309,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_VAR_UNUSED_HA if (IS_VAR == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(varptr) == IS_UNDEF)) { SAVE_OPLINE(); ZVAL_UNDEFINED_OP1(); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); ZVAL_NULL(arg); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -27233,6 +27345,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_V zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -27262,7 +27375,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_V if (IS_VAR == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(varptr) == IS_UNDEF)) { SAVE_OPLINE(); ZVAL_UNDEFINED_OP1(); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); ZVAL_NULL(arg); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -27300,6 +27412,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_FUNC_ARG_SPEC uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + zval_ptr_dtor_nogc(EX_VAR(opline->op1.var)); HANDLE_EXCEPTION(); } } else { @@ -31474,12 +31587,26 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S } while (0); } - if (IS_UNUSED != IS_UNUSED) { + if (IS_UNUSED == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if (IS_UNUSED == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if (IS_UNUSED != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if ((IS_UNUSED & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + if (IS_UNUSED & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -31503,7 +31630,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if (IS_CONST == IS_CONST && @@ -31523,7 +31649,9 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S zend_undefined_method(obj->ce, Z_STR_P(function_name)); } - + if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if (IS_CONST == IS_CONST && @@ -31532,8 +31660,10 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -31546,9 +31676,11 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - - if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -31556,12 +31688,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S } else if (IS_UNUSED & (IS_VAR|IS_TMP_VAR|IS_CV)) { if (IS_UNUSED == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -33370,12 +33496,26 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_T } while (0); } - if (IS_UNUSED != IS_UNUSED) { + if (IS_UNUSED == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if (IS_UNUSED == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if (IS_UNUSED != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if ((IS_UNUSED & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + if (IS_UNUSED & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -33399,7 +33539,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_T } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if ((IS_TMP_VAR|IS_VAR) == IS_CONST && @@ -33419,7 +33558,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_T zend_undefined_method(obj->ce, Z_STR_P(function_name)); } zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); - + if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if ((IS_TMP_VAR|IS_VAR) == IS_CONST && @@ -33428,8 +33569,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_T CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -33442,9 +33585,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_T call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - - if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -33452,12 +33597,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_T } else if (IS_UNUSED & (IS_VAR|IS_TMP_VAR|IS_CV)) { if (IS_UNUSED == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -35844,12 +35983,26 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_C } while (0); } - if (IS_UNUSED != IS_UNUSED) { + if (IS_UNUSED == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if (IS_UNUSED == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if (IS_UNUSED != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if ((IS_UNUSED & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + if (IS_UNUSED & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -35873,7 +36026,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_C } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if (IS_CV == IS_CONST && @@ -35893,7 +36045,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_C zend_undefined_method(obj->ce, Z_STR_P(function_name)); } - + if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if (IS_CV == IS_CONST && @@ -35902,8 +36056,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_C CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -35916,9 +36072,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_C call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - - if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -35926,12 +36084,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_C } else if (IS_UNUSED & (IS_VAR|IS_TMP_VAR|IS_CV)) { if (IS_UNUSED == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -36707,7 +36859,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMPZ_EX_SPEC_CV_HANDLER(ZEND_O { USE_OPLINE zval *val; - int ret; + bool ret; val = EX_VAR(opline->op1.var); @@ -36743,7 +36895,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMPNZ_EX_SPEC_CV_HANDLER(ZEND_ { USE_OPLINE zval *val; - int ret; + bool ret; val = EX_VAR(opline->op1.var); @@ -37402,7 +37554,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_JMP_SET_SPEC_CV_HANDLER(ZEND_O USE_OPLINE zval *value; zval *ref = NULL; - int ret; + bool ret; SAVE_OPLINE(); value = _get_zval_ptr_cv_BP_VAR_R(opline->op1.var EXECUTE_DATA_CC); @@ -37600,6 +37752,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_YIELD_FROM_SPEC_CV_HANDLER(ZEN goto yield_from_try_again; } else { zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables"); + UNDEF_RESULT(); HANDLE_EXCEPTION(); } @@ -38107,7 +38260,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_CONST_HANDLER } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -38165,7 +38318,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_CONST_JMPZ_HA } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -38223,7 +38376,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_CONST_JMPNZ_H } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -38281,7 +38434,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_CONST_HAN } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -38339,7 +38492,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_CONST_JMP } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -38397,7 +38550,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_CONST_JMP } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -40510,12 +40663,26 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S } while (0); } - if (IS_CV != IS_UNUSED) { + if (IS_CV == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if (IS_CV == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if (IS_CV != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if ((IS_CV & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + if (IS_CV & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -40539,7 +40706,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if (IS_CONST == IS_CONST && @@ -40559,7 +40725,9 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S zend_undefined_method(obj->ce, Z_STR_P(function_name)); } - + if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if (IS_CONST == IS_CONST && @@ -40568,8 +40736,10 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -40582,9 +40752,11 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - - if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -40592,12 +40764,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S } else if (IS_CV & (IS_VAR|IS_TMP_VAR|IS_CV)) { if (IS_CV == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -40622,6 +40788,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_SPEC_CV_C uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -40668,6 +40835,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_REF_SPEC_CV_CONST_HANDLER uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -40696,6 +40864,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_CV_CONST_HAND zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -40724,7 +40893,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_CV_CONST_HAND if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(varptr) == IS_UNDEF)) { SAVE_OPLINE(); ZVAL_UNDEFINED_OP1(); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); ZVAL_NULL(arg); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -41004,7 +41172,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_ { USE_OPLINE zval *container; - int result; + bool result; zend_ulong hval; zval *offset; @@ -41720,7 +41888,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_TMPVAR_HANDLE } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -41778,7 +41946,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_TMPVAR_JMPZ_H } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -41836,7 +42004,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_TMPVAR_JMPNZ_ } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -41894,7 +42062,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_TMPVAR_HA } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -41952,7 +42120,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_TMPVAR_JM } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -42010,7 +42178,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_TMPVAR_JM } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -44082,12 +44250,26 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMPVA } while (0); } - if (IS_CV != IS_UNUSED) { + if (IS_CV == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if (IS_CV == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if (IS_CV != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if ((IS_CV & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + if (IS_CV & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -44111,7 +44293,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMPVA } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if ((IS_TMP_VAR|IS_VAR) == IS_CONST && @@ -44131,7 +44312,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMPVA zend_undefined_method(obj->ce, Z_STR_P(function_name)); } zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); - + if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if ((IS_TMP_VAR|IS_VAR) == IS_CONST && @@ -44140,8 +44323,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMPVA CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -44154,9 +44339,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMPVA call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - - if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -44164,12 +44351,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMPVA } else if (IS_CV & (IS_VAR|IS_TMP_VAR|IS_CV)) { if (IS_CV == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -44439,7 +44620,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_ { USE_OPLINE zval *container; - int result; + bool result; zend_ulong hval; zval *offset; @@ -45726,6 +45907,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_SPEC_CV_U uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -45772,6 +45954,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_REF_SPEC_CV_UNUSED_HANDLE uint32_t arg_num; arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -45800,6 +45983,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_CV_UNUSED_HAN zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -45828,7 +46012,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_CV_UNUSED_HAN if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(varptr) == IS_UNDEF)) { SAVE_OPLINE(); ZVAL_UNDEFINED_OP1(); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); ZVAL_NULL(arg); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -45865,6 +46048,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_C zend_string *arg_name = Z_STR_P(RT_CONSTANT(opline, opline->op2)); arg = zend_handle_named_arg(&EX(call), arg_name, &arg_num, CACHE_ADDR(opline->result.num)); if (UNEXPECTED(!arg)) { + HANDLE_EXCEPTION(); } } else { @@ -45893,7 +46077,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_EX_SPEC_C if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(varptr) == IS_UNDEF)) { SAVE_OPLINE(); ZVAL_UNDEFINED_OP1(); - arg = ZEND_CALL_VAR(EX(call), opline->result.var); ZVAL_NULL(arg); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -46110,7 +46293,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_CV_S ZEND_VM_SMART_BRANCH_FALSE(); } } else { - int result; + bool result; SAVE_OPLINE(); result = !i_zend_is_true(value); @@ -46132,7 +46315,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_CV_S ZEND_VM_SMART_BRANCH_FALSE(); } } else { - int result; + bool result; SAVE_OPLINE(); result = !i_zend_is_true(value); @@ -46144,6 +46327,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_VAR_SPEC_CV_UNUS { USE_OPLINE zval *value; + /* Should be bool result? as below got: result = (opline->extended_value & ZEND_ISEMPTY) */ int result; zval *varname; zend_string *name, *tmp_name; @@ -46759,7 +46943,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_CV_HANDLER(ZE } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -46817,7 +47001,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_CV_JMPZ_HANDL } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -46875,7 +47059,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_EQUAL_SPEC_CV_CV_JMPNZ_HAND } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -46933,7 +47117,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_CV_HANDLE } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -46991,7 +47175,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_CV_JMPZ_H } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -47049,7 +47233,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_IS_NOT_EQUAL_SPEC_CV_CV_JMPNZ_ } } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) { if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { - int result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); + bool result = zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); if (IS_CV & (IS_TMP_VAR|IS_VAR)) { zval_ptr_dtor_str(op1); } @@ -49191,12 +49375,26 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HA } while (0); } - if (IS_CV != IS_UNUSED) { + if (IS_CV == IS_UNUSED) { + obj = Z_OBJ_P(object); + } else { do { - if (IS_CV == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) { + if (IS_CV != IS_CONST && EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + } else { if ((IS_CV & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) { - object = Z_REFVAL_P(object); + zend_reference *ref = Z_REF_P(object); + + object = &ref->val; if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) { + obj = Z_OBJ_P(object); + if (IS_CV & IS_VAR) { + if (UNEXPECTED(GC_DELREF(ref) == 0)) { + efree_size(ref, sizeof(zend_reference)); + } else { + Z_ADDREF_P(object); + } + } break; } } @@ -49220,7 +49418,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HA } while (0); } - obj = Z_OBJ_P(object); called_scope = obj->ce; if (IS_CV == IS_CONST && @@ -49240,7 +49437,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HA zend_undefined_method(obj->ce, Z_STR_P(function_name)); } - + if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } HANDLE_EXCEPTION(); } if (IS_CV == IS_CONST && @@ -49249,8 +49448,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HA CACHE_POLYMORPHIC_PTR(opline->result.num, called_scope, fbc); } if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(obj != orig_obj)) { - /* Reset "object" to trigger reference counting */ - object = NULL; + GC_ADDREF(obj); /* For $this pointer */ + if (GC_DELREF(orig_obj) == 0) { + zend_objects_store_del(orig_obj); + } } if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) { init_func_run_time_cache(&fbc->op_array); @@ -49263,9 +49464,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HA call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS; if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) { - - if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && UNEXPECTED(EG(exception))) { - HANDLE_EXCEPTION(); + if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(obj) == 0) { + zend_objects_store_del(obj); + if (UNEXPECTED(EG(exception))) { + HANDLE_EXCEPTION(); + } } /* call static method */ obj = (zend_object*)called_scope; @@ -49273,12 +49476,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HA } else if (IS_CV & (IS_VAR|IS_TMP_VAR|IS_CV)) { if (IS_CV == IS_CV) { GC_ADDREF(obj); /* For $this pointer */ - } else { - zval *free_op1 = EX_VAR(opline->op1.var); - if (free_op1 != object) { - GC_ADDREF(obj); /* For $this pointer */ - zval_ptr_dtor_nogc(free_op1); - } } /* CV may be changed indirectly (e.g. when it's a reference) */ call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_HAS_THIS | ZEND_CALL_RELEASE_THIS; @@ -49546,7 +49743,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_ { USE_OPLINE zval *container; - int result; + bool result; zend_ulong hval; zval *offset; @@ -61429,7 +61626,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++) { diff --git a/Zend/zend_vm_execute.skl b/Zend/zend_vm_execute.skl index 170fc300bbb8b..fcd52aba9c8da 100644 --- a/Zend/zend_vm_execute.skl +++ b/Zend/zend_vm_execute.skl @@ -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++) { diff --git a/Zend/zend_weakrefs.c b/Zend/zend_weakrefs.c index 8a444c214e9e1..a4bf195a07060 100644 --- a/Zend/zend_weakrefs.c +++ b/Zend/zend_weakrefs.c @@ -340,6 +340,7 @@ static void zend_weakmap_write_dimension(zend_object *object, zval *offset, zval zend_hash_index_add_new(&wm->ht, (zend_ulong) obj_key, value); } +/* int return and check_empty due to Object Handler API */ static int zend_weakmap_has_dimension(zend_object *object, zval *offset, int check_empty) { if (Z_TYPE_P(offset) != IS_OBJECT) { @@ -503,6 +504,7 @@ static const zend_object_iterator_funcs zend_weakmap_iterator_funcs = { NULL, /* get_gc */ }; +/* by_ref is int due to Iterator API */ static zend_object_iterator *zend_weakmap_get_iterator( zend_class_entry *ce, zval *object, int by_ref) { diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 57def3dc2dc67..20198f888be42 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,11 +12,10 @@ trigger: - UPGRADING.INTERNALS jobs: - # We specify --with-mm here, because it cannot be used together with --enable-maintainer-zts. - template: azure/job.yml parameters: configurationName: DEBUG_NTS - configurationParameters: '--enable-debug --disable-zts --with-mm' + configurationParameters: '--enable-debug --disable-zts' - template: azure/job.yml parameters: configurationName: RELEASE_ZTS @@ -37,7 +36,7 @@ jobs: - template: azure/job.yml parameters: configurationName: RELEASE_NTS - configurationParameters: '--disable-debug --disable-zts --with-mm' + configurationParameters: '--disable-debug --disable-zts' - template: azure/i386/job.yml parameters: configurationName: I386_DEBUG_NTS diff --git a/build/gen_stub.php b/build/gen_stub.php index 0584ecc710d25..214d1f563e737 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -80,10 +80,6 @@ public function __construct(string $name, bool $isBuiltin) { public static function fromNode(Node $node) { if ($node instanceof Node\Name) { - if ($node->toString() === "mixed") { - return new SimpleType($node->toString(), true); - } - assert($node->isFullyQualified()); return new SimpleType($node->toString(), false); } @@ -650,6 +646,7 @@ function parseFunctionLike( } } + $varNameSet = []; $args = []; $numRequiredArgs = 0; $foundVariadic = false; @@ -658,6 +655,11 @@ function parseFunctionLike( $preferRef = !empty($paramMeta[$varName]['preferRef']); unset($paramMeta[$varName]); + if (isset($varNameSet[$varName])) { + throw new Exception("Duplicate parameter name $varName for function $name"); + } + $varNameSet[$varName] = true; + if ($preferRef) { $sendBy = ArgInfo::SEND_PREFER_REF; } else if ($param->byRef) { @@ -680,7 +682,7 @@ function parseFunctionLike( $type && !$type->isNullable() ) { $simpleType = $type->tryToSimpleType(); - if ($simpleType === null || $simpleType->name !== "mixed") { + if ($simpleType === null) { throw new Exception( "Parameter $varName of function $name has null default, but is not nullable"); } @@ -1105,7 +1107,7 @@ function initPhpParser() { } $isInitialized = true; - $version = "4.3.0"; + $version = "4.9.0"; $phpParserDir = __DIR__ . "/PHP-Parser-$version"; if (!is_dir($phpParserDir)) { installPhpParser($version, $phpParserDir); diff --git a/configure.ac b/configure.ac index 45614f858102d..116bb6031f405 100644 --- a/configure.ac +++ b/configure.ac @@ -342,13 +342,13 @@ dnl Some systems (OpenServer 5) dislike -lsocket -lnsl, so we try to avoid -lnsl dnl checks, if we already have the functions which are usually in libnsl. Also, dnl uClibc will bark at linking with glibc's libnsl. -PHP_CHECK_FUNC(socket, socket) -PHP_CHECK_FUNC(socketpair, socket) -PHP_CHECK_FUNC(htonl, socket) -PHP_CHECK_FUNC(gethostname, nsl) -PHP_CHECK_FUNC(gethostbyaddr, nsl) -PHP_CHECK_FUNC(dlopen, dl) -PHP_CHECK_FUNC(dlsym, dl) +PHP_CHECK_FUNC(socket, socket, network) +PHP_CHECK_FUNC(socketpair, socket, network) +PHP_CHECK_FUNC(htonl, socket, network) +PHP_CHECK_FUNC(gethostname, nsl, network) +PHP_CHECK_FUNC(gethostbyaddr, nsl, network) +PHP_CHECK_FUNC(dlopen, dl, root) +PHP_CHECK_FUNC(dlsym, dl, root) if test "$ac_cv_func_dlopen" = "yes"; then AC_DEFINE(HAVE_LIBDL, 1, [ ]) fi diff --git a/ext/calendar/cal_unix.c b/ext/calendar/cal_unix.c index 6b5fbf7f79828..55d67823ff97a 100644 --- a/ext/calendar/cal_unix.c +++ b/ext/calendar/cal_unix.c @@ -25,16 +25,19 @@ PHP_FUNCTION(unixtojd) { time_t ts; - zend_bool ts_is_null = 1; + zend_long tl = 0; + zend_bool tl_is_null = 1; struct tm *ta, tmbuf; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &ts, &ts_is_null) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &tl, &tl_is_null) == FAILURE) { RETURN_THROWS(); } - if (ts_is_null) { + if (tl_is_null) { ts = time(NULL); - } else if (ts < 0) { + } else if (tl >= 0) { + ts = (time_t) tl; + } else { zend_argument_value_error(1, "must be greater than or equal to 0"); RETURN_THROWS(); } diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c index 156636db384c7..7a98481927698 100644 --- a/ext/com_dotnet/com_com.c +++ b/ext/com_dotnet/com_com.c @@ -56,7 +56,7 @@ PHP_METHOD(com, __construct) &module_name, &module_name_len, &server_name, &server_name_len, &cp, &typelib_name, &typelib_name_len) && FAILURE == zend_parse_parameters( - ZEND_NUM_ARGS(), "sa|ls", + ZEND_NUM_ARGS(), "sa/|ls", &module_name, &module_name_len, &server_params, &cp, &typelib_name, &typelib_name_len)) { RETURN_THROWS(); @@ -217,7 +217,6 @@ PHP_METHOD(com, __construct) if (server_name) { if (info.pwszName) efree(info.pwszName); - if (authid.User) efree(authid.User); } efree(moniker); @@ -437,8 +436,9 @@ HRESULT php_com_get_id_of_name(php_com_dotnet_object *obj, char *name, if (obj->typeinfo) { hr = ITypeInfo_GetIDsOfNames(obj->typeinfo, &olename, 1, dispid); if (FAILED(hr)) { + HRESULT hr1 = hr; hr = IDispatch_GetIDsOfNames(V_DISPATCH(&obj->v), &IID_NULL, &olename, 1, LOCALE_SYSTEM_DEFAULT, dispid); - if (SUCCEEDED(hr)) { + if (SUCCEEDED(hr) && hr1 != E_NOTIMPL) { /* fall back on IDispatch direct */ ITypeInfo_Release(obj->typeinfo); obj->typeinfo = NULL; @@ -585,6 +585,7 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function * } } efree(vargs); + if (byref_vals) efree(byref_vals); } return SUCCEEDED(hr) ? SUCCESS : FAILURE; diff --git a/ext/com_dotnet/com_dotnet.c b/ext/com_dotnet/com_dotnet.c index 6bd492ef1d9b9..1b0ba2220c3a0 100644 --- a/ext/com_dotnet/com_dotnet.c +++ b/ext/com_dotnet/com_dotnet.c @@ -117,6 +117,44 @@ struct dotnet_runtime_stuff { DISPID create_instance; }; +/* We link dynamically to mscoree.dll to avoid the hard dependency on .NET + * framework, which is only required if a dotnet instance is to be created. + */ +static HRESULT dotnet_bind_runtime(LPVOID FAR *ppv) +{ + HRESULT hr; + HMODULE mscoree; + typedef HRESULT (STDAPICALLTYPE *cbtr_t)(LPCWSTR pwszVersion, LPCWSTR pwszBuildFlavor, REFCLSID rclsid, REFIID riid, LPVOID FAR *ppv); + cbtr_t CorBindToRuntime; + OLECHAR *oleversion; + char *version; + + mscoree = LoadLibraryA("mscoree.dll"); + if (mscoree == NULL) { + return S_FALSE; + } + + CorBindToRuntime = (cbtr_t) GetProcAddress(mscoree, "CorBindToRuntime"); + if (CorBindToRuntime == NULL) { + FreeLibrary(mscoree); + return S_FALSE; + } + + version = INI_STR("com.dotnet_version"); + if (version == NULL || *version == '\0') { + oleversion = NULL; + } else { + oleversion = php_com_string_to_olestring(version, strlen(version), COMG(code_page)); + } + + hr = CorBindToRuntime(oleversion, NULL, &CLSID_CorRuntimeHost, &IID_ICorRuntimeHost, ppv); + + efree(oleversion); + FreeLibrary(mscoree); + + return hr; +} + static HRESULT dotnet_init(char **p_where) { HRESULT hr; @@ -130,10 +168,8 @@ static HRESULT dotnet_init(char **p_where) } memset(stuff, 0, sizeof(*stuff)); - where = "CoCreateInstance"; - hr = CoCreateInstance(&CLSID_CorRuntimeHost, NULL, CLSCTX_ALL, - &IID_ICorRuntimeHost, (LPVOID*)&stuff->dotnet_host); - + where = "dotnet_bind_runtime"; + hr = dotnet_bind_runtime((LPVOID*)&stuff->dotnet_host); if (FAILED(hr)) goto out; diff --git a/ext/com_dotnet/com_extension.c b/ext/com_dotnet/com_extension.c index 0535509412e0c..5e2c1f69de7fb 100644 --- a/ext/com_dotnet/com_extension.c +++ b/ext/com_dotnet/com_extension.c @@ -141,6 +141,7 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY("com.autoregister_casesensitive", "1", PHP_INI_ALL, OnAutoregisterCasesensitive, autoreg_case_sensitive, zend_com_dotnet_globals, com_dotnet_globals) STD_PHP_INI_ENTRY("com.code_page", "", PHP_INI_ALL, OnUpdateLong, code_page, zend_com_dotnet_globals, com_dotnet_globals) PHP_INI_ENTRY("com.typelib_file", "", PHP_INI_SYSTEM, OnTypeLibFileUpdate) + PHP_INI_ENTRY("com.dotnet_version", NULL, PHP_INI_SYSTEM, NULL) PHP_INI_END() /* }}} */ diff --git a/ext/com_dotnet/com_saproxy.c b/ext/com_dotnet/com_saproxy.c index d86fb75e3ede4..dbb00b1596b9d 100644 --- a/ext/com_dotnet/com_saproxy.c +++ b/ext/com_dotnet/com_saproxy.c @@ -112,6 +112,8 @@ static zval *saproxy_read_dimension(zend_object *object, zval *offset, int type, Z_STRLEN(proxy->indices[0]), DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, proxy->dimensions, args, 0); + efree(args); + if (res == SUCCESS) { php_com_zval_from_variant(rv, &v, proxy->obj->code_page); VariantClear(&v); @@ -372,7 +374,7 @@ static zend_object* saproxy_clone(zend_object *object) memcpy(cloneproxy, proxy, sizeof(*cloneproxy)); GC_ADDREF(&cloneproxy->obj->zo); - cloneproxy->indices = safe_emalloc(cloneproxy->dimensions, sizeof(zval *), 0); + cloneproxy->indices = safe_emalloc(cloneproxy->dimensions, sizeof(zval), 0); clone_indices(cloneproxy, proxy, proxy->dimensions); return &cloneproxy->std; @@ -422,7 +424,7 @@ int php_com_saproxy_create(zend_object *com_object, zval *proxy_out, zval *index } GC_ADDREF(&proxy->obj->zo); - proxy->indices = safe_emalloc(proxy->dimensions, sizeof(zval *), 0); + proxy->indices = safe_emalloc(proxy->dimensions, sizeof(zval), 0); if (rel) { clone_indices(proxy, rel, rel->dimensions); diff --git a/ext/com_dotnet/tests/bug64130.phpt b/ext/com_dotnet/tests/bug64130.phpt new file mode 100644 index 0000000000000..0f8e083295cc0 --- /dev/null +++ b/ext/com_dotnet/tests/bug64130.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #64130 (COM obj parameters passed by reference are not updated) +--SKIPIF-- +getMessage()}"); +} +$ie->quit(); +?> +--FILE-- +clientToWindow($x, $y); +} catch (com_exception $ex) {} +var_dump($x > 0, $y > 0); +$ie->quit(); +?> +--EXPECT-- +bool(true) +bool(true) diff --git a/ext/dom/parentnode.c b/ext/dom/parentnode.c index a7627cb84c1cb..f47416edff3dd 100644 --- a/ext/dom/parentnode.c +++ b/ext/dom/parentnode.c @@ -134,6 +134,11 @@ xmlNode* dom_zvals_to_fragment(php_libxml_ref_obj *document, xmlNode *contextNod dom_object *newNodeObj; int stricterror; + if (document == NULL) { + php_dom_throw_error(HIERARCHY_REQUEST_ERR, 1); + return NULL; + } + if (contextNode->type == XML_DOCUMENT_NODE || contextNode->type == XML_HTML_DOCUMENT_NODE) { documentNode = (xmlDoc *) contextNode; } else { diff --git a/ext/dom/tests/bug79968.phpt b/ext/dom/tests/bug79968.phpt new file mode 100644 index 0000000000000..45107351a4eb0 --- /dev/null +++ b/ext/dom/tests/bug79968.phpt @@ -0,0 +1,17 @@ +--TEST-- +dom: Bug #79968 - Crash when calling before without valid hierachy +--SKIPIF-- + +--FILE-- +before("string"); +} catch (DOMException $e) { + echo $e->getMessage(); +} +?> +--EXPECT-- +Hierarchy Request Error diff --git a/ext/enchant/enchant.c b/ext/enchant/enchant.c index 3ebb76e910f3a..566197582073c 100644 --- a/ext/enchant/enchant.c +++ b/ext/enchant/enchant.c @@ -307,8 +307,8 @@ PHP_FUNCTION(enchant_broker_free) PHP_ENCHANT_GET_BROKER; if (pbroker->nb_dict > 0) { - php_error_docref(NULL, E_WARNING, "Cannot free EnchantBroker object with open EnchantDictionary objects"); - RETURN_FALSE; + zend_throw_error(NULL, "Cannot free EnchantBroker object with open EnchantDictionary objects"); + RETURN_THROWS(); } if (pbroker->pbroker) { enchant_broker_free(pbroker->pbroker); diff --git a/ext/fileinfo/libmagic.patch b/ext/fileinfo/libmagic.patch index 5eac52463428a..5b33e42744bcb 100644 --- a/ext/fileinfo/libmagic.patch +++ b/ext/fileinfo/libmagic.patch @@ -1,6 +1,6 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c --- libmagic.orig/apprentice.c 2019-02-20 03:35:27.000000000 +0100 -+++ libmagic/apprentice.c 2020-04-07 22:25:10.486120900 +0200 ++++ libmagic/apprentice.c 2020-08-25 15:13:14.549715400 +0200 @@ -29,6 +29,8 @@ * apprentice - make one pass through /etc/magic, learning its secrets. */ @@ -635,19 +635,19 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c - if (rc) { - if (ms->flags & MAGIC_CHECK) - file_regerror(&rx, rc, ms); -+ zval pattern; ++ zend_string *pattern; + int options = 0; + pcre_cache_entry *pce; + -+ convert_libmagic_pattern(&pattern, m->value.s, strlen(m->value.s), options); ++ pattern = convert_libmagic_pattern(m->value.s, strlen(m->value.s), options); + -+ if ((pce = pcre_get_compiled_regex_cache(Z_STR(pattern))) == NULL) { -+ zval_dtor(&pattern); ++ if ((pce = pcre_get_compiled_regex_cache(pattern)) == NULL) { ++ zend_string_release(pattern); + return -1; } - file_regfree(&rx); - return rc ? -1 : 0; -+ zval_dtor(&pattern); ++ zend_string_release(pattern); + + return 0; } @@ -974,8 +974,26 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c } diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c --- libmagic.orig/ascmagic.c 2019-05-07 04:27:11.000000000 +0200 -+++ libmagic/ascmagic.c 2020-04-07 22:25:10.501740300 +0200 -@@ -96,7 +96,7 @@ ++++ libmagic/ascmagic.c 2020-08-24 14:22:57.162970900 +0200 +@@ -51,7 +51,7 @@ + #define ISSPC(x) ((x) == ' ' || (x) == '\t' || (x) == '\r' || (x) == '\n' \ + || (x) == 0x85 || (x) == '\f') + +-private unsigned char *encode_utf8(unsigned char *, size_t, unichar *, size_t); ++private unsigned char *encode_utf8(unsigned char *, size_t, unicodechar *, size_t); + private size_t trim_nuls(const unsigned char *, size_t); + + /* +@@ -70,7 +70,7 @@ + protected int + file_ascmagic(struct magic_set *ms, const struct buffer *b, int text) + { +- unichar *ubuf = NULL; ++ unicodechar *ubuf = NULL; + size_t ulen = 0; + int rv = 1; + struct buffer bb; +@@ -96,14 +96,14 @@ rv = file_ascmagic_with_encoding(ms, &bb, ubuf, ulen, code, type, text); @@ -984,6 +1002,14 @@ diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c return rv; } + + protected int + file_ascmagic_with_encoding(struct magic_set *ms, +- const struct buffer *b, unichar *ubuf, size_t ulen, const char *code, ++ const struct buffer *b, unicodechar *ubuf, size_t ulen, const char *code, + const char *type, int text) + { + struct buffer bb; @@ -144,7 +144,7 @@ /* malloc size is a conservative overestimate; could be improved, or at least realloced after conversion. */ @@ -1003,6 +1029,15 @@ diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c return rv; } +@@ -337,7 +338,7 @@ + * after end of string, or NULL if an invalid character is found. + */ + private unsigned char * +-encode_utf8(unsigned char *buf, size_t len, unichar *ubuf, size_t ulen) ++encode_utf8(unsigned char *buf, size_t len, unicodechar *ubuf, size_t ulen) + { + size_t i; + unsigned char *end = buf + len; diff -u libmagic.orig/buffer.c libmagic/buffer.c --- libmagic.orig/buffer.c 2019-05-07 04:27:11.000000000 +0200 +++ libmagic/buffer.c 2020-04-07 22:25:10.501740300 +0200 @@ -1395,7 +1430,7 @@ diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c (void)snprintf(buf, 26, "*Bad* %#16.16" INT64_T_FORMAT "x\n", diff -u libmagic.orig/compress.c libmagic/compress.c --- libmagic.orig/compress.c 2019-05-07 04:27:11.000000000 +0200 -+++ libmagic/compress.c 2020-06-17 02:13:31.620121400 +0200 ++++ libmagic/compress.c 2020-08-07 20:46:25.154923400 +0200 @@ -45,13 +45,11 @@ #endif #include @@ -1605,13 +1640,58 @@ diff -u libmagic.orig/elfclass.h libmagic/elfclass.h CAST(int, elf_getu16(swap, elfhdr.e_shstrndx)), diff -u libmagic.orig/encoding.c libmagic/encoding.c --- libmagic.orig/encoding.c 2019-04-15 18:48:41.000000000 +0200 -+++ libmagic/encoding.c 2020-04-07 22:25:10.517321000 +0200 ++++ libmagic/encoding.c 2020-08-24 14:22:57.172802500 +0200 +@@ -44,14 +44,14 @@ + #include + + +-private int looks_ascii(const unsigned char *, size_t, unichar *, size_t *); +-private int looks_utf8_with_BOM(const unsigned char *, size_t, unichar *, ++private int looks_ascii(const unsigned char *, size_t, unicodechar *, size_t *); ++private int looks_utf8_with_BOM(const unsigned char *, size_t, unicodechar *, + size_t *); +-private int looks_utf7(const unsigned char *, size_t, unichar *, size_t *); +-private int looks_ucs16(const unsigned char *, size_t, unichar *, size_t *); +-private int looks_ucs32(const unsigned char *, size_t, unichar *, size_t *); +-private int looks_latin1(const unsigned char *, size_t, unichar *, size_t *); +-private int looks_extended(const unsigned char *, size_t, unichar *, size_t *); ++private int looks_utf7(const unsigned char *, size_t, unicodechar *, size_t *); ++private int looks_ucs16(const unsigned char *, size_t, unicodechar *, size_t *); ++private int looks_ucs32(const unsigned char *, size_t, unicodechar *, size_t *); ++private int looks_latin1(const unsigned char *, size_t, unicodechar *, size_t *); ++private int looks_extended(const unsigned char *, size_t, unicodechar *, size_t *); + private void from_ebcdic(const unsigned char *, size_t, unsigned char *); + + #ifdef DEBUG_ENCODING +@@ -63,11 +63,11 @@ + /* + * Try to determine whether text is in some character code we can + * identify. Each of these tests, if it succeeds, will leave +- * the text converted into one-unichar-per-character Unicode in ++ * the text converted into one-unicodechar-per-character Unicode in + * ubuf, and the number of characters converted in ulen. + */ + protected int +-file_encoding(struct magic_set *ms, const struct buffer *b, unichar **ubuf, ++file_encoding(struct magic_set *ms, const struct buffer *b, unicodechar **ubuf, + size_t *ulen, const char **code, const char **code_mime, const char **type) + { + const unsigned char *buf = CAST(const unsigned char *, b->fbuf); +@@ -75,7 +75,7 @@ + size_t mlen; + int rv = 1, ucs_type; + unsigned char *nbuf = NULL; +- unichar *udefbuf; ++ unicodechar *udefbuf; + size_t udeflen; + + if (ubuf == NULL) @@ -89,13 +89,13 @@ *code_mime = "binary"; mlen = (nbytes + 1) * sizeof((*ubuf)[0]); - if ((*ubuf = CAST(unichar *, calloc(CAST(size_t, 1), mlen))) == NULL) { -+ if ((*ubuf = CAST(unichar *, ecalloc(CAST(size_t, 1), mlen))) == NULL) { ++ if ((*ubuf = CAST(unicodechar *, ecalloc(CAST(size_t, 1), mlen))) == NULL) { file_oomem(ms, mlen); goto done; } @@ -1634,9 +1714,123 @@ diff -u libmagic.orig/encoding.c libmagic/encoding.c return rv; } +@@ -251,7 +251,7 @@ + }; + + private int +-looks_ascii(const unsigned char *buf, size_t nbytes, unichar *ubuf, ++looks_ascii(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, + size_t *ulen) + { + size_t i; +@@ -271,7 +271,7 @@ + } + + private int +-looks_latin1(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) ++looks_latin1(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, size_t *ulen) + { + size_t i; + +@@ -290,7 +290,7 @@ + } + + private int +-looks_extended(const unsigned char *buf, size_t nbytes, unichar *ubuf, ++looks_extended(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, + size_t *ulen) + { + size_t i; +@@ -321,11 +321,11 @@ + * ubuf must be big enough! + */ + protected int +-file_looks_utf8(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) ++file_looks_utf8(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, size_t *ulen) + { + size_t i; + int n; +- unichar c; ++ unicodechar c; + int gotone = 0, ctrl = 0; + + if (ubuf) +@@ -392,7 +392,7 @@ + * rest of the text. + */ + private int +-looks_utf8_with_BOM(const unsigned char *buf, size_t nbytes, unichar *ubuf, ++looks_utf8_with_BOM(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, + size_t *ulen) + { + if (nbytes > 3 && buf[0] == 0xef && buf[1] == 0xbb && buf[2] == 0xbf) +@@ -402,7 +402,7 @@ + } + + private int +-looks_utf7(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) ++looks_utf7(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, size_t *ulen) + { + if (nbytes > 4 && buf[0] == '+' && buf[1] == '/' && buf[2] == 'v') + switch (buf[3]) { +@@ -421,7 +421,7 @@ + } + + private int +-looks_ucs16(const unsigned char *bf, size_t nbytes, unichar *ubf, ++looks_ucs16(const unsigned char *bf, size_t nbytes, unicodechar *ubf, + size_t *ulen) + { + int bigend; +@@ -444,10 +444,10 @@ + + if (bigend) + ubf[(*ulen)++] = bf[i + 1] +- | (CAST(unichar, bf[i]) << 8); ++ | (CAST(unicodechar, bf[i]) << 8); + else + ubf[(*ulen)++] = bf[i] +- | (CAST(unichar, bf[i + 1]) << 8); ++ | (CAST(unicodechar, bf[i + 1]) << 8); + + if (ubf[*ulen - 1] == 0xfffe) + return 0; +@@ -460,7 +460,7 @@ + } + + private int +-looks_ucs32(const unsigned char *bf, size_t nbytes, unichar *ubf, ++looks_ucs32(const unsigned char *bf, size_t nbytes, unicodechar *ubf, + size_t *ulen) + { + int bigend; +@@ -482,15 +482,15 @@ + /* XXX fix to properly handle chars > 65536 */ + + if (bigend) +- ubf[(*ulen)++] = CAST(unichar, bf[i + 3]) +- | (CAST(unichar, bf[i + 2]) << 8) +- | (CAST(unichar, bf[i + 1]) << 16) +- | (CAST(unichar, bf[i]) << 24); ++ ubf[(*ulen)++] = CAST(unicodechar, bf[i + 3]) ++ | (CAST(unicodechar, bf[i + 2]) << 8) ++ | (CAST(unicodechar, bf[i + 1]) << 16) ++ | (CAST(unicodechar, bf[i]) << 24); + else +- ubf[(*ulen)++] = CAST(unichar, bf[i + 0]) +- | (CAST(unichar, bf[i + 1]) << 8) +- | (CAST(unichar, bf[i + 2]) << 16) +- | (CAST(unichar, bf[i + 3]) << 24); ++ ubf[(*ulen)++] = CAST(unicodechar, bf[i + 0]) ++ | (CAST(unicodechar, bf[i + 1]) << 8) ++ | (CAST(unicodechar, bf[i + 2]) << 16) ++ | (CAST(unicodechar, bf[i + 3]) << 24); + + if (ubf[*ulen - 1] == 0xfffe) + return 0; diff -u libmagic.orig/file.h libmagic/file.h --- libmagic.orig/file.h 2019-05-07 04:27:11.000000000 +0200 -+++ libmagic/file.h 2020-06-21 00:23:48.421548900 +0200 ++++ libmagic/file.h 2020-08-25 15:11:06.907695900 +0200 @@ -33,18 +33,9 @@ #ifndef __file_h__ #define __file_h__ @@ -1738,9 +1932,12 @@ diff -u libmagic.orig/file.h libmagic/file.h ((t) == FILE_STRING || \ (t) == FILE_PSTRING || \ (t) == FILE_BESTRING16 || \ -@@ -447,28 +441,23 @@ +@@ -445,39 +439,34 @@ + }; + /* Type for Unicode characters */ - typedef unsigned long unichar; +-typedef unsigned long unichar; ++typedef unsigned long unicodechar; -struct stat; #define FILE_T_LOCAL 1 @@ -1772,7 +1969,18 @@ diff -u libmagic.orig/file.h libmagic/file.h protected int file_zmagic(struct magic_set *, const struct buffer *, const char *); #endif -@@ -491,13 +480,9 @@ + protected int file_ascmagic(struct magic_set *, const struct buffer *, + int); + protected int file_ascmagic_with_encoding(struct magic_set *, +- const struct buffer *, unichar *, size_t, const char *, const char *, int); ++ const struct buffer *, unicodechar *, size_t, const char *, const char *, int); + protected int file_encoding(struct magic_set *, const struct buffer *, +- unichar **, size_t *, const char **, const char **, const char **); ++ unicodechar **, size_t *, const char **, const char **, const char **); + protected int file_is_json(struct magic_set *, const struct buffer *); + protected int file_is_tar(struct magic_set *, const struct buffer *); + protected int file_softmagic(struct magic_set *, const struct buffer *, +@@ -491,19 +480,15 @@ protected void file_badread(struct magic_set *); protected void file_badseek(struct magic_set *); protected void file_oomem(struct magic_set *, size_t); @@ -1789,7 +1997,14 @@ diff -u libmagic.orig/file.h libmagic/file.h protected void file_showstr(FILE *, const char *, size_t); protected size_t file_mbswidth(const char *); protected const char *file_getbuffer(struct magic_set *); -@@ -513,34 +498,13 @@ + protected ssize_t sread(int, void *, size_t, int); + protected int file_check_mem(struct magic_set *, unsigned int); +-protected int file_looks_utf8(const unsigned char *, size_t, unichar *, ++protected int file_looks_utf8(const unsigned char *, size_t, unicodechar *, + size_t *); + protected size_t file_pstring_length_size(const struct magic *); + protected size_t file_pstring_get_length(const struct magic *, const char *); +@@ -513,34 +498,12 @@ size_t); #endif /* __EMX__ */ @@ -1822,12 +2037,11 @@ diff -u libmagic.orig/file.h libmagic/file.h - int); -protected void file_regfree(file_regex_t *); -protected void file_regerror(file_regex_t *, int, struct magic_set *); -+public void -+convert_libmagic_pattern(zval *pattern, char *val, size_t len, uint32_t options); ++public zend_string* convert_libmagic_pattern(char *val, size_t len, uint32_t options); typedef struct { char *buf; -@@ -550,28 +514,13 @@ +@@ -550,28 +513,13 @@ protected file_pushbuf_t *file_push_buffer(struct magic_set *); protected char *file_pop_buffer(struct magic_set *, file_pushbuf_t *); @@ -1858,7 +2072,7 @@ diff -u libmagic.orig/file.h libmagic/file.h size_t strlcat(char *, const char *, size_t); #endif #ifndef HAVE_STRCASESTR -@@ -587,39 +536,6 @@ +@@ -587,39 +535,6 @@ #ifndef HAVE_ASCTIME_R char *asctime_r(const struct tm *, char *); #endif @@ -1898,7 +2112,7 @@ diff -u libmagic.orig/file.h libmagic/file.h #if defined(HAVE_MMAP) && defined(HAVE_SYS_MMAN_H) && !defined(QUICK) #define QUICK -@@ -645,6 +561,18 @@ +@@ -645,6 +560,18 @@ #else #define FILE_RCSID(id) #endif @@ -2212,7 +2426,7 @@ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c case S_IFSOCK: diff -u libmagic.orig/funcs.c libmagic/funcs.c --- libmagic.orig/funcs.c 2019-05-07 04:27:11.000000000 +0200 -+++ libmagic/funcs.c 2020-06-17 02:13:31.651362400 +0200 ++++ libmagic/funcs.c 2020-08-25 15:11:06.872908800 +0200 @@ -31,87 +31,80 @@ #endif /* lint */ @@ -2471,7 +2685,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c - nm++; - } - rv = nm; -+ zval patt; ++ zend_string *pattern; + uint32_t opts = 0; + pcre_cache_entry *pce; + zend_string *res; @@ -2479,9 +2693,9 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c + size_t rep_cnt = 0; + + opts |= PCRE2_MULTILINE; -+ convert_libmagic_pattern(&patt, (char*)pat, strlen(pat), opts); -+ if ((pce = pcre_get_compiled_regex_cache_ex(Z_STR(patt), 0)) == NULL) { -+ zval_ptr_dtor(&patt); ++ pattern = convert_libmagic_pattern((char*)pat, strlen(pat), opts); ++ if ((pce = pcre_get_compiled_regex_cache_ex(pattern, 0)) == NULL) { ++ zend_string_release(pattern); + rep_cnt = -1; + goto out; } @@ -2489,7 +2703,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c - file_regfree(&rx); - return rv; -} -+ zval_ptr_dtor(&patt); ++ zend_string_release(pattern); -protected int -file_regcomp(file_regex_t *rx, const char *pat, int flags) @@ -3048,7 +3262,7 @@ diff -u libmagic.orig/magic.c libmagic/magic.c public const char * magic_error(struct magic_set *ms) diff -u libmagic.orig/magic.h libmagic/magic.h ---- libmagic.orig/magic.h 2020-07-08 18:10:37.403232400 +0200 +--- libmagic.orig/magic.h 2020-08-25 15:19:32.346097700 +0200 +++ libmagic/magic.h 2020-04-07 22:25:10.548560600 +0200 @@ -124,6 +124,7 @@ @@ -3060,7 +3274,7 @@ diff -u libmagic.orig/magic.h libmagic/magic.h diff -u libmagic.orig/print.c libmagic/print.c --- libmagic.orig/print.c 2019-03-12 21:43:05.000000000 +0100 -+++ libmagic/print.c 2020-07-08 18:05:40.114527900 +0200 ++++ libmagic/print.c 2020-08-22 19:28:45.849356800 +0200 @@ -28,6 +28,7 @@ /* * print.c - debugging printout routines @@ -3253,7 +3467,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c if (i != -1) diff -u libmagic.orig/softmagic.c libmagic/softmagic.c --- libmagic.orig/softmagic.c 2019-05-17 04:24:59.000000000 +0200 -+++ libmagic/softmagic.c 2020-04-26 00:43:35.734037100 +0200 ++++ libmagic/softmagic.c 2020-08-25 15:15:35.784945600 +0200 @@ -43,6 +43,10 @@ #include #include "der.h" @@ -3426,12 +3640,11 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c return rv; case FILE_USE: -@@ -1926,6 +1904,61 @@ +@@ -1926,6 +1904,60 @@ return file_strncmp(a, b, len, flags); } -+public void -+convert_libmagic_pattern(zval *pattern, char *val, size_t len, uint32_t options) ++public zend_string* convert_libmagic_pattern(char *val, size_t len, uint32_t options) +{ + int i, j; + zend_string *t; @@ -3482,20 +3695,20 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c + ZSTR_VAL(t)[j]='\0'; + ZSTR_LEN(t) = j; + -+ ZVAL_NEW_STR(pattern, t); ++ return t; +} + private int magiccheck(struct magic_set *ms, struct magic *m) { -@@ -2104,65 +2137,77 @@ +@@ -2104,65 +2136,77 @@ break; } case FILE_REGEX: { - int rc; - file_regex_t rx; - const char *search; -+ zval pattern; ++ zend_string *pattern; + uint32_t options = 0; + pcre_cache_entry *pce; @@ -3514,11 +3727,11 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c + options |= PCRE2_CASELESS; + } + -+ convert_libmagic_pattern(&pattern, (char *)m->value.s, m->vallen, options); ++ pattern = convert_libmagic_pattern((char *)m->value.s, m->vallen, options); + + l = v = 0; -+ if ((pce = pcre_get_compiled_regex_cache(Z_STR(pattern))) == NULL) { -+ zval_ptr_dtor(&pattern); ++ if ((pce = pcre_get_compiled_regex_cache(pattern)) == NULL) { ++ zend_string_release(pattern); + return -1; } else { - regmatch_t pmatch; @@ -3554,7 +3767,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c + + if (Z_LVAL(retval) < 0) { + zval_ptr_dtor(&subpats); -+ zval_ptr_dtor(&pattern); ++ zend_string_release(pattern); + return -1; + } else if ((Z_LVAL(retval) > 0) && (Z_TYPE(subpats) == IS_ARRAY)) { + /* Need to fetch global match which equals pmatch[0] */ @@ -3581,7 +3794,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c + } else { +error_out: + zval_ptr_dtor(&subpats); -+ zval_ptr_dtor(&pattern); ++ zend_string_release(pattern); + return -1; + } } else { @@ -3610,7 +3823,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c - break; } + zval_ptr_dtor(&subpats); -+ zval_ptr_dtor(&pattern); ++ zend_string_release(pattern); } - file_regfree(&rx); - if (v == CAST(uint64_t, -1)) diff --git a/ext/fileinfo/libmagic/apprentice.c b/ext/fileinfo/libmagic/apprentice.c index 03d5d89b061cd..f6ff1cf26e6e7 100644 --- a/ext/fileinfo/libmagic/apprentice.c +++ b/ext/fileinfo/libmagic/apprentice.c @@ -2590,17 +2590,17 @@ getvalue(struct magic_set *ms, struct magic *m, const char **p, int action) return -1; } if (m->type == FILE_REGEX) { - zval pattern; + zend_string *pattern; int options = 0; pcre_cache_entry *pce; - convert_libmagic_pattern(&pattern, m->value.s, strlen(m->value.s), options); + pattern = convert_libmagic_pattern(m->value.s, strlen(m->value.s), options); - if ((pce = pcre_get_compiled_regex_cache(Z_STR(pattern))) == NULL) { - zval_dtor(&pattern); + if ((pce = pcre_get_compiled_regex_cache(pattern)) == NULL) { + zend_string_release(pattern); return -1; } - zval_dtor(&pattern); + zend_string_release(pattern); return 0; } diff --git a/ext/fileinfo/libmagic/ascmagic.c b/ext/fileinfo/libmagic/ascmagic.c index 0bc0cce1de4e8..348f6d6bd71bc 100644 --- a/ext/fileinfo/libmagic/ascmagic.c +++ b/ext/fileinfo/libmagic/ascmagic.c @@ -51,7 +51,7 @@ FILE_RCSID("@(#)$File: ascmagic.c,v 1.104 2019/05/07 02:27:11 christos Exp $") #define ISSPC(x) ((x) == ' ' || (x) == '\t' || (x) == '\r' || (x) == '\n' \ || (x) == 0x85 || (x) == '\f') -private unsigned char *encode_utf8(unsigned char *, size_t, unichar *, size_t); +private unsigned char *encode_utf8(unsigned char *, size_t, unicodechar *, size_t); private size_t trim_nuls(const unsigned char *, size_t); /* @@ -70,7 +70,7 @@ trim_nuls(const unsigned char *buf, size_t nbytes) protected int file_ascmagic(struct magic_set *ms, const struct buffer *b, int text) { - unichar *ubuf = NULL; + unicodechar *ubuf = NULL; size_t ulen = 0; int rv = 1; struct buffer bb; @@ -103,7 +103,7 @@ file_ascmagic(struct magic_set *ms, const struct buffer *b, int text) protected int file_ascmagic_with_encoding(struct magic_set *ms, - const struct buffer *b, unichar *ubuf, size_t ulen, const char *code, + const struct buffer *b, unicodechar *ubuf, size_t ulen, const char *code, const char *type, int text) { struct buffer bb; @@ -338,7 +338,7 @@ file_ascmagic_with_encoding(struct magic_set *ms, * after end of string, or NULL if an invalid character is found. */ private unsigned char * -encode_utf8(unsigned char *buf, size_t len, unichar *ubuf, size_t ulen) +encode_utf8(unsigned char *buf, size_t len, unicodechar *ubuf, size_t ulen) { size_t i; unsigned char *end = buf + len; diff --git a/ext/fileinfo/libmagic/encoding.c b/ext/fileinfo/libmagic/encoding.c index 121bbd71438da..8d0e6012e5862 100644 --- a/ext/fileinfo/libmagic/encoding.c +++ b/ext/fileinfo/libmagic/encoding.c @@ -44,14 +44,14 @@ FILE_RCSID("@(#)$File: encoding.c,v 1.20 2019/04/15 16:48:41 christos Exp $") #include -private int looks_ascii(const unsigned char *, size_t, unichar *, size_t *); -private int looks_utf8_with_BOM(const unsigned char *, size_t, unichar *, +private int looks_ascii(const unsigned char *, size_t, unicodechar *, size_t *); +private int looks_utf8_with_BOM(const unsigned char *, size_t, unicodechar *, size_t *); -private int looks_utf7(const unsigned char *, size_t, unichar *, size_t *); -private int looks_ucs16(const unsigned char *, size_t, unichar *, size_t *); -private int looks_ucs32(const unsigned char *, size_t, unichar *, size_t *); -private int looks_latin1(const unsigned char *, size_t, unichar *, size_t *); -private int looks_extended(const unsigned char *, size_t, unichar *, size_t *); +private int looks_utf7(const unsigned char *, size_t, unicodechar *, size_t *); +private int looks_ucs16(const unsigned char *, size_t, unicodechar *, size_t *); +private int looks_ucs32(const unsigned char *, size_t, unicodechar *, size_t *); +private int looks_latin1(const unsigned char *, size_t, unicodechar *, size_t *); +private int looks_extended(const unsigned char *, size_t, unicodechar *, size_t *); private void from_ebcdic(const unsigned char *, size_t, unsigned char *); #ifdef DEBUG_ENCODING @@ -63,11 +63,11 @@ private void from_ebcdic(const unsigned char *, size_t, unsigned char *); /* * Try to determine whether text is in some character code we can * identify. Each of these tests, if it succeeds, will leave - * the text converted into one-unichar-per-character Unicode in + * the text converted into one-unicodechar-per-character Unicode in * ubuf, and the number of characters converted in ulen. */ protected int -file_encoding(struct magic_set *ms, const struct buffer *b, unichar **ubuf, +file_encoding(struct magic_set *ms, const struct buffer *b, unicodechar **ubuf, size_t *ulen, const char **code, const char **code_mime, const char **type) { const unsigned char *buf = CAST(const unsigned char *, b->fbuf); @@ -75,7 +75,7 @@ file_encoding(struct magic_set *ms, const struct buffer *b, unichar **ubuf, size_t mlen; int rv = 1, ucs_type; unsigned char *nbuf = NULL; - unichar *udefbuf; + unicodechar *udefbuf; size_t udeflen; if (ubuf == NULL) @@ -89,7 +89,7 @@ file_encoding(struct magic_set *ms, const struct buffer *b, unichar **ubuf, *code_mime = "binary"; mlen = (nbytes + 1) * sizeof((*ubuf)[0]); - if ((*ubuf = CAST(unichar *, ecalloc(CAST(size_t, 1), mlen))) == NULL) { + if ((*ubuf = CAST(unicodechar *, ecalloc(CAST(size_t, 1), mlen))) == NULL) { file_oomem(ms, mlen); goto done; } @@ -251,7 +251,7 @@ private char text_chars[256] = { }; private int -looks_ascii(const unsigned char *buf, size_t nbytes, unichar *ubuf, +looks_ascii(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, size_t *ulen) { size_t i; @@ -271,7 +271,7 @@ looks_ascii(const unsigned char *buf, size_t nbytes, unichar *ubuf, } private int -looks_latin1(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) +looks_latin1(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, size_t *ulen) { size_t i; @@ -290,7 +290,7 @@ looks_latin1(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ule } private int -looks_extended(const unsigned char *buf, size_t nbytes, unichar *ubuf, +looks_extended(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, size_t *ulen) { size_t i; @@ -321,11 +321,11 @@ looks_extended(const unsigned char *buf, size_t nbytes, unichar *ubuf, * ubuf must be big enough! */ protected int -file_looks_utf8(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) +file_looks_utf8(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, size_t *ulen) { size_t i; int n; - unichar c; + unicodechar c; int gotone = 0, ctrl = 0; if (ubuf) @@ -392,7 +392,7 @@ file_looks_utf8(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t * * rest of the text. */ private int -looks_utf8_with_BOM(const unsigned char *buf, size_t nbytes, unichar *ubuf, +looks_utf8_with_BOM(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, size_t *ulen) { if (nbytes > 3 && buf[0] == 0xef && buf[1] == 0xbb && buf[2] == 0xbf) @@ -402,7 +402,7 @@ looks_utf8_with_BOM(const unsigned char *buf, size_t nbytes, unichar *ubuf, } private int -looks_utf7(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) +looks_utf7(const unsigned char *buf, size_t nbytes, unicodechar *ubuf, size_t *ulen) { if (nbytes > 4 && buf[0] == '+' && buf[1] == '/' && buf[2] == 'v') switch (buf[3]) { @@ -421,7 +421,7 @@ looks_utf7(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen) } private int -looks_ucs16(const unsigned char *bf, size_t nbytes, unichar *ubf, +looks_ucs16(const unsigned char *bf, size_t nbytes, unicodechar *ubf, size_t *ulen) { int bigend; @@ -444,10 +444,10 @@ looks_ucs16(const unsigned char *bf, size_t nbytes, unichar *ubf, if (bigend) ubf[(*ulen)++] = bf[i + 1] - | (CAST(unichar, bf[i]) << 8); + | (CAST(unicodechar, bf[i]) << 8); else ubf[(*ulen)++] = bf[i] - | (CAST(unichar, bf[i + 1]) << 8); + | (CAST(unicodechar, bf[i + 1]) << 8); if (ubf[*ulen - 1] == 0xfffe) return 0; @@ -460,7 +460,7 @@ looks_ucs16(const unsigned char *bf, size_t nbytes, unichar *ubf, } private int -looks_ucs32(const unsigned char *bf, size_t nbytes, unichar *ubf, +looks_ucs32(const unsigned char *bf, size_t nbytes, unicodechar *ubf, size_t *ulen) { int bigend; @@ -482,15 +482,15 @@ looks_ucs32(const unsigned char *bf, size_t nbytes, unichar *ubf, /* XXX fix to properly handle chars > 65536 */ if (bigend) - ubf[(*ulen)++] = CAST(unichar, bf[i + 3]) - | (CAST(unichar, bf[i + 2]) << 8) - | (CAST(unichar, bf[i + 1]) << 16) - | (CAST(unichar, bf[i]) << 24); + ubf[(*ulen)++] = CAST(unicodechar, bf[i + 3]) + | (CAST(unicodechar, bf[i + 2]) << 8) + | (CAST(unicodechar, bf[i + 1]) << 16) + | (CAST(unicodechar, bf[i]) << 24); else - ubf[(*ulen)++] = CAST(unichar, bf[i + 0]) - | (CAST(unichar, bf[i + 1]) << 8) - | (CAST(unichar, bf[i + 2]) << 16) - | (CAST(unichar, bf[i + 3]) << 24); + ubf[(*ulen)++] = CAST(unicodechar, bf[i + 0]) + | (CAST(unicodechar, bf[i + 1]) << 8) + | (CAST(unicodechar, bf[i + 2]) << 16) + | (CAST(unicodechar, bf[i + 3]) << 24); if (ubf[*ulen - 1] == 0xfffe) return 0; diff --git a/ext/fileinfo/libmagic/file.h b/ext/fileinfo/libmagic/file.h index 3450f745bd36f..c74c159569adc 100644 --- a/ext/fileinfo/libmagic/file.h +++ b/ext/fileinfo/libmagic/file.h @@ -439,7 +439,7 @@ struct magic_set { }; /* Type for Unicode characters */ -typedef unsigned long unichar; +typedef unsigned long unicodechar; #define FILE_T_LOCAL 1 #define FILE_T_WINDOWS 2 @@ -464,9 +464,9 @@ protected int file_zmagic(struct magic_set *, const struct buffer *, protected int file_ascmagic(struct magic_set *, const struct buffer *, int); protected int file_ascmagic_with_encoding(struct magic_set *, - const struct buffer *, unichar *, size_t, const char *, const char *, int); + const struct buffer *, unicodechar *, size_t, const char *, const char *, int); protected int file_encoding(struct magic_set *, const struct buffer *, - unichar **, size_t *, const char **, const char **, const char **); + unicodechar **, size_t *, const char **, const char **, const char **); protected int file_is_json(struct magic_set *, const struct buffer *); protected int file_is_tar(struct magic_set *, const struct buffer *); protected int file_softmagic(struct magic_set *, const struct buffer *, @@ -488,7 +488,7 @@ protected size_t file_mbswidth(const char *); protected const char *file_getbuffer(struct magic_set *); protected ssize_t sread(int, void *, size_t, int); protected int file_check_mem(struct magic_set *, unsigned int); -protected int file_looks_utf8(const unsigned char *, size_t, unichar *, +protected int file_looks_utf8(const unsigned char *, size_t, unicodechar *, size_t *); protected size_t file_pstring_length_size(const struct magic *); protected size_t file_pstring_get_length(const struct magic *, const char *); @@ -503,8 +503,7 @@ protected void buffer_init(struct buffer *, int, const zend_stat_t *, protected void buffer_fini(struct buffer *); protected int buffer_fill(const struct buffer *); -public void -convert_libmagic_pattern(zval *pattern, char *val, size_t len, uint32_t options); +public zend_string* convert_libmagic_pattern(char *val, size_t len, uint32_t options); typedef struct { char *buf; diff --git a/ext/fileinfo/libmagic/funcs.c b/ext/fileinfo/libmagic/funcs.c index 6561f7458b7c5..a21e85ffc084a 100644 --- a/ext/fileinfo/libmagic/funcs.c +++ b/ext/fileinfo/libmagic/funcs.c @@ -516,7 +516,7 @@ file_printedlen(const struct magic_set *ms) protected int file_replace(struct magic_set *ms, const char *pat, const char *rep) { - zval patt; + zend_string *pattern; uint32_t opts = 0; pcre_cache_entry *pce; zend_string *res; @@ -524,13 +524,13 @@ file_replace(struct magic_set *ms, const char *pat, const char *rep) size_t rep_cnt = 0; opts |= PCRE2_MULTILINE; - convert_libmagic_pattern(&patt, (char*)pat, strlen(pat), opts); - if ((pce = pcre_get_compiled_regex_cache_ex(Z_STR(patt), 0)) == NULL) { - zval_ptr_dtor(&patt); + pattern = convert_libmagic_pattern((char*)pat, strlen(pat), opts); + if ((pce = pcre_get_compiled_regex_cache_ex(pattern, 0)) == NULL) { + zend_string_release(pattern); rep_cnt = -1; goto out; } - zval_ptr_dtor(&patt); + zend_string_release(pattern); repl = zend_string_init(rep, strlen(rep), 0); res = php_pcre_replace_impl(pce, NULL, ms->o.buf, strlen(ms->o.buf), repl, -1, &rep_cnt); diff --git a/ext/fileinfo/libmagic/softmagic.c b/ext/fileinfo/libmagic/softmagic.c index d71801cea5a86..fa272f625d30b 100644 --- a/ext/fileinfo/libmagic/softmagic.c +++ b/ext/fileinfo/libmagic/softmagic.c @@ -1904,8 +1904,7 @@ file_strncmp16(const char *a, const char *b, size_t len, uint32_t flags) return file_strncmp(a, b, len, flags); } -public void -convert_libmagic_pattern(zval *pattern, char *val, size_t len, uint32_t options) +public zend_string* convert_libmagic_pattern(char *val, size_t len, uint32_t options) { int i, j; zend_string *t; @@ -1956,7 +1955,7 @@ convert_libmagic_pattern(zval *pattern, char *val, size_t len, uint32_t options) ZSTR_VAL(t)[j]='\0'; ZSTR_LEN(t) = j; - ZVAL_NEW_STR(pattern, t); + return t; } private int @@ -2137,7 +2136,7 @@ magiccheck(struct magic_set *ms, struct magic *m) break; } case FILE_REGEX: { - zval pattern; + zend_string *pattern; uint32_t options = 0; pcre_cache_entry *pce; @@ -2147,11 +2146,11 @@ magiccheck(struct magic_set *ms, struct magic *m) options |= PCRE2_CASELESS; } - convert_libmagic_pattern(&pattern, (char *)m->value.s, m->vallen, options); + pattern = convert_libmagic_pattern((char *)m->value.s, m->vallen, options); l = v = 0; - if ((pce = pcre_get_compiled_regex_cache(Z_STR(pattern))) == NULL) { - zval_ptr_dtor(&pattern); + if ((pce = pcre_get_compiled_regex_cache(pattern)) == NULL) { + zend_string_release(pattern); return -1; } else { /* pce now contains the compiled regex */ @@ -2172,7 +2171,7 @@ magiccheck(struct magic_set *ms, struct magic *m) if (Z_LVAL(retval) < 0) { zval_ptr_dtor(&subpats); - zval_ptr_dtor(&pattern); + zend_string_release(pattern); return -1; } else if ((Z_LVAL(retval) > 0) && (Z_TYPE(subpats) == IS_ARRAY)) { /* Need to fetch global match which equals pmatch[0] */ @@ -2199,14 +2198,14 @@ magiccheck(struct magic_set *ms, struct magic *m) } else { error_out: zval_ptr_dtor(&subpats); - zval_ptr_dtor(&pattern); + zend_string_release(pattern); return -1; } } else { v = 1; } zval_ptr_dtor(&subpats); - zval_ptr_dtor(&pattern); + zend_string_release(pattern); } break; } diff --git a/ext/filter/callback_filter.c b/ext/filter/callback_filter.c index edba63e5627dd..68b69e9680c09 100644 --- a/ext/filter/callback_filter.c +++ b/ext/filter/callback_filter.c @@ -23,7 +23,7 @@ void php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL) int status; if (!option_array || !zend_is_callable(option_array, 0, NULL)) { - php_error_docref(NULL, E_WARNING, "First argument is expected to be a valid callback"); + zend_type_error("%s(): Option must be a valid callback", get_active_function_name()); zval_ptr_dtor(value); ZVAL_NULL(value); return; diff --git a/ext/filter/filter.c b/ext/filter/filter.c index d049c34c4fbe2..37fac29de93d8 100644 --- a/ext/filter/filter.c +++ b/ext/filter/filter.c @@ -487,8 +487,8 @@ static zval *php_filter_get_storage(zend_long arg)/* {{{ */ array_ptr = !Z_ISUNDEF(IF_G(env_array)) ? &IF_G(env_array) : &PG(http_globals)[TRACK_VARS_ENV]; break; default: - php_error_docref(NULL, E_WARNING, "Unknown source"); - break; + zend_argument_value_error(1, "must be an INPUT_* constant"); + return NULL; } if (array_ptr && Z_TYPE_P(array_ptr) != IS_ARRAY) { @@ -512,6 +512,9 @@ PHP_FUNCTION(filter_has_var) } array_ptr = php_filter_get_storage(arg); + if (EG(exception)) { + RETURN_THROWS(); + } if (array_ptr && zend_hash_exists(Z_ARRVAL_P(array_ptr), var)) { RETURN_TRUE; @@ -614,14 +617,12 @@ static void php_filter_array_handler(zval *input, zval *op, zval *return_value, ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(op), arg_key, arg_elm) { if (arg_key == NULL) { - php_error_docref(NULL, E_WARNING, "Numeric keys are not allowed in the definition array"); - zval_ptr_dtor(return_value); - RETURN_FALSE; + zend_argument_type_error(2, "must contain only string keys"); + RETURN_THROWS(); } if (ZSTR_LEN(arg_key) == 0) { - php_error_docref(NULL, E_WARNING, "Empty keys are not allowed in the definition array"); - zval_ptr_dtor(return_value); - RETURN_FALSE; + zend_argument_value_error(2, "cannot contain empty keys"); + RETURN_THROWS(); } if ((tmp = zend_hash_find(Z_ARRVAL_P(input), arg_key)) == NULL) { if (add_empty) { @@ -658,6 +659,9 @@ PHP_FUNCTION(filter_input) } input = php_filter_get_storage(fetch_from); + if (EG(exception)) { + RETURN_THROWS(); + } if (!input || (tmp = zend_hash_find(Z_ARRVAL_P(input), var)) == NULL) { zend_long filter_flags = 0; @@ -731,6 +735,9 @@ PHP_FUNCTION(filter_input_array) } array_input = php_filter_get_storage(fetch_from); + if (EG(exception)) { + RETURN_THROWS(); + } if (!array_input) { zend_long filter_flags = 0; diff --git a/ext/filter/filter_private.h b/ext/filter/filter_private.h index f8a02a4907797..0db29dc698d92 100644 --- a/ext/filter/filter_private.h +++ b/ext/filter/filter_private.h @@ -92,12 +92,15 @@ || (id >= FILTER_VALIDATE_ALL && id <= FILTER_VALIDATE_LAST) \ || id == FILTER_CALLBACK) -#define RETURN_VALIDATION_FAILED \ - zval_ptr_dtor(value); \ - if (flags & FILTER_NULL_ON_FAILURE) { \ - ZVAL_NULL(value); \ - } else { \ - ZVAL_FALSE(value); \ +#define RETURN_VALIDATION_FAILED \ + if (EG(exception)) { \ + return; \ + } else if (flags & FILTER_NULL_ON_FAILURE) { \ + zval_ptr_dtor(value); \ + ZVAL_NULL(value); \ + } else { \ + zval_ptr_dtor(value); \ + ZVAL_FALSE(value); \ } \ return; \ diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c index 76b0b977b37e7..a9fcc01d01972 100644 --- a/ext/filter/logical_filters.c +++ b/ext/filter/logical_filters.c @@ -360,7 +360,7 @@ void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ if (decimal_set) { if (decimal_len != 1) { - php_error_docref(NULL, E_WARNING, "Decimal separator must be one char"); + zend_value_error("%s(): \"decimal\" option must be one character long", get_active_function_name()); RETURN_VALIDATION_FAILED } else { dec_sep = *decimal; @@ -371,7 +371,7 @@ void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ if (thousand_set) { if (thousand_len < 1) { - php_error_docref(NULL, E_WARNING, "Thousand separator must be at least one char"); + zend_value_error("%s(): \"thousand\" option cannot be empty", get_active_function_name()); RETURN_VALIDATION_FAILED } else { tsd_sep = thousand; @@ -472,7 +472,7 @@ void php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ FETCH_STR_OPTION(regexp, "regexp"); if (!regexp_set) { - php_error_docref(NULL, E_WARNING, "'regexp' option missing"); + zend_value_error("%s(): \"regexp\" option is missing", get_active_function_name()); RETURN_VALIDATION_FAILED } @@ -919,7 +919,7 @@ void php_filter_validate_mac(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ FETCH_STRING_OPTION(exp_separator, "separator"); if (exp_separator_set && exp_separator_len != 1) { - php_error_docref(NULL, E_WARNING, "Separator must be exactly one character long"); + zend_value_error("%s(): \"separator\" option must be one character long", get_active_function_name()); RETURN_VALIDATION_FAILED; } diff --git a/ext/filter/tests/017.phpt b/ext/filter/tests/017.phpt index d11688ecebeb1..c641e3cedcf39 100644 --- a/ext/filter/tests/017.phpt +++ b/ext/filter/tests/017.phpt @@ -10,17 +10,19 @@ var_dump(filter_var("data", FILTER_VALIDATE_REGEXP, array("options"=>array("rege var_dump(filter_var("data", FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>'/^d(.*)/')))); var_dump(filter_var("data", FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>'/blah/')))); var_dump(filter_var("data", FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>'/\[/')))); -var_dump(filter_var("data", FILTER_VALIDATE_REGEXP)); +try { + filter_var("data", FILTER_VALIDATE_REGEXP); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- string(4) "data" bool(false) string(4) "data" bool(false) bool(false) - -Warning: filter_var(): 'regexp' option missing in %s on line %d -bool(false) +filter_var(): "regexp" option is missing Done diff --git a/ext/filter/tests/029.phpt b/ext/filter/tests/029.phpt index fc191f1710aa0..53d7dd77f37fc 100644 --- a/ext/filter/tests/029.phpt +++ b/ext/filter/tests/029.phpt @@ -13,9 +13,24 @@ function test($var) { var_dump(filter_var("data", FILTER_CALLBACK, array("options"=>"test"))); var_dump(filter_var("~!@#$%^&*()_QWERTYUIOPASDFGHJKLZXCVBNM<>>?\"}{:", FILTER_CALLBACK, array("options"=>"test"))); var_dump(filter_var("", FILTER_CALLBACK, array("options"=>"test"))); -var_dump(filter_var("qwe", FILTER_CALLBACK, array("options"=>"no such func"))); -var_dump(filter_var("qwe", FILTER_CALLBACK, array("options"=>""))); -var_dump(filter_var("qwe", FILTER_CALLBACK)); + +try { + filter_var("qwe", FILTER_CALLBACK, array("options"=>"no such func")); +} catch (TypeError $exception) { + echo $exception->getMessage() . "\n"; +} + +try { + filter_var("qwe", FILTER_CALLBACK, array("options"=>"")); +} catch (TypeError $exception) { + echo $exception->getMessage() . "\n"; +} + +try { + filter_var("qwe", FILTER_CALLBACK); +} catch (TypeError $exception) { + echo $exception->getMessage() . "\n"; +} /* Simple class method callback */ class test_class { @@ -62,15 +77,9 @@ echo "Done\n"; string(4) "DATA" string(46) "~!@#$%^&*()_QWERTYUIOPASDFGHJKLZXCVBNM<>>?"}{:" string(0) "" - -Warning: filter_var(): First argument is expected to be a valid callback in %s on line %d -NULL - -Warning: filter_var(): First argument is expected to be a valid callback in %s on line %d -NULL - -Warning: filter_var(): First argument is expected to be a valid callback in %s on line %d -NULL +filter_var(): Option must be a valid callback +filter_var(): Option must be a valid callback +filter_var(): Option must be a valid callback string(4) "data" string(46) "~!@#$%^&*()_qwertyuiopasdfghjklzxcvbnm<>>?"}{:" string(0) "" diff --git a/ext/filter/tests/031.phpt b/ext/filter/tests/031.phpt index 2968decafc763..0ef9f68930e67 100644 --- a/ext/filter/tests/031.phpt +++ b/ext/filter/tests/031.phpt @@ -33,12 +33,15 @@ $floats = array( echo "\ncustom decimal:\n"; foreach ($floats as $float => $dec) { - $out = filter_var($float, FILTER_VALIDATE_FLOAT, array("options"=>array('decimal' => $dec))); - var_dump($out); + try { + var_dump(filter_var($float, FILTER_VALIDATE_FLOAT, array("options"=>array('decimal' => $dec)))); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } ?> ---EXPECTF-- +--EXPECT-- float(1.234) float(1.234) float(1.234) @@ -52,7 +55,5 @@ custom decimal: bool(false) float(1.234) float(1.234) - -Warning: filter_var(): Decimal separator must be one char in %s on line %d -bool(false) +filter_var(): "decimal" option must be one character long bool(false) diff --git a/ext/filter/tests/039.phpt b/ext/filter/tests/039.phpt index bdd090ae86f8e..f5a1cf2fe7c22 100644 --- a/ext/filter/tests/039.phpt +++ b/ext/filter/tests/039.phpt @@ -30,9 +30,16 @@ var_dump(filter_var_array(array(), array("var_name"=>-1))); var_dump(filter_var_array(array("var_name"=>""), array("var_name"=>-1))); echo "-- (5)\n"; -var_dump(filter_var_array(array("var_name"=>""), array("var_name"=>-1, "asdas"=>"asdasd", "qwe"=>"rty", ""=>""))); -var_dump(filter_var_array(array("asdas"=>"text"), array("var_name"=>-1, "asdas"=>"asdasd", "qwe"=>"rty", ""=>""))); - +try { + filter_var_array(array("var_name"=>""), array("var_name"=>-1, "asdas"=>"asdasd", "qwe"=>"rty", ""=>"")); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} +try { + filter_var_array(array("asdas"=>"text"), array("var_name"=>-1, "asdas"=>"asdasd", "qwe"=>"rty", ""=>"")); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} $a = array(""=>""); $b = -1; var_dump(filter_var_array($a, $b)); @@ -48,7 +55,7 @@ var_dump($a, $b); echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- -- (1) array(0) { } @@ -86,12 +93,8 @@ array(1) { string(0) "" } -- (5) - -Warning: filter_var_array(): Empty keys are not allowed in the definition array in %s on line %d -bool(false) - -Warning: filter_var_array(): Empty keys are not allowed in the definition array in %s on line %d -bool(false) +filter_var_array(): Argument #2 ($options) cannot contain empty keys +filter_var_array(): Argument #2 ($options) cannot contain empty keys bool(false) array(1) { [""]=> diff --git a/ext/filter/tests/040.phpt b/ext/filter/tests/040.phpt index f6de3eb84cf6e..6f0a79199f2ef 100644 --- a/ext/filter/tests/040.phpt +++ b/ext/filter/tests/040.phpt @@ -16,12 +16,17 @@ var_dump(filter_has_var(INPUT_GET, "a")); var_dump(filter_has_var(INPUT_GET, "c")); var_dump(filter_has_var(INPUT_GET, "abc")); var_dump(filter_has_var(INPUT_GET, "cc")); -var_dump(filter_has_var(-1, "cc")); +try { + filter_has_var(-1, "cc"); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + var_dump(filter_has_var(0, "cc")); echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- bool(false) bool(true) bool(true) @@ -29,8 +34,6 @@ bool(true) bool(true) bool(false) bool(false) - -Warning: filter_has_var(): Unknown source in %s on line %d -bool(false) +filter_has_var(): Argument #1 ($type) must be an INPUT_* constant bool(false) Done diff --git a/ext/filter/tests/055.phpt b/ext/filter/tests/055.phpt index 896dda833825b..0edc241efdc6a 100644 --- a/ext/filter/tests/055.phpt +++ b/ext/filter/tests/055.phpt @@ -21,12 +21,16 @@ $values = Array( array("01-23-45-67-89-ab", array("options" => array("separator" => ""))), ); foreach ($values as $value) { - var_dump(filter_var($value[0], FILTER_VALIDATE_MAC, $value[1])); + try { + var_dump(filter_var($value[0], FILTER_VALIDATE_MAC, $value[1])); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- string(17) "01-23-45-67-89-ab" string(17) "01-23-45-67-89-ab" bool(false) @@ -39,10 +43,6 @@ string(17) "01:23:45:67:89:aB" bool(false) bool(false) string(14) "0123.4567.89ab" - -Warning: filter_var(): Separator must be exactly one character long in %s055.php on line %d -bool(false) - -Warning: filter_var(): Separator must be exactly one character long in %s055.php on line %d -bool(false) +filter_var(): "separator" option must be one character long +filter_var(): "separator" option must be one character long Done diff --git a/ext/filter/tests/bug51368.phpt b/ext/filter/tests/bug51368.phpt index 38ae03ca95909..ebe33a104183d 100644 --- a/ext/filter/tests/bug51368.phpt +++ b/ext/filter/tests/bug51368.phpt @@ -12,11 +12,15 @@ var_dump( filter_var('1 234.567', FILTER_VALIDATE_FLOAT, $options) ); $options = ['flags' => FILTER_FLAG_ALLOW_THOUSAND, 'options' => ['thousand' => '']]; -var_dump(filter_var('12345', FILTER_VALIDATE_FLOAT, $options)); + +try { + filter_var('12345', FILTER_VALIDATE_FLOAT, $options); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + ?> ---EXPECTF-- +--EXPECT-- float(1000) float(1234.567) - -Warning: filter_var(): Thousand separator must be at least one char in %s on line %d -bool(false) +filter_var(): "thousand" option cannot be empty diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c index 2da4769aa5172..b27fbef0128c3 100644 --- a/ext/ftp/php_ftp.c +++ b/ext/ftp/php_ftp.c @@ -1235,7 +1235,7 @@ PHP_FUNCTION(ftp_close) ftp_quit(ftp); - RETURN_BOOL(zend_list_close(Z_RES_P(z_ftp)) == SUCCESS); + RETURN_TRUE; } /* }}} */ diff --git a/ext/gd/gd.c b/ext/gd/gd.c index b015143ad8061..48dd6ecf4518f 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -861,20 +861,20 @@ PHP_FUNCTION(imagecolormatch) result = gdImageColorMatch(im1, im2); switch (result) { case -1: - php_error_docref(NULL, E_WARNING, "Image1 must be TrueColor" ); - RETURN_FALSE; + zend_argument_value_error(1, "must be TrueColor"); + RETURN_THROWS(); break; case -2: - php_error_docref(NULL, E_WARNING, "Image2 must be Palette" ); - RETURN_FALSE; + zend_argument_value_error(2, "must be Palette"); + RETURN_THROWS(); break; case -3: - php_error_docref(NULL, E_WARNING, "Image1 and Image2 must be the same size" ); - RETURN_FALSE; + zend_argument_value_error(2, "must be the same size as argument #1 ($im1)"); + RETURN_THROWS(); break; case -4: - php_error_docref(NULL, E_WARNING, "Image2 must have at least one color" ); - RETURN_FALSE; + zend_argument_value_error(2, "must have at least one color"); + RETURN_THROWS(); break; } @@ -1459,7 +1459,7 @@ gdImagePtr _php_image_create_from_string(zend_string *data, char *tn, gdImagePtr im = (*ioctx_func_p)(io_ctx); if (!im) { - php_error_docref(NULL, E_WARNING, "Passed data is not in '%s' format", tn); + php_error_docref(NULL, E_WARNING, "Passed data is not in \"%s\" format", tn); io_ctx->gd_free(io_ctx); return NULL; } @@ -1483,8 +1483,8 @@ PHP_FUNCTION(imagecreatefromstring) } if (ZSTR_LEN(data) < sizeof(sig)) { - php_error_docref(NULL, E_WARNING, "Empty string or invalid image"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } memcpy(sig, ZSTR_VAL(data), sizeof(sig)); @@ -1666,7 +1666,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, return; } - php_error_docref(NULL, E_WARNING, "'%s' is not a valid %s file", file, tn); + php_error_docref(NULL, E_WARNING, "\"%s\" is not a valid %s file", file, tn); out_err: php_stream_close(stream); RETURN_FALSE; @@ -1806,7 +1806,7 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char fp = VCWD_FOPEN(fn, "wb"); if (!fp) { - php_error_docref(NULL, E_WARNING, "Unable to open '%s' for writing", fn); + php_error_docref(NULL, E_WARNING, "Unable to open \"%s\" for writing", fn); RETURN_FALSE; } @@ -2297,8 +2297,8 @@ PHP_FUNCTION(imagecolorsforindex) add_assoc_long(return_value,"blue", gdImageBlue(im,col)); add_assoc_long(return_value,"alpha", gdImageAlpha(im,col)); } else { - php_error_docref(NULL, E_WARNING, "Color index %d out of range", col); - RETURN_FALSE; + zend_argument_value_error(2, "is out of range"); + RETURN_THROWS(); } } /* }}} */ diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index 4492a9d3812b3..9c237530085df 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -1463,6 +1463,8 @@ void gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y, int c, int color) int cx, cy; int px, py; int fline; + const int xuppper = (x > INT_MAX - f->w) ? INT_MAX : x + f->w; + const int yuppper = (y > INT_MAX - f->h) ? INT_MAX : y + f->h; cx = 0; cy = 0; #ifdef CHARSET_EBCDIC @@ -1472,8 +1474,8 @@ void gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y, int c, int color) return; } fline = (c - f->offset) * f->h * f->w; - for (py = y; (py < (y + f->h)); py++) { - for (px = x; (px < (x + f->w)); px++) { + for (py = y; py < yuppper; py++) { + for (px = x; px < xuppper; px++) { if (f->data[fline + cy * f->w + cx]) { gdImageSetPixel(im, px, py, color); } @@ -1489,6 +1491,8 @@ void gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c, int color) int cx, cy; int px, py; int fline; + const int xuppper = (x > INT_MAX - f->h) ? INT_MAX : x + f->h; + const int ylower = (y < INT_MIN + f->w) ? INT_MIN : y - f->w; cx = 0; cy = 0; #ifdef CHARSET_EBCDIC @@ -1498,8 +1502,8 @@ void gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c, int color) return; } fline = (c - f->offset) * f->h * f->w; - for (py = y; py > (y - f->w); py--) { - for (px = x; px < (x + f->h); px++) { + for (py = y; py > ylower; py--) { + for (px = x; px < xuppper; px++) { if (f->data[fline + cy * f->w + cx]) { gdImageSetPixel(im, px, py, color); } diff --git a/ext/gd/tests/001-mb.phpt b/ext/gd/tests/001-mb.phpt index c34c232d0ae70..38bf14a3cb808 100644 --- a/ext/gd/tests/001-mb.phpt +++ b/ext/gd/tests/001-mb.phpt @@ -20,6 +20,6 @@ echo "Done\n"; Warning: imagecreatefrompng(%s001私はガラスを食べられます.test): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: imagecreatefrompng(): '%s001私はガラスを食べられます.test' is not a valid PNG file in %s on line %d +Warning: imagecreatefrompng(): "%s001私はガラスを食べられます.test" is not a valid PNG file in %s on line %d bool(false) Done diff --git a/ext/gd/tests/001.phpt b/ext/gd/tests/001.phpt index 75dbcc0d471a3..d741e1f50618d 100644 --- a/ext/gd/tests/001.phpt +++ b/ext/gd/tests/001.phpt @@ -20,6 +20,6 @@ echo "Done\n"; Warning: imagecreatefrompng(%s001.test): Failed to open stream: No such file or directory in %s on line %d bool(false) -Warning: imagecreatefrompng(): '%s001.test' is not a valid PNG file in %s on line %d +Warning: imagecreatefrompng(): "%s001.test" is not a valid PNG file in %s on line %d bool(false) Done diff --git a/ext/gd/tests/bug37346-mb.phpt b/ext/gd/tests/bug37346-mb.phpt index 4ec5734fc7939..e1a9b8b4706c9 100644 --- a/ext/gd/tests/bug37346-mb.phpt +++ b/ext/gd/tests/bug37346-mb.phpt @@ -9,4 +9,4 @@ Bug #37346 (gdimagecreatefromgif, bad colormap) $im = imagecreatefromgif(__DIR__ . '/bug37346私はガラスを食べられます.gif'); ?> --EXPECTF-- -Warning: imagecreatefromgif(): '%sbug37346私はガラスを食べられます.gif' is not a valid GIF file in %sbug37346-mb.php on line %d +Warning: imagecreatefromgif(): "%sbug37346私はガラスを食べられます.gif" is not a valid GIF file in %sbug37346-mb.php on line %d diff --git a/ext/gd/tests/bug37346.phpt b/ext/gd/tests/bug37346.phpt index 57701a7ad7b75..40b3341685daa 100644 --- a/ext/gd/tests/bug37346.phpt +++ b/ext/gd/tests/bug37346.phpt @@ -9,4 +9,4 @@ Bug #37346 (gdimagecreatefromgif, bad colormap) $im = imagecreatefromgif(__DIR__ . '/bug37346.gif'); ?> --EXPECTF-- -Warning: imagecreatefromgif(): '%sbug37346.gif' is not a valid GIF file in %sbug37346.php on line %d +Warning: imagecreatefromgif(): "%sbug37346.gif" is not a valid GIF file in %sbug37346.php on line %d diff --git a/ext/gd/tests/bug37360.phpt b/ext/gd/tests/bug37360.phpt index c2b8b9592dd75..74a58223a96c0 100644 --- a/ext/gd/tests/bug37360.phpt +++ b/ext/gd/tests/bug37360.phpt @@ -10,5 +10,5 @@ $im = imagecreatefromgif(__DIR__ . '/bug37360.gif'); var_dump($im); ?> --EXPECTF-- -Warning: imagecreatefromgif(): '%s' is not a valid GIF file in %s on line %d +Warning: imagecreatefromgif(): "%s" is not a valid GIF file in %s on line %d bool(false) diff --git a/ext/gd/tests/bug38112.phpt b/ext/gd/tests/bug38112.phpt index 8a6911ad9da94..4eb553b614384 100644 --- a/ext/gd/tests/bug38112.phpt +++ b/ext/gd/tests/bug38112.phpt @@ -11,4 +11,4 @@ Bug #38112 (GIF Invalid Code size ). $im = imagecreatefromgif(__DIR__ . '/bug38112.gif'); ?> --EXPECTF-- -Warning: imagecreatefromgif(): '%sbug38112.gif' is not a valid GIF file in %sbug38112.php on line %d +Warning: imagecreatefromgif(): "%sbug38112.gif" is not a valid GIF file in %sbug38112.php on line %d diff --git a/ext/gd/tests/bug39780.phpt b/ext/gd/tests/bug39780.phpt index 2a7af3e0f4982..6468f28b7342d 100644 --- a/ext/gd/tests/bug39780.phpt +++ b/ext/gd/tests/bug39780.phpt @@ -16,5 +16,5 @@ Warning: imagecreatefrompng(): gd-png: fatal libpng error: Read Error: truncate Warning: imagecreatefrompng(): gd-png error: setjmp returns error condition in %s on line %d -Warning: imagecreatefrompng(): '%s' is not a valid PNG file in %s on line %d +Warning: imagecreatefrompng(): "%s" is not a valid PNG file in %s on line %d bool(false) diff --git a/ext/gd/tests/bug39780_extern.phpt b/ext/gd/tests/bug39780_extern.phpt index 0656e52fc7df7..e090477314831 100644 --- a/ext/gd/tests/bug39780_extern.phpt +++ b/ext/gd/tests/bug39780_extern.phpt @@ -14,5 +14,5 @@ var_dump($im); --EXPECTF-- gd-png: fatal libpng error: Read Error: truncated data gd-png error: setjmp returns error condition 2 -Warning: imagecreatefrompng(): '%sbug39780.png' is not a valid PNG file in /%s on line %d +Warning: imagecreatefrompng(): v%sbug39780.png" is not a valid PNG file in /%s on line %d bool(false) diff --git a/ext/gd/tests/bug71912-mb.phpt b/ext/gd/tests/bug71912-mb.phpt index d0bf3a89c235a..32a6ee00bc71b 100644 --- a/ext/gd/tests/bug71912-mb.phpt +++ b/ext/gd/tests/bug71912-mb.phpt @@ -11,5 +11,5 @@ imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . "invalid_neg_size私はガラ ?> OK --EXPECTF-- -Warning: imagecreatefromgd2(): '%s%einvalid_neg_size私はガラスを食べられます.gd2' is not a valid GD2 file in %s%ebug71912-mb.php on line %d +Warning: imagecreatefromgd2(): "%s%einvalid_neg_size私はガラスを食べられます.gd2" is not a valid GD2 file in %s%ebug71912-mb.php on line %d OK diff --git a/ext/gd/tests/bug71912.phpt b/ext/gd/tests/bug71912.phpt index ed4665f439a81..30bde45d214c5 100644 --- a/ext/gd/tests/bug71912.phpt +++ b/ext/gd/tests/bug71912.phpt @@ -14,5 +14,5 @@ imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . "invalid_neg_size.gd2"); ?> OK --EXPECTF-- -Warning: imagecreatefromgd2(): '%s%einvalid_neg_size.gd2' is not a valid GD2 file in %s%ebug71912.php on line %d +Warning: imagecreatefromgd2(): "%s%einvalid_neg_size.gd2" is not a valid GD2 file in %s%ebug71912.php on line %d OK diff --git a/ext/gd/tests/bug72339.phpt b/ext/gd/tests/bug72339.phpt index bd8054cced24b..4baaa92ab21e1 100644 --- a/ext/gd/tests/bug72339.phpt +++ b/ext/gd/tests/bug72339.phpt @@ -35,4 +35,4 @@ unlink($fname); Warning: imagecreatefromgd2(): Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully in %sbug72339.php on line %d -Warning: imagecreatefromgd2(): '%sbug72339.gd' is not a valid GD2 file in %sbug72339.php on line %d +Warning: imagecreatefromgd2(): "%sbug72339.gd" is not a valid GD2 file in %sbug72339.php on line %d diff --git a/ext/gd/tests/bug73161.phpt b/ext/gd/tests/bug73161.phpt index bc386dc9c22eb..90fd26274556f 100644 --- a/ext/gd/tests/bug73161.phpt +++ b/ext/gd/tests/bug73161.phpt @@ -12,5 +12,5 @@ $im = imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73161.gd2'); var_dump($im); ?> --EXPECTF-- -Warning: imagecreatefromgd2(): '%s' is not a valid GD2 file in %s on line %d +Warning: imagecreatefromgd2(): "%s" is not a valid GD2 file in %s on line %d bool(false) diff --git a/ext/gd/tests/bug73868.phpt b/ext/gd/tests/bug73868.phpt index fd9537c4a017d..ed59ac7be3068 100644 --- a/ext/gd/tests/bug73868.phpt +++ b/ext/gd/tests/bug73868.phpt @@ -12,5 +12,5 @@ var_dump(imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73868.gd2')); Warning: imagecreatefromgd2(): gd2: EOF while reading in %s on line %d -Warning: imagecreatefromgd2(): '%s' is not a valid GD2 file in %s on line %d +Warning: imagecreatefromgd2(): "%s" is not a valid GD2 file in %s on line %d bool(false) diff --git a/ext/gd/tests/bug73869.phpt b/ext/gd/tests/bug73869.phpt index 69c7e1b543902..6adb8c09a4fb1 100644 --- a/ext/gd/tests/bug73869.phpt +++ b/ext/gd/tests/bug73869.phpt @@ -10,8 +10,8 @@ var_dump(imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73869a.gd2')); var_dump(imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73869b.gd2')); ?> --EXPECTF-- -Warning: imagecreatefromgd2(): '%s' is not a valid GD2 file in %s on line %d +Warning: imagecreatefromgd2(): "%s" is not a valid GD2 file in %s on line %d bool(false) -Warning: imagecreatefromgd2(): '%s' is not a valid GD2 file in %s on line %d +Warning: imagecreatefromgd2(): "%s" is not a valid GD2 file in %s on line %d bool(false) diff --git a/ext/gd/tests/bug75111.phpt b/ext/gd/tests/bug75111.phpt index 4ec22c4a3a17f..e2e13f3b73640 100644 --- a/ext/gd/tests/bug75111.phpt +++ b/ext/gd/tests/bug75111.phpt @@ -17,7 +17,7 @@ $str .= hex2bin("01001800000000000000000000000000000000000000000000000000"); var_dump(imagecreatefromstring($str)); ?> --EXPECTF-- -Warning: imagecreatefromstring(): Passed data is not in 'BMP' format in %s on line %d +Warning: imagecreatefromstring(): Passed data is not in "BMP" format in %s on line %d Warning: imagecreatefromstring(): Couldn't create GD Image Stream out of Data in %s on line %d bool(false) diff --git a/ext/gd/tests/bug75571.phpt b/ext/gd/tests/bug75571.phpt index 10b459d421fea..898f1ecbad5c3 100644 --- a/ext/gd/tests/bug75571.phpt +++ b/ext/gd/tests/bug75571.phpt @@ -9,5 +9,5 @@ if (!extension_loaded('gd')) die('skip gd extension not available'); var_dump(imagecreatefromgif(__DIR__ . '/bug75571.gif')); ?> --EXPECTF-- -Warning: imagecreatefromgif(): '%s' is not a valid GIF file in %s on line %d +Warning: imagecreatefromgif(): "%s" is not a valid GIF file in %s on line %d bool(false) diff --git a/ext/gd/tests/bug77195.phpt b/ext/gd/tests/bug77195.phpt index f90035b7416be..fc788a6667574 100644 --- a/ext/gd/tests/bug77195.phpt +++ b/ext/gd/tests/bug77195.phpt @@ -14,4 +14,4 @@ imagecreatefromjpeg($filename); --EXPECTF-- Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: JPEG datastream contains no image in %s on line %d -Warning: imagecreatefromjpeg(): '%s' is not a valid JPEG file in %s on line %d +Warning: imagecreatefromjpeg(): "%s" is not a valid JPEG file in %s on line %d diff --git a/ext/gd/tests/bug77973.phpt b/ext/gd/tests/bug77973.phpt index c9400987e07a6..434cc4449e1a4 100644 --- a/ext/gd/tests/bug77973.phpt +++ b/ext/gd/tests/bug77973.phpt @@ -16,7 +16,7 @@ var_dump($im); --EXPECTF-- Warning: imagecreatefromxbm(): Invalid XBM in %s on line %d -Warning: imagecreatefromxbm(): '%s' is not a valid XBM file in %s on line %d +Warning: imagecreatefromxbm(): "%s" is not a valid XBM file in %s on line %d bool(false) --CLEAN-- getMessage() . "\n"; +} imagedestroy($im); $im = imagecreate(5,5); @@ -48,7 +52,11 @@ imagedestroy($im); $im = imagecreate(5,5); $c = imagecolorclosestalpha($im, 255,0,255,100); -print_r(imagecolorsforindex($im, $c)); +try { + imagecolorsforindex($im, $c); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} imagedestroy($im); $im = imagecreate(5,5); @@ -62,7 +70,6 @@ for ($i=0; $i<255; $i++) imagecolorresolvealpha($im, $i,0,0,1); $c = imagecolorclosestalpha($im, 255,0,0,1); print_r(imagecolorsforindex($im, $c)); - $im = imagecreate(5,5); for ($i=0; $i<256; $i++) { if ($i == 246) { @@ -74,12 +81,10 @@ for ($i=0; $i<256; $i++) { $c = imagecolorclosestalpha($im, 255,10,10,1); print_r(imagecolorsforindex($im, $c)); - ?> ---EXPECTF-- +--EXPECT-- FF00FF - -Warning: imagecolorsforindex(): Color index -1 out of range in %s on line %d +imagecolorsforindex(): Argument #2 ($index) is out of range Array ( [red] => 255 @@ -102,8 +107,7 @@ Array [alpha] => 0 ) 64FF00FF - -Warning: imagecolorsforindex(): Color index -1 out of range in %s on line %d +imagecolorsforindex(): Argument #2 ($index) is out of range Array ( [red] => 255 diff --git a/ext/gd/tests/colormatch.phpt b/ext/gd/tests/colormatch.phpt index 283a200571919..5641bc01017fe 100644 --- a/ext/gd/tests/colormatch.phpt +++ b/ext/gd/tests/colormatch.phpt @@ -10,12 +10,16 @@ imagecolormatch $im = imagecreatetruecolor(5,5); $im2 = imagecreate(5,5); -imagecolormatch($im, $im2); +try { + imagecolormatch($im, $im2); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} echo "ok\n"; imagedestroy($im); ?> ---EXPECTF-- -Warning: imagecolormatch(): Image2 must have at least one color in %s on line %d +--EXPECT-- +imagecolormatch(): Argument #2 ($im2) must have at least one color ok diff --git a/ext/gd/tests/crafted_gd2.phpt b/ext/gd/tests/crafted_gd2.phpt index 60687dfa3c38a..a5b0dfe339bba 100644 --- a/ext/gd/tests/crafted_gd2.phpt +++ b/ext/gd/tests/crafted_gd2.phpt @@ -11,4 +11,4 @@ Test max colors for a gd image. imagecreatefromgd(__DIR__ . '/crafted.gd2'); ?> --EXPECTF-- -Warning: imagecreatefromgd(): '%scrafted.gd2' is not a valid GD file in %s on line %d +Warning: imagecreatefromgd(): "%scrafted.gd2" is not a valid GD file in %s on line %d diff --git a/ext/gd/tests/createfromstring.phpt b/ext/gd/tests/createfromstring.phpt index 5d14708a2ee32..d4d63149f13f1 100644 --- a/ext/gd/tests/createfromstring.phpt +++ b/ext/gd/tests/createfromstring.phpt @@ -51,14 +51,17 @@ unlink($dir . '/p.png'); //empty string -$im = imagecreatefromstring(''); +try { + imagecreatefromstring(''); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} //random string > 12 $im = imagecreatefromstring(' asdf jklp foo'); ?> --EXPECTF-- createfromstring truecolor png: ok createfromstring palette png: ok - -Warning: imagecreatefromstring(): Empty string or invalid image in %screatefromstring.php on line %d +imagecreatefromstring(): Argument #1 ($image) cannot be empty Warning: imagecreatefromstring(): Data is not in a recognized format in %screatefromstring.php on line %d diff --git a/ext/gd/tests/createfromwbmp2.phpt b/ext/gd/tests/createfromwbmp2.phpt index f75d02613d328..c6a1a22427d6a 100644 --- a/ext/gd/tests/createfromwbmp2.phpt +++ b/ext/gd/tests/createfromwbmp2.phpt @@ -45,4 +45,4 @@ unlink($filename); Warning: imagecreatefromwbmp(): Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully in %s on line %d -Warning: imagecreatefromwbmp(): '%s' is not a valid WBMP file in %s on line %d +Warning: imagecreatefromwbmp(): "%s" is not a valid WBMP file in %s on line %d diff --git a/ext/gd/tests/createfromwbmp2_extern.phpt b/ext/gd/tests/createfromwbmp2_extern.phpt index ad7a130c18df4..ab15ec024e7e7 100644 --- a/ext/gd/tests/createfromwbmp2_extern.phpt +++ b/ext/gd/tests/createfromwbmp2_extern.phpt @@ -44,4 +44,4 @@ unlink($filename); --EXPECTF-- gd warning: Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully -Warning: imagecreatefromwbmp(): '%s_tmp.wbmp' is not a valid WBMP file in %s on line %d +Warning: imagecreatefromwbmp(): "%s_tmp.wbmp" is not a valid WBMP file in %s on line %d diff --git a/ext/gd/tests/imagecolormatch_error2.phpt b/ext/gd/tests/imagecolormatch_error2.phpt index 2240f987df5f2..f356b716c6147 100644 --- a/ext/gd/tests/imagecolormatch_error2.phpt +++ b/ext/gd/tests/imagecolormatch_error2.phpt @@ -13,8 +13,13 @@ $ima = imagecreate(110, 20); $background_color = imagecolorallocate($ima, 0, 0, 0); $imb = imagecreate(110, 20); $background_color = imagecolorallocate($imb, 0, 0, 100); -var_dump(imagecolormatch($ima, $imb)); + +try { + imagecolormatch($ima, $imb); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + ?> ---EXPECTF-- -Warning: imagecolormatch(): Image1 must be TrueColor in %s on line %d -bool(false) +--EXPECT-- +imagecolormatch(): Argument #1 ($im1) must be TrueColor diff --git a/ext/gd/tests/imagecolormatch_error3.phpt b/ext/gd/tests/imagecolormatch_error3.phpt index 245ebca646d03..a3f556a3e12ba 100644 --- a/ext/gd/tests/imagecolormatch_error3.phpt +++ b/ext/gd/tests/imagecolormatch_error3.phpt @@ -13,8 +13,13 @@ $ima = imagecreatetruecolor(110, 20); $background_color = imagecolorallocate($ima, 0, 0, 0); $imb = imagecreatetruecolor(110, 20); $background_color = imagecolorallocate($imb, 0, 0, 100); -var_dump(imagecolormatch($ima, $imb)); + +try { + imagecolormatch($ima, $imb); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + ?> ---EXPECTF-- -Warning: imagecolormatch(): Image2 must be Palette in %s on line %d -bool(false) +--EXPECT-- +imagecolormatch(): Argument #2 ($im2) must be Palette diff --git a/ext/gd/tests/imagecolormatch_error4.phpt b/ext/gd/tests/imagecolormatch_error4.phpt index 4579192571a24..f1392c9149e90 100644 --- a/ext/gd/tests/imagecolormatch_error4.phpt +++ b/ext/gd/tests/imagecolormatch_error4.phpt @@ -13,8 +13,13 @@ $ima = imagecreatetruecolor(110, 20); $background_color = imagecolorallocate($ima, 0, 0, 0); $imb = imagecreate(100, 20); $background_color = imagecolorallocate($imb, 0, 0, 100); -var_dump(imagecolormatch($ima, $imb)); + +try { + imagecolormatch($ima, $imb); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + ?> ---EXPECTF-- -Warning: imagecolormatch(): Image1 and Image2 must be the same size in %s on line %d -bool(false) +--EXPECT-- +imagecolormatch(): Argument #2 ($im2) must be the same size as argument #1 ($im1) diff --git a/ext/gd/tests/libgd00086.phpt b/ext/gd/tests/libgd00086.phpt index c7954a0a002da..959828f0685ac 100644 --- a/ext/gd/tests/libgd00086.phpt +++ b/ext/gd/tests/libgd00086.phpt @@ -16,5 +16,5 @@ Warning: imagecreatefrompng(): gd-png: fatal libpng error: Read Error: truncate Warning: imagecreatefrompng(): gd-png error: setjmp returns error condition in %s on line %d -Warning: imagecreatefrompng(): '%s' is not a valid PNG file in %s on line %d +Warning: imagecreatefrompng(): "%s" is not a valid PNG file in %s on line %d bool(false) diff --git a/ext/gd/tests/libgd00086_extern.phpt b/ext/gd/tests/libgd00086_extern.phpt index 36b79b4835fb4..78bafa761e88b 100644 --- a/ext/gd/tests/libgd00086_extern.phpt +++ b/ext/gd/tests/libgd00086_extern.phpt @@ -15,5 +15,5 @@ var_dump($im); gd-png: fatal libpng error: Read Error: truncated data gd-png error: setjmp returns error condition 1 -Warning: imagecreatefrompng(): '%slibgd00086.png' is not a valid PNG file in %s on line %d +Warning: imagecreatefrompng(): "%slibgd00086.png" is not a valid PNG file in %s on line %d bool(false) diff --git a/ext/gd/tests/libgd00094-mb.phpt b/ext/gd/tests/libgd00094-mb.phpt index 76b6bcd5663cf..7ce24a43b22c2 100644 --- a/ext/gd/tests/libgd00094-mb.phpt +++ b/ext/gd/tests/libgd00094-mb.phpt @@ -11,5 +11,5 @@ $im = imagecreatefromxbm(__DIR__ . '/libgd00094私はガラスを食べられま var_dump($im); ?> --EXPECTF-- -Warning: imagecreatefromxbm(): '%slibgd00094私はガラスを食べられます.xbm' is not a valid XBM file in %slibgd00094-mb.php on line %d +Warning: imagecreatefromxbm(): "%slibgd00094私はガラスを食べられます.xbm" is not a valid XBM file in %slibgd00094-mb.php on line %d bool(false) diff --git a/ext/gd/tests/libgd00094.phpt b/ext/gd/tests/libgd00094.phpt index 17c4df70d56da..8af0b342d97c0 100644 --- a/ext/gd/tests/libgd00094.phpt +++ b/ext/gd/tests/libgd00094.phpt @@ -11,5 +11,5 @@ $im = imagecreatefromxbm(__DIR__ . '/libgd00094.xbm'); var_dump($im); ?> --EXPECTF-- -Warning: imagecreatefromxbm(): '%slibgd00094.xbm' is not a valid XBM file in %slibgd00094.php on line %d +Warning: imagecreatefromxbm(): "%slibgd00094.xbm" is not a valid XBM file in %slibgd00094.php on line %d bool(false) diff --git a/ext/gd/tests/libgd00101.phpt b/ext/gd/tests/libgd00101.phpt index 7e1e4b587219c..d2e278ced9888 100644 --- a/ext/gd/tests/libgd00101.phpt +++ b/ext/gd/tests/libgd00101.phpt @@ -14,5 +14,5 @@ var_dump($im); Warning: imagecreatefromgd(): Product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully in %slibgd00101.php on line %d -Warning: imagecreatefromgd(): '%slibgd00101.gd' is not a valid GD file in %slibgd00101.php on line %d +Warning: imagecreatefromgd(): "%slibgd00101.gd" is not a valid GD file in %slibgd00101.php on line %d bool(false) diff --git a/ext/hash/hash.c b/ext/hash/hash.c index 3f01ebcce6c4d..64be043362ea6 100644 --- a/ext/hash/hash.c +++ b/ext/hash/hash.c @@ -1202,7 +1202,7 @@ PHP_FUNCTION(mhash) if (algorithm >= 0 && algorithm < MHASH_NUM_ALGOS) { struct mhash_bc_entry algorithm_lookup = mhash_to_hash[algorithm]; if (algorithm_lookup.hash_name) { - algo = zend_string_init(algorithm_lookup.hash_name, strlen(algorithm_lookup.hash_name), 1); + algo = zend_string_init(algorithm_lookup.hash_name, strlen(algorithm_lookup.hash_name), 0); } } @@ -1211,6 +1211,10 @@ PHP_FUNCTION(mhash) } else { php_hash_do_hash(return_value, algo, data, data_len, 1, 0); } + + if (algo) { + zend_string_release(algo); + } } /* }}} */ diff --git a/ext/intl/breakiterator/breakiterator_class.cpp b/ext/intl/breakiterator/breakiterator_class.cpp index 2114ada558825..3f236db2d470a 100644 --- a/ext/intl/breakiterator/breakiterator_class.cpp +++ b/ext/intl/breakiterator/breakiterator_class.cpp @@ -69,7 +69,7 @@ U_CFUNC void breakiterator_object_construct(zval *object, BreakIterator_object *bio; BREAKITER_METHOD_FETCH_OBJECT_NO_CHECK; //populate to from object - assert(bio->biter == NULL); + ZEND_ASSERT(bio->biter == NULL); bio->biter = biter; } @@ -203,10 +203,10 @@ static zend_object *BreakIterator_object_create(zend_class_entry *ce) { BreakIterator_object* intern; - intern = (BreakIterator_object*)ecalloc(1, sizeof(BreakIterator_object) + sizeof(zval) * (ce->default_properties_count - 1)); + intern = (BreakIterator_object*) zend_object_alloc(sizeof(BreakIterator_object), ce); zend_object_std_init(&intern->zo, ce); - object_properties_init((zend_object*) intern, ce); + object_properties_init(&intern->zo, ce); breakiterator_object_init(intern); intern->zo.handlers = &BreakIterator_handlers; diff --git a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp index 67fb2b502ea67..f17733da24351 100644 --- a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp +++ b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp @@ -37,13 +37,20 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS) size_t rules_len; zend_bool compiled = 0; UErrorCode status = U_ZERO_ERROR; - intl_error_reset(NULL); + BREAKITER_METHOD_INIT_VARS; + object = ZEND_THIS; if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &rules, &rules_len, &compiled) == FAILURE) { RETURN_THROWS(); } + BREAKITER_METHOD_FETCH_OBJECT_NO_CHECK; + if (bio->biter) { + zend_throw_error(NULL, "IntlRuleBasedBreakIterator object is already constructed"); + RETURN_THROWS(); + } + // instantiation of ICU object RuleBasedBreakIterator *rbbi; @@ -52,33 +59,33 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS) UParseError parseError = UParseError(); if (intl_stringFromChar(rulesStr, rules, rules_len, &status) == FAILURE) { - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "rbbi_create_instance: rules were not a valid UTF-8 string", - 0); - RETURN_NULL(); + zend_throw_exception(IntlException_ce_ptr, + "IntlRuleBasedBreakIterator::__construct(): " + "rules were not a valid UTF-8 string", 0); + RETURN_THROWS(); } rbbi = new RuleBasedBreakIterator(rulesStr, parseError, status); intl_error_set_code(NULL, status); if (U_FAILURE(status)) { - char *msg; smart_str parse_error_str; parse_error_str = intl_parse_error_to_string(&parseError); - spprintf(&msg, 0, "rbbi_create_instance: unable to create " - "RuleBasedBreakIterator from rules (%s)", parse_error_str.s? ZSTR_VAL(parse_error_str.s) : ""); + zend_throw_exception_ex(IntlException_ce_ptr, 0, + "IntlRuleBasedBreakIterator::__construct(): " + "unable to create RuleBasedBreakIterator from rules (%s)", + parse_error_str.s ? ZSTR_VAL(parse_error_str.s) : ""); smart_str_free(&parse_error_str); - intl_error_set_custom_msg(NULL, msg, 1); - efree(msg); delete rbbi; - return; + RETURN_THROWS(); } } else { // compiled rbbi = new RuleBasedBreakIterator((uint8_t*)rules, rules_len, status); if (U_FAILURE(status)) { - intl_error_set(NULL, status, "rbbi_create_instance: unable to " - "create instance from compiled rules", 0); + zend_throw_exception(IntlException_ce_ptr, + "IntlRuleBasedBreakIterator::__construct(): " + "unable to create instance from compiled rules", 0); delete rbbi; - return; + RETURN_THROWS(); } } diff --git a/ext/intl/calendar/gregoriancalendar_methods.cpp b/ext/intl/calendar/gregoriancalendar_methods.cpp index 84d594185c46f..64b753978928a 100644 --- a/ext/intl/calendar/gregoriancalendar_methods.cpp +++ b/ext/intl/calendar/gregoriancalendar_methods.cpp @@ -85,8 +85,14 @@ static void _php_intlgregcal_constructor_body( } // instantion of ICU object + Calendar_object *co = Z_INTL_CALENDAR_P(return_value); GregorianCalendar *gcal = NULL; + if (co->ucal) { + zend_throw_error(NULL, "IntlGregorianCalendar object is already constructed"); + RETURN_THROWS(); + } + if (variant <= 2) { // From timezone and locale (0 to 2 arguments) TimeZone *tz = timezone_process_timezone_argument(tz_object, NULL, @@ -174,8 +180,7 @@ static void _php_intlgregcal_constructor_body( gcal->adoptTimeZone(tz); } - Calendar_object *co = Z_INTL_CALENDAR_P(return_value); - co->ucal = gcal; + co->ucal = gcal; } U_CFUNC PHP_FUNCTION(intlgregcal_create_instance) diff --git a/ext/intl/formatter/formatter_main.c b/ext/intl/formatter/formatter_main.c index 80d99b3f01141..8f44f33fa369c 100644 --- a/ext/intl/formatter/formatter_main.c +++ b/ext/intl/formatter/formatter_main.c @@ -43,6 +43,10 @@ static int numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS) INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len); object = return_value; FORMATTER_METHOD_FETCH_OBJECT_NO_CHECK; + if (FORMATTER_OBJECT(nfo)) { + zend_throw_error(NULL, "NumberFormatter object is already constructed"); + return FAILURE; + } /* Convert pattern (if specified) to UTF-16. */ if(pattern && pattern_len) { diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c index cd38b08c9bd5e..3a0fb22e08d80 100644 --- a/ext/intl/resourcebundle/resourcebundle_class.c +++ b/ext/intl/resourcebundle/resourcebundle_class.c @@ -93,6 +93,11 @@ static int resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS) return FAILURE; } + if (rb->me) { + zend_throw_error(NULL, "ResourceBundle object is already constructed"); + return FAILURE; + } + INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len); if (locale == NULL) { diff --git a/ext/intl/tests/breakiter___construct_error.phpt b/ext/intl/tests/breakiter___construct_error.phpt index a18d8d5a5d4d4..7272d8c16b71c 100644 --- a/ext/intl/tests/breakiter___construct_error.phpt +++ b/ext/intl/tests/breakiter___construct_error.phpt @@ -4,7 +4,6 @@ IntlRuleBasedBreakIterator::__construct(): arg errors --FILE-- getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n"; @@ -36,9 +35,16 @@ try { } catch (IntlException $e) { print_exception($e); } + +$rbbi = new IntlRuleBasedBreakIterator(".;"); +try { + $rbbi->__construct(".;"); +} catch (Error $e) { + print_exception($e); +} ?> --EXPECTF-- -Exception: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: unable to create RuleBasedBreakIterator from rules (parse error on line 1, offset 31) in %s on line %d +Exception: IntlRuleBasedBreakIterator::__construct(): unable to create RuleBasedBreakIterator from rules (parse error on line 1, offset 31) in %s on line %d Exception: IntlRuleBasedBreakIterator::__construct() expects at least 1 parameter, 0 given in %s on line %d @@ -46,4 +52,6 @@ Exception: IntlRuleBasedBreakIterator::__construct() expects at most 2 parameter Exception: IntlRuleBasedBreakIterator::__construct(): Argument #2 ($areCompiled) must be of type bool, array given in %s on line %d -Exception: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: unable to create instance from compiled rules in %s on line %d +Exception: IntlRuleBasedBreakIterator::__construct(): unable to create instance from compiled rules in %s on line %d + +Exception: IntlRuleBasedBreakIterator object is already constructed in %s on line %d diff --git a/ext/intl/tests/formatter_fail.phpt b/ext/intl/tests/formatter_fail.phpt index 3201c9a82b108..15981178ac5b5 100644 --- a/ext/intl/tests/formatter_fail.phpt +++ b/ext/intl/tests/formatter_fail.phpt @@ -75,6 +75,15 @@ try { } err($fmt); +$fmt = new NumberFormatter('en_US', NumberFormatter::DECIMAL); +try { + $fmt->__construct('en_US', NumberFormatter::DECIMAL); +} catch (Error $e) { + print_exception($e); + $fmt = null; +} +err($fmt); + foreach($args as $arg) { $fmt = crt("O", $arg[0], $arg[1]); err($fmt); @@ -95,6 +104,9 @@ ArgumentCountError: numfmt_create() expects at least 2 parameters, 0 given in %s ArgumentCountError: NumberFormatter::create() expects at least 2 parameters, 0 given in %s on line %d 'U_ZERO_ERROR' +Error: NumberFormatter object is already constructed in %s on line %d +'U_ZERO_ERROR' + IntlException: Constructor failed in %s on line %d 'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR' 'numfmt_create: number formatter creation failed: U_UNSUPPORTED_ERROR' diff --git a/ext/intl/tests/gregoriancalendar___construct_error.phpt b/ext/intl/tests/gregoriancalendar___construct_error.phpt index 7e5ce659bf68a..92a7e5c30436c 100644 --- a/ext/intl/tests/gregoriancalendar___construct_error.phpt +++ b/ext/intl/tests/gregoriancalendar___construct_error.phpt @@ -33,6 +33,13 @@ try { } catch (TypeError $e) { echo $e->getMessage(), "\n"; } + +$cal = new IntlGregorianCalendar(); +try { + $cal->__construct(); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} ?> --EXPECT-- Too many arguments @@ -40,3 +47,4 @@ Too many arguments No variant with 4 arguments (excluding trailing NULLs) No variant with 4 arguments (excluding trailing NULLs) IntlGregorianCalendar::__construct(): Argument #6 ($second) must be of type int, array given +IntlGregorianCalendar object is already constructed diff --git a/ext/intl/tests/rbbiter___construct_basic.phpt b/ext/intl/tests/rbbiter___construct_basic.phpt index 9f20806fa50a7..def14d25da907 100644 --- a/ext/intl/tests/rbbiter___construct_basic.phpt +++ b/ext/intl/tests/rbbiter___construct_basic.phpt @@ -6,7 +6,6 @@ if (!extension_loaded('intl')) die('skip intl extension not enabled'); --FILE-- getMessage(), "\n"; } ?> --EXPECT-- string(26) "IntlRuleBasedBreakIterator" -int(1) -string(93) "rbbi_create_instance: unable to create instance from compiled rules: U_ILLEGAL_ARGUMENT_ERROR" +IntlRuleBasedBreakIterator::__construct(): unable to create instance from compiled rules diff --git a/ext/intl/tests/resourcebundle_double_ctor.phpt b/ext/intl/tests/resourcebundle_double_ctor.phpt new file mode 100644 index 0000000000000..8101130a4c90a --- /dev/null +++ b/ext/intl/tests/resourcebundle_double_ctor.phpt @@ -0,0 +1,18 @@ +--TEST-- +ResourceBundle double construction should not be allowed +--SKIPIF-- + +--FILE-- +__construct('en_US', BUNDLE); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +ResourceBundle object is already constructed diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index 7bed59422c151..e32ed281ee71c 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -296,12 +296,12 @@ static size_t count_commas(const char *p, const char *end) { return count; } -/* {{{ static int php_mb_parse_encoding_list() +/* {{{ static zend_result php_mb_parse_encoding_list() * Return FAILURE if input contains any illegal encoding, otherwise SUCCESS. * Emits a ValueError in function context and a warning in INI context, in INI context arg_num must be 0. */ -static int php_mb_parse_encoding_list(const char *value, size_t value_length, - const mbfl_encoding ***return_list, size_t *return_size, int persistent, uint32_t arg_num, +static zend_result php_mb_parse_encoding_list(const char *value, size_t value_length, + const mbfl_encoding ***return_list, size_t *return_size, bool persistent, uint32_t arg_num, zend_bool allow_pass_encoding) { if (value == NULL || value_length == 0) { @@ -450,7 +450,7 @@ static const char *php_mb_zend_encoding_name_getter(const zend_encoding *encodin return ((const mbfl_encoding *)encoding)->name; } -static int php_mb_zend_encoding_lexer_compatibility_checker(const zend_encoding *_encoding) +static bool php_mb_zend_encoding_lexer_compatibility_checker(const zend_encoding *_encoding) { const mbfl_encoding *encoding = (const mbfl_encoding*)_encoding; if (encoding->flag & MBFL_ENCTYPE_SBCS) { @@ -521,7 +521,7 @@ static size_t php_mb_zend_encoding_converter(unsigned char **to, size_t *to_leng return loc; } -static int php_mb_zend_encoding_list_parser(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent) +static zend_result php_mb_zend_encoding_list_parser(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent) { return php_mb_parse_encoding_list( encoding_list, encoding_list_len, @@ -534,7 +534,7 @@ static const zend_encoding *php_mb_zend_internal_encoding_getter(void) return (const zend_encoding *)MBSTRG(internal_encoding); } -static int php_mb_zend_internal_encoding_setter(const zend_encoding *encoding) +static zend_result php_mb_zend_internal_encoding_setter(const zend_encoding *encoding) { MBSTRG(internal_encoding) = (const mbfl_encoding *)encoding; return SUCCESS; diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index d2dbcb7939c1c..3f89e838fd894 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -1644,16 +1644,13 @@ static int mysqli_options_get_option_zval_type(int option) #ifdef MYSQL_OPT_COMPRESS case MYSQL_OPT_COMPRESS: #endif /* mysqlnd @ PHP 5.3.2 */ -#ifdef MYSQL_OPT_SSL_VERIFY_SERVER_CERT - REGISTER_LONG_CONSTANT("MYSQLI_OPT_SSL_VERIFY_SERVER_CERT", MYSQL_OPT_SSL_VERIFY_SERVER_CERT, CONST_CS | CONST_PERSISTENT); -#endif /* MySQL 5.1.1., mysqlnd @ PHP 5.3.3 */ #if (MYSQL_VERSION_ID >= 50611 && defined(CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS)) || defined(MYSQLI_USE_MYSQLND) case MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS: #endif return IS_LONG; #ifdef MYSQL_SHARED_MEMORY_BASE_NAME - case MYSQL_SHARED_MEMORY_BASE_NAME: + case MYSQL_SHARED_MEMORY_BASE_NAME: #endif /* MySQL 4.1.0 */ #ifdef MYSQL_SET_CLIENT_IP case MYSQL_SET_CLIENT_IP: diff --git a/ext/mysqlnd/mysqlnd_debug.c b/ext/mysqlnd/mysqlnd_debug.c index ec698a265dcf7..ab02d5645a7f9 100644 --- a/ext/mysqlnd/mysqlnd_debug.c +++ b/ext/mysqlnd/mysqlnd_debug.c @@ -412,7 +412,8 @@ MYSQLND_METHOD(mysqlnd_debug, func_leave)(MYSQLND_DEBUG * self, unsigned int lin #endif } - return zend_stack_del_top(&self->call_stack) == SUCCESS? PASS:FAIL; + zend_stack_del_top(&self->call_stack); + return PASS; } /* }}} */ diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 06ea6adcc797d..f9e65939a527d 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -291,8 +291,8 @@ PHP_MINIT_FUNCTION(oci) le_descriptor = zend_register_list_destructors_ex(php_oci_descriptor_list_dtor, NULL, "oci8 descriptor", module_number); le_collection = zend_register_list_destructors_ex(php_oci_collection_list_dtor, NULL, "oci8 collection", module_number); - INIT_CLASS_ENTRY(oci_lob_class_entry, "OCI_Lob", class_OCI_Lob_methods); - INIT_CLASS_ENTRY(oci_coll_class_entry, "OCI_Collection", class_OCI_Collection_methods); + INIT_CLASS_ENTRY(oci_lob_class_entry, "OCILob", class_OCILob_methods); + INIT_CLASS_ENTRY(oci_coll_class_entry, "OCICollection", class_OCICollection_methods); oci_lob_class_entry_ptr = zend_register_internal_class(&oci_lob_class_entry); oci_coll_class_entry_ptr = zend_register_internal_class(&oci_coll_class_entry); @@ -917,7 +917,7 @@ void php_oci_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent, int exclus php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char *password, int password_len, char *new_password, int new_password_len, char *dbname, int dbname_len, char *charset, zend_long session_mode, int persistent, int exclusive) { zval *zvp; - zend_resource *le; + zend_resource *le = NULL; zend_resource new_le; php_oci_connection *connection = NULL; smart_str hashed_details = {0}; @@ -1163,7 +1163,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char /* We have to do a hash_del but need to preserve the resource if there is a positive * refcount. Set the data pointer in the list entry to NULL */ - if (connection == connection->id->ptr) { + if (connection == connection->id->ptr && le) { le->ptr = NULL; } diff --git a/ext/oci8/oci8.stub.php b/ext/oci8/oci8.stub.php index d53caed69b348..f73226bb53b1d 100644 --- a/ext/oci8/oci8.stub.php +++ b/ext/oci8/oci8.stub.php @@ -36,87 +36,87 @@ function ocibindbyname($statement_resource, string $column_name, &$variable, int */ function oci_bind_array_by_name($statement_resource, string $column_name, &$variable, int $maximum_array_length, int $maximum_item_length = -1, int $type = SQLT_AFC): bool {} -function oci_free_descriptor(OCI_Lob $lob_descriptor): bool {} +function oci_free_descriptor(OCILob $lob_descriptor): bool {} /** * @alias oci_free_descriptor * @deprecated */ -function ocifreedesc(OCI_Lob $lob_descriptor): bool {} +function ocifreedesc(OCILob $lob_descriptor): bool {} -function oci_lob_save(OCI_Lob $lob_descriptor, string $data, int $offset = 0): bool {} +function oci_lob_save(OCILob $lob_descriptor, string $data, int $offset = 0): bool {} /** * @alias oci_lob_save * @deprecated */ -function ocisavelob(OCI_Lob $lob_descriptor, string $data, int $offset = 0): bool {} +function ocisavelob(OCILob $lob_descriptor, string $data, int $offset = 0): bool {} -function oci_lob_import(OCI_Lob $lob_descriptor, string $filename): bool {} +function oci_lob_import(OCILob $lob_descriptor, string $filename): bool {} /** * @alias oci_lob_import * @deprecated */ -function ocisavelobfile(OCI_Lob $lob_descriptor, string $filename): bool {} +function ocisavelobfile(OCILob $lob_descriptor, string $filename): bool {} -function oci_lob_load(OCI_Lob $lob_descriptor): string|false {} +function oci_lob_load(OCILob $lob_descriptor): string|false {} /** * @alias oci_lob_load * @deprecated */ -function ociloadlob(OCI_Lob $lob_descriptor): string|false {} +function ociloadlob(OCILob $lob_descriptor): string|false {} -function oci_lob_read(OCI_Lob $lob_descriptor, int $length): string|false {} +function oci_lob_read(OCILob $lob_descriptor, int $length): string|false {} -function oci_lob_eof(OCI_Lob $lob_descriptor): bool {} +function oci_lob_eof(OCILob $lob_descriptor): bool {} -function oci_lob_tell(OCI_Lob $lob_descriptor): int|false {} +function oci_lob_tell(OCILob $lob_descriptor): int|false {} -function oci_lob_rewind(OCI_Lob $lob_descriptor): bool {} +function oci_lob_rewind(OCILob $lob_descriptor): bool {} -function oci_lob_seek(OCI_Lob $lob_descriptor, int $offset, int $whence = OCI_SEEK_SET): bool {} +function oci_lob_seek(OCILob $lob_descriptor, int $offset, int $whence = OCI_SEEK_SET): bool {} -function oci_lob_size(OCI_Lob $lob_descriptor): int|false {} +function oci_lob_size(OCILob $lob_descriptor): int|false {} -function oci_lob_write(OCI_Lob $lob_descriptor, string $string, int $length = UNKNOWN): int|false {} +function oci_lob_write(OCILob $lob_descriptor, string $string, int $length = UNKNOWN): int|false {} -function oci_lob_append(OCI_Lob $lob_descriptor_to, OCI_Lob $lob_descriptor_from): bool {} +function oci_lob_append(OCILob $lob_descriptor_to, OCILob $lob_descriptor_from): bool {} -function oci_lob_truncate(OCI_Lob $lob_descriptor, int $length = 0): bool {} +function oci_lob_truncate(OCILob $lob_descriptor, int $length = 0): bool {} -function oci_lob_erase(OCI_Lob $lob_descriptor, int $offset = UNKNOWN, int $length = UNKNOWN): int|false {} +function oci_lob_erase(OCILob $lob_descriptor, int $offset = UNKNOWN, int $length = UNKNOWN): int|false {} -function oci_lob_flush(OCI_Lob $lob_descriptor, int $flag = 0): bool {} +function oci_lob_flush(OCILob $lob_descriptor, int $flag = 0): bool {} -function ocisetbufferinglob(OCI_Lob $lob_descriptor, bool $mode): bool {} +function ocisetbufferinglob(OCILob $lob_descriptor, bool $mode): bool {} -function ocigetbufferinglob(OCI_Lob $lob_descriptor): bool {} +function ocigetbufferinglob(OCILob $lob_descriptor): bool {} -function oci_lob_copy(OCI_Lob $lob_descriptor_to, OCI_Lob $lob_descriptor_from, int $length = UNKNOWN): bool {} +function oci_lob_copy(OCILob $lob_descriptor_to, OCILob $lob_descriptor_from, int $length = UNKNOWN): bool {} -function oci_lob_is_equal(OCI_Lob $lob_descriptor_first, OCI_Lob $lob_descriptor_second): bool {} +function oci_lob_is_equal(OCILob $lob_descriptor_first, OCILob $lob_descriptor_second): bool {} -function oci_lob_export(OCI_Lob $lob_descriptor, string $path, int $start = UNKNOWN, int $length = UNKNOWN): bool {} +function oci_lob_export(OCILob $lob_descriptor, string $path, int $start = UNKNOWN, int $length = UNKNOWN): bool {} /** * @alias oci_lob_export * @deprecated */ -function ociwritelobtofile(OCI_Lob $lob_descriptor, string $path, int $start = UNKNOWN, int $length = UNKNOWN): bool {} +function ociwritelobtofile(OCILob $lob_descriptor, string $path, int $start = UNKNOWN, int $length = UNKNOWN): bool {} /** * @param resource $connection_resource */ -function oci_new_descriptor($connection_resource, int $type = OCI_DTYPE_LOB): ?OCI_Lob {} +function oci_new_descriptor($connection_resource, int $type = OCI_DTYPE_LOB): ?OCILob {} /** * @param resource $connection_resource * @alias oci_new_descriptor * @deprecated */ -function ocinewdescriptor($connection_resource, int $type = OCI_DTYPE_LOB): ?OCI_Lob {} +function ocinewdescriptor($connection_resource, int $type = OCI_DTYPE_LOB): ?OCILob {} /** * @param resource $connection_resource @@ -542,75 +542,75 @@ function oci_num_rows($statement_resource): int|false {} */ function ocirowcount($statement_resource): int|false {} -function oci_free_collection(OCI_Collection $collection): bool {} +function oci_free_collection(OCICollection $collection): bool {} /** * @alias oci_free_collection * @deprecated */ -function ocifreecollection(OCI_Collection $collection): bool {} +function ocifreecollection(OCICollection $collection): bool {} -function oci_collection_append(OCI_Collection $collection, string $value): bool {} +function oci_collection_append(OCICollection $collection, string $value): bool {} /** * @alias oci_collection_append * @deprecated */ -function ocicollappend(OCI_Collection $collection, string $value): bool {} +function ocicollappend(OCICollection $collection, string $value): bool {} -function oci_collection_element_get(OCI_Collection $collection, int $index): string|float|null|false {} +function oci_collection_element_get(OCICollection $collection, int $index): string|float|null|false {} /** * @alias oci_collection_element_get * @deprecated */ -function ocicollgetelem(OCI_Collection $collection, int $index): string|float|null|false {} +function ocicollgetelem(OCICollection $collection, int $index): string|float|null|false {} -function oci_collection_assign(OCI_Collection $collection_to, OCI_Collection $collection_from): bool {} +function oci_collection_assign(OCICollection $collection_to, OCICollection $collection_from): bool {} -function oci_collection_element_assign(OCI_Collection $collection, int $index, string $value): bool {} +function oci_collection_element_assign(OCICollection $collection, int $index, string $value): bool {} /** * @alias oci_collection_element_assign * @deprecated */ -function ocicollassignelem(OCI_Collection $collection, int $index, string $value): bool {} +function ocicollassignelem(OCICollection $collection, int $index, string $value): bool {} -function oci_collection_size(OCI_Collection $collection): int|false {} +function oci_collection_size(OCICollection $collection): int|false {} /** * @alias oci_collection_size * @deprecated */ -function ocicollsize(OCI_Collection $collection): int|false {} +function ocicollsize(OCICollection $collection): int|false {} -function oci_collection_max(OCI_Collection $collection): int|false {} +function oci_collection_max(OCICollection $collection): int|false {} /** * @alias oci_collection_max * @deprecated */ -function ocicollmax(OCI_Collection $collection): int|false {} +function ocicollmax(OCICollection $collection): int|false {} -function oci_collection_trim(OCI_Collection $collection, int $number): bool {} +function oci_collection_trim(OCICollection $collection, int $number): bool {} /** * @alias oci_collection_trim * @deprecated */ -function ocicolltrim(OCI_Collection $collection, int $number): bool {} +function ocicolltrim(OCICollection $collection, int $number): bool {} /** * @param resource $connection_resource */ -function oci_new_collection($connection_resource, string $type_name, string $schema_name = UNKNOWN): OCI_Collection|false {} +function oci_new_collection($connection_resource, string $type_name, string $schema_name = UNKNOWN): OCICollection|false {} /** * @param resource $connection_resource * @alias oci_new_collection * @deprecated */ -function ocinewcollection($connection_resource, string $type_name, string $schema_name = UNKNOWN): OCI_Collection|false {} +function ocinewcollection($connection_resource, string $type_name, string $schema_name = UNKNOWN): OCICollection|false {} /** * @param resource $connection_resource @@ -622,7 +622,7 @@ function oci_register_taf_callback($connection_resource, ?callable $function_nam */ function oci_unregister_taf_callback($connection_resource): bool {} -class OCI_Lob { +class OCILob { /** * @alias oci_lob_save * @return bool @@ -693,7 +693,7 @@ public function write(string $string, int $length = UNKNOWN) {} * @alias oci_lob_append * @return bool */ - public function append(OCI_Lob $lob_descriptor_from) {} + public function append(OCILob $lob_descriptor_from) {} /** * @alias oci_lob_truncate @@ -756,7 +756,7 @@ public function close() {} public function free() {} } -class OCI_Collection { +class OCICollection { /** * @alias oci_free_collection * @return bool @@ -779,7 +779,7 @@ public function getElem(int $index) {} * @alias oci_collection_assign * @return bool */ - public function assign(OCI_Collection $collection_from) {} + public function assign(OCICollection $collection_from) {} /** * @alias oci_collection_element_assign diff --git a/ext/oci8/oci8_arginfo.h b/ext/oci8/oci8_arginfo.h index c82656f205bc3..4ebacd5260fbe 100644 --- a/ext/oci8/oci8_arginfo.h +++ b/ext/oci8/oci8_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 4a4e86dc175542bbf0bc29c9a957c5dfec834f93 */ + * Stub hash: 1c1a73f6a4de5fa2ca9595125822d65bc4f5fc55 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_define_by_name, 0, 3, _IS_BOOL, 0) ZEND_ARG_INFO(0, statement_resource) @@ -30,13 +30,13 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_bind_array_by_name, 0, 4, _I ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_free_descriptor, 0, 1, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_END_ARG_INFO() #define arginfo_ocifreedesc arginfo_oci_free_descriptor ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_lob_save, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, offset, IS_LONG, 0, "0") ZEND_END_ARG_INFO() @@ -44,33 +44,33 @@ ZEND_END_ARG_INFO() #define arginfo_ocisavelob arginfo_oci_lob_save ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_lob_import, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) ZEND_END_ARG_INFO() #define arginfo_ocisavelobfile arginfo_oci_lob_import ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_oci_lob_load, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_END_ARG_INFO() #define arginfo_ociloadlob arginfo_oci_lob_load ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_oci_lob_read, 0, 2, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) ZEND_END_ARG_INFO() #define arginfo_oci_lob_eof arginfo_oci_free_descriptor ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_oci_lob_tell, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_END_ARG_INFO() #define arginfo_oci_lob_rewind arginfo_oci_free_descriptor ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_lob_seek, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, whence, IS_LONG, 0, "OCI_SEEK_SET") ZEND_END_ARG_INFO() @@ -78,52 +78,52 @@ ZEND_END_ARG_INFO() #define arginfo_oci_lob_size arginfo_oci_lob_tell ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_oci_lob_write, 0, 2, MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_lob_append, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor_to, OCI_Lob, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor_from, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor_to, OCILob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor_from, OCILob, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_lob_truncate, 0, 1, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 0, "0") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_oci_lob_erase, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_lob_flush, 0, 1, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flag, IS_LONG, 0, "0") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ocisetbufferinglob, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_ARG_TYPE_INFO(0, mode, _IS_BOOL, 0) ZEND_END_ARG_INFO() #define arginfo_ocigetbufferinglob arginfo_oci_free_descriptor ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_lob_copy, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor_to, OCI_Lob, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor_from, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor_to, OCILob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor_from, OCILob, 0) ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_lob_is_equal, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor_first, OCI_Lob, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor_second, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor_first, OCILob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor_second, OCILob, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_lob_export, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCI_Lob, 0) + ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0) ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, start, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) @@ -131,7 +131,7 @@ ZEND_END_ARG_INFO() #define arginfo_ociwritelobtofile arginfo_oci_lob_export -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_oci_new_descriptor, 0, 1, OCI_Lob, 1) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_oci_new_descriptor, 0, 1, OCILob, 1) ZEND_ARG_INFO(0, connection_resource) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_LONG, 0, "OCI_DTYPE_LOB") ZEND_END_ARG_INFO() @@ -374,32 +374,32 @@ ZEND_END_ARG_INFO() #define arginfo_ocirowcount arginfo_oci_num_rows ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_free_collection, 0, 1, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, collection, OCI_Collection, 0) + ZEND_ARG_OBJ_INFO(0, collection, OCICollection, 0) ZEND_END_ARG_INFO() #define arginfo_ocifreecollection arginfo_oci_free_collection ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_collection_append, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, collection, OCI_Collection, 0) + ZEND_ARG_OBJ_INFO(0, collection, OCICollection, 0) ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) ZEND_END_ARG_INFO() #define arginfo_ocicollappend arginfo_oci_collection_append ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_oci_collection_element_get, 0, 2, MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_NULL|MAY_BE_FALSE) - ZEND_ARG_OBJ_INFO(0, collection, OCI_Collection, 0) + ZEND_ARG_OBJ_INFO(0, collection, OCICollection, 0) ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) ZEND_END_ARG_INFO() #define arginfo_ocicollgetelem arginfo_oci_collection_element_get ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_collection_assign, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, collection_to, OCI_Collection, 0) - ZEND_ARG_OBJ_INFO(0, collection_from, OCI_Collection, 0) + ZEND_ARG_OBJ_INFO(0, collection_to, OCICollection, 0) + ZEND_ARG_OBJ_INFO(0, collection_from, OCICollection, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_collection_element_assign, 0, 3, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, collection, OCI_Collection, 0) + ZEND_ARG_OBJ_INFO(0, collection, OCICollection, 0) ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) ZEND_END_ARG_INFO() @@ -407,7 +407,7 @@ ZEND_END_ARG_INFO() #define arginfo_ocicollassignelem arginfo_oci_collection_element_assign ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_oci_collection_size, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_OBJ_INFO(0, collection, OCI_Collection, 0) + ZEND_ARG_OBJ_INFO(0, collection, OCICollection, 0) ZEND_END_ARG_INFO() #define arginfo_ocicollsize arginfo_oci_collection_size @@ -417,13 +417,13 @@ ZEND_END_ARG_INFO() #define arginfo_ocicollmax arginfo_oci_collection_size ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_collection_trim, 0, 2, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, collection, OCI_Collection, 0) + ZEND_ARG_OBJ_INFO(0, collection, OCICollection, 0) ZEND_ARG_TYPE_INFO(0, number, IS_LONG, 0) ZEND_END_ARG_INFO() #define arginfo_ocicolltrim arginfo_oci_collection_trim -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_oci_new_collection, 0, 2, OCI_Collection, MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_oci_new_collection, 0, 2, OCICollection, MAY_BE_FALSE) ZEND_ARG_INFO(0, connection_resource) ZEND_ARG_TYPE_INFO(0, type_name, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, schema_name, IS_STRING, 0) @@ -438,106 +438,106 @@ ZEND_END_ARG_INFO() #define arginfo_oci_unregister_taf_callback arginfo_oci_rollback -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_save, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_save, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, offset, IS_LONG, 0, "0") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_import, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_import, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) ZEND_END_ARG_INFO() -#define arginfo_class_OCI_Lob_savefile arginfo_class_OCI_Lob_import +#define arginfo_class_OCILob_savefile arginfo_class_OCILob_import -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_load, 0, 0, 0) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_load, 0, 0, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_read, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_read, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) ZEND_END_ARG_INFO() -#define arginfo_class_OCI_Lob_eof arginfo_class_OCI_Lob_load +#define arginfo_class_OCILob_eof arginfo_class_OCILob_load -#define arginfo_class_OCI_Lob_tell arginfo_class_OCI_Lob_load +#define arginfo_class_OCILob_tell arginfo_class_OCILob_load -#define arginfo_class_OCI_Lob_rewind arginfo_class_OCI_Lob_load +#define arginfo_class_OCILob_rewind arginfo_class_OCILob_load -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_seek, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_seek, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, whence, IS_LONG, 0, "OCI_SEEK_SET") ZEND_END_ARG_INFO() -#define arginfo_class_OCI_Lob_size arginfo_class_OCI_Lob_load +#define arginfo_class_OCILob_size arginfo_class_OCILob_load -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_write, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_write, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_append, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, lob_descriptor_from, OCI_Lob, 0) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_append, 0, 0, 1) + ZEND_ARG_OBJ_INFO(0, lob_descriptor_from, OCILob, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_truncate, 0, 0, 0) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_truncate, 0, 0, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 0, "0") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_erase, 0, 0, 0) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_erase, 0, 0, 0) ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_OCI_Lob_flush, 0, 0, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_OCILob_flush, 0, 0, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flag, IS_LONG, 0, "0") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_setbuffering, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_setbuffering, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, mode, _IS_BOOL, 0) ZEND_END_ARG_INFO() -#define arginfo_class_OCI_Lob_getbuffering arginfo_class_OCI_Lob_load +#define arginfo_class_OCILob_getbuffering arginfo_class_OCILob_load -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_writetofile, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_writetofile, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, start, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0) ZEND_END_ARG_INFO() -#define arginfo_class_OCI_Lob_export arginfo_class_OCI_Lob_writetofile +#define arginfo_class_OCILob_export arginfo_class_OCILob_writetofile -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Lob_writetemporary, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_writetemporary, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_LONG, 0, "OCI_TEMP_CLOB") ZEND_END_ARG_INFO() -#define arginfo_class_OCI_Lob_close arginfo_class_OCI_Lob_load +#define arginfo_class_OCILob_close arginfo_class_OCILob_load -#define arginfo_class_OCI_Lob_free arginfo_class_OCI_Lob_load +#define arginfo_class_OCILob_free arginfo_class_OCILob_load -#define arginfo_class_OCI_Collection_free arginfo_class_OCI_Lob_load +#define arginfo_class_OCICollection_free arginfo_class_OCILob_load -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Collection_append, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCICollection_append, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Collection_getElem, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCICollection_getElem, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Collection_assign, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, collection_from, OCI_Collection, 0) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCICollection_assign, 0, 0, 1) + ZEND_ARG_OBJ_INFO(0, collection_from, OCICollection, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Collection_assignelem, 0, 0, 2) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCICollection_assignelem, 0, 0, 2) ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) ZEND_END_ARG_INFO() -#define arginfo_class_OCI_Collection_size arginfo_class_OCI_Lob_load +#define arginfo_class_OCICollection_size arginfo_class_OCILob_load -#define arginfo_class_OCI_Collection_max arginfo_class_OCI_Lob_load +#define arginfo_class_OCICollection_max arginfo_class_OCILob_load -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCI_Collection_trim, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCICollection_trim, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, number, IS_LONG, 0) ZEND_END_ARG_INFO() @@ -751,41 +751,41 @@ static const zend_function_entry ext_functions[] = { }; -static const zend_function_entry class_OCI_Lob_methods[] = { - ZEND_ME_MAPPING(save, oci_lob_save, arginfo_class_OCI_Lob_save, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(import, oci_lob_import, arginfo_class_OCI_Lob_import, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(savefile, oci_lob_import, arginfo_class_OCI_Lob_savefile, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(load, oci_lob_load, arginfo_class_OCI_Lob_load, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(read, oci_lob_read, arginfo_class_OCI_Lob_read, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(eof, oci_lob_eof, arginfo_class_OCI_Lob_eof, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(tell, oci_lob_tell, arginfo_class_OCI_Lob_tell, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(rewind, oci_lob_rewind, arginfo_class_OCI_Lob_rewind, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(seek, oci_lob_seek, arginfo_class_OCI_Lob_seek, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(size, oci_lob_size, arginfo_class_OCI_Lob_size, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(write, oci_lob_write, arginfo_class_OCI_Lob_write, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(append, oci_lob_append, arginfo_class_OCI_Lob_append, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(truncate, oci_lob_truncate, arginfo_class_OCI_Lob_truncate, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(erase, oci_lob_erase, arginfo_class_OCI_Lob_erase, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(flush, oci_lob_flush, arginfo_class_OCI_Lob_flush, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(setbuffering, ocisetbufferinglob, arginfo_class_OCI_Lob_setbuffering, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(getbuffering, ocigetbufferinglob, arginfo_class_OCI_Lob_getbuffering, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(writetofile, oci_lob_export, arginfo_class_OCI_Lob_writetofile, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(export, oci_lob_export, arginfo_class_OCI_Lob_export, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(writetemporary, oci_lob_write_temporary, arginfo_class_OCI_Lob_writetemporary, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(close, oci_lob_close, arginfo_class_OCI_Lob_close, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(free, oci_free_descriptor, arginfo_class_OCI_Lob_free, ZEND_ACC_PUBLIC) +static const zend_function_entry class_OCILob_methods[] = { + ZEND_ME_MAPPING(save, oci_lob_save, arginfo_class_OCILob_save, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(import, oci_lob_import, arginfo_class_OCILob_import, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(savefile, oci_lob_import, arginfo_class_OCILob_savefile, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(load, oci_lob_load, arginfo_class_OCILob_load, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(read, oci_lob_read, arginfo_class_OCILob_read, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(eof, oci_lob_eof, arginfo_class_OCILob_eof, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(tell, oci_lob_tell, arginfo_class_OCILob_tell, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(rewind, oci_lob_rewind, arginfo_class_OCILob_rewind, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(seek, oci_lob_seek, arginfo_class_OCILob_seek, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(size, oci_lob_size, arginfo_class_OCILob_size, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(write, oci_lob_write, arginfo_class_OCILob_write, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(append, oci_lob_append, arginfo_class_OCILob_append, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(truncate, oci_lob_truncate, arginfo_class_OCILob_truncate, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(erase, oci_lob_erase, arginfo_class_OCILob_erase, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(flush, oci_lob_flush, arginfo_class_OCILob_flush, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(setbuffering, ocisetbufferinglob, arginfo_class_OCILob_setbuffering, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(getbuffering, ocigetbufferinglob, arginfo_class_OCILob_getbuffering, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(writetofile, oci_lob_export, arginfo_class_OCILob_writetofile, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(export, oci_lob_export, arginfo_class_OCILob_export, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(writetemporary, oci_lob_write_temporary, arginfo_class_OCILob_writetemporary, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(close, oci_lob_close, arginfo_class_OCILob_close, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(free, oci_free_descriptor, arginfo_class_OCILob_free, ZEND_ACC_PUBLIC) ZEND_FE_END }; -static const zend_function_entry class_OCI_Collection_methods[] = { - ZEND_ME_MAPPING(free, oci_free_collection, arginfo_class_OCI_Collection_free, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(append, oci_collection_append, arginfo_class_OCI_Collection_append, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(getElem, oci_collection_element_get, arginfo_class_OCI_Collection_getElem, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(assign, oci_collection_assign, arginfo_class_OCI_Collection_assign, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(assignelem, oci_collection_element_assign, arginfo_class_OCI_Collection_assignelem, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(size, oci_collection_size, arginfo_class_OCI_Collection_size, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(max, oci_collection_max, arginfo_class_OCI_Collection_max, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(trim, oci_collection_trim, arginfo_class_OCI_Collection_trim, ZEND_ACC_PUBLIC) +static const zend_function_entry class_OCICollection_methods[] = { + ZEND_ME_MAPPING(free, oci_free_collection, arginfo_class_OCICollection_free, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(append, oci_collection_append, arginfo_class_OCICollection_append, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(getElem, oci_collection_element_get, arginfo_class_OCICollection_getElem, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(assign, oci_collection_assign, arginfo_class_OCICollection_assign, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(assignelem, oci_collection_element_assign, arginfo_class_OCICollection_assignelem, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(size, oci_collection_size, arginfo_class_OCICollection_size, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(max, oci_collection_max, arginfo_class_OCICollection_max, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(trim, oci_collection_trim, arginfo_class_OCICollection_trim, ZEND_ACC_PUBLIC) ZEND_FE_END }; diff --git a/ext/oci8/oci8_failover.c b/ext/oci8/oci8_failover.c index 1d9c4e58cf11b..5bbf0108e7fa7 100644 --- a/ext/oci8/oci8_failover.c +++ b/ext/oci8/oci8_failover.c @@ -69,7 +69,7 @@ sb4 callback_fn(void *svchp, void *envhp, void *fo_ctx, ub4 fo_type, ub4 fo_even returnValue = (sb4) Z_LVAL(retval); } - /* Setting params[0] to null so resource isn't destroyed on zval_dtor */ + /* Setting params[0] to null so resource isn't destroyed on zval_ptr_dtor */ ZVAL_NULL(¶ms[0]); /* Cleanup */ diff --git a/ext/oci8/package.xml b/ext/oci8/package.xml index 930ccb25802fb..eb6007dca9feb 100644 --- a/ext/oci8/package.xml +++ b/ext/oci8/package.xml @@ -72,9 +72,9 @@ Oracle's standard cross-version connectivity applies. For example, PHP OCI8 lin Removed obsolete no-op function oci_internal_debug(). (Jens de Nies) - The OCI-Lob class is now called OCI_Lob. + The OCI-Lob class is now called OCILob for standards compliance. - The OCI-Collection calls is now called OCI_Collection. + The OCI-Collection class is now called OCICollection for standards compliance. Generate arginfo from function stubs. (Jens de Nies) diff --git a/ext/oci8/tests/bug35973.phpt b/ext/oci8/tests/bug35973.phpt index 2eec32db837b8..53c43d41d5070 100644 --- a/ext/oci8/tests/bug35973.phpt +++ b/ext/oci8/tests/bug35973.phpt @@ -36,7 +36,7 @@ echo "Done\n"; --EXPECTF-- array(1) { ["NC"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/bug44008.phpt b/ext/oci8/tests/bug44008.phpt index d8120325cfcc2..d3b9cafdd41a5 100644 --- a/ext/oci8/tests/bug44008.phpt +++ b/ext/oci8/tests/bug44008.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug #44008 (Incorrect usage of OCI_Lob->close crashes PHP) +Bug #44008 (Incorrect usage of OCILob->close crashes PHP) --SKIPIF-- true, 'timesten' => false); // test runs on these DBs @@ -30,7 +30,7 @@ $r = $textLob->load(); echo "$r\n"; // Incorrectly closing the lob doesn't cause a crash. -// OCI-LOB->close() is documented for use only with OCI_Lob->writeTemporary() +// OCI-LOB->close() is documented for use only with OCILob->writeTemporary() $textLob->close(); // Cleanup diff --git a/ext/oci8/tests/coll_001.phpt b/ext/oci8/tests/coll_001.phpt index fdf17f1647c10..f4863013d51bc 100644 --- a/ext/oci8/tests/coll_001.phpt +++ b/ext/oci8/tests/coll_001.phpt @@ -20,7 +20,7 @@ require __DIR__."/drop_type.inc"; ?> --EXPECTF-- -object(OCI_Collection)#%d (1) { +object(OCICollection)#%d (1) { ["collection"]=> resource(%d) of type (oci8 collection) } diff --git a/ext/oci8/tests/coll_002.phpt b/ext/oci8/tests/coll_002.phpt index d466e8ee29e0f..2eabc209150b6 100644 --- a/ext/oci8/tests/coll_002.phpt +++ b/ext/oci8/tests/coll_002.phpt @@ -28,12 +28,12 @@ require __DIR__."/drop_type.inc"; ?> --EXPECTF-- -object(OCI_Collection)#%d (1) { +object(OCICollection)#%d (1) { ["collection"]=> resource(%d) of type (oci8 collection) } bool(true) -string(%d) "OCI_Collection::size(): supplied resource is not a valid oci8 collection resource" +string(%d) "OCICollection::size(): supplied resource is not a valid oci8 collection resource" Warning: oci_new_collection(): OCI-22303: type ""."NONEXISTENT" not found in %s on line %d bool(false) diff --git a/ext/oci8/tests/coll_002_func.phpt b/ext/oci8/tests/coll_002_func.phpt index 1cd6070d76934..0e931ddd4d796 100644 --- a/ext/oci8/tests/coll_002_func.phpt +++ b/ext/oci8/tests/coll_002_func.phpt @@ -27,7 +27,7 @@ require __DIR__."/drop_type.inc"; ?> --EXPECTF-- -object(OCI_Collection)#%d (1) { +object(OCICollection)#%d (1) { ["collection"]=> resource(%d) of type (oci8 collection) } diff --git a/ext/oci8/tests/coll_003.phpt b/ext/oci8/tests/coll_003.phpt index 1d47681fe7d7e..1608ee81fed05 100644 --- a/ext/oci8/tests/coll_003.phpt +++ b/ext/oci8/tests/coll_003.phpt @@ -29,7 +29,7 @@ require __DIR__."/drop_type.inc"; int(0) int(0) -Warning: OCI_Collection::trim(): OCI-22167: given trim size [3] must be less than or equal to [0] in %s on line %d +Warning: OCICollection::trim(): OCI-22167: given trim size [3] must be less than or equal to [0] in %s on line %d bool(false) bool(true) float(1) diff --git a/ext/oci8/tests/coll_009.phpt b/ext/oci8/tests/coll_009.phpt index c293a8d64ff9b..6f00f6d9c56bd 100644 --- a/ext/oci8/tests/coll_009.phpt +++ b/ext/oci8/tests/coll_009.phpt @@ -38,7 +38,7 @@ require __DIR__."/drop_type.inc"; ?> --EXPECTF-- -Warning: OCI_Collection::append(): OCI-01861: literal does not match format string in %s on line %d +Warning: OCICollection::append(): OCI-01861: literal does not match format string in %s on line %d bool(false) bool(true) bool(false) diff --git a/ext/oci8/tests/coll_016.phpt b/ext/oci8/tests/coll_016.phpt index 5eab7d4d23fd5..342af18f10193 100644 --- a/ext/oci8/tests/coll_016.phpt +++ b/ext/oci8/tests/coll_016.phpt @@ -40,10 +40,10 @@ require __DIR__."/drop_type.inc"; --EXPECTF-- bool(true) -Warning: OCI_Collection::assignelem(): OCI-22165: given index [%d] must be in the range of %s to [0] in %s on line %d +Warning: OCICollection::assignelem(): OCI-22165: given index [%d] must be in the range of %s to [0] in %s on line %d bool(false) -Warning: OCI_Collection::assignelem(): OCI-22165: given index [5000] must be in the range of %s to [0] in %s on line %d +Warning: OCICollection::assignelem(): OCI-22165: given index [5000] must be in the range of %s to [0] in %s on line %d bool(false) bool(false) bool(false) diff --git a/ext/oci8/tests/coll_019.phpt b/ext/oci8/tests/coll_019.phpt index 64b2bc31d6823..be79e98aab800 100644 --- a/ext/oci8/tests/coll_019.phpt +++ b/ext/oci8/tests/coll_019.phpt @@ -75,33 +75,33 @@ echo "Done\n"; --EXPECTF-- Test 0 -Notice: OCI_Collection::append(): Unknown or unsupported type of element: 113 in %s on line %d +Notice: OCICollection::append(): Unknown or unsupported type of element: 113 in %s on line %d bool(false) -Notice: OCI_Collection::assignelem(): Unknown or unsupported type of element: 113 in %s on line %d +Notice: OCICollection::assignelem(): Unknown or unsupported type of element: 113 in %s on line %d bool(false) bool(false) Test 1 -Warning: OCI_Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d +Warning: OCICollection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d bool(false) bool(false) Test 2 -Warning: OCI_Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d +Warning: OCICollection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d bool(false) bool(false) Test 3 -Warning: OCI_Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d +Warning: OCICollection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d bool(false) bool(false) Test 4 -Warning: OCI_Collection::append(): OCI-01840: input value not long enough for date format in %s on line %d +Warning: OCICollection::append(): OCI-01840: input value not long enough for date format in %s on line %d bool(false) -Warning: OCI_Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d +Warning: OCICollection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d bool(false) bool(false) Done diff --git a/ext/oci8/tests/define3.phpt b/ext/oci8/tests/define3.phpt index 520748f3d8245..69fb5a48c11f7 100644 --- a/ext/oci8/tests/define3.phpt +++ b/ext/oci8/tests/define3.phpt @@ -89,12 +89,12 @@ string(32) "614fcbba1effb7caa27ef0ef25c27fcf" string(32) "06d4f219d946c74d748d43932cd9dcb2" Test 1 bool(true) -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } file md5:614fcbba1effb7caa27ef0ef25c27fcf -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/descriptors.phpt b/ext/oci8/tests/descriptors.phpt index 8a5b42e791e0c..6b1e47d7a9f47 100644 --- a/ext/oci8/tests/descriptors.phpt +++ b/ext/oci8/tests/descriptors.phpt @@ -44,7 +44,7 @@ echo "Done\n"; --EXPECTF-- array(1) { ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/fetch_object_2.phpt b/ext/oci8/tests/fetch_object_2.phpt index 27f558e4b08e9..fcf80fd853364 100644 --- a/ext/oci8/tests/fetch_object_2.phpt +++ b/ext/oci8/tests/fetch_object_2.phpt @@ -69,7 +69,7 @@ object(stdClass)#%d (3) { ["COL1"]=> string(3) "123" ["COL2"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -80,7 +80,7 @@ object(stdClass)#%d (3) { ["COL1"]=> string(3) "456" ["COL2"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -91,7 +91,7 @@ object(stdClass)#%d (3) { ["COL1"]=> string(3) "789" ["COL2"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_001.phpt b/ext/oci8/tests/lob_001.phpt index 51e8c07673203..c94f5201e790a 100644 Binary files a/ext/oci8/tests/lob_001.phpt and b/ext/oci8/tests/lob_001.phpt differ diff --git a/ext/oci8/tests/lob_002.phpt b/ext/oci8/tests/lob_002.phpt index 78b10f21e057b..a4714caceaaae 100644 --- a/ext/oci8/tests/lob_002.phpt +++ b/ext/oci8/tests/lob_002.phpt @@ -52,7 +52,7 @@ oci8_test_sql_execute($c, $stmtarray); ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_003.phpt b/ext/oci8/tests/lob_003.phpt index fef078a26f589..80bead5964bd2 100644 Binary files a/ext/oci8/tests/lob_003.phpt and b/ext/oci8/tests/lob_003.phpt differ diff --git a/ext/oci8/tests/lob_004.phpt b/ext/oci8/tests/lob_004.phpt index 4ff1a8b65ec26..ead1bc0e2ac8b 100644 --- a/ext/oci8/tests/lob_004.phpt +++ b/ext/oci8/tests/lob_004.phpt @@ -57,7 +57,7 @@ echo "Done\n"; ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -67,12 +67,12 @@ int(3) bool(true) array(2) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_005.phpt b/ext/oci8/tests/lob_005.phpt index 317c8d5be9ff8..9e656bea7a23a 100644 --- a/ext/oci8/tests/lob_005.phpt +++ b/ext/oci8/tests/lob_005.phpt @@ -41,12 +41,12 @@ echo "Done\n"; --EXPECTF-- array(2) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_006.phpt b/ext/oci8/tests/lob_006.phpt index 9f2c310fef582..748283870a21b 100644 Binary files a/ext/oci8/tests/lob_006.phpt and b/ext/oci8/tests/lob_006.phpt differ diff --git a/ext/oci8/tests/lob_007.phpt b/ext/oci8/tests/lob_007.phpt index fcf23472da6a6..3a3137ae03702 100644 --- a/ext/oci8/tests/lob_007.phpt +++ b/ext/oci8/tests/lob_007.phpt @@ -45,7 +45,7 @@ echo "Done\n"; ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -54,12 +54,12 @@ int(7000) int(7000) array(2) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_008.phpt b/ext/oci8/tests/lob_008.phpt index 87257224b8fb8..15b300df86cf2 100644 --- a/ext/oci8/tests/lob_008.phpt +++ b/ext/oci8/tests/lob_008.phpt @@ -47,19 +47,19 @@ echo "Done\n"; ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } int(7000) array(2) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_009.phpt b/ext/oci8/tests/lob_009.phpt index 872f94d4fa71d..5e0d2afaab49d 100644 --- a/ext/oci8/tests/lob_009.phpt +++ b/ext/oci8/tests/lob_009.phpt @@ -44,7 +44,7 @@ echo "Done\n"; ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -52,12 +52,12 @@ bool(true) bool(true) array(2) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_016.phpt b/ext/oci8/tests/lob_016.phpt index 757224e0a54dc..24000f36f90d7 100644 --- a/ext/oci8/tests/lob_016.phpt +++ b/ext/oci8/tests/lob_016.phpt @@ -55,12 +55,12 @@ echo "Done\n"; --EXPECTF-- array(2) { ["LOB_1"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["LOB_2"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_017.phpt b/ext/oci8/tests/lob_017.phpt index 8e656f809d5e0..15c336c9d7761 100644 --- a/ext/oci8/tests/lob_017.phpt +++ b/ext/oci8/tests/lob_017.phpt @@ -57,12 +57,12 @@ echo "Done\n"; --EXPECTF-- array(2) { ["LOB_1"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["LOB_2"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_019.phpt b/ext/oci8/tests/lob_019.phpt index b41167b4e3ed3..248bff70d59b1 100644 Binary files a/ext/oci8/tests/lob_019.phpt and b/ext/oci8/tests/lob_019.phpt differ diff --git a/ext/oci8/tests/lob_020.phpt b/ext/oci8/tests/lob_020.phpt index 01db85a01fae3..affdef912634d 100644 Binary files a/ext/oci8/tests/lob_020.phpt and b/ext/oci8/tests/lob_020.phpt differ diff --git a/ext/oci8/tests/lob_021.phpt b/ext/oci8/tests/lob_021.phpt index 49dc1a7a9506c..0833715569a40 100644 --- a/ext/oci8/tests/lob_021.phpt +++ b/ext/oci8/tests/lob_021.phpt @@ -62,7 +62,7 @@ int(4) bool(true) int(4) bool(true) -string(%d) "OCI_Lob::write(): %s is not a valid oci8 descriptor resource" +string(%d) "OCILob::write(): %s is not a valid oci8 descriptor resource" string(%d) "oci_free_descriptor(): %s is not a valid oci8 descriptor resource" Warning: oci_free_descriptor(): Unable to find descriptor property in %s on line %d diff --git a/ext/oci8/tests/lob_022.phpt b/ext/oci8/tests/lob_022.phpt index 768dbe7ebfdb6..dba5adcbe36cd 100644 --- a/ext/oci8/tests/lob_022.phpt +++ b/ext/oci8/tests/lob_022.phpt @@ -67,7 +67,7 @@ echo "Done\n"; ?> --EXPECTF-- -Warning: OCI_Lob::save(): Offset parameter must be greater than or equal to 0 in %s on line %d +Warning: OCILob::save(): Offset parameter must be greater than or equal to 0 in %s on line %d string(4) "data" string(9) "long data" string(9) "long data" diff --git a/ext/oci8/tests/lob_023.phpt b/ext/oci8/tests/lob_023.phpt index 6eb1b85ac9af1..1c45e8d8d801a 100644 --- a/ext/oci8/tests/lob_023.phpt +++ b/ext/oci8/tests/lob_023.phpt @@ -47,7 +47,7 @@ echo "Done\n"; ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -59,12 +59,12 @@ Warning: oci_lob_import(): Unable to find descriptor property in %s on line %d bool(false) array(2) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_024.phpt b/ext/oci8/tests/lob_024.phpt index 4ce0154c6450f..b4c44d6b7217e 100644 --- a/ext/oci8/tests/lob_024.phpt +++ b/ext/oci8/tests/lob_024.phpt @@ -47,7 +47,7 @@ echo "Done\n"; ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -56,12 +56,12 @@ int(7000) int(7000) array(2) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_025.phpt b/ext/oci8/tests/lob_025.phpt index f4ee78c11b833..897e3c73742ad 100644 --- a/ext/oci8/tests/lob_025.phpt +++ b/ext/oci8/tests/lob_025.phpt @@ -52,12 +52,12 @@ int(7000) int(7000) array(2) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_026.phpt b/ext/oci8/tests/lob_026.phpt index e1c624124a42b..ee52a9c816f0f 100644 --- a/ext/oci8/tests/lob_026.phpt +++ b/ext/oci8/tests/lob_026.phpt @@ -56,7 +56,7 @@ echo "Done\n"; ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -66,12 +66,12 @@ int(3) bool(true) array(2) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_027.phpt b/ext/oci8/tests/lob_027.phpt index d3639ca2e4512..05390d1403df0 100644 --- a/ext/oci8/tests/lob_027.phpt +++ b/ext/oci8/tests/lob_027.phpt @@ -67,19 +67,19 @@ echo "Done\n"; ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } int(72) array(2) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } ["BLOB"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -96,11 +96,11 @@ string(10) "this is a " bool(true) string(0) "" -Warning: OCI_Lob::truncate(): Length must be greater than or equal to zero in %s on line %d +Warning: OCILob::truncate(): Length must be greater than or equal to zero in %s on line %d bool(false) string(0) "" -Warning: OCI_Lob::truncate(): Length must be greater than or equal to zero in %s on line %d +Warning: OCILob::truncate(): Length must be greater than or equal to zero in %s on line %d bool(false) bool(true) Done diff --git a/ext/oci8/tests/lob_028.phpt b/ext/oci8/tests/lob_028.phpt index b81c8179eb3ca..9d05f8c712365 100644 --- a/ext/oci8/tests/lob_028.phpt +++ b/ext/oci8/tests/lob_028.phpt @@ -48,27 +48,27 @@ echo "Done\n"; ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_032.phpt b/ext/oci8/tests/lob_032.phpt index ff1a7c840769d..6b66ae9cbe6c5 100644 --- a/ext/oci8/tests/lob_032.phpt +++ b/ext/oci8/tests/lob_032.phpt @@ -32,5 +32,5 @@ echo "Done\n"; ?> --EXPECTF-- -Warning: OCI_Lob::write(): ORA-22990: %s in %s on line 19 +Warning: OCILob::write(): ORA-22990: %s in %s on line 19 Done diff --git a/ext/oci8/tests/lob_033.phpt b/ext/oci8/tests/lob_033.phpt index 82fa51b6cf476..35f0f1275ebd0 100644 --- a/ext/oci8/tests/lob_033.phpt +++ b/ext/oci8/tests/lob_033.phpt @@ -35,7 +35,7 @@ echo "Done\n"; ?> --EXPECTF-- -Warning: OCI_Lob::save(): OCI_INVALID_HANDLE in %s on line %d +Warning: OCILob::save(): OCI_INVALID_HANDLE in %s on line %d bool(true) bool(true) Done diff --git a/ext/oci8/tests/lob_034.phpt b/ext/oci8/tests/lob_034.phpt index 511750eaf558f..b19b38dac71cb 100644 --- a/ext/oci8/tests/lob_034.phpt +++ b/ext/oci8/tests/lob_034.phpt @@ -48,6 +48,6 @@ bool(true) bool(true) bool(true) -Warning: OCI_Lob::flush(): Invalid flag value: -1 in %s on line %d +Warning: OCILob::flush(): Invalid flag value: -1 in %s on line %d bool(false) Done diff --git a/ext/oci8/tests/lob_038.phpt b/ext/oci8/tests/lob_038.phpt index 924e776200547..1ea912df92798 100644 --- a/ext/oci8/tests/lob_038.phpt +++ b/ext/oci8/tests/lob_038.phpt @@ -125,7 +125,7 @@ Test 1b bool(true) array(1) { ["CLOB"]=> - object(OCI_Lob)#2 (1) { + object(OCILob)#2 (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -133,7 +133,7 @@ array(1) { string(11) "clob test 1" array(1) { ["CLOB"]=> - object(OCI_Lob)#3 (1) { + object(OCILob)#3 (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -141,7 +141,7 @@ array(1) { string(11) "clob test 2" array(1) { ["CLOB"]=> - object(OCI_Lob)#2 (1) { + object(OCILob)#2 (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -167,7 +167,7 @@ Test 2b bool(true) array(1) { ["BLOB"]=> - object(OCI_Lob)#3 (1) { + object(OCILob)#3 (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -175,7 +175,7 @@ array(1) { string(11) "blob test 1" array(1) { ["BLOB"]=> - object(OCI_Lob)#4 (1) { + object(OCILob)#4 (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } @@ -183,7 +183,7 @@ array(1) { string(11) "blob test 2" array(1) { ["BLOB"]=> - object(OCI_Lob)#3 (1) { + object(OCILob)#3 (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_041.phpt b/ext/oci8/tests/lob_041.phpt index a81fc56da8c60..cc15989a2e0a2 100644 --- a/ext/oci8/tests/lob_041.phpt +++ b/ext/oci8/tests/lob_041.phpt @@ -69,7 +69,7 @@ test data Test 2 - implicit statement close test data -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (Unknown) } @@ -78,7 +78,7 @@ Test 3 - no preallocated descriptor test data array(1) { ["C1"]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/oci8/tests/lob_042.phpt b/ext/oci8/tests/lob_042.phpt index e0393eeafb2a0..eb447f22afd80 100644 --- a/ext/oci8/tests/lob_042.phpt +++ b/ext/oci8/tests/lob_042.phpt @@ -44,29 +44,29 @@ echo "Done\n"; ?> --EXPECTF-- -object(OCI_Lob)#%d (1) { +object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } -Warning: OCI_Lob::writetemporary(): Invalid temporary lob type: %d in %s on line %d +Warning: OCILob::writetemporary(): Invalid temporary lob type: %d in %s on line %d bool(false) int(6) bool(true) bool(true) -Warning: OCI_Lob::truncate(): Size must be less than or equal to the current LOB size in %s on line %d +Warning: OCILob::truncate(): Size must be less than or equal to the current LOB size in %s on line %d bool(false) -Warning: OCI_Lob::truncate(): Length must be greater than or equal to zero in %s on line %d +Warning: OCILob::truncate(): Length must be greater than or equal to zero in %s on line %d bool(false) -Warning: OCI_Lob::read(): Offset must be less than size of the LOB in %s on line %d +Warning: OCILob::read(): Offset must be less than size of the LOB in %s on line %d bool(false) -Warning: OCI_Lob::import(): Can't open file %s in %s on line %d +Warning: OCILob::import(): Can't open file %s in %s on line %d bool(false) -Warning: OCI_Lob::savefile(): Can't open file %s in %s on line %d +Warning: OCILob::savefile(): Can't open file %s in %s on line %d bool(false) Done diff --git a/ext/oci8/tests/null_byte_1.phpt b/ext/oci8/tests/null_byte_1.phpt index 50cc9fb5d65cb..06abe04957a29 100644 --- a/ext/oci8/tests/null_byte_1.phpt +++ b/ext/oci8/tests/null_byte_1.phpt @@ -35,9 +35,9 @@ var_dump($r); --EXPECTF-- Test 1: Import -Warning: OCI_Lob::savefile(): Argument #1 ($function) must be a valid path, string given in %snull_byte_1.php on line %d +Warning: OCILob::savefile(): Argument #1 ($function) must be a valid path, string given in %snull_byte_1.php on line %d NULL Test 2: Export -Warning: OCI_Lob::export(): Argument #1 ($function) must be a valid path, string given in %snull_byte_1.php on line %d +Warning: OCILob::export(): Argument #1 ($function) must be a valid path, string given in %snull_byte_1.php on line %d NULL diff --git a/ext/oci8/tests/xmltype_02.phpt b/ext/oci8/tests/xmltype_02.phpt index 6294c1783126b..962c4c5697433 100644 --- a/ext/oci8/tests/xmltype_02.phpt +++ b/ext/oci8/tests/xmltype_02.phpt @@ -111,7 +111,7 @@ oci8_test_sql_execute($c, $stmtarray); Test 1 Insert new XML data using a temporary CLOB array(1) { [0]=> - object(OCI_Lob)#%d (1) { + object(OCILob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) } diff --git a/ext/opcache/Optimizer/sccp.c b/ext/opcache/Optimizer/sccp.c index 1615423abe017..d0dffc275da3e 100644 --- a/ext/opcache/Optimizer/sccp.c +++ b/ext/opcache/Optimizer/sccp.c @@ -788,7 +788,7 @@ static inline int ct_eval_func_call( uint32_t i; zend_execute_data *execute_data, *prev_execute_data; zend_function *func; - int overflow; + bool overflow; if (num_args == 0) { if (zend_string_equals_literal(name, "php_sapi_name") diff --git a/ext/opcache/Optimizer/zend_dump.c b/ext/opcache/Optimizer/zend_dump.c index 51dcc2076cf43..f6d9bd519a505 100644 --- a/ext/opcache/Optimizer/zend_dump.c +++ b/ext/opcache/Optimizer/zend_dump.c @@ -234,7 +234,8 @@ static void zend_dump_type_info(uint32_t info, zend_class_entry *ce, int is_inst if (first) first = 0; else fprintf(stderr, ", "); fprintf(stderr, "array"); if ((info & MAY_BE_ARRAY_KEY_ANY) != 0 && - (info & MAY_BE_ARRAY_KEY_ANY) != MAY_BE_ARRAY_KEY_ANY) { + ((info & MAY_BE_ARRAY_KEY_LONG) == 0 || + (info & MAY_BE_ARRAY_KEY_STRING) == 0)) { int afirst = 1; fprintf(stderr, " ["); if (info & MAY_BE_ARRAY_KEY_LONG) { diff --git a/ext/opcache/Optimizer/zend_func_info.c b/ext/opcache/Optimizer/zend_func_info.c index 47c4af5115c45..a387942919cb6 100644 --- a/ext/opcache/Optimizer/zend_func_info.c +++ b/ext/opcache/Optimizer/zend_func_info.c @@ -64,7 +64,7 @@ static uint32_t zend_range_info(const zend_call_info *call_info, const zend_ssa uint32_t t2 = _ssa_op1_info(op_array, ssa, call_info->arg_info[1].opline, &ssa->ops[call_info->arg_info[1].opline - op_array->opcodes]); uint32_t t3 = 0; - uint32_t tmp = MAY_BE_RC1 | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG; + uint32_t tmp = MAY_BE_RC1 | MAY_BE_ARRAY | MAY_BE_ARRAY_PACKED; if (call_info->num_args == 3) { t3 = _ssa_op1_info(op_array, ssa, call_info->arg_info[2].opline, @@ -86,7 +86,7 @@ static uint32_t zend_range_info(const zend_call_info *call_info, const zend_ssa return tmp; } else { /* May throw */ - return MAY_BE_RC1 | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_DOUBLE | MAY_BE_ARRAY_OF_STRING; + return MAY_BE_RC1 | MAY_BE_ARRAY | MAY_BE_ARRAY_PACKED | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_DOUBLE | MAY_BE_ARRAY_OF_STRING; } } diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c index ab8b751acc461..9a66c91d64cb9 100644 --- a/ext/opcache/Optimizer/zend_inference.c +++ b/ext/opcache/Optimizer/zend_inference.c @@ -2454,7 +2454,7 @@ static zend_always_inline int _zend_update_type_info( if (t1 & MAY_BE_OBJECT) { tmp |= MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF; } else { - tmp |= ((t1 & MAY_BE_ANY) << MAY_BE_ARRAY_SHIFT) | ((t1 & MAY_BE_ANY)? MAY_BE_ARRAY_KEY_LONG : 0); + tmp |= ((t1 & MAY_BE_ANY) << MAY_BE_ARRAY_SHIFT) | ((t1 & MAY_BE_ANY) ? MAY_BE_ARRAY_PACKED : 0); } } UPDATE_SSA_TYPE(tmp, ssa_op->result_def); @@ -3474,7 +3474,7 @@ static zend_always_inline int _zend_update_type_info( UPDATE_SSA_TYPE(MAY_BE_LONG, ssa_op->result_def); break; case ZEND_FUNC_GET_ARGS: - UPDATE_SSA_TYPE(MAY_BE_RC1|MAY_BE_RCN| MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY, ssa_op->result_def); + UPDATE_SSA_TYPE(MAY_BE_RC1|MAY_BE_RCN| MAY_BE_ARRAY | MAY_BE_ARRAY_PACKED | MAY_BE_ARRAY_OF_ANY, ssa_op->result_def); break; case ZEND_GET_CLASS: case ZEND_GET_CALLED_CLASS: diff --git a/ext/opcache/Optimizer/zend_inference.h b/ext/opcache/Optimizer/zend_inference.h index 3d8a0a0dcf169..2bd120c882fbe 100644 --- a/ext/opcache/Optimizer/zend_inference.h +++ b/ext/opcache/Optimizer/zend_inference.h @@ -26,7 +26,7 @@ /* Bitmask for type inference (zend_ssa_var_info.type) */ #include "zend_type_info.h" -#define AVOID_REFCOUNTING (1<<26) /* avoid reference counting */ +#define MAY_BE_PACKED_GUARD (1<<27) /* needs packed array guard */ #define MAY_BE_CLASS_GUARD (1<<27) /* needs class guard */ #define MAY_BE_GUARD (1<<28) /* needs type guard */ #define MAY_BE_IN_REG (1<<29) /* value allocated in CPU register */ @@ -179,6 +179,9 @@ static zend_always_inline uint32_t _const_op_type(const zval *zv) { } tmp |= 1 << (Z_TYPE_P(val) + MAY_BE_ARRAY_SHIFT); } ZEND_HASH_FOREACH_END(); + if (HT_IS_PACKED(ht)) { + tmp &= ~MAY_BE_ARRAY_HASH; + } return tmp; } else { uint32_t tmp = (1 << Z_TYPE_P(zv)); diff --git a/ext/opcache/Optimizer/zend_ssa.h b/ext/opcache/Optimizer/zend_ssa.h index 7d065ac42ab42..e7190da3f8ddb 100644 --- a/ext/opcache/Optimizer/zend_ssa.h +++ b/ext/opcache/Optimizer/zend_ssa.h @@ -128,6 +128,7 @@ typedef struct _zend_ssa_var_info { unsigned int recursive : 1; unsigned int use_as_double : 1; unsigned int delayed_fetch_this : 1; + unsigned int avoid_refcounting : 1; } zend_ssa_var_info; typedef struct _zend_ssa { diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index a8187f0e905ce..9ee1a5b5d7243 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -119,15 +119,15 @@ zend_bool fallback_process = 0; /* process uses file cache fallback */ #endif static zend_op_array *(*accelerator_orig_compile_file)(zend_file_handle *file_handle, int type); -static int (*accelerator_orig_zend_stream_open_function)(const char *filename, zend_file_handle *handle ); +static zend_result (*accelerator_orig_zend_stream_open_function)(const char *filename, zend_file_handle *handle ); static zend_string *(*accelerator_orig_zend_resolve_path)(const char *filename, size_t filename_len); static void (*accelerator_orig_zend_error_cb)(int type, const char *error_filename, const uint32_t error_lineno, zend_string *message); static zif_handler orig_chdir = NULL; static ZEND_INI_MH((*orig_include_path_on_modify)) = NULL; -static int (*orig_post_startup_cb)(void); +static zend_result (*orig_post_startup_cb)(void); static void accel_gen_system_id(void); -static int accel_post_startup(void); +static zend_result accel_post_startup(void); static int accel_finish_startup(void); static void preload_shutdown(void); @@ -304,7 +304,7 @@ static inline int accel_restart_is_active(void) } /* Creates a read lock for SHM access */ -static inline int accel_activate_add(void) +static inline zend_result accel_activate_add(void) { #ifdef ZEND_WIN32 SHM_UNPROTECT(); @@ -493,7 +493,7 @@ zend_string* ZEND_FASTCALL accel_new_interned_string(zend_string *str) } while (pos != STRTAB_INVALID_POS); } - if (UNEXPECTED(ZCSG(interned_strings).end - ZCSG(interned_strings).top < STRTAB_STR_SIZE(str))) { + if (UNEXPECTED((char*)ZCSG(interned_strings).end - (char*)ZCSG(interned_strings).top < STRTAB_STR_SIZE(str))) { /* no memory, return the same non-interned string */ zend_accel_error(ACCEL_LOG_WARNING, "Interned string buffer overflow"); return str; @@ -551,7 +551,7 @@ static zend_always_inline zend_string *accel_find_interned_string_ex(zend_ulong return NULL; } -static zend_string* ZEND_FASTCALL accel_init_interned_string_for_php(const char *str, size_t size, int permanent) +static zend_string* ZEND_FASTCALL accel_init_interned_string_for_php(const char *str, size_t size, bool permanent) { if (ZCG(counted)) { zend_ulong h = zend_inline_hash_func(str, size); @@ -2269,7 +2269,7 @@ static int accel_gen_uname_id(void) #endif /* zend_stream_open_function() replacement for PHP 5.3 and above */ -static int persistent_stream_open_function(const char *filename, zend_file_handle *handle) +static zend_result persistent_stream_open_function(const char *filename, zend_file_handle *handle) { if (ZCG(cache_persistent_script)) { /* check if callback is called from include_once or it's a main request */ @@ -2400,7 +2400,7 @@ static void accel_reset_pcre_cache(void) } ZEND_HASH_FOREACH_END(); } -int accel_activate(INIT_FUNC_ARGS) +zend_result accel_activate(INIT_FUNC_ARGS) { if (!ZCG(enabled) || !accel_startup_ok) { ZCG(accelerator_enabled) = 0; @@ -2963,13 +2963,13 @@ static int accel_startup(zend_extension *extension) return SUCCESS; } -static int accel_post_startup(void) +static zend_result accel_post_startup(void) { zend_function *func; zend_ini_entry *ini_entry; if (orig_post_startup_cb) { - int (*cb)(void) = orig_post_startup_cb; + zend_result (*cb)(void) = orig_post_startup_cb; orig_post_startup_cb = NULL; if (cb() != SUCCESS) { @@ -4368,7 +4368,7 @@ static void preload_load(void) } } -static int preload_autoload(zend_string *filename) +static zend_result preload_autoload(zend_string *filename) { zend_persistent_script *persistent_script; zend_op_array *op_array; diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h index 05a05fa1b68a4..0d6dda86a1256 100644 --- a/ext/opcache/ZendAccelerator.h +++ b/ext/opcache/ZendAccelerator.h @@ -316,7 +316,7 @@ extern zend_accel_globals accel_globals; extern char *zps_api_failure_reason; void accel_shutdown(void); -int accel_activate(INIT_FUNC_ARGS); +zend_result accel_activate(INIT_FUNC_ARGS); int accel_post_deactivate(void); void zend_accel_schedule_restart(zend_accel_restart_reason reason); void zend_accel_schedule_restart_if_necessary(zend_accel_restart_reason reason); diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index e2e85f3431904..5d1b2414a84da 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -116,7 +116,7 @@ static void ZEND_FASTCALL zend_runtime_jit(void); static int zend_jit_trace_op_len(const zend_op *opline); static int zend_jit_trace_may_exit(const zend_op_array *op_array, const zend_op *opline); -static uint32_t zend_jit_trace_get_exit_point(const zend_op *from_opline, const zend_op *to_opline, zend_jit_trace_rec *trace, uint32_t flags); +static uint32_t zend_jit_trace_get_exit_point(const zend_op *to_opline, uint32_t flags); static const void *zend_jit_trace_get_exit_addr(uint32_t n); static void zend_jit_trace_add_code(const void *start, uint32_t size); @@ -2165,23 +2165,17 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op || op_array->opcodes[ssa->cfg.blocks[b].start - 1].opcode == ZEND_SWITCH_LONG || op_array->opcodes[ssa->cfg.blocks[b].start - 1].opcode == ZEND_SWITCH_STRING || op_array->opcodes[ssa->cfg.blocks[b].start - 1].opcode == ZEND_MATCH)) { - if (!zend_jit_reset_opline(&dasm_state, op_array->opcodes + ssa->cfg.blocks[b].start) - || !zend_jit_set_valid_ip(&dasm_state, op_array->opcodes + ssa->cfg.blocks[b].start)) { + zend_jit_reset_opline(); + if (!zend_jit_set_valid_ip(&dasm_state, op_array->opcodes + ssa->cfg.blocks[b].start)) { goto jit_failure; } } else { - if (!zend_jit_set_opline(&dasm_state, op_array->opcodes + ssa->cfg.blocks[b].start)) { - goto jit_failure; - } + zend_jit_set_opline(op_array->opcodes + ssa->cfg.blocks[b].start); } } else if (ssa->cfg.blocks[b].flags & ZEND_BB_TARGET) { - if (!zend_jit_reset_opline(&dasm_state, op_array->opcodes + ssa->cfg.blocks[b].start)) { - goto jit_failure; - } + zend_jit_reset_opline(); } else if (ssa->cfg.blocks[b].flags & (ZEND_BB_START|ZEND_BB_RECV_ENTRY|ZEND_BB_ENTRY)) { - if (!zend_jit_set_opline(&dasm_state, op_array->opcodes + ssa->cfg.blocks[b].start)) { - goto jit_failure; - } + zend_jit_set_opline(op_array->opcodes + ssa->cfg.blocks[b].start); } if (ssa->cfg.blocks[b].flags & ZEND_BB_LOOP_HEADER) { if (!zend_jit_check_timeout(&dasm_state, op_array->opcodes + ssa->cfg.blocks[b].start, NULL)) { @@ -2254,7 +2248,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op res_addr = 0; } op1_def_info = OP1_DEF_INFO(); - if (!zend_jit_inc_dec(&dasm_state, opline, op_array, + if (!zend_jit_inc_dec(&dasm_state, opline, op1_info, OP1_REG_ADDR(), op1_def_info, OP1_DEF_REG_ADDR(), res_use_info, res_info, @@ -2296,7 +2290,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op res_use_info = RES_USE_INFO(); res_addr = RES_REG_ADDR(); } - if (!zend_jit_long_math(&dasm_state, opline, op_array, + if (!zend_jit_long_math(&dasm_state, opline, op1_info, OP1_RANGE(), OP1_REG_ADDR(), op2_info, OP2_RANGE(), OP2_REG_ADDR(), res_use_info, RES_INFO(), res_addr, @@ -2320,7 +2314,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op if (opline->opcode == ZEND_ADD && (op1_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY && (op2_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY) { - if (!zend_jit_add_arrays(&dasm_state, opline, op_array, op1_info, op2_info)) { + if (!zend_jit_add_arrays(&dasm_state, opline, op1_info, op2_info)) { goto jit_failure; } goto done; @@ -2344,7 +2338,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op res_addr = RES_REG_ADDR(); } res_info = RES_INFO(); - if (!zend_jit_math(&dasm_state, opline, op_array, + if (!zend_jit_math(&dasm_state, opline, op1_info, OP1_REG_ADDR(), op2_info, OP2_REG_ADDR(), res_use_info, res_info, res_addr, @@ -2378,8 +2372,8 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op } else { send_result = 0; } - if (!zend_jit_concat(&dasm_state, opline, op_array, - op1_info, op2_info, RES_INFO(), send_result, + if (!zend_jit_concat(&dasm_state, opline, + op1_info, op2_info, send_result, zend_may_throw(opline, ssa_op, op_array, ssa))) { goto jit_failure; } @@ -2426,7 +2420,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op } } op1_def_info = OP1_DEF_INFO(); - if (!zend_jit_assign_op(&dasm_state, opline, op_array, + if (!zend_jit_assign_op(&dasm_state, opline, op1_info, op1_def_info, OP1_RANGE(), op2_info, OP2_RANGE(), (op1_info & MAY_BE_LONG) && (op2_info & MAY_BE_LONG) && (op1_def_info & MAY_BE_DOUBLE) && zend_may_overflow(opline, op_array, ssa), @@ -2446,7 +2440,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op if (PROFITABILITY_CHECKS && (!ssa->ops || !ssa->var_info)) { break; } - if (!zend_jit_assign_dim_op(&dasm_state, opline, op_array, + if (!zend_jit_assign_dim_op(&dasm_state, opline, OP1_INFO(), OP1_DEF_INFO(), OP1_REG_ADDR(), OP2_INFO(), OP1_DATA_INFO(), OP1_DATA_RANGE(), zend_may_throw(opline, ssa_op, op_array, ssa))) { @@ -2460,7 +2454,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op if (PROFITABILITY_CHECKS && (!ssa->ops || !ssa->var_info)) { break; } - if (!zend_jit_assign_dim(&dasm_state, opline, op_array, + if (!zend_jit_assign_dim(&dasm_state, opline, OP1_INFO(), OP1_REG_ADDR(), OP2_INFO(), OP1_DATA_INFO(), zend_may_throw(opline, ssa_op, op_array, ssa))) { goto jit_failure; @@ -2488,7 +2482,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op } else { op2_def_addr = op2_addr; } - if (!zend_jit_assign(&dasm_state, opline, op_array, + if (!zend_jit_assign(&dasm_state, opline, OP1_INFO(), OP1_REG_ADDR(), OP1_DEF_INFO(), OP1_DEF_REG_ADDR(), OP2_INFO(), op2_addr, op2_def_addr, @@ -2506,7 +2500,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op } else { op1_def_addr = op1_addr; } - if (!zend_jit_qm_assign(&dasm_state, opline, op_array, + if (!zend_jit_qm_assign(&dasm_state, opline, OP1_INFO(), op1_addr, op1_def_addr, RES_INFO(), RES_REG_ADDR())) { goto jit_failure; @@ -2529,7 +2523,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op && opline->op2.num > MAX_ARG_FLAG_NUM) { break; } - if (!zend_jit_send_val(&dasm_state, opline, op_array, + if (!zend_jit_send_val(&dasm_state, opline, OP1_INFO(), OP1_REG_ADDR())) { goto jit_failure; } @@ -2579,7 +2573,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op if (opline->op2.num > MAX_ARG_FLAG_NUM) { break; } - if (!zend_jit_check_func_arg(&dasm_state, opline, op_array)) { + if (!zend_jit_check_func_arg(&dasm_state, opline)) { goto jit_failure; } goto done; @@ -2626,7 +2620,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op smart_branch_opcode = 0; target_label = target_label2 = (uint32_t)-1; } - if (!zend_jit_cmp(&dasm_state, opline, op_array, + if (!zend_jit_cmp(&dasm_state, opline, OP1_INFO(), OP1_REG_ADDR(), OP2_INFO(), OP2_REG_ADDR(), res_addr, @@ -2639,6 +2633,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op } case ZEND_IS_IDENTICAL: case ZEND_IS_NOT_IDENTICAL: + case ZEND_CASE_STRICT: if ((opline->result_type & IS_TMP_VAR) && (i + 1) <= end && ((opline+1)->opcode == ZEND_JMPZ @@ -2654,7 +2649,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op smart_branch_opcode = 0; target_label = target_label2 = (uint32_t)-1; } - if (!zend_jit_identical(&dasm_state, opline, op_array, + if (!zend_jit_identical(&dasm_state, opline, OP1_INFO(), OP1_REG_ADDR(), OP2_INFO(), OP2_REG_ADDR(), RES_REG_ADDR(), @@ -2680,7 +2675,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op smart_branch_opcode = 0; target_label = target_label2 = (uint32_t)-1; } - if (!zend_jit_defined(&dasm_state, opline, op_array, smart_branch_opcode, target_label, target_label2, NULL)) { + if (!zend_jit_defined(&dasm_state, opline, smart_branch_opcode, target_label, target_label2, NULL)) { goto jit_failure; } goto done; @@ -2704,7 +2699,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op smart_branch_opcode = 0; target_label = target_label2 = (uint32_t)-1; } - if (!zend_jit_type_check(&dasm_state, opline, op_array, OP1_INFO(), smart_branch_opcode, target_label, target_label2, NULL)) { + if (!zend_jit_type_check(&dasm_state, opline, OP1_INFO(), smart_branch_opcode, target_label, target_label2, NULL)) { goto jit_failure; } goto done; @@ -2740,22 +2735,22 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op goto jit_failure; } for (j = 0 ; j < op_array->last_var; j++) { - uint32_t info = zend_ssa_cv_info(opline, op_array, ssa, j); + uint32_t info = zend_ssa_cv_info(op_array, ssa, j); if (info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) { - if (!zend_jit_free_cv(&dasm_state, opline, op_array, info, j)) { + if (!zend_jit_free_cv(&dasm_state, info, j)) { goto jit_failure; } } } - if (!zend_jit_leave_func(&dasm_state, opline, op_array, NULL, NULL, 1)) { + if (!zend_jit_leave_func(&dasm_state, op_array, NULL, NULL, 1)) { goto jit_failure; } } goto done; case ZEND_BOOL: case ZEND_BOOL_NOT: - if (!zend_jit_bool_jmpznz(&dasm_state, opline, op_array, + if (!zend_jit_bool_jmpznz(&dasm_state, opline, OP1_INFO(), OP1_REG_ADDR(), RES_REG_ADDR(), -1, -1, zend_may_throw(opline, ssa_op, op_array, ssa), @@ -2782,7 +2777,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op } else { res_addr = RES_REG_ADDR(); } - if (!zend_jit_bool_jmpznz(&dasm_state, opline, op_array, + if (!zend_jit_bool_jmpznz(&dasm_state, opline, OP1_INFO(), OP1_REG_ADDR(), res_addr, ssa->cfg.blocks[b].successors[0], ssa->cfg.blocks[b].successors[1], zend_may_throw(opline, ssa_op, op_array, ssa), @@ -2790,13 +2785,41 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op goto jit_failure; } goto done; + case ZEND_ISSET_ISEMPTY_CV: + if ((opline->extended_value & ZEND_ISEMPTY)) { + // TODO: support for empty() ??? + break; + } + if ((opline->result_type & IS_TMP_VAR) + && (i + 1) <= end + && ((opline+1)->opcode == ZEND_JMPZ + || (opline+1)->opcode == ZEND_JMPNZ + || (opline+1)->opcode == ZEND_JMPZNZ) + && (opline+1)->op1_type == IS_TMP_VAR + && (opline+1)->op1.var == opline->result.var) { + i++; + smart_branch_opcode = (opline+1)->opcode; + target_label = ssa->cfg.blocks[b].successors[0]; + target_label2 = ssa->cfg.blocks[b].successors[1]; + } else { + smart_branch_opcode = 0; + target_label = target_label2 = (uint32_t)-1; + } + if (!zend_jit_isset_isempty_cv(&dasm_state, opline, + OP1_INFO(), OP1_REG_ADDR(), + smart_branch_opcode, target_label, target_label2, + NULL)) { + goto jit_failure; + } + goto done; case ZEND_FETCH_DIM_R: case ZEND_FETCH_DIM_IS: if (PROFITABILITY_CHECKS && (!ssa->ops || !ssa->var_info)) { break; } - if (!zend_jit_fetch_dim_read(&dasm_state, opline, op_array, ssa, ssa_op, - OP1_INFO(), OP1_REG_ADDR(), OP2_INFO(), RES_INFO(), RES_REG_ADDR(), + if (!zend_jit_fetch_dim_read(&dasm_state, opline, ssa, ssa_op, + OP1_INFO(), OP1_REG_ADDR(), 0, + OP2_INFO(), RES_INFO(), RES_REG_ADDR(), zend_may_throw(opline, ssa_op, op_array, ssa))) { goto jit_failure; } @@ -2824,8 +2847,9 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op smart_branch_opcode = 0; target_label = target_label2 = (uint32_t)-1; } - if (!zend_jit_isset_isempty_dim(&dasm_state, opline, op_array, - OP1_INFO(), OP1_REG_ADDR(), OP2_INFO(), + if (!zend_jit_isset_isempty_dim(&dasm_state, opline, + OP1_INFO(), OP1_REG_ADDR(), 0, + OP2_INFO(), zend_may_throw(opline, ssa_op, op_array, ssa), smart_branch_opcode, target_label, target_label2, NULL)) { @@ -2865,7 +2889,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op } } if (!zend_jit_fetch_obj(&dasm_state, opline, op_array, ssa, ssa_op, - op1_info, op1_addr, 0, ce, ce_is_instanceof, 0, NULL, + op1_info, op1_addr, 0, ce, ce_is_instanceof, 0, 0, NULL, zend_may_throw(opline, ssa_op, op_array, ssa))) { goto jit_failure; } @@ -2876,7 +2900,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op } else { op1_info = OP1_INFO(); } - if (!zend_jit_bind_global(&dasm_state, opline, op_array, op1_info)) { + if (!zend_jit_bind_global(&dasm_state, opline, op1_info)) { goto jit_failure; } goto done; @@ -2894,7 +2918,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op goto done; case ZEND_FREE: case ZEND_FE_FREE: - if (!zend_jit_free(&dasm_state, opline, op_array, OP1_INFO(), + if (!zend_jit_free(&dasm_state, opline, OP1_INFO(), zend_may_throw(opline, ssa_op, op_array, ssa))) { goto jit_failure; } @@ -2904,7 +2928,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op if ((op1_info & (MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_REF)) != MAY_BE_STRING) { break; } - if (!zend_jit_echo(&dasm_state, opline, op_array, op1_info)) { + if (!zend_jit_echo(&dasm_state, opline, op1_info)) { goto jit_failure; } goto done; @@ -2913,7 +2937,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op if ((op1_info & (MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_REF)) != MAY_BE_STRING) { break; } - if (!zend_jit_strlen(&dasm_state, opline, op_array, op1_info)) { + if (!zend_jit_strlen(&dasm_state, opline, op1_info)) { goto jit_failure; } goto done; @@ -2925,7 +2949,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op case ZEND_SWITCH_LONG: case ZEND_SWITCH_STRING: case ZEND_MATCH: - if (!zend_jit_switch(&dasm_state, opline, op_array, ssa, NULL)) { + if (!zend_jit_switch(&dasm_state, opline, op_array, ssa, NULL, NULL)) { goto jit_failure; } goto done; @@ -2968,7 +2992,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op goto jit_failure; } } - zend_jit_set_opline(&dasm_state, opline+1); + zend_jit_set_opline(opline+1); break; case ZEND_NOP: case ZEND_OP_DATA: diff --git a/ext/opcache/jit/zend_jit_internal.h b/ext/opcache/jit/zend_jit_internal.h index 7dd8786fde2e1..0254c0daf8af7 100644 --- a/ext/opcache/jit/zend_jit_internal.h +++ b/ext/opcache/jit/zend_jit_internal.h @@ -210,6 +210,7 @@ typedef enum _zend_jit_trace_stop { #define ZEND_JIT_EXIT_POLYMORPHISM (1<<4) /* exit because of polymorphic call */ #define ZEND_JIT_EXIT_FREE_OP1 (1<<5) #define ZEND_JIT_EXIT_FREE_OP2 (1<<6) +#define ZEND_JIT_EXIT_PACKED_GUARD (1<<7) typedef union _zend_op_trace_info { zend_op dummy; /* the size of this structure must be the same as zend_op */ @@ -245,6 +246,7 @@ typedef enum _zend_jit_trace_op { } zend_jit_trace_op; #define IS_UNKNOWN 255 /* may be used for zend_jit_trace_rec.op?_type */ +#define IS_TRACE_PACKED (1<<4) #define IS_TRACE_REFERENCE (1<<5) #define IS_TRACE_INDIRECT (1<<6) @@ -350,6 +352,7 @@ typedef struct _zend_jit_trace_info { uint32_t stack_map_size; uint32_t flags; /* See ZEND_JIT_TRACE_... defines above */ uint32_t polymorphism; /* Counter of polymorphic calls */ + uint32_t jmp_table_size;/* number of jmp_table slots */ const zend_op *opline; /* first opline */ const void *code_start; /* address of native code */ zend_jit_trace_exit_info *exit_info; /* info about side exits */ diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index 96fa37abb79a5..2d9585e23f655 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -132,7 +132,7 @@ static const void *zend_jit_trace_get_exit_addr(uint32_t n) ((n % ZEND_JIT_EXIT_POINTS_PER_GROUP) * ZEND_JIT_EXIT_POINTS_SPACING)); } -static uint32_t zend_jit_trace_get_exit_point(const zend_op *from_opline, const zend_op *to_opline, zend_jit_trace_rec *trace, uint32_t flags) +static uint32_t zend_jit_trace_get_exit_point(const zend_op *to_opline, uint32_t flags) { zend_jit_trace_info *t = &zend_jit_traces[ZEND_JIT_TRACE_NUM]; uint32_t exit_point; @@ -257,6 +257,7 @@ static int zend_jit_trace_may_exit(const zend_op_array *op_array, const zend_op case ZEND_IS_SMALLER: case ZEND_IS_SMALLER_OR_EQUAL: case ZEND_CASE: + case ZEND_CASE_STRICT: case ZEND_ISSET_ISEMPTY_CV: case ZEND_ISSET_ISEMPTY_VAR: case ZEND_ISSET_ISEMPTY_DIM_OBJ: @@ -1357,17 +1358,20 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin level = 0; for (;;p++) { if (p->op == ZEND_JIT_TRACE_VM) { - uint8_t op1_type, op2_type, op3_type; + uint8_t orig_op1_type, op1_type, op2_type, op3_type; // TODO: range inference ??? opline = p->opline; - op1_type = p->op1_type; + op1_type = orig_op1_type = p->op1_type; op2_type = p->op2_type; op3_type = p->op3_type; if (op1_type & (IS_TRACE_REFERENCE|IS_TRACE_INDIRECT)) { op1_type = IS_UNKNOWN; } + if (op1_type != IS_UNKNOWN) { + op1_type &= ~IS_TRACE_PACKED; + } if (op2_type & (IS_TRACE_REFERENCE|IS_TRACE_INDIRECT)) { op2_type = IS_UNKNOWN; } @@ -1420,8 +1424,7 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin case ZEND_CASE: case ZEND_IS_IDENTICAL: case ZEND_IS_NOT_IDENTICAL: - case ZEND_FETCH_DIM_R: - case ZEND_FETCH_DIM_IS: + case ZEND_CASE_STRICT: case ZEND_BW_OR: case ZEND_BW_AND: case ZEND_BW_XOR: @@ -1488,13 +1491,50 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin case ZEND_BOOL_NOT: ADD_OP1_TRACE_GUARD(); break; + case ZEND_ISSET_ISEMPTY_CV: + if ((opline->extended_value & ZEND_ISEMPTY)) { + // TODO: support for empty() ??? + break; + } + ADD_OP1_TRACE_GUARD(); + break; case ZEND_ISSET_ISEMPTY_DIM_OBJ: if ((opline->extended_value & ZEND_ISEMPTY)) { // TODO: support for empty() ??? break; } + /* break missing intentionally */ + case ZEND_FETCH_DIM_R: + case ZEND_FETCH_DIM_IS: ADD_OP1_TRACE_GUARD(); ADD_OP2_TRACE_GUARD(); + + if (opline->op1_type != IS_CONST + && op1_type == IS_ARRAY + && ((opline->op2_type == IS_CONST + && Z_TYPE_P(RT_CONSTANT(opline, opline->op2)) == IS_LONG) + || (opline->op2_type != IS_CONST + && op2_type == IS_LONG))) { + + zend_ssa_var_info *info = &tssa->var_info[tssa->ops[idx].op1_use]; + + if ((info->type & MAY_BE_ARRAY_PACKED) + && (info->type & MAY_BE_ARRAY_HASH) + && orig_op1_type != IS_UNKNOWN + && !(orig_op1_type & IS_TRACE_REFERENCE)) { + /* setup "packed" guards only for loop invariant or reused variables */ + if ((trace_buffer->stop == ZEND_JIT_TRACE_STOP_LOOP + && tssa->ops[idx].op1_use < trace_buffer->op_array->last_var) + || tssa->ops[idx].op1_use_chain >= 0) { + info->type |= MAY_BE_PACKED_GUARD; + if (orig_op1_type & IS_TRACE_PACKED) { + info->type &= ~MAY_BE_ARRAY_HASH; + } else { + info->type &= ~MAY_BE_ARRAY_PACKED; + } + } + } + } break; case ZEND_SEND_VAL_EX: case ZEND_SEND_VAR_EX: @@ -1625,6 +1665,11 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin && !(op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS)) { /* RECV_INIT always copy the constant */ ssa_var_info[ssa_ops[idx].result_def].type = _const_op_type(RT_CONSTANT(opline, opline->op2)); + } else if ((opline->opcode == ZEND_FE_FETCH_R || opline->opcode == ZEND_FE_FETCH_RW) + && ssa_opcodes[idx + 1] == ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value)) { + if (ssa_ops[idx].op2_use >= 0 && ssa_ops[idx].op2_def >= 0) { + ssa_var_info[ssa_ops[idx].op2_def] = ssa_var_info[ssa_ops[idx].op2_use]; + } } else { if (zend_update_type_info(op_array, tssa, script, (zend_op*)opline, ssa_ops + idx, ssa_opcodes, optimization_level) == FAILURE) { // TODO: @@ -1653,7 +1698,10 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin } } if (ssa_ops[idx].op2_def >= 0) { - zend_jit_trace_restrict_ssa_var_info(op_array, ssa, ssa_opcodes, tssa, ssa_ops[idx].op2_def); + if ((opline->opcode != ZEND_FE_FETCH_R && opline->opcode != ZEND_FE_FETCH_RW) + || ssa_opcodes[idx + 1] != ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value)) { + zend_jit_trace_restrict_ssa_var_info(op_array, ssa, ssa_opcodes, tssa, ssa_ops[idx].op2_def); + } } if (ssa_ops[idx].result_def >= 0) { zend_jit_trace_restrict_ssa_var_info(op_array, ssa, ssa_opcodes, tssa, ssa_ops[idx].result_def); @@ -2090,6 +2138,26 @@ static zend_lifetime_interval** zend_jit_trace_allocate_registers(zend_jit_trace && !zend_ssa_is_no_val_use(opline, ssa_op, ssa_op->op1_use)) { if (support_opline) { zend_jit_trace_use_var(idx, ssa_op->op1_use, ssa_op->op1_def, ssa_op->op1_use_chain, start, end, flags, ssa, ssa_opcodes, op_array, op_array_ssa); + if (opline->op1_type != IS_CV) { + if (opline->opcode == ZEND_CASE + || opline->opcode == ZEND_CASE_STRICT + || opline->opcode == ZEND_SWITCH_LONG + || opline->opcode == ZEND_MATCH + || opline->opcode == ZEND_FETCH_LIST_R + || opline->opcode == ZEND_COPY_TMP + || opline->opcode == ZEND_SWITCH_STRING + || opline->opcode == ZEND_FE_FETCH_R + || opline->opcode == ZEND_FE_FETCH_RW + || opline->opcode == ZEND_FETCH_LIST_W + || opline->opcode == ZEND_VERIFY_RETURN_TYPE + || opline->opcode == ZEND_BIND_LEXICAL + || opline->opcode == ZEND_ROPE_ADD) { + /* The value is kept alive and may be used outside of the trace */ + flags[ssa_op->op1_use] |= ZREG_STORE; + } else { + flags[ssa_op->op1_use] |= ZREG_LAST_USE; + } + } } else { start[ssa_op->op1_use] = -1; end[ssa_op->op1_use] = -1; @@ -2102,6 +2170,9 @@ static zend_lifetime_interval** zend_jit_trace_allocate_registers(zend_jit_trace && !zend_ssa_is_no_val_use(opline, ssa_op, ssa_op->op2_use)) { if (support_opline) { zend_jit_trace_use_var(idx, ssa_op->op2_use, ssa_op->op2_def, ssa_op->op2_use_chain, start, end, flags, ssa, ssa_opcodes, op_array, op_array_ssa); + if (opline->op2_type != IS_CV) { + flags[ssa_op->op2_use] |= ZREG_LAST_USE; + } } else { start[ssa_op->op2_use] = -1; end[ssa_op->op2_use] = -1; @@ -2196,6 +2267,9 @@ static zend_lifetime_interval** zend_jit_trace_allocate_registers(zend_jit_trace && !zend_ssa_is_no_val_use(opline, ssa_op, ssa_op->op1_use)) { if (support_opline) { zend_jit_trace_use_var(idx, ssa_op->op1_use, ssa_op->op1_def, ssa_op->op1_use_chain, start, end, flags, ssa, ssa_opcodes, op_array, op_array_ssa); + if (opline->op1_type != IS_CV) { + flags[ssa_op->op1_use] |= ZREG_LAST_USE; + } } else { start[ssa_op->op1_use] = -1; end[ssa_op->op1_use] = -1; @@ -2854,6 +2928,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par zend_class_entry *ce; zend_bool ce_is_instanceof; zend_bool delayed_fetch_this = 0; + zend_bool avoid_refcounting = 0; uint32_t i; zend_jit_trace_stack_frame *frame, *top, *call; zend_jit_trace_stack *stack; @@ -2913,13 +2988,13 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par parent_trace ? &zend_jit_traces[parent_trace] : NULL, exit_num); if (!parent_trace) { - zend_jit_set_opline(&dasm_state, opline); + zend_jit_set_opline(opline); } else { if (zend_jit_traces[parent_trace].exit_info[exit_num].opline == NULL) { zend_jit_trace_opline_guard(&dasm_state, opline); - zend_jit_set_opline(&dasm_state, opline); + zend_jit_set_opline(opline); } else { - zend_jit_reset_opline(&dasm_state, opline); + zend_jit_reset_opline(); } } @@ -2976,6 +3051,16 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } else { SET_STACK_TYPE(stack, i, IS_UNKNOWN); } + + if ((info & MAY_BE_PACKED_GUARD) != 0 + && trace_buffer->stop == ZEND_JIT_TRACE_STOP_LOOP + && ssa->vars[i].use_chain != -1) { + if (!zend_jit_packed_guard(&dasm_state, opline, EX_NUM_TO_VAR(i), info)) { + goto jit_failure; + } + info &= ~MAY_BE_PACKED_GUARD; + ssa->var_info[i].type = info; + } } if (parent_trace) { @@ -3038,7 +3123,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (trace_buffer->stop != ZEND_JIT_TRACE_STOP_RECURSIVE_RET) { if (ra && zend_jit_trace_stack_needs_deoptimization(stack, op_array->last_var + op_array->T)) { - uint32_t exit_point = zend_jit_trace_get_exit_point(NULL, NULL, NULL, ZEND_JIT_EXIT_TO_VM); + uint32_t exit_point = zend_jit_trace_get_exit_point(NULL, ZEND_JIT_EXIT_TO_VM); timeout_exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!timeout_exit_addr) { @@ -3080,6 +3165,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (op1_type & (IS_TRACE_REFERENCE|IS_TRACE_INDIRECT)) { op1_type = IS_UNKNOWN; } + if (op1_type != IS_UNKNOWN) { + op1_type &= ~IS_TRACE_PACKED; + } if (op2_type & (IS_TRACE_REFERENCE|IS_TRACE_INDIRECT)) { op2_type = IS_UNKNOWN; } @@ -3140,7 +3228,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par res_addr = 0; } op1_def_info = OP1_DEF_INFO(); - if (!zend_jit_inc_dec(&dasm_state, opline, op_array, + if (!zend_jit_inc_dec(&dasm_state, opline, op1_info, OP1_REG_ADDR(), op1_def_info, OP1_DEF_REG_ADDR(), res_use_info, res_info, @@ -3214,7 +3302,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par res_addr = RES_REG_ADDR(); } res_info = RES_INFO(); - if (!zend_jit_long_math(&dasm_state, opline, op_array, + if (!zend_jit_long_math(&dasm_state, opline, op1_info, OP1_RANGE(), OP1_REG_ADDR(), op2_info, OP2_RANGE(), OP2_REG_ADDR(), res_use_info, res_info, res_addr, @@ -3237,7 +3325,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (opline->opcode == ZEND_ADD && (op1_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY && (op2_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY) { - if (!zend_jit_add_arrays(&dasm_state, opline, op_array, op1_info, op2_info)) { + if (!zend_jit_add_arrays(&dasm_state, opline, op1_info, op2_info)) { goto jit_failure; } goto done; @@ -3285,7 +3373,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par res_addr = RES_REG_ADDR(); } res_info = RES_INFO(); - if (!zend_jit_math(&dasm_state, opline, op_array, + if (!zend_jit_math(&dasm_state, opline, op1_info, OP1_REG_ADDR(), op2_info, OP2_REG_ADDR(), res_use_info, res_info, res_addr, @@ -3337,9 +3425,8 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } else { send_result = 0; } - res_info = RES_INFO(); - if (!zend_jit_concat(&dasm_state, opline, op_array, - op1_info, op2_info, res_info, send_result, + if (!zend_jit_concat(&dasm_state, opline, + op1_info, op2_info, send_result, zend_may_throw(opline, ssa_op, op_array, ssa))) { goto jit_failure; } @@ -3385,7 +3472,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } } op1_def_info = OP1_DEF_INFO(); - if (!zend_jit_assign_op(&dasm_state, opline, op_array, + if (!zend_jit_assign_op(&dasm_state, opline, op1_info, op1_def_info, OP1_RANGE(), op2_info, OP2_RANGE(), (op1_info & MAY_BE_LONG) && (op2_info & MAY_BE_LONG) && (op1_def_info & (MAY_BE_DOUBLE|MAY_BE_GUARD)) && zend_may_overflow_ex(opline, ssa_op, op_array, ssa), @@ -3423,7 +3510,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par op1_data_info = OP1_DATA_INFO(); CHECK_OP1_DATA_TRACE_TYPE(); op1_def_info = OP1_DEF_INFO(); - if (!zend_jit_assign_dim_op(&dasm_state, opline, op_array, + if (!zend_jit_assign_dim_op(&dasm_state, opline, op1_info, op1_def_info, op1_addr, op2_info, op1_data_info, OP1_DATA_RANGE(), zend_may_throw_ex(opline, ssa_op, op_array, ssa, op1_info, op2_info))) { @@ -3448,7 +3535,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par CHECK_OP2_TRACE_TYPE(); op1_data_info = OP1_DATA_INFO(); CHECK_OP1_DATA_TRACE_TYPE(); - if (!zend_jit_assign_dim(&dasm_state, opline, op_array, + if (!zend_jit_assign_dim(&dasm_state, opline, op1_info, op1_addr, op2_info, op1_data_info, zend_may_throw_ex(opline, ssa_op, op_array, ssa, op1_info, op2_info))) { goto jit_failure; @@ -3484,7 +3571,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (!zend_jit_fetch_reference(&dasm_state, opline, orig_op1_type, &op1_info, &op1_addr, 0)) { goto jit_failure; } - if (!zend_jit_assign_to_typed_ref(&dasm_state, opline, op_array, opline->op2_type, op2_addr, 1)) { + if (!zend_jit_assign_to_typed_ref(&dasm_state, opline, opline->op2_type, op2_addr, 1)) { goto jit_failure; } op1_def_addr = op1_addr; @@ -3497,7 +3584,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par op1_def_info &= ~MAY_BE_REF; } } - if (!zend_jit_assign(&dasm_state, opline, op_array, + if (!zend_jit_assign(&dasm_state, opline, op1_info, op1_addr, op1_def_info, op1_def_addr, op2_info, op2_addr, op2_def_addr, @@ -3523,7 +3610,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par op1_info = OP1_INFO(); CHECK_OP1_TRACE_TYPE(); res_info = RES_INFO(); - if (!zend_jit_qm_assign(&dasm_state, opline, op_array, + if (!zend_jit_qm_assign(&dasm_state, opline, op1_info, op1_addr, op1_def_addr, res_info, RES_REG_ADDR())) { goto jit_failure; @@ -3548,7 +3635,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } op1_info = OP1_INFO(); CHECK_OP1_TRACE_TYPE(); - if (!zend_jit_send_val(&dasm_state, opline, op_array, + if (!zend_jit_send_val(&dasm_state, opline, op1_info, OP1_REG_ADDR())) { goto jit_failure; } @@ -3631,7 +3718,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par || !JIT_G(current_frame)->call->func)) { break; } - if (!zend_jit_check_func_arg(&dasm_state, opline, op_array)) { + if (!zend_jit_check_func_arg(&dasm_state, opline)) { goto jit_failure; } goto done; @@ -3665,7 +3752,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (ra) { zend_jit_trace_clenup_stack(stack, opline, ssa_op, ssa, ra); } - exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, p + 1, 0); + exit_point = zend_jit_trace_get_exit_point(exit_opline, 0); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { goto jit_failure; @@ -3675,7 +3762,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par smart_branch_opcode = 0; exit_addr = NULL; } - if (!zend_jit_cmp(&dasm_state, opline, op_array, + if (!zend_jit_cmp(&dasm_state, opline, op1_info, OP1_REG_ADDR(), op2_info, OP2_REG_ADDR(), RES_REG_ADDR(), @@ -3686,6 +3773,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par goto done; case ZEND_IS_IDENTICAL: case ZEND_IS_NOT_IDENTICAL: + case ZEND_CASE_STRICT: op1_info = OP1_INFO(); CHECK_OP1_TRACE_TYPE(); op2_info = OP2_INFO(); @@ -3698,7 +3786,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (ra) { zend_jit_trace_clenup_stack(stack, opline, ssa_op, ssa, ra); } - exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, p + 1, 0); + exit_point = zend_jit_trace_get_exit_point(exit_opline, 0); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { goto jit_failure; @@ -3711,7 +3799,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par smart_branch_opcode = 0; exit_addr = NULL; } - if (!zend_jit_identical(&dasm_state, opline, op_array, + if (!zend_jit_identical(&dasm_state, opline, op1_info, OP1_REG_ADDR(), op2_info, OP2_REG_ADDR(), RES_REG_ADDR(), @@ -3724,7 +3812,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if ((opline->result_type & (IS_SMART_BRANCH_JMPZ|IS_SMART_BRANCH_JMPNZ)) != 0) { zend_bool exit_if_true = 0; const zend_op *exit_opline = zend_jit_trace_get_exit_opline(p + 1, opline + 1, &exit_if_true); - uint32_t exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, p + 1, 0); + uint32_t exit_point = zend_jit_trace_get_exit_point(exit_opline, 0); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -3735,7 +3823,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par smart_branch_opcode = 0; exit_addr = NULL; } - if (!zend_jit_defined(&dasm_state, opline, op_array, smart_branch_opcode, -1, -1, exit_addr)) { + if (!zend_jit_defined(&dasm_state, opline, smart_branch_opcode, -1, -1, exit_addr)) { goto jit_failure; } goto done; @@ -3753,7 +3841,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (ra) { zend_jit_trace_clenup_stack(stack, opline, ssa_op, ssa, ra); } - exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, p + 1, 0); + exit_point = zend_jit_trace_get_exit_point(exit_opline, 0); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { goto jit_failure; @@ -3763,7 +3851,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par smart_branch_opcode = 0; exit_addr = NULL; } - if (!zend_jit_type_check(&dasm_state, opline, op_array, op1_info, smart_branch_opcode, -1, -1, exit_addr)) { + if (!zend_jit_type_check(&dasm_state, opline, op1_info, smart_branch_opcode, -1, -1, exit_addr)) { goto jit_failure; } goto done; @@ -3805,11 +3893,11 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par && TRACE_FRAME_IS_RETURN_VALUE_USED(JIT_G(current_frame))) { continue; } - info = zend_ssa_cv_info(opline, op_array, op_array_ssa, j); + info = zend_ssa_cv_info(op_array, op_array_ssa, j); type = STACK_TYPE(stack, j); info = zend_jit_trace_type_to_info_ex(type, info); if (info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) { - if (!zend_jit_free_cv(&dasm_state, opline, op_array, info, j)) { + if (!zend_jit_free_cv(&dasm_state, info, j)) { goto jit_failure; } if (info & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_ARRAY_OF_RESOURCE)) { @@ -3819,7 +3907,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } } } - if (!zend_jit_leave_func(&dasm_state, opline, op_array, p + 1, &zend_jit_traces[ZEND_JIT_TRACE_NUM], may_throw)) { + if (!zend_jit_leave_func(&dasm_state, op_array, p + 1, &zend_jit_traces[ZEND_JIT_TRACE_NUM], may_throw)) { goto jit_failure; } } @@ -3828,7 +3916,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par case ZEND_BOOL_NOT: op1_info = OP1_INFO(); CHECK_OP1_TRACE_TYPE(); - if (!zend_jit_bool_jmpznz(&dasm_state, opline, op_array, + if (!zend_jit_bool_jmpznz(&dasm_state, opline, op1_info, OP1_REG_ADDR(), RES_REG_ADDR(), -1, -1, zend_may_throw(opline, ssa_op, op_array, ssa), @@ -3885,10 +3973,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par uint32_t old_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var)); SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), IS_UNKNOWN); - exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, p+1, 0); + exit_point = zend_jit_trace_get_exit_point(exit_opline, 0); SET_STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var), old_info); } else { - exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, p+1, 0); + exit_point = zend_jit_trace_get_exit_point(exit_opline, 0); } exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -3904,7 +3992,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } op1_info = OP1_INFO(); CHECK_OP1_TRACE_TYPE(); - if (!zend_jit_bool_jmpznz(&dasm_state, opline, op_array, + if (!zend_jit_bool_jmpznz(&dasm_state, opline, op1_info, OP1_REG_ADDR(), res_addr, -1, -1, zend_may_throw(opline, ssa_op, op_array, ssa), @@ -3912,6 +4000,41 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par goto jit_failure; } goto done; + case ZEND_ISSET_ISEMPTY_CV: + if ((opline->extended_value & ZEND_ISEMPTY)) { + // TODO: support for empty() ??? + break; + } + op1_info = OP1_INFO(); + op1_addr = OP1_REG_ADDR(); + if (orig_op1_type != IS_UNKNOWN + && (orig_op1_type & IS_TRACE_REFERENCE)) { + if (!zend_jit_fetch_reference(&dasm_state, opline, orig_op1_type, &op1_info, &op1_addr, 1)) { + goto jit_failure; + } + } else { + CHECK_OP1_TRACE_TYPE(); + } + if ((opline->result_type & (IS_SMART_BRANCH_JMPZ|IS_SMART_BRANCH_JMPNZ)) != 0) { + zend_bool exit_if_true = 0; + const zend_op *exit_opline = zend_jit_trace_get_exit_opline(p + 1, opline + 1, &exit_if_true); + uint32_t exit_point = zend_jit_trace_get_exit_point(exit_opline, 0); + + exit_addr = zend_jit_trace_get_exit_addr(exit_point); + if (!exit_addr) { + goto jit_failure; + } + smart_branch_opcode = exit_if_true ? ZEND_JMPNZ : ZEND_JMPZ; + } else { + smart_branch_opcode = 0; + exit_addr = NULL; + } + if (!zend_jit_isset_isempty_cv(&dasm_state, opline, + op1_info, op1_addr, + smart_branch_opcode, -1, -1, exit_addr)) { + goto jit_failure; + } + goto done; case ZEND_FETCH_DIM_FUNC_ARG: if (!JIT_G(current_frame) || !JIT_G(current_frame)->call @@ -3935,8 +4058,15 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par op2_info = OP2_INFO(); CHECK_OP2_TRACE_TYPE(); res_info = RES_INFO(); - if (!zend_jit_fetch_dim_read(&dasm_state, opline, op_array, ssa, ssa_op, - op1_info, op1_addr, op2_info, res_info, RES_REG_ADDR(), + avoid_refcounting = + ssa_op->op1_use >= 0 && + ssa->var_info[ssa_op->op1_use].avoid_refcounting; + if (op1_info & MAY_BE_PACKED_GUARD) { + ssa->var_info[ssa_op->op1_use].type &= ~MAY_BE_PACKED_GUARD; + } + if (!zend_jit_fetch_dim_read(&dasm_state, opline, ssa, ssa_op, + op1_info, op1_addr, avoid_refcounting, + op2_info, res_info, RES_REG_ADDR(), ( (op1_info & MAY_BE_ANY) != MAY_BE_ARRAY || (op2_info & (MAY_BE_ANY - (MAY_BE_LONG|MAY_BE_STRING))) != 0 || @@ -3977,16 +4107,17 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (ra) { zend_jit_trace_clenup_stack(stack, opline, ssa_op, ssa, ra); } - if (op1_info & AVOID_REFCOUNTING) { + if (ssa_op->op1_use >= 0 + && ssa->var_info[ssa_op->op1_use].avoid_refcounting) { /* Temporary reset ZREG_ZVAL_TRY_ADDREF */ zend_jit_trace_stack *stack = JIT_G(current_frame)->stack; uint32_t old_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->op1.var)); SET_STACK_REG(stack, EX_VAR_TO_NUM(opline->op1.var), ZREG_NONE); - exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, p + 1, 0); + exit_point = zend_jit_trace_get_exit_point(exit_opline, 0); SET_STACK_INFO(stack, EX_VAR_TO_NUM(opline->op1.var), old_info); } else { - exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, p + 1, 0); + exit_point = zend_jit_trace_get_exit_point(exit_opline, 0); } exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -3997,8 +4128,15 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par smart_branch_opcode = 0; exit_addr = NULL; } - if (!zend_jit_isset_isempty_dim(&dasm_state, opline, op_array, - op1_info, op1_addr, op2_info, + avoid_refcounting = + ssa_op->op1_use >= 0 && + ssa->var_info[ssa_op->op1_use].avoid_refcounting; + if (op1_info & MAY_BE_PACKED_GUARD) { + ssa->var_info[ssa_op->op1_use].type &= ~MAY_BE_PACKED_GUARD; + } + if (!zend_jit_isset_isempty_dim(&dasm_state, opline, + op1_info, op1_addr, avoid_refcounting, + op2_info, zend_may_throw_ex(opline, ssa_op, op_array, ssa, op1_info, op2_info), smart_branch_opcode, -1, -1, exit_addr)) { @@ -4017,6 +4155,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par case ZEND_FETCH_OBJ_IS: case ZEND_FETCH_OBJ_W: delayed_fetch_this = 0; + avoid_refcounting = 0; if (opline->op2_type != IS_CONST || Z_TYPE_P(RT_CONSTANT(opline, opline->op2)) != IS_STRING || Z_STRVAL_P(RT_CONSTANT(opline, opline->op2))[0] == '\0') { @@ -4065,11 +4204,12 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } if (ssa_op->op1_use >= 0) { delayed_fetch_this = ssa->var_info[ssa_op->op1_use].delayed_fetch_this; + avoid_refcounting = ssa->var_info[ssa_op->op1_use].avoid_refcounting; } } if (!zend_jit_fetch_obj(&dasm_state, opline, op_array, ssa, ssa_op, op1_info, op1_addr, op1_indirect, ce, ce_is_instanceof, - delayed_fetch_this, op1_ce, + delayed_fetch_this, avoid_refcounting, op1_ce, zend_may_throw_ex(opline, ssa_op, op_array, ssa, op1_info, MAY_BE_STRING))) { goto jit_failure; } @@ -4083,7 +4223,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } else { op1_info = OP1_INFO(); } - if (!zend_jit_bind_global(&dasm_state, opline, op_array, op1_info)) { + if (!zend_jit_bind_global(&dasm_state, opline, op1_info)) { goto jit_failure; } if ((opline+1)->opcode == ZEND_BIND_GLOBAL) { @@ -4123,7 +4263,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par case ZEND_FREE: case ZEND_FE_FREE: op1_info = OP1_INFO(); - if (!zend_jit_free(&dasm_state, opline, op_array, op1_info, + if (!zend_jit_free(&dasm_state, opline, op1_info, zend_may_throw(opline, ssa_op, op_array, ssa))) { goto jit_failure; } @@ -4134,7 +4274,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if ((op1_info & (MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_REF)) != MAY_BE_STRING) { break; } - if (!zend_jit_echo(&dasm_state, opline, op_array, op1_info)) { + if (!zend_jit_echo(&dasm_state, opline, op1_info)) { goto jit_failure; } goto done; @@ -4144,7 +4284,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if ((op1_info & (MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_REF)) != MAY_BE_STRING) { break; } - if (!zend_jit_strlen(&dasm_state, opline, op_array, op1_info)) { + if (!zend_jit_strlen(&dasm_state, opline, op1_info)) { goto jit_failure; } goto done; @@ -4163,7 +4303,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par case ZEND_SWITCH_LONG: case ZEND_SWITCH_STRING: case ZEND_MATCH: - if (!zend_jit_switch(&dasm_state, opline, op_array, op_array_ssa, p+1)) { + if (!zend_jit_switch(&dasm_state, opline, op_array, op_array_ssa, p+1, &zend_jit_traces[ZEND_JIT_TRACE_NUM])) { goto jit_failure; } goto done; @@ -4173,7 +4313,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par goto jit_failure; } if ((p+1)->op == ZEND_JIT_TRACE_INIT_CALL && (p+1)->func) { - if (!zend_jit_init_fcall_guard(&dasm_state, opline, (p+1)->func, opline+1)) { + if (!zend_jit_init_fcall_guard(&dasm_state, (p+1)->func, opline+1)) { goto jit_failure; } } @@ -4185,7 +4325,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if ((opline->op1_type != IS_CONST || opline->op2_type != IS_CONST) && (p+1)->op == ZEND_JIT_TRACE_INIT_CALL && (p+1)->func) { - if (!zend_jit_init_fcall_guard(&dasm_state, opline, (p+1)->func, opline+1)) { + if (!zend_jit_init_fcall_guard(&dasm_state, (p+1)->func, opline+1)) { goto jit_failure; } } @@ -4196,7 +4336,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } if (opline->op2_type != IS_CONST && (p+1)->op == ZEND_JIT_TRACE_INIT_CALL && (p+1)->func) { - if (!zend_jit_init_fcall_guard(&dasm_state, opline, (p+1)->func, opline+1)) { + if (!zend_jit_init_fcall_guard(&dasm_state, (p+1)->func, opline+1)) { goto jit_failure; } } @@ -4208,7 +4348,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (opline->op1_type != IS_CONST && (p+1)->op == ZEND_JIT_TRACE_INIT_CALL && (p+1)->func) { SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), IS_OBJECT); - if (!zend_jit_init_fcall_guard(&dasm_state, opline, (p+1)->func, opline+1)) { + if (!zend_jit_init_fcall_guard(&dasm_state, (p+1)->func, opline+1)) { goto jit_failure; } } @@ -4278,7 +4418,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (opline->opcode == ZEND_FETCH_THIS && delayed_fetch_this) { SET_STACK_REG(stack, EX_VAR_TO_NUM(opline->result.var), ZREG_THIS); - } else if (ssa->var_info[ssa_op->result_def].type & AVOID_REFCOUNTING) { + } else if (ssa->var_info[ssa_op->result_def].avoid_refcounting) { SET_STACK_REG(stack, EX_VAR_TO_NUM(opline->result.var), ZREG_ZVAL_TRY_ADDREF); } else if (ra && ra[ssa_op->result_def]) { SET_STACK_REG(stack, EX_VAR_TO_NUM(opline->result.var), ra[ssa_op->result_def]->reg); @@ -4432,7 +4572,8 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par /* Check if SEND_UNPACK/SEND_ARRAY may cause enter at different opline */ if (opline > op_array->opcodes && ((opline-1)->opcode == ZEND_SEND_ARRAY - || (opline-1)->opcode == ZEND_SEND_UNPACK) + || (opline-1)->opcode == ZEND_SEND_UNPACK + || (opline-1)->opcode == ZEND_CHECK_UNDEF_ARGS) && p->op_array->num_args && (p->op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0 && ((p+1)->op == ZEND_JIT_TRACE_VM @@ -4445,7 +4586,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if ((p+1)->op == ZEND_JIT_TRACE_END) { p++; - zend_jit_set_opline(&dasm_state, p->opline); + zend_jit_set_opline(p->opline); break; } op_array = (zend_op_array*)p->op_array; @@ -4473,7 +4614,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par } } } - zend_jit_set_opline(&dasm_state, (p+1)->opline); + zend_jit_set_opline((p+1)->opline); } else if (p->op == ZEND_JIT_TRACE_BACK) { op_array = (zend_op_array*)p->op_array; jit_extension = @@ -4549,6 +4690,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (p->func) { if (p->func->type == ZEND_USER_FUNCTION) { if (JIT_G(opt_level) >= ZEND_JIT_LEVEL_INLINE) { + zend_jit_op_array_trace_extension *jit_extension = + (zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(p->op_array); + i = 0; while (i < p->op_array->num_args) { /* Types of arguments are going to be stored in abstract stack when processing SEV instruction */ @@ -4556,7 +4700,12 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par i++; } while (i < p->op_array->last_var) { - SET_STACK_TYPE(call->stack, i, IS_UNDEF); + if (jit_extension + && zend_jit_var_may_be_modified_indirectly(p->op_array, &jit_extension->func_info.ssa, i)) { + SET_STACK_TYPE(call->stack, i, IS_UNKNOWN); + } else { + SET_STACK_TYPE(call->stack, i, IS_UNDEF); + } i++; } while (i < p->op_array->last_var + p->op_array->T) { @@ -4606,7 +4755,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par opline = q->opline; ZEND_ASSERT(opline != NULL); } - if (!zend_jit_init_fcall_guard(&dasm_state, NULL, p->func, opline)) { + if (!zend_jit_init_fcall_guard(&dasm_state, p->func, opline)) { goto jit_failure; } } @@ -4677,15 +4826,26 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par if (handler) { if (p->stop == ZEND_JIT_TRACE_STOP_RECURSIVE_CALL) { - op_array = trace_buffer->op_array; + const zend_op_array *rec_op_array; + + rec_op_array = op_array = trace_buffer->op_array; + jit_extension = + (zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array); p = trace_buffer + ZEND_JIT_TRACE_START_REC_SIZE; for (;;p++) { if (p->op == ZEND_JIT_TRACE_VM) { opline = p->opline; } else if (p->op == ZEND_JIT_TRACE_ENTER) { - if (p->op_array == op_array) { + if (p->op_array == rec_op_array) { zend_jit_trace_setup_ret_counter(opline, jit_extension->offset); } + op_array = p->op_array; + jit_extension = + (zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array); + } else if (p->op == ZEND_JIT_TRACE_BACK) { + op_array = p->op_array; + jit_extension = + (zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array); } else if (p->op == ZEND_JIT_TRACE_END) { break; } @@ -4827,6 +4987,7 @@ static zend_jit_trace_stop zend_jit_compile_root_trace(zend_jit_trace_rec *trace t->stack_map_size = 0; t->flags = 0; t->polymorphism = 0; + t->jmp_table_size = 0; t->opline = trace_buffer[1].opline; t->exit_info = exit_info; t->stack_map = NULL; @@ -5033,8 +5194,8 @@ static void zend_jit_dump_trace(zend_jit_trace_rec *trace_buffer, zend_ssa *tssa fprintf(stderr, " op1(%sobject of class %s)", ref, ZSTR_VAL(p->ce->name)); } else { - const char *type = (op1_type == 0) ? "undef" : zend_get_type_by_const(op1_type & ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT)); - fprintf(stderr, " op1(%s%s)", ref, type); + const char *type = (op1_type == 0) ? "undef" : zend_get_type_by_const(op1_type & ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT|IS_TRACE_PACKED)); + fprintf(stderr, " op1(%s%s%s)", ref, (op1_type & IS_TRACE_PACKED) ? "packed " : "", type); } } if (op2_type != IS_UNKNOWN) { @@ -5353,6 +5514,7 @@ static void zend_jit_blacklist_trace_exit(uint32_t trace_num, uint32_t exit_num) zend_jit_link_side_trace( zend_jit_traces[trace_num].code_start, zend_jit_traces[trace_num].code_size, + zend_jit_traces[trace_num].jmp_table_size, exit_num, handler); } @@ -5421,6 +5583,7 @@ static zend_jit_trace_stop zend_jit_compile_side_trace(zend_jit_trace_rec *trace t->stack_map_size = 0; t->flags = 0; t->polymorphism = polymorphism; + t->jmp_table_size = 0; t->opline = NULL; t->exit_info = exit_info; t->stack_map = NULL; @@ -5464,6 +5627,7 @@ static zend_jit_trace_stop zend_jit_compile_side_trace(zend_jit_trace_rec *trace zend_jit_link_side_trace( zend_jit_traces[parent_num].code_start, zend_jit_traces[parent_num].code_size, + zend_jit_traces[parent_num].jmp_table_size, exit_num, handler); diff --git a/ext/opcache/jit/zend_jit_vm_helpers.c b/ext/opcache/jit/zend_jit_vm_helpers.c index f7704b72a40ff..dca5f97f04b42 100644 --- a/ext/opcache/jit/zend_jit_vm_helpers.c +++ b/ext/opcache/jit/zend_jit_vm_helpers.c @@ -659,10 +659,14 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex, op1_type = Z_TYPE_P(zv); flags |= IS_TRACE_REFERENCE; } - op1_type |= flags; if (Z_TYPE_P(zv) == IS_OBJECT) { ce1 = Z_OBJCE_P(zv); + } else if (Z_TYPE_P(zv) == IS_ARRAY) { + if (HT_IS_PACKED(Z_ARRVAL_P(zv))) { + flags |= IS_TRACE_PACKED; + } } + op1_type |= flags; } if (opline->op2_type & (IS_TMP_VAR|IS_VAR|IS_CV) && opline->opcode != ZEND_INSTANCEOF @@ -684,10 +688,10 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex, op2_type = Z_TYPE_P(zv); flags |= IS_TRACE_REFERENCE; } - op2_type |= flags; if (Z_TYPE_P(zv) == IS_OBJECT) { ce2 = Z_OBJCE_P(zv); } + op2_type |= flags; } if (opline->opcode == ZEND_ASSIGN_DIM || opline->opcode == ZEND_ASSIGN_OBJ || diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 32bd3b46774e2..6cad84ffdf175 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -153,7 +153,7 @@ static size_t tsrm_tls_offset; |.globals zend_lb static void* dasm_labels[zend_lb_MAX]; -|.section code, cold_code +|.section code, cold_code, jmp_table #define IS_32BIT(addr) (((uintptr_t)(addr)) <= 0xffffffff) @@ -894,8 +894,8 @@ static void* dasm_labels[zend_lb_MAX]; || } | .if X64 || } else if (!IS_32BIT(zv)) { -| mov64 tmp_reg, ((uintptr_t)zv) -| SSE_AVX_INS movsd, vmovsd, xmm(dst_reg-ZREG_XMM0), qword [tmp_reg] +| mov64 Ra(tmp_reg), ((uintptr_t)zv) +| SSE_AVX_INS movsd, vmovsd, xmm(dst_reg-ZREG_XMM0), qword [Ra(tmp_reg)] | .endif || } else { | SSE_AVX_INS movsd, vmovsd, xmm(dst_reg-ZREG_XMM0), qword [((uint32_t)(uintptr_t)zv)] @@ -913,8 +913,8 @@ static void* dasm_labels[zend_lb_MAX]; || if (Z_MODE(dst_addr) == IS_REG) { | mov64 Ra(Z_REG(dst_addr)), ((uintptr_t)Z_LVAL_P(zv)) || } else { -| mov64 tmp_reg, ((uintptr_t)Z_LVAL_P(zv)) -| SET_ZVAL_LVAL dst_addr, tmp_reg +| mov64 Ra(tmp_reg), ((uintptr_t)Z_LVAL_P(zv)) +| SET_ZVAL_LVAL dst_addr, Ra(tmp_reg) || } || } else { | SET_ZVAL_LVAL dst_addr, Z_LVAL_P(zv) @@ -948,8 +948,8 @@ static void* dasm_labels[zend_lb_MAX]; || } | .if X64 || } else if (!IS_32BIT(zv)) { -| mov64 tmp_reg, ((uintptr_t)zv) -| SSE_AVX_INS movsd, vmovsd, xmm(dst_reg-ZREG_XMM0), qword [tmp_reg] +| mov64 Ra(tmp_reg), ((uintptr_t)zv) +| SSE_AVX_INS movsd, vmovsd, xmm(dst_reg-ZREG_XMM0), qword [Ra(tmp_reg)] | .endif || } else { | SSE_AVX_INS movsd, vmovsd, xmm(dst_reg-ZREG_XMM0), qword [((uint32_t)(uintptr_t)zv)] @@ -986,9 +986,9 @@ static void* dasm_labels[zend_lb_MAX]; | mov64 Ra(Z_REG(res_addr)), ((uintptr_t)Z_LVAL_P(zv)) | SET_ZVAL_LVAL dst_addr, Ra(Z_REG(res_addr)) || } else { -| mov64 tmp_reg, ((uintptr_t)Z_LVAL_P(zv)) -| SET_ZVAL_LVAL dst_addr, tmp_reg -| SET_ZVAL_LVAL res_addr, tmp_reg +| mov64 Ra(tmp_reg), ((uintptr_t)Z_LVAL_P(zv)) +| SET_ZVAL_LVAL dst_addr, Ra(tmp_reg) +| SET_ZVAL_LVAL res_addr, Ra(tmp_reg) || } || } else if (Z_MODE(dst_addr) == IS_REG) { | SET_ZVAL_LVAL dst_addr, Z_LVAL_P(zv) @@ -1419,7 +1419,7 @@ static void* dasm_labels[zend_lb_MAX]; || } |.endmacro -|.macro FREE_OP, op_type, op, op_info, cold, op_array, opline +|.macro FREE_OP, op_type, op, op_info, cold, opline || if (op_type & (IS_VAR|IS_TMP_VAR)) { | ZVAL_PTR_DTOR ZEND_ADDR_MEM_ZVAL(ZREG_FP, op.var), op_info, 0, cold, opline || } @@ -1471,17 +1471,16 @@ static void* dasm_labels[zend_lb_MAX]; || } |.endmacro -|.macro EFREE_REG_24, op_array, opline +|.macro EFREE_REG_24 ||#if ZEND_DEBUG -|| const char *filename = op_array->filename ? op_array->filename->val : NULL; -| LOAD_ADDR FCARG2a, filename +| xor FCARG2a, FCARG2a // filename | .if X64WIN -| mov CARG3d, opline->lineno +| xor CARG3d, CARG3d // lineno | xor CARG4, CARG4 | mov aword A5, 0 | EXT_CALL _efree, r0 | .elif X64 -| mov CARG3d, opline->lineno +| xor CARG3d, CARG3d // lineno | xor CARG4, CARG4 | xor CARG5, CARG5 | EXT_CALL _efree, r0 @@ -1489,7 +1488,7 @@ static void* dasm_labels[zend_lb_MAX]; | sub r4, 4 | push 0 | push 0 -| push opline->lineno +| push 0 // lineno | EXT_CALL _efree, r0 | add r4, 4 | .endif @@ -1502,9 +1501,9 @@ static void* dasm_labels[zend_lb_MAX]; ||#endif |.endmacro -|.macro EFREE_24, ptr, op_array, opline +|.macro EFREE_24, ptr | mov FCARG1a, ptr -| EFREE_REG_24 op_array, opline +| EFREE_REG_24 |.endmacro |.macro EMALLOC, size, op_array, opline @@ -2946,7 +2945,7 @@ static int zend_jit_trace_begin(dasm_State **Dst, uint32_t trace_num, zend_jit_t static int zend_jit_trace_opline_guard(dasm_State **Dst, const zend_op *opline) { - uint32_t exit_point = zend_jit_trace_get_exit_point(NULL, NULL, NULL, 0); + uint32_t exit_point = zend_jit_trace_get_exit_point(NULL, 0); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -3093,12 +3092,26 @@ mrm: typedef ZEND_SET_ALIGNED(1, uint16_t unaligned_uint16_t); typedef ZEND_SET_ALIGNED(1, int32_t unaligned_int32_t); -static int zend_jit_patch(const void *code, size_t size, const void *from_addr, const void *to_addr) +static int zend_jit_patch(const void *code, size_t size, uint32_t jmp_table_size, const void *from_addr, const void *to_addr) { int ret = 0; - uint8_t *p = (uint8_t*)code; - uint8_t *end = p + size - 5; + uint8_t *p, *end; + + if (jmp_table_size) { + const void **jmp_slot = (const void **)((char*)code + size); + size -= jmp_table_size * sizeof(void*); + do { + jmp_slot--; + if (*jmp_slot == from_addr) { + *jmp_slot = to_addr; + ret++; + } + } while (--jmp_table_size); + } + + p = (uint8_t*)code; + end = p + size - 5; while (p < end) { if ((*(unaligned_uint16_t*)p & 0xf0ff) == 0x800f && p + *(unaligned_int32_t*)(p+2) == (uint8_t*)from_addr - 6) { *(unaligned_int32_t*)(p+2) = ((uint8_t*)to_addr - (p + 6)); @@ -3115,9 +3128,9 @@ static int zend_jit_patch(const void *code, size_t size, const void *from_addr, return ret; } -static int zend_jit_link_side_trace(const void *code, size_t size, uint32_t exit_num, const void *addr) +static int zend_jit_link_side_trace(const void *code, size_t size, uint32_t jmp_table_size, uint32_t exit_num, const void *addr) { - return zend_jit_patch(code, size, zend_jit_trace_get_exit_addr(exit_num), addr); + return zend_jit_patch(code, size, jmp_table_size, zend_jit_trace_get_exit_addr(exit_num), addr); } static int zend_jit_trace_link_to_root(dasm_State **Dst, zend_jit_trace_info *t) @@ -3210,7 +3223,7 @@ static int zend_jit_trace_return(dasm_State **Dst, zend_bool original_handler) static int zend_jit_type_guard(dasm_State **Dst, const zend_op *opline, uint32_t var, uint8_t type) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, 0); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, 0); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -3221,6 +3234,27 @@ static int zend_jit_type_guard(dasm_State **Dst, const zend_op *opline, uint32_t return 1; } +static int zend_jit_packed_guard(dasm_State **Dst, const zend_op *opline, uint32_t var, uint32_t op_info) +{ + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_PACKED_GUARD); + const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); + + if (!exit_addr) { + return 0; + } + + | GET_ZVAL_LVAL ZREG_FCARG1a, ZEND_ADDR_MEM_ZVAL(ZREG_FP, var) + if (op_info & MAY_BE_ARRAY_PACKED) { + | test dword [FCARG1a + offsetof(zend_array, u.flags)], HASH_FLAG_PACKED + | jz &exit_addr + } else { + | test dword [FCARG1a + offsetof(zend_array, u.flags)], HASH_FLAG_PACKED + | jnz &exit_addr + } + + return 1; +} + static int zend_jit_trace_handler(dasm_State **Dst, const zend_op_array *op_array, const zend_op *opline, int may_throw, zend_jit_trace_rec *trace) { zend_jit_op_array_trace_extension *jit_extension = @@ -3332,7 +3366,7 @@ static int zend_jit_trace_handler(dasm_State **Dst, const zend_op_array *op_arra old_res_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var)); SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), IS_UNKNOWN); } - exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, trace, 0); + exit_point = zend_jit_trace_get_exit_point(exit_opline, 0); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (opline->result_type == IS_VAR || opline->result_type == IS_TMP_VAR) { @@ -3441,18 +3475,16 @@ static int zend_jit_tail_handler(dasm_State **Dst, const zend_op *opline) return 1; } -static int zend_jit_set_opline(dasm_State **Dst, const zend_op *target_opline) +static void zend_jit_set_opline(const zend_op *target_opline) { if (!reuse_ip) { last_valid_opline = target_opline; } - return 1; } -static int zend_jit_reset_opline(dasm_State **Dst, const zend_op *target_opline) +static void zend_jit_reset_opline(void) { last_valid_opline = NULL; - return 1; } static void zend_jit_start_reuse_ip(void) { @@ -3676,7 +3708,7 @@ static int zend_jit_store_const(dasm_State **Dst, int var, zend_reg reg) return 1; } -static int zend_jit_inc_dec(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op1_def_info, zend_jit_addr op1_def_addr, uint32_t res_use_info, uint32_t res_info, zend_jit_addr res_addr, int may_overflow, int may_throw) +static int zend_jit_inc_dec(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op1_def_info, zend_jit_addr op1_def_addr, uint32_t res_use_info, uint32_t res_info, zend_jit_addr res_addr, int may_overflow, int may_throw) { if (op1_info & ((MAY_BE_UNDEF|MAY_BE_ANY)-MAY_BE_LONG)) { | IF_NOT_ZVAL_TYPE op1_addr, IS_LONG, >2 @@ -3726,7 +3758,7 @@ static int zend_jit_inc_dec(dasm_State **Dst, const zend_op *opline, const zend_ } } - exit_point = zend_jit_trace_get_exit_point(opline, opline + 1, NULL, 0); + exit_point = zend_jit_trace_get_exit_point(opline + 1, 0); exit_addr = zend_jit_trace_get_exit_addr(exit_point); | jo &exit_addr @@ -3909,7 +3941,6 @@ static int zend_jit_inc_dec(dasm_State **Dst, const zend_op *opline, const zend_ } static int zend_jit_math_long_long(dasm_State **Dst, - const zend_op_array *op_array, const zend_op *opline, zend_uchar opcode, zend_jit_addr op1_addr, @@ -3926,8 +3957,11 @@ static int zend_jit_math_long_long(dasm_State **Dst, result_reg = Z_REG(res_addr); } else if (Z_MODE(op1_addr) == IS_REG && Z_LAST_USE(op1_addr)) { result_reg = Z_REG(op1_addr); - } else { + } else if (Z_REG(res_addr) != ZREG_R0) { result_reg = ZREG_R0; + } else { + /* ASSIGN_DIM_OP */ + result_reg = ZREG_FCARG1a; } if (opcode == ZEND_MUL && @@ -3979,7 +4013,7 @@ static int zend_jit_math_long_long(dasm_State **Dst, } if (may_overflow) { if (res_info & MAY_BE_GUARD) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, 0); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, 0); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); | jo &exit_addr } else { @@ -4226,7 +4260,6 @@ static int zend_jit_math_double_double(dasm_State **Dst, static int zend_jit_math_helper(dasm_State **Dst, const zend_op *opline, zend_uchar opcode, - const zend_op_array *op_array, zend_uchar op1_type, znode_op op1, zend_jit_addr op1_addr, @@ -4270,7 +4303,7 @@ static int zend_jit_math_helper(dasm_State **Dst, | IF_NOT_ZVAL_TYPE op2_addr, IS_LONG, >6 } } - if (!zend_jit_math_long_long(Dst, op_array, opline, opcode, op1_addr, op2_addr, res_addr, res_info, res_use_info, may_overflow)) { + if (!zend_jit_math_long_long(Dst, opline, opcode, op1_addr, op2_addr, res_addr, res_info, res_use_info, may_overflow)) { return 0; } if (op1_info & MAY_BE_DOUBLE) { @@ -4383,7 +4416,6 @@ static int zend_jit_math_helper(dasm_State **Dst, |.cold_code } |6: - | SAVE_VALID_OPLINE opline, r0 if (Z_MODE(res_addr) == IS_REG) { zend_jit_addr real_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, res_var); | LOAD_ZVAL_ADDR FCARG1a, real_addr @@ -4411,6 +4443,7 @@ static int zend_jit_math_helper(dasm_State **Dst, | sub r4, 12 | PUSH_ZVAL_ADDR op2_addr, r0 |.endif + | SAVE_VALID_OPLINE opline, r0 if (opcode == ZEND_ADD) { | EXT_CALL add_function, r0 } else if (opcode == ZEND_SUB) { @@ -4425,8 +4458,8 @@ static int zend_jit_math_helper(dasm_State **Dst, |.if not(X64) | add r4, 12 |.endif - | FREE_OP op1_type, op1, op1_info, 0, op_array, opline - | FREE_OP op2_type, op2, op2_info, 0, op_array, opline + | FREE_OP op1_type, op1, op1_info, 0, opline + | FREE_OP op2_type, op2, op2_info, 0, opline if (may_throw) { zend_jit_check_exception(Dst); } @@ -4446,7 +4479,7 @@ static int zend_jit_math_helper(dasm_State **Dst, return 1; } -static int zend_jit_math(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, zend_jit_addr op2_addr, uint32_t res_use_info, uint32_t res_info, zend_jit_addr res_addr, zend_bool send_result, int may_overflow, int may_throw) +static int zend_jit_math(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, zend_jit_addr op2_addr, uint32_t res_use_info, uint32_t res_info, zend_jit_addr res_addr, zend_bool send_result, int may_overflow, int may_throw) { ZEND_ASSERT(!(op1_info & MAY_BE_UNDEF) && !(op2_info & MAY_BE_UNDEF)); ZEND_ASSERT((op1_info & (MAY_BE_LONG|MAY_BE_DOUBLE)) && @@ -4461,7 +4494,7 @@ static int zend_jit_math(dasm_State **Dst, const zend_op *opline, const zend_op_ res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_RX, (opline+1)->result.var); } - if (!zend_jit_math_helper(Dst, opline, opline->opcode, op_array, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, opline->result.var, res_addr, res_info, res_use_info, may_overflow, may_throw)) { + if (!zend_jit_math_helper(Dst, opline, opline->opcode, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, opline->result.var, res_addr, res_info, res_use_info, may_overflow, may_throw)) { return 0; } if (!zend_jit_store_var_if_necessary(Dst, opline->result.var, res_addr, res_info)) { @@ -4470,7 +4503,7 @@ static int zend_jit_math(dasm_State **Dst, const zend_op *opline, const zend_op_ return 1; } -static int zend_jit_add_arrays(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, uint32_t op2_info) +static int zend_jit_add_arrays(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, uint32_t op2_info) { zend_jit_addr op1_addr = OP1_ADDR(); zend_jit_addr op2_addr = OP2_ADDR(); @@ -4481,15 +4514,14 @@ static int zend_jit_add_arrays(dasm_State **Dst, const zend_op *opline, const ze | EXT_CALL zend_jit_add_arrays_helper, r0 | SET_ZVAL_PTR res_addr, r0 | SET_ZVAL_TYPE_INFO res_addr, IS_ARRAY_EX - | FREE_OP opline->op1_type, opline->op1, op1_info, 0, op_array, opline - | FREE_OP opline->op2_type, opline->op2, op2_info, 0, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline + | FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline return 1; } static int zend_jit_long_math_helper(dasm_State **Dst, const zend_op *opline, zend_uchar opcode, - const zend_op_array *op_array, zend_uchar op1_type, znode_op op1, zend_jit_addr op1_addr, @@ -4537,8 +4569,17 @@ static int zend_jit_long_math_helper(dasm_State **Dst, result_reg = Z_REG(res_addr); } else if (Z_MODE(op1_addr) == IS_REG && Z_LAST_USE(op1_addr)) { result_reg = Z_REG(op1_addr); - } else { + } else if (Z_REG(res_addr) != ZREG_R0) { result_reg = ZREG_R0; + } else { + /* ASSIGN_DIM_OP */ + if (sizeof(void*) == 4 + && (opcode == ZEND_SL || opcode == ZEND_SR) + && Z_MODE(op2_addr) != IS_CONST_ZVAL) { + result_reg = ZREG_R2; + } else { + result_reg = ZREG_FCARG1a; + } } if (opcode == ZEND_SL) { @@ -4708,7 +4749,6 @@ static int zend_jit_long_math_helper(dasm_State **Dst, |.cold_code } |6: - | SAVE_VALID_OPLINE opline, r0 if (Z_MODE(res_addr) == IS_REG) { zend_jit_addr real_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, res_var); | LOAD_ZVAL_ADDR FCARG1a, real_addr @@ -4736,6 +4776,7 @@ static int zend_jit_long_math_helper(dasm_State **Dst, | sub r4, 12 | PUSH_ZVAL_ADDR op2_addr, r0 |.endif + | SAVE_VALID_OPLINE opline, r0 if (opcode == ZEND_BW_OR) { | EXT_CALL bitwise_or_function, r0 } else if (opcode == ZEND_BW_AND) { @@ -4754,8 +4795,8 @@ static int zend_jit_long_math_helper(dasm_State **Dst, |.if not(X64) | add r4, 12 |.endif - | FREE_OP op1_type, op1, op1_info, 0, op_array, opline - | FREE_OP op2_type, op2, op2_info, 0, op_array, opline + | FREE_OP op1_type, op1, op1_info, 0, opline + | FREE_OP op2_type, op2, op2_info, 0, opline if (may_throw) { zend_jit_check_exception(Dst); } @@ -4776,7 +4817,7 @@ static int zend_jit_long_math_helper(dasm_State **Dst, return 1; } -static int zend_jit_long_math(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_ssa_range *op1_range, zend_jit_addr op1_addr, uint32_t op2_info, zend_ssa_range *op2_range, zend_jit_addr op2_addr, uint32_t res_use_info, uint32_t res_info, zend_jit_addr res_addr, zend_bool send_result, int may_throw) +static int zend_jit_long_math(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_ssa_range *op1_range, zend_jit_addr op1_addr, uint32_t op2_info, zend_ssa_range *op2_range, zend_jit_addr op2_addr, uint32_t res_use_info, uint32_t res_info, zend_jit_addr res_addr, zend_bool send_result, int may_throw) { ZEND_ASSERT(!(op1_info & MAY_BE_UNDEF) && !(op2_info & MAY_BE_UNDEF)); ZEND_ASSERT((op1_info & MAY_BE_LONG) && (op2_info & MAY_BE_LONG)); @@ -4790,7 +4831,7 @@ static int zend_jit_long_math(dasm_State **Dst, const zend_op *opline, const zen res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_RX, (opline+1)->result.var); } - if (!zend_jit_long_math_helper(Dst, opline, opline->opcode, op_array, + if (!zend_jit_long_math_helper(Dst, opline, opline->opcode, opline->op1_type, opline->op1, op1_addr, op1_info, op1_range, opline->op2_type, opline->op2, op2_addr, op2_info, op2_range, opline->result.var, res_addr, res_info, res_use_info, may_throw)) { @@ -4804,7 +4845,6 @@ static int zend_jit_long_math(dasm_State **Dst, const zend_op *opline, const zen static int zend_jit_concat_helper(dasm_State **Dst, const zend_op *opline, - const zend_op_array *op_array, zend_uchar op1_type, znode_op op1, zend_jit_addr op1_addr, @@ -4814,7 +4854,6 @@ static int zend_jit_concat_helper(dasm_State **Dst, zend_jit_addr op2_addr, uint32_t op2_info, zend_jit_addr res_addr, - uint32_t res_info, int may_throw) { #if 1 @@ -4847,8 +4886,8 @@ static int zend_jit_concat_helper(dasm_State **Dst, | add r4, 12 |.endif } - | FREE_OP op1_type, op1, op1_info, 0, op_array, opline - | FREE_OP op2_type, op2, op2_info, 0, op_array, opline + | FREE_OP op1_type, op1, op1_info, 0, opline + | FREE_OP op2_type, op2, op2_info, 0, opline |5: } if ((op1_info & ((MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_REF) - MAY_BE_STRING)) || @@ -4858,7 +4897,6 @@ static int zend_jit_concat_helper(dasm_State **Dst, |6: } #endif - | SAVE_VALID_OPLINE opline, r0 if (Z_REG(res_addr) != ZREG_FCARG1a || Z_OFFSET(res_addr) != 0) { | LOAD_ZVAL_ADDR FCARG1a, res_addr } @@ -4869,12 +4907,13 @@ static int zend_jit_concat_helper(dasm_State **Dst, | sub r4, 12 | PUSH_ZVAL_ADDR op2_addr, r0 |.endif + | SAVE_VALID_OPLINE opline, r0 | EXT_CALL concat_function, r0 |.if not(X64) | add r4, 12 |.endif - | FREE_OP op1_type, op1, op1_info, 0, op_array, opline - | FREE_OP op2_type, op2, op2_info, 0, op_array, opline + | FREE_OP op1_type, op1, op1_info, 0, opline + | FREE_OP op2_type, op2, op2_info, 0, opline if (may_throw) { zend_jit_check_exception(Dst); } @@ -4889,7 +4928,7 @@ static int zend_jit_concat_helper(dasm_State **Dst, return 1; } -static int zend_jit_concat(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, uint32_t op2_info, uint32_t res_info, zend_bool send_result, int may_throw) +static int zend_jit_concat(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, uint32_t op2_info, zend_bool send_result, int may_throw) { zend_jit_addr op1_addr, op2_addr, res_addr; @@ -4909,10 +4948,10 @@ static int zend_jit_concat(dasm_State **Dst, const zend_op *opline, const zend_o } else { res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var); } - return zend_jit_concat_helper(Dst, opline, op_array, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, res_addr, res_info, may_throw); + return zend_jit_concat_helper(Dst, opline, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, res_addr, may_throw); } -static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_op *opline, uint32_t type, uint32_t op1_info, uint32_t op2_info, uint32_t found, uint32_t not_found, const void *found_exit_addr, const void *not_found_exit_addr, const void *exit_addr) +static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_op *opline, uint32_t type, uint32_t op1_info, uint32_t op2_info, const void *found_exit_addr, const void *not_found_exit_addr, const void *exit_addr) /* Labels: 1,2,3,4,5 */ { zend_jit_addr op2_addr = OP2_ADDR(); @@ -4921,7 +4960,7 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE && type == BP_VAR_R && !exit_addr) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { return 0; @@ -4929,70 +4968,71 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o } if (op2_info & MAY_BE_LONG) { + zend_bool op2_loaded = 0; + zend_bool packed_loaded = 0; + if (op2_info & ((MAY_BE_ANY|MAY_BE_UNDEF) - MAY_BE_LONG)) { | // if (EXPECTED(Z_TYPE_P(dim) == IS_LONG)) | IF_NOT_ZVAL_TYPE op2_addr, IS_LONG, >3 } - if (type == BP_VAR_W || type == BP_VAR_RW) { + if (op1_info & MAY_BE_PACKED_GUARD) { + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_PACKED_GUARD); + const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); + + if (!exit_addr) { + return 0; + } + if (op1_info & MAY_BE_ARRAY_PACKED) { + | test dword [FCARG1a + offsetof(zend_array, u.flags)], HASH_FLAG_PACKED + | jz &exit_addr + } else { + | test dword [FCARG1a + offsetof(zend_array, u.flags)], HASH_FLAG_PACKED + | jnz &exit_addr + } + } + if (type == BP_VAR_W) { | // hval = Z_LVAL_P(dim); | GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr + op2_loaded = 1; } - if (op1_info & MAY_BE_ARRAY_KEY_LONG) { + if (op1_info & MAY_BE_ARRAY_PACKED) { + zend_long val = -1; + if (Z_MODE(op2_addr) == IS_CONST_ZVAL) { - zend_long val = Z_LVAL_P(Z_ZV(op2_addr)); + val = Z_LVAL_P(Z_ZV(op2_addr)); if (val >= 0 && val < HT_MAX_SIZE) { - | // ZEND_HASH_INDEX_FIND(ht, hval, retval, num_undef); - | test dword [FCARG1a + offsetof(zend_array, u.flags)], HASH_FLAG_PACKED - | jz >4 // HASH_FIND - | // if (EXPECTED((zend_ulong)(_h) < (zend_ulong)(_ht)->nNumUsed)) - |.if X64 - | movsxd r0, dword [FCARG1a + offsetof(zend_array, nNumUsed)] - if (val == 0) { - | test r0, r0 - } else { - | cmp r0, val - } - |.else - | cmp dword [FCARG1a + offsetof(zend_array, nNumUsed)], val - |.endif - if (type == BP_JIT_IS) { - if (not_found_exit_addr) { - | jbe ¬_found_exit_addr - } else { - | jbe >9 // NOT_FOUND - } - } else if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE && type == BP_VAR_R) { - | jbe &exit_addr - } else if (type == BP_VAR_IS && not_found_exit_addr) { - | jbe ¬_found_exit_addr - } else { - | jbe >2 // NOT_FOUND - } - | // _ret = &_ht->arData[_h].val; - | mov r0, aword [FCARG1a + offsetof(zend_array, arData)] - if (val != 0) { - | add r0, val * sizeof(Bucket) - } - if (type == BP_JIT_IS) { - | jmp >5 - } else { - | IF_NOT_Z_TYPE r0, IS_UNDEF, >8 - } + packed_loaded = 1; } } else { - if (type != BP_VAR_W && type != BP_VAR_RW) { + if (!op2_loaded) { | // hval = Z_LVAL_P(dim); | GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr + op2_loaded = 1; } + packed_loaded = 1; + } + if (packed_loaded) { | // ZEND_HASH_INDEX_FIND(ht, hval, retval, num_undef); - | test dword [FCARG1a + offsetof(zend_array, u.flags)], HASH_FLAG_PACKED - | jz >4 // HASH_FIND + if (op1_info & MAY_BE_ARRAY_HASH) { + | test dword [FCARG1a + offsetof(zend_array, u.flags)], HASH_FLAG_PACKED + | jz >4 // HASH_FIND + } | // if (EXPECTED((zend_ulong)(_h) < (zend_ulong)(_ht)->nNumUsed)) |.if X64 | movsxd r0, dword [FCARG1a + offsetof(zend_array, nNumUsed)] - | cmp r0, FCARG2a + if (val == 0) { + | test r0, r0 + } else if (val > 0 && !op2_loaded) { + | cmp r0, val + } else { + | cmp r0, FCARG2a + } |.else - | cmp dword [FCARG1a + offsetof(zend_array, nNumUsed)], FCARG2a + if (val >= 0 && !op2_loaded) { + | cmp dword [FCARG1a + offsetof(zend_array, nNumUsed)], val + } else { + | cmp dword [FCARG1a + offsetof(zend_array, nNumUsed)], FCARG2a + } |.endif if (type == BP_JIT_IS) { if (not_found_exit_addr) { @@ -5004,80 +5044,103 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o | jbe &exit_addr } else if (type == BP_VAR_IS && not_found_exit_addr) { | jbe ¬_found_exit_addr + } else if (type == BP_VAR_IS && found_exit_addr) { + | jbe >7 // NOT_FOUND } else { | jbe >2 // NOT_FOUND } | // _ret = &_ht->arData[_h].val; - |.if X64 - | mov r0, FCARG2a - | shl r0, 5 - |.else - | imul r0, FCARG2a, sizeof(Bucket) - |.endif - | add r0, aword [FCARG1a + offsetof(zend_array, arData)] - if (type == BP_JIT_IS) { - | jmp >5 + if (val >= 0) { + | mov r0, aword [FCARG1a + offsetof(zend_array, arData)] + if (val != 0) { + | add r0, val * sizeof(Bucket) + } } else { - | IF_NOT_Z_TYPE r0, IS_UNDEF, >8 + |.if X64 + | mov r0, FCARG2a + | shl r0, 5 + |.else + | imul r0, FCARG2a, sizeof(Bucket) + |.endif + | add r0, aword [FCARG1a + offsetof(zend_array, arData)] } } } switch (type) { case BP_JIT_IS: - if (op1_info & MAY_BE_ARRAY_KEY_LONG) { + if (op1_info & MAY_BE_ARRAY_HASH) { + if (packed_loaded) { + | jmp >5 + } |4: - } - if (Z_MODE(op2_addr) == IS_CONST_ZVAL) { - | // hval = Z_LVAL_P(dim); - | GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr - } - | EXT_CALL _zend_hash_index_find, r0 - | test r0, r0 - if (not_found_exit_addr) { - | jz ¬_found_exit_addr + if (!op2_loaded) { + | // hval = Z_LVAL_P(dim); + | GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr + } + | EXT_CALL _zend_hash_index_find, r0 + | test r0, r0 + if (not_found_exit_addr) { + | jz ¬_found_exit_addr + } else { + | jz >9 // NOT_FOUND + } + if (op2_info & MAY_BE_STRING) { + | jmp >5 + } + } else if (packed_loaded) { + if (op2_info & MAY_BE_STRING) { + | jmp >5 + } + } else if (not_found_exit_addr) { + | jmp ¬_found_exit_addr } else { - | jz >9 // NOT_FOUND - } - if (op2_info & MAY_BE_STRING) { - | jmp >5 + | jmp >9 // NOT_FOUND } break; case BP_VAR_R: case BP_VAR_IS: case BP_VAR_UNSET: - if (op1_info & MAY_BE_ARRAY_KEY_LONG) { - if (Z_MODE(op2_addr) == IS_CONST_ZVAL) { - zend_long val = Z_LVAL_P(Z_ZV(op2_addr)); - if (val >= 0 && val < HT_MAX_SIZE) { - if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE && type == BP_VAR_R) { - | jmp &exit_addr - } else if (type == BP_VAR_IS && not_found_exit_addr) { - | jmp ¬_found_exit_addr - } else { - | jmp >2 // NOT_FOUND - } - } + if (packed_loaded) { + if (op1_info & MAY_BE_ARRAY_HASH) { + | IF_NOT_Z_TYPE r0, IS_UNDEF, >8 } else if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE && type == BP_VAR_R) { + | IF_Z_TYPE r0, IS_UNDEF, &exit_addr + } else if (type == BP_VAR_IS && not_found_exit_addr) { + | IF_Z_TYPE r0, IS_UNDEF, ¬_found_exit_addr + } else if (type == BP_VAR_IS && found_exit_addr) { + | IF_Z_TYPE r0, IS_UNDEF, >7 // NOT_FOUND + } else { + | IF_Z_TYPE r0, IS_UNDEF, >2 // NOT_FOUND + } + } + if (!(op1_info & MAY_BE_ARRAY_KEY_LONG) || (packed_loaded && (op1_info & MAY_BE_ARRAY_HASH))) { + if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE && type == BP_VAR_R) { | jmp &exit_addr } else if (type == BP_VAR_IS && not_found_exit_addr) { | jmp ¬_found_exit_addr + } else if (type == BP_VAR_IS && found_exit_addr) { + | jmp >7 // NOT_FOUND } else { | jmp >2 // NOT_FOUND } - |4: - } - if (Z_MODE(op2_addr) == IS_CONST_ZVAL) { - | // hval = Z_LVAL_P(dim); - | GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr } - | EXT_CALL _zend_hash_index_find, r0 - | test r0, r0 - if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE && type == BP_VAR_R) { - | jz &exit_addr - } else if (type == BP_VAR_IS && not_found_exit_addr) { - | jz ¬_found_exit_addr - } else { - | jz >2 // NOT_FOUND + if (op1_info & MAY_BE_ARRAY_HASH) { + |4: + if (!op2_loaded) { + | // hval = Z_LVAL_P(dim); + | GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr + } + | EXT_CALL _zend_hash_index_find, r0 + | test r0, r0 + if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE && type == BP_VAR_R) { + | jz &exit_addr + } else if (type == BP_VAR_IS && not_found_exit_addr) { + | jz ¬_found_exit_addr + } else if (type == BP_VAR_IS && found_exit_addr) { + | jz >7 // NOT_FOUND + } else { + | jz >2 // NOT_FOUND + } } |.cold_code |2: @@ -5092,7 +5155,7 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o break; case BP_VAR_IS: case BP_VAR_UNSET: - if (!not_found_exit_addr) { + if (!not_found_exit_addr && !found_exit_addr) { | // retval = &EG(uninitialized_zval); | SET_ZVAL_TYPE_INFO res_addr, IS_NULL | jmp >9 @@ -5104,31 +5167,51 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o |.code break; case BP_VAR_RW: + if (packed_loaded) { + | IF_NOT_Z_TYPE r0, IS_UNDEF, >8 + } |2: - if (op1_info & MAY_BE_ARRAY_KEY_LONG) { - |4: - | SAVE_VALID_OPLINE opline, r0 - | EXT_CALL zend_jit_hash_index_lookup_rw, r0 - | test r0, r0 - | jz >9 + |4: + if (!op2_loaded) { + | // hval = Z_LVAL_P(dim); + | GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr } + | SAVE_VALID_OPLINE opline, r0 + | EXT_CALL zend_jit_hash_index_lookup_rw, r0 + | test r0, r0 + | jz >9 break; case BP_VAR_W: - |2: - | //retval = zend_hash_index_add_new(ht, hval, &EG(uninitialized_zval)); - |.if X64 - | LOAD_ADDR_ZTS CARG3, executor_globals, uninitialized_zval - |.else - | sub r4, 12 - | PUSH_ADDR_ZTS executor_globals, uninitialized_zval, r0 - |.endif - | EXT_CALL zend_hash_index_add_new, r0 - |.if not(X64) - | add r4, 12 - |.endif - if (op1_info & MAY_BE_ARRAY_KEY_LONG) { - | jmp >8 + if (packed_loaded) { + | IF_NOT_Z_TYPE r0, IS_UNDEF, >8 + } + if (!(op1_info & MAY_BE_ARRAY_KEY_LONG) || packed_loaded) { + |2: + | //retval = zend_hash_index_add_new(ht, hval, &EG(uninitialized_zval)); + if (!op2_loaded) { + | // hval = Z_LVAL_P(dim); + | GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr + } + |.if X64 + | LOAD_ADDR_ZTS CARG3, executor_globals, uninitialized_zval + |.else + | sub r4, 12 + | PUSH_ADDR_ZTS executor_globals, uninitialized_zval, r0 + |.endif + | EXT_CALL zend_hash_index_add_new, r0 + |.if not(X64) + | add r4, 12 + |.endif + if (op1_info & MAY_BE_ARRAY_HASH) { + | jmp >8 + } + } + if (op1_info & MAY_BE_ARRAY_HASH) { |4: + if (!op2_loaded) { + | // hval = Z_LVAL_P(dim); + | GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr + } | EXT_CALL zend_jit_hash_index_lookup_w, r0 } break; @@ -5197,6 +5280,8 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o | jz &exit_addr } else if (type == BP_VAR_IS && not_found_exit_addr) { | jz ¬_found_exit_addr + } else if (type == BP_VAR_IS && found_exit_addr) { + | jz >7 // NOT_FOUND } else { | jz >2 // NOT_FOUND } @@ -5217,13 +5302,11 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o // zend_error(E_WARNING, "Undefined array key \"%s\"", ZSTR_VAL(offset_key)); | UNDEFINED_INDEX opline | jmp >9 - } else { - | jmp &exit_addr } break; case BP_VAR_IS: case BP_VAR_UNSET: - if (!not_found_exit_addr) { + if (!not_found_exit_addr && !found_exit_addr) { | // retval = &EG(uninitialized_zval); | SET_ZVAL_TYPE_INFO res_addr, IS_NULL | jmp >9 @@ -5349,7 +5432,6 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o static int zend_jit_simple_assign(dasm_State **Dst, const zend_op *opline, - const zend_op_array *op_array, zend_jit_addr var_addr, uint32_t var_info, uint32_t var_def_info, @@ -5362,20 +5444,28 @@ static int zend_jit_simple_assign(dasm_State **Dst, int save_r1) /* Labels: 1,2,3 */ { - ZEND_ASSERT(Z_MODE(var_addr) == IS_REG || Z_REG(var_addr) != ZREG_R0); + zend_reg tmp_reg; + + if (Z_MODE(var_addr) == IS_REG || Z_REG(var_addr) != ZREG_R0) { + tmp_reg = ZREG_R0; + } else { + /* ASSIGN_DIM */ + tmp_reg = ZREG_FCARG1a; + } + if (Z_MODE(val_addr) == IS_CONST_ZVAL) { zval *zv = Z_ZV(val_addr); if (!res_addr) { - | ZVAL_COPY_CONST var_addr, var_info, var_def_info, zv, r0 + | ZVAL_COPY_CONST var_addr, var_info, var_def_info, zv, tmp_reg } else { - | ZVAL_COPY_CONST_2 var_addr, res_addr, var_info, var_def_info, zv, r0 + | ZVAL_COPY_CONST_2 var_addr, res_addr, var_info, var_def_info, zv, tmp_reg } if (Z_REFCOUNTED_P(zv)) { if (!res_addr) { - | ADDREF_CONST zv, r0 + | ADDREF_CONST zv, Ra(tmp_reg) } else { - | ADDREF_CONST_2 zv, r0 + | ADDREF_CONST_2 zv, Ra(tmp_reg) } } } else { @@ -5395,7 +5485,7 @@ static int zend_jit_simple_assign(dasm_State **Dst, if (res_addr) { | SET_ZVAL_TYPE_INFO res_addr, IS_NULL } - | SAVE_VALID_OPLINE opline, r0 + | SAVE_VALID_OPLINE opline, Ra(tmp_reg) | mov FCARG1d, val.var | EXT_CALL zend_jit_undefined_op_helper, r0 if (save_r1) { @@ -5430,28 +5520,28 @@ static int zend_jit_simple_assign(dasm_State **Dst, | // ZVAL_COPY_VALUE(return_value, &ref->value); ref_addr = ZEND_ADDR_MEM_ZVAL(ZREG_R2, 8); if (!res_addr) { - | ZVAL_COPY_VALUE var_addr, var_info, ref_addr, val_info, ZREG_R2, ZREG_R0 + | ZVAL_COPY_VALUE var_addr, var_info, ref_addr, val_info, ZREG_R2, tmp_reg } else { - | ZVAL_COPY_VALUE_2 var_addr, var_info, res_addr, ref_addr, val_info, ZREG_R2, ZREG_R0 + | ZVAL_COPY_VALUE_2 var_addr, var_info, res_addr, ref_addr, val_info, ZREG_R2, tmp_reg } | je >2 | IF_NOT_REFCOUNTED dh, >3 if (!res_addr) { - | GC_ADDREF r0 + | GC_ADDREF Ra(tmp_reg) } else { - | add dword [r0], 2 + | add dword [Ra(tmp_reg)], 2 } | jmp >3 |2: if (res_addr) { | IF_NOT_REFCOUNTED dh, >2 - | GC_ADDREF r0 + | GC_ADDREF Ra(tmp_reg) |2: } if (save_r1) { | mov aword T1, FCARG1a // save } - | EFREE_24 aword [Ra(Z_REG(val_addr))+Z_OFFSET(val_addr)], op_array, opline + | EFREE_24 aword [Ra(Z_REG(val_addr))+Z_OFFSET(val_addr)] if (save_r1) { | mov FCARG1a, aword T1 // restore } @@ -5465,20 +5555,20 @@ static int zend_jit_simple_assign(dasm_State **Dst, } if (!res_addr) { - | ZVAL_COPY_VALUE var_addr, var_info, val_addr, val_info, ZREG_R2, ZREG_R0 + | ZVAL_COPY_VALUE var_addr, var_info, val_addr, val_info, ZREG_R2, tmp_reg } else { - | ZVAL_COPY_VALUE_2 var_addr, var_info, res_addr, val_addr, val_info, ZREG_R2, ZREG_R0 + | ZVAL_COPY_VALUE_2 var_addr, var_info, res_addr, val_addr, val_info, ZREG_R2, tmp_reg } if (val_type == IS_CV) { if (!res_addr) { - | TRY_ADDREF val_info, dh, r0 + | TRY_ADDREF val_info, dh, Ra(tmp_reg) } else { - | TRY_ADDREF_2 val_info, dh, r0 + | TRY_ADDREF_2 val_info, dh, Ra(tmp_reg) } } else { if (res_addr) { - | TRY_ADDREF val_info, dh, r0 + | TRY_ADDREF val_info, dh, Ra(tmp_reg) } } |3: @@ -5488,7 +5578,6 @@ static int zend_jit_simple_assign(dasm_State **Dst, static int zend_jit_assign_to_typed_ref(dasm_State **Dst, const zend_op *opline, - const zend_op_array *op_array, zend_uchar val_type, zend_jit_addr val_addr, zend_bool check_exception) @@ -5526,7 +5615,6 @@ static int zend_jit_assign_to_typed_ref(dasm_State **Dst, static int zend_jit_assign_to_variable(dasm_State **Dst, const zend_op *opline, - const zend_op_array *op_array, zend_jit_addr var_use_addr, zend_jit_addr var_addr, uint32_t var_info, @@ -5540,24 +5628,33 @@ static int zend_jit_assign_to_variable(dasm_State **Dst, /* Labels: 1,2,3,4,5,8 */ { int done = 0; + zend_reg ref_reg, tmp_reg; + + if (Z_MODE(var_addr) == IS_REG || Z_REG(var_use_addr) != ZREG_R0) { + ref_reg = ZREG_FCARG1a; + tmp_reg = ZREG_R0; + } else { + /* ASSIGN_DIM */ + ref_reg = ZREG_R0; + tmp_reg = ZREG_FCARG1a; + } if (var_info & MAY_BE_REF) { - if (Z_MODE(var_use_addr) != IS_MEM_ZVAL || Z_REG(var_use_addr) != ZREG_FCARG1a || Z_OFFSET(var_use_addr) != 0) { - | LOAD_ZVAL_ADDR FCARG1a, var_use_addr - var_addr = var_use_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0); + if (Z_MODE(var_use_addr) != IS_MEM_ZVAL || Z_REG(var_use_addr) != ref_reg || Z_OFFSET(var_use_addr) != 0) { + | LOAD_ZVAL_ADDR Ra(ref_reg), var_use_addr + var_addr = var_use_addr = ZEND_ADDR_MEM_ZVAL(ref_reg, 0); } | // if (Z_ISREF_P(variable_ptr)) { - | IF_NOT_Z_TYPE, FCARG1a, IS_REFERENCE, >1 + | IF_NOT_Z_TYPE, Ra(ref_reg), IS_REFERENCE, >1 | // if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(Z_REF_P(variable_ptr)))) { - | GET_Z_PTR FCARG1a, FCARG1a - if (!zend_jit_assign_to_typed_ref(Dst, opline, op_array, val_type, val_addr, check_exception)) { + | GET_Z_PTR FCARG1a, Ra(ref_reg) + if (!zend_jit_assign_to_typed_ref(Dst, opline, val_type, val_addr, check_exception)) { return 0; } - | add FCARG1a, offsetof(zend_reference, val) + | lea Ra(ref_reg), [FCARG1a + offsetof(zend_reference, val)] |1: } if (var_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) { - ZEND_ASSERT(Z_REG(var_use_addr) != ZREG_R0); if (RC_MAY_BE_1(var_info)) { int in_cold = 0; @@ -5567,18 +5664,47 @@ static int zend_jit_assign_to_variable(dasm_State **Dst, |1: in_cold = 1; } - if (Z_REG(var_use_addr) == ZREG_FCARG1a) { - | GET_ZVAL_PTR r0, var_use_addr - | mov aword T1, r0 // save - if (!zend_jit_simple_assign(Dst, opline, op_array, var_addr, var_info, var_def_info, val_type, val, val_addr, val_info, res_addr, in_cold, 0)) { + if (Z_REG(var_use_addr) == ZREG_FCARG1a || Z_REG(var_use_addr) == ZREG_R0) { + zend_bool keep_gc = 0; + + | GET_ZVAL_PTR Ra(tmp_reg), var_use_addr + if (tmp_reg == ZREG_FCARG1a) { + if (Z_MODE(val_addr) == IS_REG) { + keep_gc = 1; + } else if ((val_info & ((MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_GUARD)-(MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE))) == 0) { + keep_gc = 1; + } else if (Z_MODE(val_addr) == IS_CONST_ZVAL) { + if (sizeof(void*) == 4) { + keep_gc = 1; + } else { + zval *zv = Z_ZV(val_addr); + + if (Z_TYPE_P(zv) == IS_DOUBLE) { + if (Z_DVAL_P(zv) == 0 || IS_32BIT(zv)) { + keep_gc = 1; + } + } else if (IS_SIGNED_32BIT(Z_LVAL_P(zv))) { + keep_gc = 1; + } + } + } else if (Z_MODE(val_addr) == IS_MEM_ZVAL) { + if ((val_info & (MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_GUARD)) == MAY_BE_DOUBLE) { + keep_gc = 1; + } + } + } + if (!keep_gc) { + | mov aword T1, Ra(tmp_reg) // save + } + if (!zend_jit_simple_assign(Dst, opline, var_addr, var_info, var_def_info, val_type, val, val_addr, val_info, res_addr, in_cold, 0)) { return 0; } - if (Z_REG(var_use_addr) == ZREG_FCARG1a) { + if (!keep_gc) { | mov FCARG1a, aword T1 // restore } } else { | GET_ZVAL_PTR FCARG1a, var_use_addr - if (!zend_jit_simple_assign(Dst, opline, op_array, var_addr, var_info, var_def_info, val_type, val, val_addr, val_info, res_addr, in_cold, 1)) { + if (!zend_jit_simple_assign(Dst, opline, var_addr, var_info, var_def_info, val_type, val, val_addr, val_info, res_addr, in_cold, 1)) { return 0; } } @@ -5615,32 +5741,26 @@ static int zend_jit_assign_to_variable(dasm_State **Dst, if (var_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_OBJECT|MAY_BE_RESOURCE))) { | IF_NOT_ZVAL_REFCOUNTED var_use_addr, >5 } - | GET_ZVAL_PTR r0, var_use_addr - | GC_DELREF r0 if (var_info & (MAY_BE_ARRAY|MAY_BE_OBJECT)) { if (Z_REG(var_use_addr) == ZREG_FP) { - | GET_ZVAL_PTR FCARG1a, var_use_addr - | IF_GC_MAY_NOT_LEAK FCARG1a, >5 - } else if (Z_REG(var_use_addr) != ZREG_FCARG1a) { - | GET_ZVAL_PTR FCARG1a, var_use_addr - | IF_GC_MAY_NOT_LEAK FCARG1a, >5 | mov T1, Ra(Z_REG(var_use_addr)) // save - } else { - | GET_ZVAL_PTR r0, var_use_addr - | IF_GC_MAY_NOT_LEAK r0, >5 - | mov T1, Ra(Z_REG(var_use_addr)) // save - | GET_ZVAL_PTR FCARG1a, var_use_addr } + | GET_ZVAL_PTR FCARG1a, var_use_addr + | GC_DELREF FCARG1a + | IF_GC_MAY_NOT_LEAK FCARG1a, >5 | EXT_CALL gc_possible_root, r0 if (Z_REG(var_use_addr) != ZREG_FP) { | mov Ra(Z_REG(var_use_addr)), T1 // restore } + } else { + | GET_ZVAL_PTR Ra(tmp_reg), var_use_addr + | GC_DELREF Ra(tmp_reg) } |5: } } - if (!done && !zend_jit_simple_assign(Dst, opline, op_array, var_addr, var_info, var_def_info, val_type, val, val_addr, val_info, res_addr, 0, 0)) { + if (!done && !zend_jit_simple_assign(Dst, opline, var_addr, var_info, var_def_info, val_type, val, val_addr, val_info, res_addr, 0, 0)) { return 0; } @@ -5649,7 +5769,7 @@ static int zend_jit_assign_to_variable(dasm_State **Dst, return 1; } -static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, uint32_t val_info, int may_throw) +static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, uint32_t val_info, int may_throw) { zend_jit_addr op2_addr, op3_addr, res_addr; @@ -5711,7 +5831,7 @@ static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, const ze |6: if (opline->op2_type == IS_UNUSED) { uint32_t var_info = MAY_BE_NULL; - zend_jit_addr var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0); + zend_jit_addr var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_R0, 0); | // var_ptr = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval)); | LOAD_ADDR_ZTS FCARG2a, executor_globals, uninitialized_zval @@ -5726,30 +5846,28 @@ static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, const ze | //ZEND_VM_C_GOTO(assign_dim_op_ret_null); | jmp >9 |.code - | mov FCARG1a, r0 - if (!zend_jit_simple_assign(Dst, opline, op_array, var_addr, var_info, -1, (opline+1)->op1_type, (opline+1)->op1, op3_addr, val_info, res_addr, 0, 0)) { + if (!zend_jit_simple_assign(Dst, opline, var_addr, var_info, -1, (opline+1)->op1_type, (opline+1)->op1, op3_addr, val_info, res_addr, 0, 0)) { return 0; } } else { uint32_t var_info = zend_array_element_type(op1_info, opline->op1_type, 0, 0); - zend_jit_addr var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0); + zend_jit_addr var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_R0, 0); - if (!zend_jit_fetch_dimension_address_inner(Dst, opline, BP_VAR_W, op1_info, op2_info, 8, 8, NULL, NULL, NULL)) { + if (!zend_jit_fetch_dimension_address_inner(Dst, opline, BP_VAR_W, op1_info, op2_info, NULL, NULL, NULL)) { return 0; } - |8: - | mov FCARG1a, r0 - if (op1_info & (MAY_BE_ARRAY_OF_REF|MAY_BE_OBJECT)) { var_info |= MAY_BE_REF; } if (var_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) { var_info |= MAY_BE_RC1; } + + |8: | // value = zend_assign_to_variable(variable_ptr, value, OP_DATA_TYPE); - if (!zend_jit_assign_to_variable(Dst, opline, op_array, var_addr, var_addr, var_info, -1, (opline+1)->op1_type, (opline+1)->op1, op3_addr, val_info, res_addr, 0)) { + if (!zend_jit_assign_to_variable(Dst, opline, var_addr, var_addr, var_info, -1, (opline+1)->op1_type, (opline+1)->op1, op3_addr, val_info, res_addr, 0)) { return 0; } } @@ -5831,7 +5949,7 @@ static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, const ze } #endif - | FREE_OP (opline+1)->op1_type, (opline+1)->op1, val_info, 0, op_array, opline + | FREE_OP (opline+1)->op1_type, (opline+1)->op1, val_info, 0, opline } if (op1_info & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_ARRAY)) { @@ -5850,7 +5968,7 @@ static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, const ze #endif |9: - | FREE_OP opline->op2_type, opline->op2, op2_info, 0, op_array, opline + | FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline if (may_throw) { zend_jit_check_exception(Dst); @@ -5859,7 +5977,7 @@ static int zend_jit_assign_dim(dasm_State **Dst, const zend_op *opline, const ze return 1; } -static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, uint32_t op1_def_info, zend_jit_addr op1_addr, uint32_t op2_info, uint32_t op1_data_info, zend_ssa_range *op1_data_range, int may_throw) +static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, uint32_t op1_def_info, zend_jit_addr op1_addr, uint32_t op2_info, uint32_t op1_data_info, zend_ssa_range *op1_data_range, int may_throw) { zend_jit_addr op2_addr, op3_addr, var_addr; @@ -5952,7 +6070,6 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, const | //ZEND_VM_C_GOTO(assign_dim_op_ret_null); | jmp >9 |.code - | mov FCARG1a, r0 } else { var_info = zend_array_element_type(op1_info, opline->op1_type, 0, 0); if (op1_info & (MAY_BE_ARRAY_OF_REF|MAY_BE_OBJECT)) { @@ -5962,19 +6079,18 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, const var_info |= MAY_BE_RC1; } - if (!zend_jit_fetch_dimension_address_inner(Dst, opline, BP_VAR_RW, op1_info, op2_info, 8, 8, NULL, NULL, NULL)) { + if (!zend_jit_fetch_dimension_address_inner(Dst, opline, BP_VAR_RW, op1_info, op2_info, NULL, NULL, NULL)) { return 0; } |8: - | mov FCARG1a, r0 if (op1_info & (MAY_BE_ARRAY_OF_REF)) { binary_op_type binary_op = get_binary_op(opline->extended_value); - | IF_NOT_Z_TYPE, FCARG1a, IS_REFERENCE, >1 - | GET_Z_PTR FCARG1a, FCARG1a + | IF_NOT_Z_TYPE, r0, IS_REFERENCE, >1 + | GET_Z_PTR FCARG1a, r0 | cmp aword [FCARG1a + offsetof(zend_reference, sources.ptr)], 0 | jnz >2 - | add FCARG1a, offsetof(zend_reference, val) + | lea r0, aword [FCARG1a + offsetof(zend_reference, val)] |.cold_code |2: | LOAD_ZVAL_ADDR FCARG2a, op3_addr @@ -5996,13 +6112,13 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, const } } - var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0); + var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_R0, 0); switch (opline->extended_value) { case ZEND_ADD: case ZEND_SUB: case ZEND_MUL: case ZEND_DIV: - if (!zend_jit_math_helper(Dst, opline, opline->extended_value, op_array, IS_CV, opline->op1, var_addr, var_info, (opline+1)->op1_type, (opline+1)->op1, op3_addr, op1_data_info, 0, var_addr, var_def_info, var_info, + if (!zend_jit_math_helper(Dst, opline, opline->extended_value, IS_CV, opline->op1, var_addr, var_info, (opline+1)->op1_type, (opline+1)->op1, op3_addr, op1_data_info, 0, var_addr, var_def_info, var_info, 1 /* may overflow */, may_throw)) { return 0; } @@ -6013,7 +6129,7 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, const case ZEND_SL: case ZEND_SR: case ZEND_MOD: - if (!zend_jit_long_math_helper(Dst, opline, opline->extended_value, op_array, + if (!zend_jit_long_math_helper(Dst, opline, opline->extended_value, IS_CV, opline->op1, var_addr, var_info, NULL, (opline+1)->op1_type, (opline+1)->op1, op3_addr, op1_data_info, op1_data_range, @@ -6022,7 +6138,7 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, const } break; case ZEND_CONCAT: - if (!zend_jit_concat_helper(Dst, opline, op_array, IS_CV, opline->op1, var_addr, var_info, (opline+1)->op1_type, (opline+1)->op1, op3_addr, op1_data_info, var_addr, op1_def_info, + if (!zend_jit_concat_helper(Dst, opline, IS_CV, opline->op1, var_addr, var_info, (opline+1)->op1_type, (opline+1)->op1, op3_addr, op1_data_info, var_addr, may_throw)) { return 0; } @@ -6080,7 +6196,7 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, const return 1; } -static int zend_jit_assign_op(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, uint32_t op1_def_info, zend_ssa_range *op1_range, uint32_t op2_info, zend_ssa_range *op2_range, int may_overflow, int may_throw) +static int zend_jit_assign_op(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, uint32_t op1_def_info, zend_ssa_range *op1_range, uint32_t op2_info, zend_ssa_range *op2_range, int may_overflow, int may_throw) { zend_jit_addr op1_addr, op2_addr; @@ -6125,7 +6241,7 @@ static int zend_jit_assign_op(dasm_State **Dst, const zend_op *opline, const zen case ZEND_SUB: case ZEND_MUL: case ZEND_DIV: - result = zend_jit_math_helper(Dst, opline, opline->extended_value, op_array, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, opline->op1.var, op1_addr, op1_def_info, op1_info, may_overflow, may_throw); + result = zend_jit_math_helper(Dst, opline, opline->extended_value, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, opline->op1.var, op1_addr, op1_def_info, op1_info, may_overflow, may_throw); break; case ZEND_BW_OR: case ZEND_BW_AND: @@ -6133,13 +6249,13 @@ static int zend_jit_assign_op(dasm_State **Dst, const zend_op *opline, const zen case ZEND_SL: case ZEND_SR: case ZEND_MOD: - result = zend_jit_long_math_helper(Dst, opline, opline->extended_value, op_array, + result = zend_jit_long_math_helper(Dst, opline, opline->extended_value, opline->op1_type, opline->op1, op1_addr, op1_info, op1_range, opline->op2_type, opline->op2, op2_addr, op2_info, op2_range, opline->op1.var, op1_addr, op1_def_info, op1_info, may_throw); break; case ZEND_CONCAT: - result = zend_jit_concat_helper(Dst, opline, op_array, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, op1_addr, op1_def_info, may_throw); + result = zend_jit_concat_helper(Dst, opline, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, op1_addr, may_throw); break; default: ZEND_UNREACHABLE(); @@ -6187,6 +6303,7 @@ static int zend_jit_cmp_long_long(dasm_State **Dst, const zend_op *opline, zend_ case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: | sete al break; case ZEND_IS_NOT_EQUAL: @@ -6220,6 +6337,7 @@ static int zend_jit_cmp_long_long(dasm_State **Dst, const zend_op *opline, zend_ case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: if (exit_addr) { | jne &exit_addr } else { @@ -6279,6 +6397,7 @@ static int zend_jit_cmp_long_long(dasm_State **Dst, const zend_op *opline, zend_ case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: if (exit_addr) { | je &exit_addr } else { @@ -6337,6 +6456,7 @@ static int zend_jit_cmp_long_long(dasm_State **Dst, const zend_op *opline, zend_ case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: | jne => target_label break; case ZEND_IS_NOT_EQUAL: @@ -6369,6 +6489,7 @@ static int zend_jit_cmp_long_long(dasm_State **Dst, const zend_op *opline, zend_ case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: | sete al break; case ZEND_IS_NOT_EQUAL: @@ -6408,6 +6529,7 @@ static int zend_jit_cmp_double_common(dasm_State **Dst, const zend_op *opline, z case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: if (exit_addr) { | jne &exit_addr | jp &exit_addr @@ -6477,6 +6599,7 @@ static int zend_jit_cmp_double_common(dasm_State **Dst, const zend_op *opline, z case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: | jp >1 if (exit_addr) { | je &exit_addr @@ -6546,6 +6669,7 @@ static int zend_jit_cmp_double_common(dasm_State **Dst, const zend_op *opline, z case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: | jne => target_label | jp => target_label break; @@ -6579,6 +6703,7 @@ static int zend_jit_cmp_double_common(dasm_State **Dst, const zend_op *opline, z case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: | SET_ZVAL_TYPE_INFO res_addr, IS_FALSE | jne => target_label | jp => target_label @@ -6624,6 +6749,7 @@ static int zend_jit_cmp_double_common(dasm_State **Dst, const zend_op *opline, z case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: | jp >1 | SET_ZVAL_TYPE_INFO res_addr, IS_TRUE | je => target_label @@ -6678,6 +6804,7 @@ static int zend_jit_cmp_double_common(dasm_State **Dst, const zend_op *opline, z case ZEND_IS_EQUAL: case ZEND_IS_IDENTICAL: case ZEND_CASE: + case ZEND_CASE_STRICT: | jp >1 | mov eax, IS_TRUE | je >2 @@ -6915,7 +7042,7 @@ static int zend_jit_cmp_slow(dasm_State **Dst, const zend_op *opline, zend_jit_a return 1; } -static int zend_jit_cmp(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, zend_jit_addr op2_addr, zend_jit_addr res_addr, int may_throw, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) +static int zend_jit_cmp(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, zend_jit_addr op2_addr, zend_jit_addr res_addr, int may_throw, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) { zend_bool same_ops = (opline->op1_type == opline->op2_type) && (opline->op1.var == opline->op2.var); zend_bool has_slow; @@ -7120,9 +7247,9 @@ static int zend_jit_cmp(dasm_State **Dst, const zend_op *opline, const zend_op_a | add r4, 12 |.endif if (opline->opcode != ZEND_CASE) { - | FREE_OP opline->op1_type, opline->op1, op1_info, 0, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline } - | FREE_OP opline->op2_type, opline->op2, op2_info, 0, op_array, opline + | FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline if (may_throw) { zend_jit_check_exception_undef_result(Dst, opline); } @@ -7140,13 +7267,13 @@ static int zend_jit_cmp(dasm_State **Dst, const zend_op *opline, const zend_op_a return 1; } -static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, zend_jit_addr op2_addr, zend_jit_addr res_addr, int may_throw, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) +static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, zend_jit_addr op2_addr, zend_jit_addr res_addr, int may_throw, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) { uint32_t identical_label = (uint32_t)-1; uint32_t not_identical_label = (uint32_t)-1; if (smart_branch_opcode && !exit_addr) { - if (opline->opcode == ZEND_IS_IDENTICAL) { + if (opline->opcode != ZEND_IS_NOT_IDENTICAL) { if (smart_branch_opcode == ZEND_JMPZ) { not_identical_label = target_label; } else if (smart_branch_opcode == ZEND_JMPNZ) { @@ -7157,7 +7284,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen } else { ZEND_UNREACHABLE(); } - } else if (opline->opcode == ZEND_IS_NOT_IDENTICAL) { + } else { if (smart_branch_opcode == ZEND_JMPZ) { identical_label = target_label; } else if (smart_branch_opcode == ZEND_JMPNZ) { @@ -7168,8 +7295,6 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen } else { ZEND_UNREACHABLE(); } - } else { - ZEND_UNREACHABLE(); } } @@ -7292,13 +7417,16 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen } if ((op1_info & op2_info & MAY_BE_ANY) == 0) { - if (((opline->op1_type & (IS_VAR|IS_TMP_VAR)) && + if ((opline->opcode != ZEND_CASE_STRICT && + (opline->op1_type & (IS_VAR|IS_TMP_VAR)) && (op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))) || ((opline->op2_type & (IS_VAR|IS_TMP_VAR)) && (op2_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)))) { | SAVE_VALID_OPLINE opline, r0 - | FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline - | FREE_OP opline->op2_type, opline->op2, op2_info, 1, op_array, opline + if (opline->opcode != ZEND_CASE_STRICT) { + | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline + } + | FREE_OP opline->op2_type, opline->op2, op2_info, 1, opline } if (smart_branch_opcode) { zend_jit_check_exception_undef_result(Dst, opline); @@ -7310,7 +7438,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen | jmp =>not_identical_label } } else { - | SET_ZVAL_TYPE_INFO res_addr, (opline->opcode == ZEND_IS_IDENTICAL ? IS_FALSE : IS_TRUE) + | SET_ZVAL_TYPE_INFO res_addr, (opline->opcode != ZEND_IS_NOT_IDENTICAL ? IS_FALSE : IS_TRUE) zend_jit_check_exception(Dst); } } else if (has_concrete_type(op1_info) && @@ -7326,7 +7454,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen | jmp =>identical_label } } else { - | SET_ZVAL_TYPE_INFO res_addr, (opline->opcode == ZEND_IS_IDENTICAL ? IS_TRUE : IS_FALSE) + | SET_ZVAL_TYPE_INFO res_addr, (opline->opcode != ZEND_IS_NOT_IDENTICAL ? IS_TRUE : IS_FALSE) } } else if (Z_MODE(op1_addr) == IS_CONST_ZVAL && Z_MODE(op2_addr) == IS_CONST_ZVAL) { if (zend_is_identical(Z_ZV(op1_addr), Z_ZV(op2_addr))) { @@ -7339,7 +7467,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen | jmp =>identical_label } } else { - | SET_ZVAL_TYPE_INFO res_addr, (opline->opcode == ZEND_IS_IDENTICAL ? IS_TRUE : IS_FALSE) + | SET_ZVAL_TYPE_INFO res_addr, (opline->opcode != ZEND_IS_NOT_IDENTICAL ? IS_TRUE : IS_FALSE) } } else { if (smart_branch_opcode) { @@ -7351,7 +7479,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen | jmp =>not_identical_label } } else { - | SET_ZVAL_TYPE_INFO res_addr, (opline->opcode == ZEND_IS_IDENTICAL ? IS_FALSE : IS_TRUE) + | SET_ZVAL_TYPE_INFO res_addr, (opline->opcode != ZEND_IS_NOT_IDENTICAL ? IS_FALSE : IS_TRUE) } } } else if (Z_MODE(op1_addr) == IS_CONST_ZVAL && Z_TYPE_P(Z_ZV(op1_addr)) <= IS_TRUE) { @@ -7362,7 +7490,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen if (opline->op2_type == IS_VAR && (op2_info & MAY_BE_REF)) { | jne >8 | SAVE_VALID_OPLINE opline, r0 - | FREE_OP opline->op2_type, opline->op2, op2_info, 1, op_array, opline + | FREE_OP opline->op2_type, opline->op2, op2_info, 1, opline zend_jit_check_exception_undef_result(Dst, opline); if (exit_addr && smart_branch_opcode == ZEND_JMPNZ) { | jmp &exit_addr @@ -7380,7 +7508,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen | je >9 } } else { - if (opline->opcode == ZEND_IS_IDENTICAL) { + if (opline->opcode != ZEND_IS_NOT_IDENTICAL) { | sete al } else { | setne al @@ -7392,7 +7520,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen if ((opline->op2_type & (IS_VAR|IS_TMP_VAR)) && (op2_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))) { | SAVE_VALID_OPLINE opline, r0 - | FREE_OP opline->op2_type, opline->op2, op2_info, 1, op_array, opline + | FREE_OP opline->op2_type, opline->op2, op2_info, 1, opline zend_jit_check_exception_undef_result(Dst, opline); } if (exit_addr) { @@ -7407,10 +7535,11 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen | cmp byte [FCARG1a + offsetof(zval, u1.v.type)], Z_TYPE_P(val) if (smart_branch_opcode) { - if (opline->op1_type == IS_VAR && (op1_info & MAY_BE_REF)) { + if (opline->opcode != ZEND_CASE_STRICT + && opline->op1_type == IS_VAR && (op1_info & MAY_BE_REF)) { | jne >8 | SAVE_VALID_OPLINE opline, r0 - | FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline zend_jit_check_exception_undef_result(Dst, opline); if (exit_addr && smart_branch_opcode == ZEND_JMPNZ) { | jmp &exit_addr @@ -7428,7 +7557,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen | je >9 } } else { - if (opline->opcode == ZEND_IS_IDENTICAL) { + if (opline->opcode != ZEND_IS_NOT_IDENTICAL) { | sete al } else { | setne al @@ -7437,10 +7566,11 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen | lea eax, [eax + 2] | SET_ZVAL_TYPE_INFO res_addr, eax } - if ((opline->op1_type & (IS_VAR|IS_TMP_VAR)) && + if (opline->opcode != ZEND_CASE_STRICT + && (opline->op1_type & (IS_VAR|IS_TMP_VAR)) && (op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))) { | SAVE_VALID_OPLINE opline, r0 - | FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline zend_jit_check_exception_undef_result(Dst, opline); } if (smart_branch_opcode) { @@ -7460,14 +7590,17 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen | LOAD_ZVAL_ADDR FCARG2a, op2_addr } | EXT_CALL zend_is_identical, r0 - if (((opline->op1_type & (IS_VAR|IS_TMP_VAR)) && + if ((opline->opcode != ZEND_CASE_STRICT && + (opline->op1_type & (IS_VAR|IS_TMP_VAR)) && (op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))) || ((opline->op2_type & (IS_VAR|IS_TMP_VAR)) && (op2_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)))) { | mov aword T1, r0 // save | SAVE_VALID_OPLINE opline, r0 - | FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline - | FREE_OP opline->op2_type, opline->op2, op2_info, 1, op_array, opline + if (opline->opcode != ZEND_CASE_STRICT) { + | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline + } + | FREE_OP opline->op2_type, opline->op2, op2_info, 1, opline zend_jit_check_exception_undef_result(Dst, opline); | mov r0, aword T1 // restore } @@ -7489,7 +7622,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen } } else { | movzx eax, al - if (opline->opcode == ZEND_IS_IDENTICAL) { + if (opline->opcode != ZEND_IS_NOT_IDENTICAL) { | lea eax, [eax + 2] } else { | neg eax @@ -7506,7 +7639,7 @@ static int zend_jit_identical(dasm_State **Dst, const zend_op *opline, const zen return 1; } -static int zend_jit_bool_jmpznz(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr, zend_jit_addr res_addr, uint32_t target_label, uint32_t target_label2, int may_throw, zend_uchar branch_opcode, const void *exit_addr) +static int zend_jit_bool_jmpznz(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr, zend_jit_addr res_addr, uint32_t target_label, uint32_t target_label2, int may_throw, zend_uchar branch_opcode, const void *exit_addr) { uint32_t true_label = -1; uint32_t false_label = -1; @@ -7971,7 +8104,7 @@ static int zend_jit_bool_jmpznz(dasm_State **Dst, const zend_op *opline, const z return 1; } -static int zend_jit_qm_assign(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr, zend_jit_addr op1_def_addr, uint32_t res_info, zend_jit_addr res_addr) +static int zend_jit_qm_assign(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr, zend_jit_addr op1_def_addr, uint32_t res_info, zend_jit_addr res_addr) { if (op1_addr != op1_def_addr) { if (!zend_jit_update_regs(Dst, op1_addr, op1_def_addr, op1_info)) { @@ -7982,7 +8115,7 @@ static int zend_jit_qm_assign(dasm_State **Dst, const zend_op *opline, const zen } } - if (!zend_jit_simple_assign(Dst, opline, op_array, res_addr, -1, -1, opline->op1_type, opline->op1, op1_addr, op1_info, 0, 0, 0)) { + if (!zend_jit_simple_assign(Dst, opline, res_addr, -1, -1, opline->op1_type, opline->op1, op1_addr, op1_info, 0, 0, 0)) { return 0; } if (!zend_jit_store_var_if_necessary(Dst, opline->result.var, res_addr, res_info)) { @@ -7991,7 +8124,7 @@ static int zend_jit_qm_assign(dasm_State **Dst, const zend_op *opline, const zen return 1; } -static int zend_jit_assign(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_use_addr, uint32_t op1_def_info, zend_jit_addr op1_addr, uint32_t op2_info, zend_jit_addr op2_addr, zend_jit_addr op2_def_addr, uint32_t res_info, zend_jit_addr res_addr, int may_throw) +static int zend_jit_assign(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_use_addr, uint32_t op1_def_info, zend_jit_addr op1_addr, uint32_t op2_info, zend_jit_addr op2_addr, zend_jit_addr op2_def_addr, uint32_t res_info, zend_jit_addr res_addr, int may_throw) { ZEND_ASSERT(opline->op1_type == IS_CV); @@ -8011,7 +8144,7 @@ static int zend_jit_assign(dasm_State **Dst, const zend_op *opline, const zend_o /* Force type update */ op1_info |= MAY_BE_UNDEF; } - if (!zend_jit_assign_to_variable(Dst, opline, op_array, op1_use_addr, op1_addr, op1_info, op1_def_info, opline->op2_type, opline->op2, op2_addr, op2_info, res_addr, + if (!zend_jit_assign_to_variable(Dst, opline, op1_use_addr, op1_addr, op1_info, op1_def_info, opline->op2_type, opline->op2, op2_addr, op2_info, res_addr, may_throw)) { return 0; } @@ -8027,7 +8160,7 @@ static int zend_jit_assign(dasm_State **Dst, const zend_op *opline, const zend_o return 1; } -static int zend_jit_push_call_frame(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, zend_function *func) +static int zend_jit_push_call_frame(dasm_State **Dst, const zend_op *opline, zend_function *func) { uint32_t used_stack; @@ -8068,7 +8201,7 @@ static int zend_jit_push_call_frame(dasm_State **Dst, const zend_op *opline, con } if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -8305,7 +8438,7 @@ static int zend_jit_needs_call_chain(zend_call_info *call_info, uint32_t b, cons } } -static int zend_jit_init_fcall_guard(dasm_State **Dst, const zend_op *opline, const zend_function *func, const zend_op *to_opline) +static int zend_jit_init_fcall_guard(dasm_State **Dst, const zend_function *func, const zend_op *to_opline) { int32_t exit_point; const void *exit_addr; @@ -8325,7 +8458,7 @@ static int zend_jit_init_fcall_guard(dasm_State **Dst, const zend_op *opline, co return 0; } - exit_point = zend_jit_trace_get_exit_point(opline, to_opline, NULL, ZEND_JIT_EXIT_POLYMORPHISM); + exit_point = zend_jit_trace_get_exit_point(to_opline, ZEND_JIT_EXIT_POLYMORPHISM); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { return 0; @@ -8452,7 +8585,7 @@ static int zend_jit_init_fcall(dasm_State **Dst, const zend_op *opline, uint32_t | mov r1, EX->run_time_cache | mov aword [r1 + opline->result.num], r0 if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, 0); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, 0); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -8503,7 +8636,7 @@ static int zend_jit_init_fcall(dasm_State **Dst, const zend_op *opline, uint32_t |3: } - if (!zend_jit_push_call_frame(Dst, opline, op_array, func)) { + if (!zend_jit_push_call_frame(Dst, opline, func)) { return 0; } @@ -8641,7 +8774,7 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend if (opline->opcode == ZEND_DO_FCALL) { if (!func) { if (trace) { - uint32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + uint32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -8959,7 +9092,7 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend if (opline->opcode == ZEND_DO_FCALL_BY_NAME) { if (!func) { if (trace) { - uint32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + uint32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -9007,7 +9140,7 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend | // EG(current_execute_data) = execute_data; | MEM_OP2_1_ZTS mov, aword, executor_globals, current_execute_data, RX, r1 - zend_jit_reset_opline(Dst, NULL); + zend_jit_reset_opline(); | // fbc->internal_function.handler(call, ret); | mov FCARG1a, RX @@ -9106,7 +9239,7 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend // TODO: Can we avoid checking for interrupts after each call ??? if (trace && last_valid_opline != opline) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline + 1, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline + 1, ZEND_JIT_EXIT_TO_VM); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -9135,7 +9268,7 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend return 1; } -static int zend_jit_send_val(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr) +static int zend_jit_send_val(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr) { uint32_t arg_num = opline->op2.num; zend_jit_addr arg_addr; @@ -9162,7 +9295,7 @@ static int zend_jit_send_val(dasm_State **Dst, const zend_op *opline, const zend return 0; } } else if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { return 0; @@ -9188,7 +9321,7 @@ static int zend_jit_send_val(dasm_State **Dst, const zend_op *opline, const zend if (opline->op1_type == IS_CONST) { zval *zv = RT_CONSTANT(opline, opline->op1); - | ZVAL_COPY_CONST arg_addr, MAY_BE_ANY, MAY_BE_ANY, zv, r0 + | ZVAL_COPY_CONST arg_addr, MAY_BE_ANY, MAY_BE_ANY, zv, ZREG_R0 if (Z_REFCOUNTED_P(zv)) { | ADDREF_CONST zv, r0 } @@ -9291,7 +9424,7 @@ static int zend_jit_send_ref(dasm_State **Dst, const zend_op *opline, const zend } |6: - | FREE_OP opline->op1_type, opline->op1, op1_info, !cold, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, !cold, opline |7: return 1; @@ -9353,7 +9486,7 @@ static int zend_jit_send_var(dasm_State **Dst, const zend_op *opline, const zend /* Don't generate code that always throws exception */ return 0; } else { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { return 0; @@ -9383,7 +9516,7 @@ static int zend_jit_send_var(dasm_State **Dst, const zend_op *opline, const zend | test dword [r0 + offsetof(zend_function, quick_arg_flags)], mask | jnz >7 if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { return 0; @@ -9455,7 +9588,7 @@ static int zend_jit_send_var(dasm_State **Dst, const zend_op *opline, const zend | je >7 } if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { return 0; @@ -9494,7 +9627,7 @@ static int zend_jit_send_var(dasm_State **Dst, const zend_op *opline, const zend | GC_ADDREF r2 | jmp >2 |1: - | EFREE_REG_24 op_array, opline + | EFREE_REG_24 | jmp >2 |.code | ZVAL_COPY_VALUE arg_addr, MAY_BE_ANY, op1_addr, op1_info, ZREG_R0, ZREG_R2 @@ -9520,7 +9653,7 @@ static int zend_jit_send_var(dasm_State **Dst, const zend_op *opline, const zend return 1; } -static int zend_jit_check_func_arg(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array) +static int zend_jit_check_func_arg(dasm_State **Dst, const zend_op *opline) { uint32_t arg_num = opline->op2.num; @@ -9629,7 +9762,7 @@ static int zend_jit_smart_false(dasm_State **Dst, const zend_op *opline, int jmp return 1; } -static int zend_jit_defined(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) +static int zend_jit_defined(dasm_State **Dst, const zend_op *opline, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) { uint32_t defined_label = (uint32_t)-1; uint32_t undefined_label = (uint32_t)-1; @@ -9725,7 +9858,7 @@ static int zend_jit_defined(dasm_State **Dst, const zend_op *opline, const zend_ return 1; } -static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) +static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) { uint32_t mask; zend_uchar type; @@ -9786,7 +9919,7 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, const ze } if (!(op1_info & MAY_BE_GUARD) && !(op1_info & (MAY_BE_ANY - mask))) { - | FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline if (exit_addr) { if (smart_branch_opcode == ZEND_JMPNZ) { | jmp &exit_addr @@ -9795,7 +9928,7 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, const ze return 0; } } else if (!(op1_info & MAY_BE_GUARD) && !(op1_info & mask)) { - | FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline if (exit_addr) { if (smart_branch_opcode == ZEND_JMPZ) { | jmp &exit_addr @@ -9883,7 +10016,7 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, const ze | movzx eax, al | add eax, 2 | SET_ZVAL_TYPE_INFO res_addr, eax - | FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline } } else { if (smart_branch_opcode && @@ -9958,7 +10091,7 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, const ze | movzx eax, al | add eax, 2 | SET_ZVAL_TYPE_INFO res_addr, eax - | FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline + | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline } } } @@ -9969,7 +10102,7 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, const ze return 1; } -static uint32_t zend_ssa_cv_info(const zend_op *opline, const zend_op_array *op_array, zend_ssa *ssa, uint32_t var) +static uint32_t zend_ssa_cv_info(const zend_op_array *op_array, zend_ssa *ssa, uint32_t var) { uint32_t j, info; @@ -10015,7 +10148,7 @@ static int zend_jit_leave_frame(dasm_State **Dst) return 1; } -static int zend_jit_free_cv(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t info, uint32_t var) +static int zend_jit_free_cv(dasm_State **Dst, uint32_t info, uint32_t var) { if (info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) { uint32_t offset = EX_NUM_TO_VAR(var); @@ -10024,7 +10157,7 @@ static int zend_jit_free_cv(dasm_State **Dst, const zend_op *opline, const zend_ return 1; } -static int zend_jit_free_op(dasm_State **Dst, const zend_op *opline, /*const zend_op_array *op_array, */uint32_t info, uint32_t var_offset) +static int zend_jit_free_op(dasm_State **Dst, const zend_op *opline, uint32_t info, uint32_t var_offset) { if (info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) { | ZVAL_PTR_DTOR ZEND_ADDR_MEM_ZVAL(ZREG_FP, var_offset), info, 0, 1, opline @@ -10032,7 +10165,7 @@ static int zend_jit_free_op(dasm_State **Dst, const zend_op *opline, /*const zen return 1; } -static int zend_jit_leave_func(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, zend_jit_trace_rec *trace, zend_jit_trace_info *trace_info, int may_throw) +static int zend_jit_leave_func(dasm_State **Dst, const zend_op_array *op_array, zend_jit_trace_rec *trace, zend_jit_trace_info *trace_info, int may_throw) { /* ZEND_CALL_FAKE_CLOSURE handled on slow path to eliminate check for ZEND_CALL_CLOSURE on fast path */ | mov FCARG1d, dword [FP + offsetof(zend_execute_data, This.u1.type_info)] @@ -10087,6 +10220,8 @@ static int zend_jit_leave_func(dasm_State **Dst, const zend_op *opline, const ze | mov FCARG1a, EX->This.value.obj | // OBJ_RELEASE(object); | OBJ_RELEASE ZREG_FCARG1a, >4 + // TODO: avoid EG(excption) check for $this->foo() calls + may_throw = 1; } |4: } @@ -10099,7 +10234,7 @@ static int zend_jit_leave_func(dasm_State **Dst, const zend_op *opline, const ze if (trace) { if (trace->op != ZEND_JIT_TRACE_END && (JIT_G(current_frame) && !TRACE_FRAME_IS_UNKNOWN_RETURN(JIT_G(current_frame)))) { - zend_jit_reset_opline(Dst, NULL); + zend_jit_reset_opline(); } else { | LOAD_OPLINE | ADD_IP sizeof(zend_op) @@ -10130,7 +10265,7 @@ static int zend_jit_leave_func(dasm_State **Dst, const zend_op *opline, const ze ZEND_ASSERT(next_opline != NULL); current_frame = JIT_G(current_frame); JIT_G(current_frame) = NULL; - exit_point = zend_jit_trace_get_exit_point(opline, NULL, trace, 0); + exit_point = zend_jit_trace_get_exit_point(NULL, 0); JIT_G(current_frame) = current_frame; exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -10292,7 +10427,7 @@ static int zend_jit_return(dasm_State **Dst, const zend_op *opline, const zend_o if (opline->op1_type == IS_CONST) { zval *zv = RT_CONSTANT(opline, opline->op1); - | ZVAL_COPY_CONST ret_addr, MAY_BE_ANY, MAY_BE_ANY, zv, r0 + | ZVAL_COPY_CONST ret_addr, MAY_BE_ANY, MAY_BE_ANY, zv, ZREG_R0 if (Z_REFCOUNTED_P(zv)) { | ADDREF_CONST zv, r0 } @@ -10337,7 +10472,7 @@ static int zend_jit_return(dasm_State **Dst, const zend_op *opline, const zend_o | jmp >9 } |2: - | EFREE_24 r0, op_array, opline + | EFREE_24 r0 if (jit_return_label >= 0) { | jmp =>jit_return_label } else { @@ -10426,26 +10561,37 @@ static zend_bool zend_jit_may_avoid_refcounting(const zend_op *opline) return 0; } -static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, zend_ssa *ssa, const zend_ssa_op *ssa_op, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, uint32_t res_info, zend_jit_addr res_addr, int may_throw) +static int zend_jit_fetch_dim_read(dasm_State **Dst, + const zend_op *opline, + zend_ssa *ssa, + const zend_ssa_op *ssa_op, + uint32_t op1_info, + zend_jit_addr op1_addr, + zend_bool op1_avoid_refcounting, + uint32_t op2_info, + uint32_t res_info, + zend_jit_addr res_addr, + int may_throw) { zend_jit_addr orig_op1_addr, op2_addr; const void *exit_addr = NULL; const void *not_found_exit_addr = NULL; const void *res_exit_addr = NULL; + zend_bool result_avoid_refcounting = 0; orig_op1_addr = OP1_ADDR(); op2_addr = OP2_ADDR(); if (opline->opcode != ZEND_FETCH_DIM_IS && JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { return 0; } } - if (op1_info & AVOID_REFCOUNTING) { + if (op1_avoid_refcounting) { SET_STACK_REG(JIT_G(current_frame)->stack, EX_VAR_TO_NUM(opline->op1.var), ZREG_NONE); } @@ -10459,7 +10605,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, cons int32_t exit_point; if ((opline->op1_type & (IS_VAR|IS_TMP_VAR)) - && !(op1_info & AVOID_REFCOUNTING)) { + && !op1_avoid_refcounting) { flags |= ZEND_JIT_EXIT_FREE_OP1; } if ((opline->op2_type & (IS_VAR|IS_TMP_VAR)) @@ -10471,24 +10617,15 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, cons && (ssa_op+1)->op1_use == ssa_op->result_def && !(op2_info & ((MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_REF) - (MAY_BE_STRING|MAY_BE_LONG))) && zend_jit_may_avoid_refcounting(opline+1)) { - res_info |= AVOID_REFCOUNTING; - ssa->var_info[ssa_op->result_def].type |= AVOID_REFCOUNTING; - } - old_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var)); - SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), IS_UNKNOWN); - SET_STACK_REG(stack, EX_VAR_TO_NUM(opline->result.var), ZREG_ZVAL_COPY_R0); - exit_point = zend_jit_trace_get_exit_point(opline, opline+1, NULL, flags); - SET_STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var), old_info); - res_exit_addr = zend_jit_trace_get_exit_addr(exit_point); - if (!res_exit_addr) { - return 0; + result_avoid_refcounting = 1; + ssa->var_info[ssa_op->result_def].avoid_refcounting = 1; } if (!(op2_info & ((MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_REF) - (MAY_BE_STRING|MAY_BE_LONG)))) { old_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var)); SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), IS_UNKNOWN); SET_STACK_REG(stack, EX_VAR_TO_NUM(opline->result.var), ZREG_ZVAL_COPY_R0); - exit_point = zend_jit_trace_get_exit_point(opline, opline+1, NULL, flags); + exit_point = zend_jit_trace_get_exit_point(opline+1, flags); SET_STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var), old_info); res_exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!res_exit_addr) { @@ -10503,7 +10640,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, cons old_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var)); SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), IS_NULL); SET_STACK_REG(stack, EX_VAR_TO_NUM(opline->result.var), ZREG_NULL); - exit_point = zend_jit_trace_get_exit_point(opline, opline+1, NULL, flags); + exit_point = zend_jit_trace_get_exit_point(opline+1, flags); SET_STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var), old_info); not_found_exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!not_found_exit_addr) { @@ -10527,7 +10664,7 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, cons } } | GET_ZVAL_LVAL ZREG_FCARG1a, op1_addr - if (!zend_jit_fetch_dimension_address_inner(Dst, opline, (opline->opcode != ZEND_FETCH_DIM_IS) ? BP_VAR_R : BP_VAR_IS, op1_info, op2_info, 8, 9, NULL, not_found_exit_addr, exit_addr)) { + if (!zend_jit_fetch_dimension_address_inner(Dst, opline, (opline->opcode != ZEND_FETCH_DIM_IS) ? BP_VAR_R : BP_VAR_IS, op1_info, op2_info, res_exit_addr, not_found_exit_addr, exit_addr)) { return 0; } } @@ -10665,11 +10802,26 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, cons if (op1_info & MAY_BE_ARRAY_OF_REF) { | ZVAL_DEREF r0, MAY_BE_REF } - | IF_NOT_ZVAL_TYPE val_addr, type, &res_exit_addr + if (type < IS_STRING) { + | IF_NOT_ZVAL_TYPE val_addr, type, &res_exit_addr + } else { + | GET_ZVAL_TYPE_INFO edx, val_addr + | IF_NOT_TYPE dl, type, &res_exit_addr + } | // ZVAL_COPY - | ZVAL_COPY_VALUE res_addr, -1, val_addr, res_info, ZREG_R1, ZREG_R2 - if (!(res_info & AVOID_REFCOUNTING)) { - | TRY_ADDREF res_info, ch, r2 + |7: + | ZVAL_COPY_VALUE_V res_addr, -1, val_addr, res_info, ZREG_R0, ZREG_R1 + if (Z_MODE(res_addr) == IS_MEM_ZVAL) { + if (type < IS_STRING) { + | SET_ZVAL_TYPE_INFO res_addr, type + } else { + | SET_ZVAL_TYPE_INFO res_addr, edx + if (!result_avoid_refcounting) { + | TRY_ADDREF res_info, dh, r1 + } + } + } else if (!zend_jit_store_var_if_necessary(Dst, opline->result.var, res_addr, res_info)) { + return 0; } } else if (op1_info & MAY_BE_ARRAY_OF_REF) { | // ZVAL_COPY_DEREF @@ -10692,9 +10844,9 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, cons } #endif - | FREE_OP opline->op2_type, opline->op2, op2_info, 0, op_array, opline - if (!(op1_info & AVOID_REFCOUNTING)) { - | FREE_OP opline->op1_type, opline->op1, op1_info, 0, op_array, opline + | FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline + if (!op1_avoid_refcounting) { + | FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline } if (may_throw) { @@ -10706,7 +10858,17 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, cons return 1; } -static int zend_jit_isset_isempty_dim(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, int may_throw, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) +static int zend_jit_isset_isempty_dim(dasm_State **Dst, + const zend_op *opline, + uint32_t op1_info, + zend_jit_addr op1_addr, + zend_bool op1_avoid_refcounting, + uint32_t op2_info, + int may_throw, + zend_uchar smart_branch_opcode, + uint32_t target_label, + uint32_t target_label2, + const void *exit_addr) { zend_jit_addr op2_addr, res_addr; @@ -10733,7 +10895,7 @@ static int zend_jit_isset_isempty_dim(dasm_State **Dst, const zend_op *opline, c if (exit_addr && !(op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_ARRAY)) && !may_throw - && (!(opline->op1_type & (IS_TMP_VAR|IS_VAR)) || (op1_info & AVOID_REFCOUNTING)) + && (!(opline->op1_type & (IS_TMP_VAR|IS_VAR)) || op1_avoid_refcounting) && (!(opline->op2_type & (IS_TMP_VAR|IS_VAR)) || !(op2_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_LONG)))) { if (smart_branch_opcode == ZEND_JMPNZ) { found_exit_addr = exit_addr; @@ -10741,7 +10903,7 @@ static int zend_jit_isset_isempty_dim(dasm_State **Dst, const zend_op *opline, c not_found_exit_addr = exit_addr; } } - if (!zend_jit_fetch_dimension_address_inner(Dst, opline, BP_JIT_IS, op1_info, op2_info, 8, 9, found_exit_addr, not_found_exit_addr, NULL)) { + if (!zend_jit_fetch_dimension_address_inner(Dst, opline, BP_JIT_IS, op1_info, op2_info, found_exit_addr, not_found_exit_addr, NULL)) { return 0; } @@ -10774,7 +10936,10 @@ static int zend_jit_isset_isempty_dim(dasm_State **Dst, const zend_op *opline, c | EXT_CALL zend_jit_isset_dim_helper, r0 | test r0, r0 | jz >9 - | jmp >8 + if (op1_info & MAY_BE_ARRAY) { + | jmp >8 + |.code + } } else { if (op2_info & MAY_BE_UNDEF) { if (op2_info & MAY_BE_ANY) { @@ -10784,11 +10949,10 @@ static int zend_jit_isset_isempty_dim(dasm_State **Dst, const zend_op *opline, c | EXT_CALL zend_jit_undefined_op_helper, r0 |1: } - | jmp >9 - } - - if (op1_info & MAY_BE_ARRAY) { - |.code + if (op1_info & MAY_BE_ARRAY) { + | jmp >9 + |.code + } } } @@ -10799,46 +10963,48 @@ static int zend_jit_isset_isempty_dim(dasm_State **Dst, const zend_op *opline, c } #endif - |8: - | FREE_OP opline->op2_type, opline->op2, op2_info, 0, op_array, opline - if (!(op1_info & AVOID_REFCOUNTING)) { - | FREE_OP opline->op1_type, opline->op1, op1_info, 0, op_array, opline - } - if (may_throw) { - if (!zend_jit_check_exception_undef_result(Dst, opline)) { - return 0; + if (op1_info & (MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_OBJECT)) { + |8: + | FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline + if (!op1_avoid_refcounting) { + | FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline } - } - if (!(opline->extended_value & ZEND_ISEMPTY)) { - if (exit_addr) { - if (smart_branch_opcode == ZEND_JMPNZ) { - | jmp &exit_addr - } else { - | jmp >8 + if (may_throw) { + if (!zend_jit_check_exception_undef_result(Dst, opline)) { + return 0; } - } else if (smart_branch_opcode) { - if (smart_branch_opcode == ZEND_JMPZ) { - | jmp =>target_label2 - } else if (smart_branch_opcode == ZEND_JMPNZ) { - | jmp =>target_label - } else if (smart_branch_opcode == ZEND_JMPZNZ) { - | jmp =>target_label2 + } + if (!(opline->extended_value & ZEND_ISEMPTY)) { + if (exit_addr) { + if (smart_branch_opcode == ZEND_JMPNZ) { + | jmp &exit_addr + } else { + | jmp >8 + } + } else if (smart_branch_opcode) { + if (smart_branch_opcode == ZEND_JMPZ) { + | jmp =>target_label2 + } else if (smart_branch_opcode == ZEND_JMPNZ) { + | jmp =>target_label + } else if (smart_branch_opcode == ZEND_JMPZNZ) { + | jmp =>target_label2 + } else { + ZEND_UNREACHABLE(); + } } else { - ZEND_UNREACHABLE(); + | SET_ZVAL_TYPE_INFO res_addr, IS_TRUE + | jmp >8 } } else { - | SET_ZVAL_TYPE_INFO res_addr, IS_TRUE - | jmp >8 + | //???? + | int3 } - } else { - | //???? - | int3 } |9: // not found - | FREE_OP opline->op2_type, opline->op2, op2_info, 0, op_array, opline - if (!(op1_info & AVOID_REFCOUNTING)) { - | FREE_OP opline->op1_type, opline->op1, op1_info, 0, op_array, opline + | FREE_OP opline->op2_type, opline->op2, op2_info, 0, opline + if (!op1_avoid_refcounting) { + | FREE_OP opline->op1_type, opline->op1, op1_info, 0, opline } if (may_throw) { if (!zend_jit_check_exception_undef_result(Dst, opline)) { @@ -10872,7 +11038,7 @@ static int zend_jit_isset_isempty_dim(dasm_State **Dst, const zend_op *opline, c return 1; } -static int zend_jit_bind_global(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info) +static int zend_jit_bind_global(dasm_State **Dst, const zend_op *opline, uint32_t op1_info) { zend_jit_addr op1_addr = OP1_ADDR(); zend_string *varname = Z_STR_P(RT_CONSTANT(opline, opline->op2)); @@ -11040,7 +11206,7 @@ static int zend_jit_recv(dasm_State **Dst, const zend_op *opline, const zend_op_ if (arg_info || (opline+1)->opcode != ZEND_RECV) { | cmp dword EX->This.u2.num_args, arg_num if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -11092,7 +11258,7 @@ static int zend_jit_recv_init(dasm_State **Dst, const zend_op *opline, const zen | cmp dword EX->This.u2.num_args, arg_num | jae >5 } - | ZVAL_COPY_CONST res_addr, -1, -1, zv, r0 + | ZVAL_COPY_CONST res_addr, -1, -1, zv, ZREG_R0 if (Z_REFCOUNTED_P(zv)) { | ADDREF_CONST zv, r0 } @@ -11240,7 +11406,7 @@ static zend_bool zend_may_be_dynamic_property(zend_class_entry *ce, zend_string static int zend_jit_class_guard(dasm_State **Dst, const zend_op *opline, zend_class_entry *ce) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, 0); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, 0); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -11262,7 +11428,20 @@ static int zend_jit_class_guard(dasm_State **Dst, const zend_op *opline, zend_cl return 1; } -static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, zend_ssa *ssa, const zend_ssa_op *ssa_op, uint32_t op1_info, zend_jit_addr op1_addr, zend_bool op1_indirect, zend_class_entry *ce, zend_bool ce_is_instanceof, zend_bool use_this, zend_class_entry *trace_ce, int may_throw) +static int zend_jit_fetch_obj(dasm_State **Dst, + const zend_op *opline, + const zend_op_array *op_array, + zend_ssa *ssa, + const zend_ssa_op *ssa_op, + uint32_t op1_info, + zend_jit_addr op1_addr, + zend_bool op1_indirect, + zend_class_entry *ce, + zend_bool ce_is_instanceof, + zend_bool use_this, + zend_bool op1_avoid_refcounting, + zend_class_entry *trace_ce, + int may_throw) { zval *member; zend_property_info *prop_info; @@ -11300,7 +11479,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen } if (op1_info & ((MAY_BE_UNDEF|MAY_BE_ANY)- MAY_BE_OBJECT)) { if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -11383,7 +11562,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen prop_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, prop_info->offset); | mov edx, dword [FCARG1a + prop_info->offset + 8] if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -11436,7 +11615,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen } } } - if (op1_info & AVOID_REFCOUNTING) { + if (op1_avoid_refcounting) { SET_STACK_REG(JIT_G(current_frame)->stack, EX_VAR_TO_NUM(opline->op1.var), ZREG_NONE); } @@ -11448,6 +11627,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen | SET_ZVAL_TYPE_INFO res_addr, IS_INDIRECT } else { uint32_t res_info = RES_INFO(); + zend_bool result_avoid_refcounting = 0; if ((res_info & MAY_BE_GUARD) && JIT_G(current_frame) && prop_info) { uint32_t flags = 0; @@ -11460,7 +11640,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen if ((opline->op1_type & (IS_VAR|IS_TMP_VAR)) && !use_this - && !(op1_info & AVOID_REFCOUNTING)) { + && !op1_avoid_refcounting) { flags = ZEND_JIT_EXIT_FREE_OP1; } @@ -11470,14 +11650,14 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen && (res_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) && (ssa_op+1)->op1_use == ssa_op->result_def && zend_jit_may_avoid_refcounting(opline+1)) { - res_info |= AVOID_REFCOUNTING; - ssa->var_info[ssa_op->result_def].type |= AVOID_REFCOUNTING; + result_avoid_refcounting = 1; + ssa->var_info[ssa_op->result_def].avoid_refcounting = 1; } old_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var)); SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), IS_UNKNOWN); SET_STACK_REG(stack, EX_VAR_TO_NUM(opline->result.var), ZREG_ZVAL_COPY_R0); - exit_point = zend_jit_trace_get_exit_point(opline, opline+1, NULL, flags); + exit_point = zend_jit_trace_get_exit_point(opline+1, flags); SET_STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var), old_info); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -11501,12 +11681,12 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen | IF_NOT_TYPE dl, type, &exit_addr } | // ZVAL_COPY - | ZVAL_COPY_VALUE_V res_addr, -1, val_addr, res_info, ZREG_R2, ZREG_R1 + | ZVAL_COPY_VALUE_V res_addr, -1, val_addr, res_info, ZREG_R0, ZREG_R1 if (type < IS_STRING) { | SET_ZVAL_TYPE_INFO res_addr, type } else { | SET_ZVAL_TYPE_INFO res_addr, edx - if (!(res_info & AVOID_REFCOUNTING)) { + if (!result_avoid_refcounting) { | TRY_ADDREF res_info, dh, r1 } } @@ -11594,8 +11774,8 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen | SAVE_VALID_OPLINE opline, r0 | EXT_CALL zend_jit_extract_helper, r0 |1: - } else if (!(op1_info & AVOID_REFCOUNTING)) { - | FREE_OP opline->op1_type, opline->op1, op1_info, 1, op_array, opline + } else if (!op1_avoid_refcounting) { + | FREE_OP opline->op1_type, opline->op1, op1_info, 1, opline } } @@ -11615,7 +11795,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen return 1; } -static int zend_jit_free(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, int may_throw) +static int zend_jit_free(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, int may_throw) { zend_jit_addr op1_addr = OP1_ADDR(); @@ -11644,7 +11824,7 @@ static int zend_jit_free(dasm_State **Dst, const zend_op *opline, const zend_op_ return 1; } -static int zend_jit_echo(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info) +static int zend_jit_echo(dasm_State **Dst, const zend_op *opline, uint32_t op1_info) { if (opline->op1_type == IS_CONST) { zval *zv; @@ -11702,7 +11882,7 @@ static int zend_jit_echo(dasm_State **Dst, const zend_op *opline, const zend_op_ return 1; } -static int zend_jit_strlen(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info) +static int zend_jit_strlen(dasm_State **Dst, const zend_op *opline, uint32_t op1_info) { zend_jit_addr res_addr = RES_ADDR(); @@ -11751,7 +11931,7 @@ static int zend_jit_fetch_this(dasm_State **Dst, const zend_op *opline, const ze if (!JIT_G(current_frame) || !TRACE_FRAME_IS_THIS_CHECKED(JIT_G(current_frame))) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); | cmp byte EX->This.u1.v.type, IS_OBJECT @@ -11782,7 +11962,82 @@ static int zend_jit_fetch_this(dasm_State **Dst, const zend_op *opline, const ze return 1; } -static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, zend_ssa *ssa, zend_jit_trace_rec *trace) +static int zend_jit_hash_jmp(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, zend_ssa *ssa, HashTable *jumptable, int default_b, const void *default_label, const zend_op *next_opline, zend_jit_trace_info *trace_info) +{ + uint32_t count; + Bucket *p; + const zend_op *target; + int b; + int32_t exit_point; + const void *exit_addr; + + | test r0, r0 + if (default_label) { + | jz &default_label + } else if (next_opline) { + | jz >3 + } else { + | jz =>default_b + } + | LOAD_ADDR FCARG1a, jumptable + | sub r0, aword [FCARG1a + offsetof(HashTable, arData)] + | mov FCARG1a, (sizeof(Bucket) / sizeof(void*)) + |.if X64 + | cqo + |.else + | cdq + |.endif + | idiv FCARG1a + |.if X64 + if (!IS_32BIT(dasm_end)) { + | lea FCARG1a, aword [>4] + | jmp aword [FCARG1a + r0] + } else { + | jmp aword [r0 + >4] + } + |.else + | jmp aword [r0 + >4] + |.endif + |.jmp_table + |.align aword + |4: + if (trace_info) { + trace_info->jmp_table_size += zend_hash_num_elements(jumptable); + } + + count = jumptable->nNumUsed; + p = jumptable->arData; + do { + if (Z_TYPE(p->val) == IS_UNDEF) { + if (default_label) { + | .aword &default_label + } else if (next_opline) { + | .aword >3 + } else { + | .aword =>default_b + } + } else { + target = ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL(p->val)); + if (!next_opline) { + b = ssa->cfg.map[target - op_array->opcodes]; + | .aword =>b + } else if (next_opline == target) { + | .aword >3 + } else { + exit_point = zend_jit_trace_get_exit_point(target, 0); + exit_addr = zend_jit_trace_get_exit_addr(exit_point); + | .aword &exit_addr + } + } + p++; + count--; + } while (count); + |.code + + return 1; +} + +static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, zend_ssa *ssa, zend_jit_trace_rec *trace, zend_jit_trace_info *trace_info) { HashTable *jumptable = Z_ARRVAL_P(RT_CONSTANT(opline, opline->op2)); const zend_op *next_opline = NULL; @@ -11793,62 +12048,53 @@ static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_o next_opline = trace->opline; } - // TODO: Implement for match instructions - if (opline->opcode == ZEND_MATCH) { - // Since the match expression doesn't have a IS_IDENTICAL/JMPNZ chain - // we can't skip the jumptable and thus can't JIT the function - return 0; - } - if (opline->op1_type == IS_CONST) { zval *zv = RT_CONSTANT(opline, opline->op1); - zval *jump_zv; + zval *jump_zv = NULL; int b; if (opline->opcode == ZEND_SWITCH_LONG) { if (Z_TYPE_P(zv) == IS_LONG) { jump_zv = zend_hash_index_find(jumptable, Z_LVAL_P(zv)); - if (next_opline) { - const zend_op *target = ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(jump_zv)); - - ZEND_ASSERT(target == next_opline); - } else { - if (jump_zv != NULL) { - b = ssa->cfg.map[ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(jump_zv)) - op_array->opcodes]; - } else { - b = ssa->cfg.map[ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value) - op_array->opcodes]; - } - | jmp =>b - } } } else if (opline->opcode == ZEND_SWITCH_STRING) { if (Z_TYPE_P(zv) == IS_STRING) { jump_zv = zend_hash_find_ex(jumptable, Z_STR_P(zv), 1); - if (next_opline) { - const zend_op *target = ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(jump_zv)); - - ZEND_ASSERT(target == next_opline); - } else { - if (jump_zv != NULL) { - b = ssa->cfg.map[ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(jump_zv)) - op_array->opcodes]; - } else { - b = ssa->cfg.map[ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value) - op_array->opcodes]; - } - | jmp =>b - } + } + } else if (opline->opcode == ZEND_MATCH) { + if (Z_TYPE_P(zv) == IS_LONG) { + jump_zv = zend_hash_index_find(jumptable, Z_LVAL_P(zv)); + } else if (Z_TYPE_P(zv) == IS_STRING) { + jump_zv = zend_hash_find_ex(jumptable, Z_STR_P(zv), 1); } } else { ZEND_UNREACHABLE(); } + if (next_opline) { + const zend_op *target; + + if (jump_zv != NULL) { + target = ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(jump_zv)); + } else { + target = ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value); + } + ZEND_ASSERT(target == next_opline); + } else { + if (jump_zv != NULL) { + b = ssa->cfg.map[ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(jump_zv)) - op_array->opcodes]; + } else { + b = ssa->cfg.map[ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value) - op_array->opcodes]; + } + | jmp =>b + } } else { zend_ssa_op *ssa_op = &ssa->ops[opline - op_array->opcodes]; uint32_t op1_info = OP1_INFO(); zend_jit_addr op1_addr = OP1_ADDR(); const zend_op *default_opline = ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value); const zend_op *target; - int default_b = ssa->cfg.map[default_opline - op_array->opcodes]; + int default_b = next_opline ? -1 : ssa->cfg.map[default_opline - op_array->opcodes]; int b; - zval *val; int32_t exit_point; const void *fallback_label = NULL; const void *default_label = NULL; @@ -11856,11 +12102,11 @@ static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_o if (next_opline) { if (next_opline != opline + 1) { - exit_point = zend_jit_trace_get_exit_point(opline, opline + 1, NULL, 0); + exit_point = zend_jit_trace_get_exit_point(opline + 1, 0); fallback_label = zend_jit_trace_get_exit_addr(exit_point); } if (next_opline != default_opline) { - exit_point = zend_jit_trace_get_exit_point(opline, default_opline, NULL, 0); + exit_point = zend_jit_trace_get_exit_point(default_opline, 0); default_label = zend_jit_trace_get_exit_addr(exit_point); } } @@ -11920,9 +12166,12 @@ static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_o |.else | jmp aword [FCARG2a * 4 + >4] |.endif - |.cold_code + |.jmp_table |.align aword |4: + if (trace_info) { + trace_info->jmp_table_size += count; + } p = jumptable->arData; do { if (Z_TYPE(p->val) == IS_UNDEF) { @@ -11941,7 +12190,7 @@ static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_o } else if (next_opline == target) { | .aword >3 } else { - exit_point = zend_jit_trace_get_exit_point(opline, target, NULL, 0); + exit_point = zend_jit_trace_get_exit_point(target, 0); exit_addr = zend_jit_trace_get_exit_addr(exit_point); | .aword &exit_addr } @@ -11954,50 +12203,9 @@ static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_o } else { | LOAD_ADDR FCARG1a, jumptable | EXT_CALL zend_hash_index_find, r0 - | test r0, r0 - if (default_label) { - | jz &default_label - } else if (next_opline) { - | jz >3 - } else { - | jz =>default_b - } - | LOAD_ADDR FCARG1a, jumptable - | sub r0, aword [FCARG1a + offsetof(HashTable, arData)] - | mov FCARG1a, (sizeof(Bucket) / sizeof(void*)) - |.if X64 - | cqo - |.else - | cdq - |.endif - | idiv FCARG1a - |.if X64 - if (!IS_32BIT(dasm_end)) { - | lea FCARG1a, aword [>4] - | jmp aword [FCARG1a + r0] - } else { - | jmp aword [r0 + >4] + if (!zend_jit_hash_jmp(Dst, opline, op_array, ssa, jumptable, default_b, default_label, next_opline, trace_info)) { + return 0; } - |.else - | jmp aword [r0 + >4] - |.endif - |.cold_code - |.align aword - |4: - ZEND_HASH_FOREACH_VAL(jumptable, val) { - target = ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(val)); - if (!next_opline) { - b = ssa->cfg.map[target - op_array->opcodes]; - | .aword =>b - } else if (next_opline == target) { - | .aword >3 - } else { - exit_point = zend_jit_trace_get_exit_point(opline, target, NULL, 0); - exit_addr = zend_jit_trace_get_exit_addr(exit_point); - | .aword &exit_addr - } - } ZEND_HASH_FOREACH_END(); - |.code |3: } } @@ -12036,52 +12244,87 @@ static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, const zend_o } | LOAD_ADDR FCARG1a, jumptable | EXT_CALL zend_hash_find, r0 - | test r0, r0 - if (default_label) { - | jz &default_label - } else if (next_opline) { - | jz >3 - } else { - | jz =>default_b + if (!zend_jit_hash_jmp(Dst, opline, op_array, ssa, jumptable, default_b, default_label, next_opline, trace_info)) { + return 0; + } + |3: + } + } else if (opline->opcode == ZEND_MATCH) { + if (op1_info & (MAY_BE_LONG|MAY_BE_STRING)) { + if (op1_info & MAY_BE_REF) { + | LOAD_ZVAL_ADDR FCARG2a, op1_addr + | ZVAL_DEREF FCARG2a, op1_info + op1_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG2a, 0); } | LOAD_ADDR FCARG1a, jumptable - | sub r0, aword [FCARG1a + offsetof(HashTable, arData)] - | mov FCARG1a, (sizeof(Bucket) / sizeof(void*)) - |.if X64 - | cqo - |.else - | cdq - |.endif - | idiv FCARG1a - |.if X64 - if (!IS_32BIT(dasm_end)) { - | lea FCARG1a, aword [>4] - | jmp aword [FCARG1a + r0] - } else { - | jmp aword [r0 + >4] + if (op1_info & MAY_BE_LONG) { + if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_LONG)) { + if (op1_info & MAY_BE_STRING) { + | IF_NOT_ZVAL_TYPE op1_addr, IS_LONG, >5 + } else if (op1_info & MAY_BE_UNDEF) { + | IF_NOT_ZVAL_TYPE op1_addr, IS_LONG, >6 + } else if (default_label) { + | IF_NOT_ZVAL_TYPE op1_addr, IS_LONG, &default_label + } else if (next_opline) { + | IF_NOT_ZVAL_TYPE op1_addr, IS_LONG, >3 + } else { + | IF_NOT_ZVAL_TYPE op1_addr, IS_LONG, =>default_b + } + } + | GET_ZVAL_LVAL ZREG_FCARG2a, op1_addr + | EXT_CALL zend_hash_index_find, r0 + if (op1_info & MAY_BE_STRING) { + | jmp >2 + } } - |.else - | jmp aword [r0 + >4] - |.endif - |.cold_code - |.align aword - |4: - ZEND_HASH_FOREACH_VAL(jumptable, val) { - target = ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(val)); - if (!next_opline) { - b = ssa->cfg.map[target - op_array->opcodes]; - | .aword =>b - } else if (next_opline == target) { - | .aword >3 + if (op1_info & MAY_BE_STRING) { + |5: + if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_LONG|MAY_BE_STRING))) { + if (op1_info & MAY_BE_UNDEF) { + | IF_NOT_ZVAL_TYPE op1_addr, IS_STRING, >6 + } else if (default_label) { + | IF_NOT_ZVAL_TYPE op1_addr, IS_STRING, &default_label + } else if (next_opline) { + | IF_NOT_ZVAL_TYPE op1_addr, IS_STRING, >3 + } else { + | IF_NOT_ZVAL_TYPE op1_addr, IS_STRING, =>default_b + } + } + | GET_ZVAL_PTR FCARG2a, op1_addr + | EXT_CALL zend_hash_find, r0 + } + |2: + if (!zend_jit_hash_jmp(Dst, opline, op_array, ssa, jumptable, default_b, default_label, next_opline, trace_info)) { + return 0; + } + } + if (op1_info & MAY_BE_UNDEF) { + |6: + if (op1_info & (MAY_BE_ANY-(MAY_BE_LONG|MAY_BE_STRING))) { + if (default_label) { + | IF_NOT_ZVAL_TYPE op1_addr, IS_UNDEF, &default_label + } else if (next_opline) { + | IF_NOT_ZVAL_TYPE op1_addr, IS_UNDEF, >3 } else { - exit_point = zend_jit_trace_get_exit_point(opline, target, NULL, 0); - exit_addr = zend_jit_trace_get_exit_addr(exit_point); - | .aword &exit_addr + | IF_NOT_ZVAL_TYPE op1_addr, IS_UNDEF, =>default_b } - } ZEND_HASH_FOREACH_END(); - |.code - |3: + } + | // zend_error(E_WARNING, "Undefined variable $%s", ZSTR_VAL(CV_DEF_OF(EX_VAR_TO_NUM(opline->op1.var)))); + | SAVE_VALID_OPLINE opline, r0 + | mov FCARG1d, opline->op1.var + | EXT_CALL zend_jit_undefined_op_helper, r0 + if (!zend_jit_check_exception_undef_result(Dst, opline)) { + return 0; + } } + if (default_label) { + | jmp &default_label + } else if (next_opline) { + | jmp >3 + } else { + | jmp =>default_b + } + |3: } else { ZEND_UNREACHABLE(); } @@ -12145,9 +12388,78 @@ static zend_bool zend_jit_verify_return_type(dasm_State **Dst, const zend_op *op return 1; } +static int zend_jit_isset_isempty_cv(dasm_State **Dst, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr, zend_uchar smart_branch_opcode, uint32_t target_label, uint32_t target_label2, const void *exit_addr) +{ + zend_jit_addr res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var); + + // TODO: support for empty() ??? + ZEND_ASSERT(!(opline->extended_value & ZEND_ISEMPTY)); + + if (op1_info & MAY_BE_REF) { + if (Z_MODE(op1_addr) != IS_MEM_ZVAL || Z_REG(op1_addr) != ZREG_FCARG1a || Z_OFFSET(op1_addr) != 0) { + | LOAD_ZVAL_ADDR FCARG1a, op1_addr + op1_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0); + } + | ZVAL_DEREF FCARG1a, op1_info + |1: + } + + if (!(op1_info & (MAY_BE_UNDEF|MAY_BE_NULL))) { + if (exit_addr) { + ZEND_ASSERT(smart_branch_opcode == ZEND_JMPZ); + } else if (smart_branch_opcode) { + if (smart_branch_opcode == ZEND_JMPNZ) { + | jmp =>target_label + } else if (smart_branch_opcode == ZEND_JMPZNZ) { + | jmp =>target_label2 + } + } else { + | SET_ZVAL_TYPE_INFO res_addr, IS_TRUE + } + } else if (!(op1_info & (MAY_BE_ANY - MAY_BE_NULL))) { + if (exit_addr) { + ZEND_ASSERT(smart_branch_opcode == ZEND_JMPNZ); + } else if (smart_branch_opcode) { + if (smart_branch_opcode != ZEND_JMPNZ) { + | jmp =>target_label + } + } else { + | SET_ZVAL_TYPE_INFO res_addr, IS_FALSE + } + } else { + ZEND_ASSERT(Z_MODE(op1_addr) == IS_MEM_ZVAL); + | cmp byte [Ra(Z_REG(op1_addr))+Z_OFFSET(op1_addr)+offsetof(zval, u1.v.type)], IS_NULL + if (exit_addr) { + if (smart_branch_opcode == ZEND_JMPNZ) { + | jg &exit_addr + } else { + | jle &exit_addr + } + } else if (smart_branch_opcode) { + if (smart_branch_opcode == ZEND_JMPZ) { + | jle =>target_label + } else if (smart_branch_opcode == ZEND_JMPNZ) { + | jg =>target_label + } else if (smart_branch_opcode == ZEND_JMPZNZ) { + | jle =>target_label + | jmp =>target_label2 + } else { + ZEND_UNREACHABLE(); + } + } else { + | setg al + | movzx eax, al + | lea eax, [eax + IS_FALSE] + | SET_ZVAL_TYPE_INFO res_addr, eax + } + } + + return 1; +} + static zend_bool zend_jit_noref_guard(dasm_State **Dst, const zend_op *opline, zend_jit_addr var_addr) { - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, 0); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, 0); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -12162,7 +12474,7 @@ static zend_bool zend_jit_fetch_reference(dasm_State **Dst, const zend_op *oplin { zend_jit_addr var_addr = *var_addr_ptr; uint32_t var_info = *var_info_ptr; - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, 0); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, 0); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -12175,7 +12487,9 @@ static zend_bool zend_jit_fetch_reference(dasm_State **Dst, const zend_op *oplin var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, offsetof(zend_reference, val)); *var_addr_ptr = var_addr; - var_type &= ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT); + if (var_type != IS_UNKNOWN) { + var_type &= ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT|IS_TRACE_PACKED); + } if (add_type_guard && var_type != IS_UNKNOWN && (var_info & (MAY_BE_ANY|MAY_BE_UNDEF)) != (1 << var_type)) { @@ -12203,7 +12517,7 @@ static zend_bool zend_jit_fetch_indirect_var(dasm_State **Dst, const zend_op *op { zend_jit_addr var_addr = *var_addr_ptr; uint32_t var_info = *var_info_ptr; - int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, 0); + int32_t exit_point = zend_jit_trace_get_exit_point(opline, 0); const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -12215,11 +12529,13 @@ static zend_bool zend_jit_fetch_indirect_var(dasm_State **Dst, const zend_op *op var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0); *var_addr_ptr = var_addr; - var_type &= ~IS_TRACE_INDIRECT; + if (var_type != IS_UNKNOWN) { + var_type &= ~(IS_TRACE_INDIRECT|IS_TRACE_PACKED); + } if (!(var_type & IS_TRACE_REFERENCE) && var_type != IS_UNKNOWN && (var_info & (MAY_BE_ANY|MAY_BE_UNDEF)) != (1 << var_type)) { - exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, 0); + exit_point = zend_jit_trace_get_exit_point(opline, 0); exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { @@ -12335,7 +12651,7 @@ static zend_bool zend_jit_opline_supports_reg(const zend_op_array *op_array, zen op2_info = OP2_INFO(); if (trace && trace->op1_type != IS_UNKNOWN - && (trace->op1_type & ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT)) == IS_ARRAY) { + && (trace->op1_type & ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT|IS_TRACE_PACKED)) == IS_ARRAY) { op1_info &= ~((MAY_BE_ANY|MAY_BE_UNDEF) - MAY_BE_ARRAY); } return ((op1_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY) && diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index 624f2f0db3d5b..0df11aa3887c9 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -892,9 +892,14 @@ PHP_FUNCTION(pcntl_signal) RETURN_THROWS(); } - if (signo < 1 || signo >= NSIG) { - php_error_docref(NULL, E_WARNING, "Invalid signal"); - RETURN_FALSE; + if (signo < 1) { + zend_argument_value_error(1, "must be greater than or equal to 1"); + RETURN_THROWS(); + } + + if (signo >= NSIG) { + zend_argument_value_error(1, "must be less than %d", NSIG); + RETURN_THROWS(); } if (!PCNTL_G(spares)) { @@ -920,8 +925,8 @@ PHP_FUNCTION(pcntl_signal) /* Special long value case for SIG_DFL and SIG_IGN */ if (Z_TYPE_P(handle) == IS_LONG) { if (Z_LVAL_P(handle) != (zend_long) SIG_DFL && Z_LVAL_P(handle) != (zend_long) SIG_IGN) { - php_error_docref(NULL, E_WARNING, "Invalid value for handle argument specified"); - RETURN_FALSE; + zend_argument_value_error(2, "must be either SIG_DFL or SIG_IGN when an integer value is given"); + RETURN_THROWS(); } if (php_signal(signo, (Sigfunc *) Z_LVAL_P(handle), (int) restart_syscalls) == (void *)SIG_ERR) { PCNTL_G(last_error) = errno; @@ -935,10 +940,11 @@ PHP_FUNCTION(pcntl_signal) if (!zend_is_callable_ex(handle, NULL, 0, NULL, NULL, &error)) { zend_string *func_name = zend_get_callable_name(handle); PCNTL_G(last_error) = EINVAL; - php_error_docref(NULL, E_WARNING, "Specified handler \"%s\" is not callable (%s)", ZSTR_VAL(func_name), error); + + zend_argument_type_error(2, "must be of type callable|int, %s given", zend_zval_type_name(handle)); zend_string_release_ex(func_name, 0); efree(error); - RETURN_FALSE; + RETURN_THROWS(); } ZEND_ASSERT(!error); @@ -966,8 +972,8 @@ PHP_FUNCTION(pcntl_signal_get_handler) } if (signo < 1 || signo > 32) { - php_error_docref(NULL, E_WARNING, "Invalid signal"); - RETURN_FALSE; + zend_argument_value_error(1, "must be between 1 and 32"); + RETURN_THROWS(); } if ((prev_handle = zend_hash_index_find(&PCNTL_G(php_signal_table), signo)) != NULL) { @@ -1197,8 +1203,8 @@ PHP_FUNCTION(pcntl_getpriority) php_error_docref(NULL, E_WARNING, "Error %d: No process was located using the given parameters", errno); break; case EINVAL: - php_error_docref(NULL, E_WARNING, "Error %d: Invalid identifier flag", errno); - break; + zend_argument_value_error(2, "must be one of PRIO_PGRP, PRIO_USER, or PRIO_PROCESS"); + RETURN_THROWS(); default: php_error_docref(NULL, E_WARNING, "Unknown error %d has occurred", errno); break; @@ -1231,8 +1237,8 @@ PHP_FUNCTION(pcntl_setpriority) php_error_docref(NULL, E_WARNING, "Error %d: No process was located using the given parameters", errno); break; case EINVAL: - php_error_docref(NULL, E_WARNING, "Error %d: Invalid identifier flag", errno); - break; + zend_argument_value_error(3, "must be one of PRIO_PGRP, PRIO_USER, or PRIO_PROCESS"); + RETURN_THROWS(); case EPERM: php_error_docref(NULL, E_WARNING, "Error %d: A process was located, but neither its effective nor real user ID matched the effective user ID of the caller", errno); break; @@ -1400,19 +1406,18 @@ PHP_FUNCTION(pcntl_async_signals) PHP_FUNCTION(pcntl_unshare) { zend_long flags; - int ret; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(flags) ZEND_PARSE_PARAMETERS_END(); - ret = unshare(flags); - if (ret == -1) { + if (unshare(flags) == -1) { PCNTL_G(last_error) = errno; switch (errno) { #ifdef EINVAL case EINVAL: - php_error_docref(NULL, E_WARNING, "Error %d: Invalid flag specified", errno); + zend_argument_value_error(1, "must be a combination of CLONE_* flags"); + RETURN_THROWS(); break; #endif #ifdef ENOMEM diff --git a/ext/pcntl/pcntl.stub.php b/ext/pcntl/pcntl.stub.php index 0c56b04966543..2c3cd64aad170 100644 --- a/ext/pcntl/pcntl.stub.php +++ b/ext/pcntl/pcntl.stub.php @@ -19,7 +19,7 @@ function pcntl_wait(&$status, int $options = 0, &$rusage = []): int {} /** @param callable|int $handler */ function pcntl_signal(int $signo, $handler, bool $restart_syscalls = true): bool {} -/** @return mixed */ +/** @return callable|int */ function pcntl_signal_get_handler(int $signo) {} function pcntl_signal_dispatch(): bool {} diff --git a/ext/pcntl/pcntl_arginfo.h b/ext/pcntl/pcntl_arginfo.h index 4c34a762c81e8..fb0fe5fa08049 100644 --- a/ext/pcntl/pcntl_arginfo.h +++ b/ext/pcntl/pcntl_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: df744f88533ce9b84864fa2aa4dd7a5b7373231d */ + * Stub hash: 306208d94ba3bf6f8112f868a332e99717bc07fa */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_fork, 0, 0, IS_LONG, 0) ZEND_END_ARG_INFO() diff --git a/ext/pcntl/php_signal.c b/ext/pcntl/php_signal.c index 95b4a16d6df9e..d618800480827 100644 --- a/ext/pcntl/php_signal.c +++ b/ext/pcntl/php_signal.c @@ -48,9 +48,7 @@ Sigfunc *php_signal4(int signo, Sigfunc *func, int restart, int mask_all) act.sa_flags |= SA_RESTART; /* SVR4, 4.3+BSD */ #endif } - if (zend_sigaction(signo, &act, &oact) < 0) { - return (void*)SIG_ERR; - } + zend_sigaction(signo, &act, &oact); #ifdef HAVE_STRUCT_SIGINFO_T return oact.sa_sigaction; diff --git a/ext/pcntl/tests/pcntl_getpriority_error.phpt b/ext/pcntl/tests/pcntl_getpriority_error.phpt new file mode 100644 index 0000000000000..5276d4df77f6e --- /dev/null +++ b/ext/pcntl/tests/pcntl_getpriority_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +pcntl_getpriority() - Wrong process identifier +--SKIPIF-- + +--FILE-- +getMessage() . "\n"; +} + +?> +--EXPECT-- +pcntl_getpriority(): Argument #2 ($process_identifier) must be one of PRIO_PGRP, PRIO_USER, or PRIO_PROCESS diff --git a/ext/pcntl/tests/pcntl_setpriority_error.phpt b/ext/pcntl/tests/pcntl_setpriority_error.phpt new file mode 100644 index 0000000000000..d354ab2bc5c14 --- /dev/null +++ b/ext/pcntl/tests/pcntl_setpriority_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +pcntl_setpriority() - Wrong process identifier +--SKIPIF-- + +--FILE-- +getMessage() . "\n"; +} + +?> +--EXPECT-- +pcntl_setpriority(): Argument #3 ($process_identifier) must be one of PRIO_PGRP, PRIO_USER, or PRIO_PROCESS diff --git a/ext/pcntl/tests/pcntl_signal.phpt b/ext/pcntl/tests/pcntl_signal.phpt index cd55d9ad96739..4b94064e2a973 100644 --- a/ext/pcntl/tests/pcntl_signal.phpt +++ b/ext/pcntl/tests/pcntl_signal.phpt @@ -18,10 +18,24 @@ posix_kill(posix_getpid(), SIGUSR1); pcntl_signal_dispatch(); var_dump(pcntl_signal(SIGALRM, SIG_IGN)); -var_dump(pcntl_signal(-1, -1)); -var_dump(pcntl_signal(-1, function(){})); -var_dump(pcntl_signal(SIGALRM, "not callable")); +try { + pcntl_signal(-1, -1); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + +try { + pcntl_signal(-1, function(){}); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + +try { + pcntl_signal(SIGALRM, "not callable"); +} catch (TypeError $exception) { + echo $exception->getMessage() . "\n"; +} /* test freeing queue in RSHUTDOWN */ posix_kill(posix_getpid(), SIGTERM); @@ -31,13 +45,7 @@ echo "ok\n"; signal dispatched got signal from %r\d+|nobody%r bool(true) - -Warning: pcntl_signal(): Invalid signal %s -bool(false) - -Warning: pcntl_signal(): Invalid signal %s -bool(false) - -Warning: pcntl_signal(): Specified handler "not callable" is not callable (%s) in %s -bool(false) +pcntl_signal(): Argument #1 ($signo) must be greater than or equal to 1 +pcntl_signal(): Argument #1 ($signo) must be greater than or equal to 1 +pcntl_signal(): Argument #2 ($handler) must be of type callable|int, string given ok diff --git a/ext/pcntl/tests/pcntl_unshare_01.phpt b/ext/pcntl/tests/pcntl_unshare_01.phpt index 6debaace58a3e..fcbf112e4d6f4 100644 --- a/ext/pcntl/tests/pcntl_unshare_01.phpt +++ b/ext/pcntl/tests/pcntl_unshare_01.phpt @@ -7,9 +7,9 @@ if (!extension_loaded("posix")) die("skip posix extension not available"); if (!function_exists("pcntl_unshare")) die("skip pcntl_unshare is not available"); if (!defined("CLONE_NEWUSER")) die("skip flag unavailable"); if (@pcntl_unshare(CLONE_NEWUSER) == false && pcntl_get_last_error() == PCNTL_EPERM) { - die("skip Insufficient previleges to use CLONE_NEWUSER"); + die("skip Insufficient privileges to use CLONE_NEWUSER"); } - +?> --FILE-- --FILE-- +--FILE-- +getMessage() . "\n"; +} + +?> +--EXPECT-- +pcntl_unshare(): Argument #1 ($flags) must be a combination of CLONE_* flags diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index acaeb19dc68ca..801d19fc4f9a9 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -1193,8 +1193,8 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, zend_string *subject_str, } if ((global && (subpats_order < PREG_PATTERN_ORDER || subpats_order > PREG_SET_ORDER)) || (!global && subpats_order != 0)) { - php_error_docref(NULL, E_WARNING, "Invalid flags specified"); - return; + zend_argument_value_error(4, "must be a PREG_* constant"); + RETURN_THROWS(); } } else { offset_capture = 0; @@ -2410,9 +2410,7 @@ PHP_FUNCTION(preg_replace_callback_array) } if (!zend_is_callable_ex(replace, NULL, 0, NULL, &fcc, NULL)) { - zend_string *callback_name = zend_get_callable_name(replace); - zend_type_error("'%s' is not a valid callback", ZSTR_VAL(callback_name)); - zend_string_release_ex(callback_name, 0); + zend_argument_type_error(1, "must contain only valid callbacks"); RETURN_THROWS(); } diff --git a/ext/pcre/tests/002.phpt b/ext/pcre/tests/002.phpt index 073a7a8d566ef..641cffb05e971 100644 --- a/ext/pcre/tests/002.phpt +++ b/ext/pcre/tests/002.phpt @@ -3,7 +3,11 @@ preg_* with bogus vals --FILE-- getMessage() . "\n"; +} var_dump(preg_quote('')); @@ -13,8 +17,7 @@ var_dump(preg_replace('/(.)/e', 'for ($', 'abc')); ?> --EXPECTF-- -Warning: preg_match_all(): Invalid flags specified in %s002.php on line %d -NULL +preg_match_all(): Argument #4 ($flags) must be a PREG_* constant string(0) "" string(12) "a${1b${1c${1" diff --git a/ext/pcre/tests/preg_replace_callback_array2.phpt b/ext/pcre/tests/preg_replace_callback_array2.phpt index 679a4b0c54ec2..aca11dc19c6f5 100644 --- a/ext/pcre/tests/preg_replace_callback_array2.phpt +++ b/ext/pcre/tests/preg_replace_callback_array2.phpt @@ -30,7 +30,7 @@ try { echo "Done\n"; ?> --EXPECTF-- -'s' is not a valid callback +preg_replace_callback_array(): Argument #1 ($pattern) must contain only valid callbacks string(0) "" Warning: preg_replace_callback_array(): No ending delimiter '/' found in %spreg_replace_callback_array2.php on line %d diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index a7c383bd3ab80..780de94707b1e 100644 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -1207,8 +1207,8 @@ int pdo_hash_methods(pdo_dbh_object_t *dbh_obj, int kind) } dbh->cls_methods[kind] = pemalloc(sizeof(HashTable), dbh->is_persistent); - zend_hash_init_ex(dbh->cls_methods[kind], 8, NULL, - dbh->is_persistent? cls_method_pdtor : cls_method_dtor, dbh->is_persistent, 0); + zend_hash_init(dbh->cls_methods[kind], 8, NULL, + dbh->is_persistent? cls_method_pdtor : cls_method_dtor, dbh->is_persistent); memset(&func, 0, sizeof(func)); diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index d2876573bccc6..95acae32c5bf9 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -911,8 +911,8 @@ static PHP_GINIT_FUNCTION(pgsql) #endif memset(pgsql_globals, 0, sizeof(zend_pgsql_globals)); /* Initialize notice message hash at MINIT only */ - zend_hash_init_ex(&pgsql_globals->notices, 0, NULL, ZVAL_PTR_DTOR, 1, 0); - zend_hash_init_ex(&pgsql_globals->hashes, 0, NULL, ZVAL_PTR_DTOR, 1, 0); + zend_hash_init(&pgsql_globals->notices, 0, NULL, ZVAL_PTR_DTOR, 1); + zend_hash_init(&pgsql_globals->hashes, 0, NULL, ZVAL_PTR_DTOR, 1); } /* }}} */ diff --git a/ext/phar/func_interceptors.c b/ext/phar/func_interceptors.c index b3eea43ec8ace..f7cfe2249f777 100644 --- a/ext/phar/func_interceptors.c +++ b/ext/phar/func_interceptors.c @@ -97,7 +97,8 @@ PHAR_FUNC(phar_file_get_contents) /* {{{ */ zend_bool use_include_path = 0; php_stream *stream; zend_long offset = -1; - zend_long maxlen = PHP_STREAM_COPY_ALL; + zend_long maxlen; + zend_bool maxlen_is_null = 1; zval *zcontext = NULL; if (!PHAR_G(intercepted)) { @@ -110,10 +111,14 @@ PHAR_FUNC(phar_file_get_contents) /* {{{ */ } /* Parse arguments */ - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "p|br!ll", &filename, &filename_len, &use_include_path, &zcontext, &offset, &maxlen) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "p|br!ll!", &filename, &filename_len, &use_include_path, &zcontext, &offset, &maxlen, &maxlen_is_null) == FAILURE) { goto skip_phar; } + if (maxlen_is_null) { + maxlen = (ssize_t) PHP_STREAM_COPY_ALL; + } + if (use_include_path || (!IS_ABSOLUTE_PATH(filename, filename_len) && !strstr(filename, "://"))) { char *arch, *entry, *fname; zend_string *entry_str = NULL; @@ -135,10 +140,10 @@ PHAR_FUNC(phar_file_get_contents) /* {{{ */ /* fopen within phar, if :// is not in the url, then prepend phar:/// */ entry_len = filename_len; - if (ZEND_NUM_ARGS() == 5 && maxlen < 0) { + if (!maxlen_is_null && maxlen < 0) { efree(arch); - php_error_docref(NULL, E_WARNING, "Length must be greater than or equal to zero"); - RETURN_FALSE; + zend_argument_value_error(5, "must be greater than or equal to 0"); + RETURN_THROWS(); } /* retrieving a file defaults to within the current directory, so use this if possible */ diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 97be3e900c117..efb7048cf6ab5 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -2918,7 +2918,7 @@ PHP_METHOD(Phar, setDefaultStub) size_t index_len = 0, webindex_len = 0; int created_stub = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!", &index, &index_len, &webindex, &webindex_len) == FAILURE) { RETURN_THROWS(); } @@ -2935,9 +2935,9 @@ PHP_METHOD(Phar, setDefaultStub) RETURN_THROWS(); } - if (ZEND_NUM_ARGS() > 0 && (phar_obj->archive->is_tar || phar_obj->archive->is_zip)) { - php_error_docref(NULL, E_WARNING, "Method accepts no arguments for a tar- or zip-based phar stub, %d given", ZEND_NUM_ARGS()); - RETURN_FALSE; + if ((index || webindex) && (phar_obj->archive->is_tar || phar_obj->archive->is_zip)) { + zend_argument_value_error(index ? 1 : 2, "must be null for a tar- or zip-based phar stub, string given"); + RETURN_THROWS(); } if (PHAR_G(readonly)) { diff --git a/ext/phar/phar_object.stub.php b/ext/phar/phar_object.stub.php index 7f0eca1034f8f..d9b69f784f4d2 100644 --- a/ext/phar/phar_object.stub.php +++ b/ext/phar/phar_object.stub.php @@ -125,7 +125,7 @@ public function offsetUnset($entry) {} public function setAlias(string $alias) {} /** @return bool */ - public function setDefaultStub(?string $index = null, string $webindex = UNKNOWN) {} + public function setDefaultStub(?string $index = null, ?string $webindex = null) {} /** * @param mixed $metadata @@ -398,7 +398,7 @@ public function setAlias(string $alias) {} * @return bool * @alias Phar::setDefaultStub */ - public function setDefaultStub(?string $index = null, string $webindex = UNKNOWN) {} + public function setDefaultStub(?string $index = null, ?string $webindex = null) {} /** * @param mixed $metadata diff --git a/ext/phar/phar_object_arginfo.h b/ext/phar/phar_object_arginfo.h index 67b5ba558029f..95799bd487822 100644 --- a/ext/phar/phar_object_arginfo.h +++ b/ext/phar/phar_object_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: f25efd47b496a7d06a30c77911a565a49e383bce */ + * Stub hash: be0f8bcd0ef8fdac59700160dff7d0beb210aa48 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) @@ -125,7 +125,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_setDefaultStub, 0, 0, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, index, IS_STRING, 1, "null") - ZEND_ARG_TYPE_INFO(0, webindex, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, webindex, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_setMetadata, 0, 0, 1) diff --git a/ext/phar/tests/fgc_edgecases.phpt b/ext/phar/tests/fgc_edgecases.phpt index a902b669c9aa7..38ff03cce8b0e 100644 --- a/ext/phar/tests/fgc_edgecases.phpt +++ b/ext/phar/tests/fgc_edgecases.phpt @@ -29,7 +29,11 @@ mkdir($pname . '/oops'); file_put_contents($pname . '/foo/hi', 'getMessage() . "\n"; +} echo file_get_contents("fgc_edgecases.txt"); set_include_path("' . addslashes(__DIR__) . '"); echo file_get_contents("fgc_edgecases.txt", true); @@ -53,7 +57,11 @@ blah getMessage() . "\n"; +} echo file_get_contents("fgc_edgecases.txt"); set_include_path("%stests"); echo file_get_contents("fgc_edgecases.txt", true); @@ -63,14 +71,17 @@ echo file_get_contents("./hi", 0, $context, 50000); echo file_get_contents("./hi"); echo file_get_contents("./hi", 0, $context, 0, 0); ?> - -Warning: file_get_contents(): Length must be greater than or equal to zero in phar://%sfgc_edgecases.phar.php/foo/hi on line %d +file_get_contents(): Argument #5 ($maxlen) must be greater than or equal to 0 test test getMessage() . "\n"; +} echo file_get_contents("fgc_edgecases.txt"); set_include_path("%stests"); echo file_get_contents("fgc_edgecases.txt", true); @@ -87,7 +98,11 @@ Warning: file_get_contents(): Failed to seek to position 50000 in the stream in getMessage() . "\n"; +} echo file_get_contents("fgc_edgecases.txt"); set_include_path("%stests"); echo file_get_contents("fgc_edgecases.txt", true); diff --git a/ext/phar/tests/tar/phar_setdefaultstub.phpt b/ext/phar/tests/tar/phar_setdefaultstub.phpt index 6811c4c59dd26..7404a5851eb89 100644 --- a/ext/phar/tests/tar/phar_setdefaultstub.phpt +++ b/ext/phar/tests/tar/phar_setdefaultstub.phpt @@ -33,18 +33,28 @@ echo "========================================================================== try { $phar->setDefaultStub('my/custom/thingy.php'); +} catch(ValueError $e) { + echo $e->getMessage(). "\n"; +} + +try { $phar->stopBuffering(); } catch(Exception $e) { echo $e->getMessage(). "\n"; } - var_dump($phar->getStub()); echo "============================================================================\n"; echo "============================================================================\n"; + try { $phar->setDefaultStub('my/custom/thingy.php', 'the/web.php'); +} catch(ValueError $e) { + echo $e->getMessage(). "\n"; +} + +try { $phar->stopBuffering(); } catch(Exception $e) { echo $e->getMessage(). "\n"; @@ -57,7 +67,7 @@ var_dump($phar->getStub()); ---EXPECTF-- +--EXPECT-- string(51) " " ============================================================================ @@ -66,13 +76,11 @@ string(60) "setDefaultStub('my/custom/thingy.php'); +} catch(Error $e) { + echo $e->getMessage(). "\n"; +} + +try { $phar->stopBuffering(); } catch(Exception $e) { echo $e->getMessage(). "\n"; @@ -45,6 +50,11 @@ echo "========================================================================== try { $phar->setDefaultStub('my/custom/thingy.php', 'the/web.php'); +} catch(ValueError $e) { + echo $e->getMessage(). "\n"; +} + +try { $phar->stopBuffering(); } catch(Exception $e) { echo $e->getMessage(). "\n"; @@ -57,7 +67,7 @@ var_dump($phar->getStub()); ---EXPECTF-- +--EXPECT-- string(51) " " ============================================================================ @@ -66,13 +76,11 @@ string(60) "type != le_pspell_config) { \ - php_error_docref(NULL, E_WARNING, ZEND_LONG_FMT " is not a PSPELL config index", conf); \ - RETURN_FALSE; \ + zend_throw_error(NULL, "%s(): " ZEND_LONG_FMT " is not a PSPELL config index", get_active_function_name(), conf); \ + RETURN_THROWS(); \ } \ config = (PspellConfig *)Z_RES_P(res)->ptr; \ } while (0) @@ -85,8 +85,8 @@ static void php_pspell_close_config(zend_resource *rsrc) #define PSPELL_FETCH_MANAGER do { \ zval *res = zend_hash_index_find(&EG(regular_list), scin); \ if (res == NULL || Z_RES_P(res)->type != le_pspell) { \ - php_error_docref(NULL, E_WARNING, ZEND_LONG_FMT " is not a PSPELL result index", scin); \ - RETURN_FALSE; \ + zend_throw_error(NULL, "%s(): " ZEND_LONG_FMT " is not a PSPELL result index", get_active_function_name(), scin); \ + RETURN_THROWS(); \ } \ manager = (PspellManager *)Z_RES_P(res)->ptr; \ } while (0); diff --git a/ext/pspell/tests/003.phpt b/ext/pspell/tests/003.phpt index 4fc34bf6bd88f..e8677ae82687d 100644 --- a/ext/pspell/tests/003.phpt +++ b/ext/pspell/tests/003.phpt @@ -15,7 +15,11 @@ $p = pspell_new_config($cfg); var_dump(pspell_check($p, 'yy')); $p2 = pspell_new_config($cfg2); -var_dump(pspell_check($p2, 'yy')); +try { + pspell_check($p2, 'yy'); +} catch (Error $exception) { + echo $exception->getMessage() . "\n"; +} echo "---\n"; var_dump(pspell_config_ignore($cfg, 2)); @@ -30,9 +34,7 @@ var_dump(pspell_config_ignore($cfg, PHP_INT_MAX)); bool(false) Warning: pspell_new_config(): PSPELL couldn't open the dictionary. reason: The encoding "b0rked" is not known. This could also mean that the file "%sb0rked.%s" could not be opened for reading or does not exist. in %s003.php on line 9 - -Warning: pspell_check(): 0 is not a PSPELL result index in %s003.php on line 10 -bool(false) +pspell_check(): 0 is not a PSPELL result index --- bool(true) bool(true) diff --git a/ext/shmop/shmop.c b/ext/shmop/shmop.c index 7cd66f830016f..3d8975e76fae5 100644 --- a/ext/shmop/shmop.c +++ b/ext/shmop/shmop.c @@ -149,8 +149,8 @@ PHP_FUNCTION(shmop_open) } if (flags_len != 1) { - php_error_docref(NULL, E_WARNING, "%s is not a valid flag", flags); - RETURN_FALSE; + zend_argument_value_error(2, "must be a valid access mode"); + RETURN_THROWS(); } object_init_ex(return_value, shmop_ce); @@ -178,35 +178,35 @@ PHP_FUNCTION(shmop_open) */ break; default: - php_error_docref(NULL, E_WARNING, "Invalid access mode"); + zend_argument_value_error(2, "must be a valid access mode"); goto err; } if (shmop->shmflg & IPC_CREAT && shmop->size < 1) { - php_error_docref(NULL, E_WARNING, "Shared memory segment size must be greater than zero"); + zend_argument_value_error(4, "must be greater than 0 for the \"c\" and \"n\" access modes"); goto err; } shmop->shmid = shmget(shmop->key, shmop->size, shmop->shmflg); if (shmop->shmid == -1) { - php_error_docref(NULL, E_WARNING, "Unable to attach or create shared memory segment '%s'", strerror(errno)); + php_error_docref(NULL, E_WARNING, "Unable to attach or create shared memory segment \"%s\"", strerror(errno)); goto err; } if (shmctl(shmop->shmid, IPC_STAT, &shm)) { /* please do not add coverage here: the segment would be leaked and impossible to delete via php */ - php_error_docref(NULL, E_WARNING, "Unable to get shared memory segment information '%s'", strerror(errno)); + php_error_docref(NULL, E_WARNING, "Unable to get shared memory segment information \"%s\"", strerror(errno)); goto err; } if (shm.shm_segsz > ZEND_LONG_MAX) { - php_error_docref(NULL, E_WARNING, "shared memory segment too large to attach"); + zend_argument_value_error(4, "is too large"); goto err; } shmop->addr = shmat(shmop->shmid, 0, shmop->shmatflg); if (shmop->addr == (char*) -1) { - php_error_docref(NULL, E_WARNING, "Unable to attach to shared memory segment '%s'", strerror(errno)); + php_error_docref(NULL, E_WARNING, "Unable to attach to shared memory segment \"%s\"", strerror(errno)); goto err; } @@ -236,13 +236,13 @@ PHP_FUNCTION(shmop_read) shmop = Z_SHMOP_P(shmid); if (start < 0 || start > shmop->size) { - php_error_docref(NULL, E_WARNING, "Start is out of range"); - RETURN_FALSE; + zend_argument_value_error(2, "must be between 0 and the segment size"); + RETURN_THROWS(); } if (count < 0 || start > (INT_MAX - count) || start + count > shmop->size) { - php_error_docref(NULL, E_WARNING, "Count is out of range"); - RETURN_FALSE; + zend_argument_value_error(3, "is out of range"); + RETURN_THROWS(); } startaddr = shmop->addr + start; @@ -297,13 +297,13 @@ PHP_FUNCTION(shmop_write) shmop = Z_SHMOP_P(shmid); if ((shmop->shmatflg & SHM_RDONLY) == SHM_RDONLY) { - php_error_docref(NULL, E_WARNING, "Trying to write to a read only segment"); - RETURN_FALSE; + zend_throw_error(NULL, "Read-only segment cannot be written"); + RETURN_THROWS(); } if (offset < 0 || offset > shmop->size) { - php_error_docref(NULL, E_WARNING, "Offset out of range"); - RETURN_FALSE; + zend_argument_value_error(3, "is out of range"); + RETURN_THROWS(); } writesize = ((zend_long)ZSTR_LEN(data) < shmop->size - offset) ? (zend_long)ZSTR_LEN(data) : shmop->size - offset; diff --git a/ext/shmop/shmop.stub.php b/ext/shmop/shmop.stub.php index c19cbc26f0e07..cddb9c64f4892 100644 --- a/ext/shmop/shmop.stub.php +++ b/ext/shmop/shmop.stub.php @@ -6,13 +6,13 @@ final class Shmop {} function shmop_open(int $key, string $flags, int $mode, int $size): Shmop|false {} -function shmop_read(Shmop $shmid, int $start, int $count): string|false {} +function shmop_read(Shmop $shmid, int $start, int $count): string {} /** @deprecated */ function shmop_close(Shmop $shmid): void {} function shmop_size(Shmop $shmid): int {} -function shmop_write(Shmop $shmid, string $data, int $offset): int|false {} +function shmop_write(Shmop $shmid, string $data, int $offset): int {} function shmop_delete(Shmop $shmid): bool {} diff --git a/ext/shmop/shmop_arginfo.h b/ext/shmop/shmop_arginfo.h index 494559e4f5b72..211204720ad0a 100644 --- a/ext/shmop/shmop_arginfo.h +++ b/ext/shmop/shmop_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: e451ccfbe66fc2b6fc0dae6e7e5710ededaf7b0c */ + * Stub hash: 1fe8d001718e20ca915480d1ab6cb6996115b547 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_shmop_open, 0, 4, Shmop, MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, key, IS_LONG, 0) @@ -8,7 +8,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_shmop_open, 0, 4, Shmop, MAY ZEND_ARG_TYPE_INFO(0, size, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_shmop_read, 0, 3, MAY_BE_STRING|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_shmop_read, 0, 3, IS_STRING, 0) ZEND_ARG_OBJ_INFO(0, shmid, Shmop, 0) ZEND_ARG_TYPE_INFO(0, start, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, count, IS_LONG, 0) @@ -22,7 +22,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_shmop_size, 0, 1, IS_LONG, 0) ZEND_ARG_OBJ_INFO(0, shmid, Shmop, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_shmop_write, 0, 3, MAY_BE_LONG|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_shmop_write, 0, 3, IS_LONG, 0) ZEND_ARG_OBJ_INFO(0, shmid, Shmop, 0) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0) diff --git a/ext/shmop/tests/001.phpt b/ext/shmop/tests/001.phpt index 55e8476b844a2..4cac82d2f0c8b 100644 --- a/ext/shmop/tests/001.phpt +++ b/ext/shmop/tests/001.phpt @@ -43,7 +43,11 @@ shmop extension test echo "data in memory is: " . shmop_read($shm_id, 0, $written) . "\n"; /* try to append data to the shared memory segment, this should fail */ - shmop_write($shm_id, $write_d1, $written); + try { + shmop_write($shm_id, $write_d1, $written); + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } echo "shm open for read only: "; $shm_id = shmop_open($hex_shm_id, "w", 0644, 1024); @@ -53,7 +57,7 @@ shmop extension test echo "ok\n"; } - echo "shm write test #1: "; + echo "shm write test #2: "; $written = shmop_write($shm_id, $write_d2, $written); if ($written != strlen($write_d2)) { die("failed\n"); @@ -70,16 +74,15 @@ shmop extension test echo "ok\n"; } ?> ---EXPECTF-- +--EXPECT-- shm open for create: ok shm size is: 1024 shm write test #1: ok data in memory is: test #1 of the shmop() extension shm open for read only: ok data in memory is: test #1 of the shmop() extension - -Warning: shmop_write(): Trying to write to a read only segment in %s on line %d +Read-only segment cannot be written shm open for read only: ok -shm write test #1: ok +shm write test #2: ok data in memory is: test #1 of the shmop() extensiontest #2 append data to shared memory segment deletion of shm segment: ok diff --git a/ext/shmop/tests/002.phpt b/ext/shmop/tests/002.phpt index f1f084fdbf8b7..6b82fc27c0582 100644 --- a/ext/shmop/tests/002.phpt +++ b/ext/shmop/tests/002.phpt @@ -11,57 +11,81 @@ edgarsandi - --FILE-- getMessage() . "\n"; +} - // warning outputs: unable to attach or create shared memory segment - var_dump(shmop_open(null, 'a', 0644, 1024)); +try { + shmop_open(1338, 'b', 0644, 1024); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} - // warning outputs: Shared memory segment size must be greater than zero - var_dump(shmop_open(1338, "c", 0666, 0)); +// Warning outputs: Unable to attach or create shared memory segment +var_dump(shmop_open(null, 'a', 0644, 1024)); -echo PHP_EOL, '## shmop_read function tests ##'; - // warning outputs: start is out of range - $shm_id = shmop_open(1338, 'n', 0600, 1024); - var_dump(shmop_read($shm_id, -10, 0)); - shmop_delete($shm_id); +// Shared memory segment size must be greater than zero +try { + shmop_open(null, 'a', 0644, 1024); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} - // warning outputs: count is out of range - $shm_id = shmop_open(1339, 'n', 0600, 1024); - var_dump(shmop_read($shm_id, 0, -10)); - shmop_delete($shm_id); +//Shared memory segment size must be greater than zero +try { + shmop_open(1338, "c", 0666, 0); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} -echo PHP_EOL, '## shmop_write function tests ##'; - // warning outputs: offset out of range - $shm_id = shmop_open(1340, 'n', 0600, 1024); - var_dump(shmop_write($shm_id, 'text to try write', -10)); - shmop_delete($shm_id); +echo PHP_EOL, '## shmop_read function tests ##', PHP_EOL; +// Start is out of range +$shm_id = shmop_open(1338, 'n', 0600, 1024); +try { + shmop_read($shm_id, -10, 0); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} +shmop_delete($shm_id); + +// Count is out of range +$shm_id = shmop_open(1339, 'n', 0600, 1024); +try { + shmop_read($shm_id, 0, -10); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} +shmop_delete($shm_id); + +echo PHP_EOL, '## shmop_write function tests ##', PHP_EOL; +// Offset out of range +$shm_id = shmop_open(1340, 'n', 0600, 1024); +try { + shmop_write($shm_id, 'text to try write', -10); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} +shmop_delete($shm_id); ?> --EXPECTF-- ## shmop_open function tests ## -Warning: shmop_open(): is not a valid flag in %s on line %d -bool(false) - -Warning: shmop_open(): Invalid access mode in %s on line %d -bool(false) +shmop_open(): Argument #2 ($flags) must be a valid access mode +shmop_open(): Argument #2 ($flags) must be a valid access mode -Warning: shmop_open(): Unable to attach or create shared memory segment '%s' in %s on line %d +Warning: shmop_open(): Unable to attach or create shared memory segment "%s" in %s on line %d bool(false) -Warning: shmop_open(): Shared memory segment size must be greater than zero in %s on line %d -bool(false) +Warning: shmop_open(): Unable to attach or create shared memory segment "%s" in %s on line %d +shmop_open(): Argument #4 ($size) must be greater than 0 for the "c" and "n" access modes ## shmop_read function tests ## -Warning: shmop_read(): Start is out of range in %s on line %d -bool(false) - -Warning: shmop_read(): Count is out of range in %s on line %d -bool(false) +shmop_read(): Argument #2 ($start) must be between 0 and the segment size +shmop_read(): Argument #3 ($count) is out of range ## shmop_write function tests ## -Warning: shmop_write(): Offset out of range in %s on line %d -bool(false) +shmop_write(): Argument #3 ($offset) is out of range diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index afd655aeedd73..1944ecf797819 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -374,34 +374,13 @@ static zval *sxe_dimension_read(zend_object *object, zval *offset, int type, zva /* }}} */ /* {{{ change_node_zval() */ -static void change_node_zval(xmlNodePtr node, zval *value) +static void change_node_zval(xmlNodePtr node, zend_string *value) { - xmlChar *buffer; - - if (!value) - { - xmlNodeSetContentLen(node, (xmlChar *)"", 0); - return; - } - switch (Z_TYPE_P(value)) { - case IS_LONG: - case IS_FALSE: - case IS_TRUE: - case IS_DOUBLE: - case IS_NULL: - convert_to_string(value); - /* break missing intentionally */ - case IS_STRING: - buffer = xmlEncodeEntitiesReentrant(node->doc, (xmlChar *)Z_STRVAL_P(value)); - /* check for NULL buffer in case of memory error in xmlEncodeEntitiesReentrant */ - if (buffer) { - xmlNodeSetContent(node, buffer); - xmlFree(buffer); - } - break; - default: - php_error_docref(NULL, E_WARNING, "It is not possible to assign complex types to nodes"); - break; + xmlChar *buffer = xmlEncodeEntitiesReentrant(node->doc, (xmlChar *)ZSTR_VAL(value)); + /* check for NULL buffer in case of memory error in xmlEncodeEntitiesReentrant */ + if (buffer) { + xmlNodeSetContent(node, buffer); + xmlFree(buffer); } } /* }}} */ @@ -419,10 +398,10 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, int is_attr = 0; int nodendx = 0; int test = 0; - int new_value = 0; zend_long cnt = 0; - zval tmp_zv, zval_copy; + zval tmp_zv; zend_string *trim_str; + zend_string *value_str = NULL; sxe = php_sxe_fetch_object(object); @@ -432,7 +411,7 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, * and could also be E_PARSE, but we use this only during parsing * and this is during runtime. */ - zend_throw_error(NULL, "Cannot create unnamed attribute"); + zend_throw_error(NULL, "Cannot append to an attribute list"); return &EG(error_zval); } goto long_dim; @@ -457,7 +436,7 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, } if (!Z_STRLEN_P(member)) { - php_error_docref(NULL, E_WARNING, "Cannot write or create unnamed %s", attribs ? "attribute" : "element"); + zend_value_error("Cannot create %s with an empty name", attribs ? "attribute" : "element"); if (member == &tmp_zv) { zval_ptr_dtor_str(&tmp_zv); } @@ -485,7 +464,7 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, * and could also be E_PARSE, but we use this only during parsing * and this is during runtime. */ - zend_throw_error(NULL, "Cannot create unnamed attribute"); + zend_value_error("Cannot append to an attribute list"); return &EG(error_zval); } if (attribs && !node && sxe->iter.type == SXE_ITER_ELEMENT) { @@ -503,23 +482,18 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, case IS_TRUE: case IS_DOUBLE: case IS_NULL: - if (Z_TYPE_P(value) != IS_STRING) { - ZVAL_STR(&zval_copy, zval_get_string_func(value)); - value = &zval_copy; - new_value = 1; - } - break; case IS_STRING: + value_str = zval_get_string(value); break; case IS_OBJECT: if (Z_OBJCE_P(value) == sxe_class_entry) { + zval zval_copy; if (sxe_object_cast_ex(Z_OBJ_P(value), &zval_copy, IS_STRING) == FAILURE) { - zend_error(E_ERROR, "Unable to cast node to string"); - /* FIXME: Should not be fatal */ + zend_throw_error(NULL, "Unable to cast node to string"); + return &EG(error_zval); } - value = &zval_copy; - new_value = 1; + value_str = Z_STR(zval_copy); break; } /* break is missing intentionally */ @@ -527,7 +501,7 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, if (member == &tmp_zv) { zval_ptr_dtor_str(&tmp_zv); } - zend_error(E_WARNING, "It is not yet possible to assign complex types to %s", attribs ? "attributes" : "properties"); + zend_type_error("It's not possible to assign a complex type to %s, %s given", attribs ? "attributes" : "properties", zend_zval_type_name(value)); return &EG(error_zval); } } @@ -563,8 +537,8 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, if (!member || Z_TYPE_P(member) == IS_LONG) { if (node->type == XML_ATTRIBUTE_NODE) { zend_throw_error(NULL, "Cannot create duplicate attribute"); - if (new_value) { - zval_ptr_dtor(value); + if (value_str) { + zend_string_release(value_str); } return &EG(error_zval); } @@ -602,12 +576,12 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, if (is_attr) { newnode = (xmlNodePtr) attr; } - if (value) { + if (value_str) { while ((tempnode = (xmlNodePtr) newnode->children)) { xmlUnlinkNode(tempnode); php_libxml_node_free_resource((xmlNodePtr) tempnode); } - change_node_zval(newnode, value); + change_node_zval(newnode, value_str); } } else if (counter > 1) { php_error_docref(NULL, E_WARNING, "Cannot assign to an array of nodes (duplicate subnodes or attr detected)"); @@ -615,21 +589,21 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, } else if (elements) { if (!node) { if (!member || Z_TYPE_P(member) == IS_LONG) { - newnode = xmlNewTextChild(mynode->parent, mynode->ns, mynode->name, value ? (xmlChar *)Z_STRVAL_P(value) : NULL); + newnode = xmlNewTextChild(mynode->parent, mynode->ns, mynode->name, value_str ? (xmlChar *)ZSTR_VAL(value_str) : NULL); } else { - newnode = xmlNewTextChild(mynode, mynode->ns, (xmlChar *)Z_STRVAL_P(member), value ? (xmlChar *)Z_STRVAL_P(value) : NULL); + newnode = xmlNewTextChild(mynode, mynode->ns, (xmlChar *)Z_STRVAL_P(member), value_str ? (xmlChar *)ZSTR_VAL(value_str) : NULL); } } else if (!member || Z_TYPE_P(member) == IS_LONG) { if (member && cnt < Z_LVAL_P(member)) { php_error_docref(NULL, E_WARNING, "Cannot add element %s number " ZEND_LONG_FMT " when only " ZEND_LONG_FMT " such elements exist", mynode->name, Z_LVAL_P(member), cnt); } - newnode = xmlNewTextChild(mynode->parent, mynode->ns, mynode->name, value ? (xmlChar *)Z_STRVAL_P(value) : NULL); + newnode = xmlNewTextChild(mynode->parent, mynode->ns, mynode->name, value_str ? (xmlChar *)ZSTR_VAL(value_str) : NULL); } } else if (attribs) { if (Z_TYPE_P(member) == IS_LONG) { php_error_docref(NULL, E_WARNING, "Cannot change attribute number " ZEND_LONG_FMT " when only %d attributes exist", Z_LVAL_P(member), nodendx); } else { - newnode = (xmlNodePtr)xmlNewProp(node, (xmlChar *)Z_STRVAL_P(member), value ? (xmlChar *)Z_STRVAL_P(value) : NULL); + newnode = (xmlNodePtr)xmlNewProp(node, (xmlChar *)Z_STRVAL_P(member), value_str ? (xmlChar *)ZSTR_VAL(value_str) : NULL); } } } @@ -640,8 +614,8 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value, if (pnewnode) { *pnewnode = newnode; } - if (new_value) { - zval_ptr_dtor(value); + if (value_str) { + zend_string_release(value_str); } return value; } @@ -682,7 +656,7 @@ static zval *sxe_property_get_adr(zend_object *object, zend_string *zname, int f } ZVAL_STR(&member, zname); if (sxe_prop_dim_write(object, &member, NULL, 1, 0, &node) == &EG(error_zval)) { - return NULL; + return &EG(error_zval); } type = SXE_ITER_NONE; name = NULL; @@ -1710,8 +1684,8 @@ SXE_METHOD(addChild) } if (qname_len == 0) { - php_error_docref(NULL, E_WARNING, "Element name is required"); - return; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } sxe = Z_SXEOBJ_P(ZEND_THIS); @@ -1775,8 +1749,8 @@ SXE_METHOD(addAttribute) } if (qname_len == 0) { - php_error_docref(NULL, E_WARNING, "Attribute name is required"); - return; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } sxe = Z_SXEOBJ_P(ZEND_THIS); @@ -2300,8 +2274,8 @@ PHP_FUNCTION(simplexml_load_file) } if (ZEND_LONG_EXCEEDS_INT(options)) { - php_error_docref(NULL, E_WARNING, "Invalid options"); - RETURN_FALSE; + zend_argument_value_error(3, "is too large"); + RETURN_THROWS(); } docp = xmlReadFile(filename, NULL, (int)options); @@ -2345,16 +2319,16 @@ PHP_FUNCTION(simplexml_load_string) } if (ZEND_SIZE_T_INT_OVFL(data_len)) { - php_error_docref(NULL, E_WARNING, "Data is too long"); - RETURN_FALSE; + zend_argument_value_error(1, "is too long"); + RETURN_THROWS(); } if (ZEND_SIZE_T_INT_OVFL(ns_len)) { - php_error_docref(NULL, E_WARNING, "Namespace is too long"); - RETURN_FALSE; + zend_argument_value_error(4, "is too long"); + RETURN_THROWS(); } if (ZEND_LONG_EXCEEDS_INT(options)) { - php_error_docref(NULL, E_WARNING, "Invalid options"); - RETURN_FALSE; + zend_argument_value_error(3, "is too large"); + RETURN_THROWS(); } docp = xmlReadMemory(data, (int)data_len, NULL, NULL, (int)options); diff --git a/ext/simplexml/simplexml.stub.php b/ext/simplexml/simplexml.stub.php index d3e48b0e6aaf7..18cddf2886162 100644 --- a/ext/simplexml/simplexml.stub.php +++ b/ext/simplexml/simplexml.stub.php @@ -59,7 +59,7 @@ public function rewind() {} /** @return bool */ public function valid() {} - /** @return ?SimpleXMLElement */ + /** @return SimpleXMLElement|null */ public function current() {} /** @return string|false */ @@ -71,7 +71,7 @@ public function next() {} /** @return bool */ public function hasChildren() {} - /** @return ?SimpleXMLElement */ + /** @return SimpleXMLElement|null */ public function getChildren() {} } diff --git a/ext/simplexml/simplexml_arginfo.h b/ext/simplexml/simplexml_arginfo.h index dc369e03212d8..5aa6d50ba1d03 100644 --- a/ext/simplexml/simplexml_arginfo.h +++ b/ext/simplexml/simplexml_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: fbe25d8a7a0a1de0cbd5dc9118e77a2e8d5dbd67 */ + * Stub hash: 953089f230247acf18b9ac48c0a4c516d144a987 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_simplexml_load_file, 0, 1, SimpleXMLElement, MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) diff --git a/ext/simplexml/tests/012.phpt b/ext/simplexml/tests/012.phpt index b687b71988198..307f8219cd70e 100644 --- a/ext/simplexml/tests/012.phpt +++ b/ext/simplexml/tests/012.phpt @@ -14,8 +14,12 @@ EOF; $sxe = simplexml_load_string($xml); +try { + $sxe[""] = "value"; +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} -$sxe[""] = "warning"; $sxe["attr"] = "value"; echo $sxe->asXML(); @@ -24,19 +28,19 @@ $sxe["attr"] = "new value"; echo $sxe->asXML(); -$sxe[] = "error"; +try { + $sxe[] = "error"; +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} __HALT_COMPILER(); ?> ===DONE=== ---EXPECTF-- -Warning: main(): Cannot write or create unnamed attribute in %s012.php on line %d +--EXPECT-- +Cannot create attribute with an empty name - -Fatal error: Uncaught Error: Cannot create unnamed attribute in %s012.php:%d -Stack trace: -#0 {main} - thrown in %s012.php on line %d +Cannot append to an attribute list diff --git a/ext/simplexml/tests/038.phpt b/ext/simplexml/tests/038.phpt new file mode 100644 index 0000000000000..75d016a5ddf8e --- /dev/null +++ b/ext/simplexml/tests/038.phpt @@ -0,0 +1,14 @@ +--TEST-- +SimpleXML: Property assignment return value +--SKIPIF-- + +--FILE-- + +EOF; +$root = simplexml_load_string($xml); +var_dump($root->prop = 42); +?> +--EXPECT-- +int(42) diff --git a/ext/simplexml/tests/SimpleXMLElement_addAttribute_required_attribute_name.phpt b/ext/simplexml/tests/SimpleXMLElement_addAttribute_required_attribute_name.phpt index 34e2e683195b0..50928ff55e553 100644 --- a/ext/simplexml/tests/SimpleXMLElement_addAttribute_required_attribute_name.phpt +++ b/ext/simplexml/tests/SimpleXMLElement_addAttribute_required_attribute_name.phpt @@ -8,10 +8,16 @@ Havard Eide --FILE-- testfest"); -$a->addAttribute( "", "" ); + +try { + $a->addAttribute( "", "" ); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + echo $a->asXML(); ?> ---EXPECTF-- -Warning: SimpleXMLElement::addAttribute(): Attribute name is required in %s on line %d +--EXPECT-- +SimpleXMLElement::addAttribute(): Argument #1 ($qualifiedName) cannot be empty testfest diff --git a/ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt b/ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt index b389bcfc582f0..bcff7db2db06a 100644 --- a/ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt +++ b/ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt @@ -7,11 +7,14 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only"); ?> --FILE-- getMessage() . "\n"; +} + ?> --EXPECTF-- Warning: Undefined variable $x in %s on line %d - -Warning: simplexml_load_string(): Invalid options in %s on line %d -bool(false) +simplexml_load_string(): Argument #3 ($options) is too large diff --git a/ext/simplexml/tests/bug37076_1.phpt b/ext/simplexml/tests/bug37076_1.phpt index 019915a1b4ee5..d002c93f08562 100644 --- a/ext/simplexml/tests/bug37076_1.phpt +++ b/ext/simplexml/tests/bug37076_1.phpt @@ -4,13 +4,18 @@ Bug #37076 (SimpleXML ignores .=) (appending to unnamed attribute) --FILE-- "); -$xml->{""} .= "bar"; + +try { + $xml->{""} .= "bar"; +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + print $xml->asXML(); ?> ---EXPECTF-- -Warning: main(): Cannot write or create unnamed element in %s on line %d - -Warning: main(): Cannot write or create unnamed element in %s on line %d +--EXPECT-- +Cannot create element with an empty name diff --git a/ext/simplexml/tests/bug38406.phpt b/ext/simplexml/tests/bug38406.phpt index 51a716cbd352e..7e20c7e70447f 100644 --- a/ext/simplexml/tests/bug38406.phpt +++ b/ext/simplexml/tests/bug38406.phpt @@ -13,7 +13,12 @@ $item->otherAttribute = $item->attribute; var_dump($item->otherAttribute); $a = array(); -$item->$a = new stdclass; + +try { + $item->$a = new stdclass; +} catch (TypeError $exception) { + echo $exception->getMessage() . "\n"; +} echo "Done\n"; ?> @@ -28,6 +33,5 @@ object(SimpleXMLElement)#%d (1) { } Warning: Array to string conversion in %s on line %d - -Warning: It is not yet possible to assign complex types to properties in %s on line %d +It's not possible to assign a complex type to properties, stdClass given Done diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index 8b251155fde09..03fcc46776ea2 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -1365,11 +1365,24 @@ static char *get_http_header_value(char *headers, char *type) /* match */ tmp = pos + typelen; + + /* strip leading whitespace */ + while (*tmp == ' ' || *tmp == '\t') { + tmp++; + } + eol = strchr(tmp, '\n'); if (eol == NULL) { eol = headers + headerslen; - } else if (eol > tmp && *(eol-1) == '\r') { - eol--; + } else if (eol > tmp) { + if (*(eol-1) == '\r') { + eol--; + } + + /* strip trailing whitespace */ + while (eol > tmp && (*(eol-1) == ' ' || *(eol-1) == '\t')) { + eol--; + } } return estrndup(tmp, eol - tmp); } diff --git a/ext/soap/soap.c b/ext/soap/soap.c index de921cde8af4a..527753bd1b503 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -1786,7 +1786,7 @@ static void soap_server_fault_ex(sdlFunctionPtr function, zval* fault, soapHeade our fault code with their own handling... Figure this out later */ if (use_http_error_status) { - sapi_add_header("HTTP/1.1 500 Internal Service Error", sizeof("HTTP/1.1 500 Internal Service Error")-1, 1); + sapi_add_header("HTTP/1.1 500 Internal Server Error", sizeof("HTTP/1.1 500 Internal Server Error")-1, 1); } if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0)) { sapi_add_header("Connection: close", sizeof("Connection: close")-1, 1); diff --git a/ext/soap/tests/bug47021.phpt b/ext/soap/tests/bug47021.phpt new file mode 100644 index 0000000000000..757e74ef15ee3 --- /dev/null +++ b/ext/soap/tests/bug47021.phpt @@ -0,0 +1,80 @@ +--TEST-- +Bug #47021 SoapClient (SoapClient stumbles over WSDL delivered with "Transfer-Encoding: chunked") +--INI-- +soap.wsdl_cache_enabled=0 +--SKIPIF-- + +--FILE-- + $v) { + $chunks[$k] = sprintf("%08x\r\n%s\r\n", strlen($v), $v); + } + + return join('', $chunks); +} + +$wsdl = file_get_contents(__DIR__.'/server030.wsdl'); + +$soap = << +text0text1text2text3text4text5text6text7text8text9 +EOF; + +$responses = [ + "data://text/plain,HTTP/1.1 200 OK\r\n". + "Content-Type: text/xml;charset=utf-8\r\n". + "Transfer-Encoding: \t chunked\t \r\n". + "Connection: close\r\n". + "\r\n". + chunk_body($wsdl, 64), + "data://text/plain,HTTP/1.1 200 OK\r\n". + "Content-Type: text/xml;charset=utf-8\r\n". + "Transfer-Encoding: \t chunked\t \r\n". + "Connection: close\r\n". + "\r\n". + chunk_body($soap, 156), +]; + + +$pid = http_server('tcp://127.0.0.1:12342', $responses); + +$options = [ + 'trace' => true, + 'location' => 'http://127.0.0.1:12342/', +]; + +class BugSoapClient extends SoapClient +{ + public function __doRequest($request, $location, $action, $version, $one_way = null) + { + $response = parent::__doRequest($request, $location, $action, $version, $one_way); + + var_dump(strlen($response)); + + return $response; + } +} + +$client = new BugSoapClient('http://127.0.0.1:12342/', $options); + +var_dump(count($client->getItems())); + +http_server_kill($pid); + +?> +--EXPECT-- +int(1291) +int(10) diff --git a/ext/sockets/tests/socket_cmsg_credentials.phpt b/ext/sockets/tests/socket_cmsg_credentials.phpt index 31d7eb47993e3..f2b56018d68c8 100644 --- a/ext/sockets/tests/socket_cmsg_credentials.phpt +++ b/ext/sockets/tests/socket_cmsg_credentials.phpt @@ -16,12 +16,12 @@ die('skip SO_PASSCRED is not defined'); } --CLEAN-- file_name == NULL) { if (spl_filesystem_object_get_file_name(intern) != SUCCESS) { + zend_restore_error_handling(&error_handling); RETURN_THROWS(); } } #if defined(PHP_WIN32) || defined(HAVE_SYMLINK) if (intern->file_name == NULL) { + zend_restore_error_handling(&error_handling); php_error_docref(NULL, E_WARNING, "Empty filename"); RETURN_FALSE; } else if (!IS_ABSOLUTE_PATH(intern->file_name, intern->file_name_len)) { char expanded_path[MAXPATHLEN]; if (!expand_filepath_with_mode(intern->file_name, expanded_path, NULL, 0, CWD_EXPAND )) { + zend_restore_error_handling(&error_handling); php_error_docref(NULL, E_WARNING, "No such file or directory"); RETURN_FALSE; } @@ -1275,6 +1278,7 @@ PHP_METHOD(SplFileInfo, getRealPath) if (intern->type == SPL_FS_DIR && !intern->file_name && intern->u.dir.entry.d_name[0]) { if (spl_filesystem_object_get_file_name(intern) != SUCCESS) { + zend_restore_error_handling(&error_handling); RETURN_THROWS(); } } diff --git a/ext/spl/tests/bug79987.phpt b/ext/spl/tests/bug79987.phpt new file mode 100644 index 0000000000000..bda5841ee7a69 --- /dev/null +++ b/ext/spl/tests/bug79987.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #79987 (Memory leak in SplFileInfo because of missing zend_restore_error_handling()) +--FILE-- +getLinkTarget()); +} catch (Throwable $e) { + echo $e->getMessage() . "\n"; +} +--EXPECT-- +Object not initialized diff --git a/ext/sqlite3/config.w32 b/ext/sqlite3/config.w32 index 41eccb5af94ea..ab54989e1c403 100644 --- a/ext/sqlite3/config.w32 +++ b/ext/sqlite3/config.w32 @@ -8,6 +8,7 @@ if (PHP_SQLITE3 != "no") { AC_DEFINE("HAVE_SQLITE3", 1, "SQLite support"); AC_DEFINE("HAVE_SQLITE3_ERRSTR", 1, "have sqlite3_errstr function"); + AC_DEFINE("HAVE_SQLITE3_EXPANDED_SQL", 1, "have sqlite3_expanded_sql function"); } else { WARNING("sqlite3 not enabled; libraries and/or headers not found"); } diff --git a/ext/sqlite3/config0.m4 b/ext/sqlite3/config0.m4 index 0d607593b742b..e83ec5f224fca 100644 --- a/ext/sqlite3/config0.m4 +++ b/ext/sqlite3/config0.m4 @@ -15,6 +15,10 @@ if test $PHP_SQLITE3 != "no"; then AC_DEFINE(HAVE_SQLITE3_ERRSTR, 1, [have sqlite3_errstr function]) ], [], [$SQLITE3_SHARED_LIBADD]) + PHP_CHECK_LIBRARY(sqlite3, sqlite3_expanded_sql, [ + AC_DEFINE(HAVE_SQLITE3_EXPANDED_SQL, 1, [have sqlite3_expanded_sql function]) + ], [], [$SQLITE3_SHARED_LIBADD]) + PHP_CHECK_LIBRARY(sqlite3,sqlite3_load_extension, [], [AC_DEFINE(SQLITE_OMIT_LOAD_EXTENSION, 1, [have sqlite3 with extension support])], diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index ad85d0f11f465..b06f723b4caf6 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -1641,7 +1641,7 @@ PHP_METHOD(SQLite3Stmt, getSQL) } if (expanded) { -#if SQLITE_VERSION_NUMBER >= 3014000 +#ifdef HAVE_SQLITE3_EXPANDED_SQL char *sql = sqlite3_expanded_sql(stmt_obj->stmt); RETVAL_STRING(sql); sqlite3_free(sql); diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 51a44a3ffb15b..30080bcc36c56 100755 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1989,14 +1989,7 @@ PHP_FUNCTION(highlight_string) hicompiled_string_description = zend_make_compiled_string_description("highlighted code"); - if (highlight_string(expr, &syntax_highlighter_ini, hicompiled_string_description) == FAILURE) { - efree(hicompiled_string_description); - EG(error_reporting) = old_error_reporting; - if (i) { - php_output_end(); - } - RETURN_FALSE; - } + highlight_string(expr, &syntax_highlighter_ini, hicompiled_string_description); efree(hicompiled_string_description); EG(error_reporting) = old_error_reporting; @@ -2006,6 +1999,7 @@ PHP_FUNCTION(highlight_string) php_output_discard(); ZEND_ASSERT(Z_TYPE_P(return_value) == IS_STRING); } else { + // TODO Make this function void? RETURN_TRUE; } } diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index f3ab8734ea334..73a82b627d7c3 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -169,13 +169,13 @@ function array_count_values(array $array): array {} function array_column(array $array, int|string|null $column_key, int|string|null $index_key = null): array {} -function array_reverse(array $input, bool $preserve_keys = false): array {} +function array_reverse(array $array, bool $preserve_keys = false): array {} function array_pad(array $array, int $pad_size, mixed $pad_value): array {} function array_flip(array $array): array {} -function array_change_key_case(array $input, int $case = CASE_LOWER): array {} +function array_change_key_case(array $array, int $case = CASE_LOWER): array {} function array_unique(array $array, int $flags = SORT_STRING): array {} @@ -1500,11 +1500,11 @@ function convert_uudecode(string $data): string|false {} /* var.c */ -function var_dump(mixed $value, mixed ...$value): void {} +function var_dump(mixed $value, mixed ...$values): void {} function var_export(mixed $value, bool $return = false): ?string {} -function debug_zval_dump(mixed $value, mixed ...$value): void {} +function debug_zval_dump(mixed $value, mixed ...$values): void {} function serialize(mixed $value): string {} diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index d59c0167deff0..31200dbb92d3f 100755 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 269d4da84e4bc6fae246b90e4c50e48463b86f41 */ + * Stub hash: 8b6ef365e9635c92ef86adb40b2aba077867f3b2 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0) @@ -251,7 +251,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_array_column, 0, 2, IS_ARRAY, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_array_reverse, 0, 1, IS_ARRAY, 0) - ZEND_ARG_TYPE_INFO(0, input, IS_ARRAY, 0) + ZEND_ARG_TYPE_INFO(0, array, IS_ARRAY, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, preserve_keys, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() @@ -264,7 +264,7 @@ ZEND_END_ARG_INFO() #define arginfo_array_flip arginfo_array_values ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_array_change_key_case, 0, 1, IS_ARRAY, 0) - ZEND_ARG_TYPE_INFO(0, input, IS_ARRAY, 0) + ZEND_ARG_TYPE_INFO(0, array, IS_ARRAY, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, case, IS_LONG, 0, "CASE_LOWER") ZEND_END_ARG_INFO() @@ -2173,7 +2173,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_var_dump, 0, 1, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) - ZEND_ARG_VARIADIC_TYPE_INFO(0, value, IS_MIXED, 0) + ZEND_ARG_VARIADIC_TYPE_INFO(0, values, IS_MIXED, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_var_export, 0, 1, IS_STRING, 1) diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c index abb5d69df8d84..e9ee1b1f0e176 100644 --- a/ext/standard/browscap.c +++ b/ext/standard/browscap.c @@ -418,8 +418,8 @@ static int browscap_read_file(char *filename, browser_data *browdata, int persis } browdata->htab = pemalloc(sizeof *browdata->htab, persistent); - zend_hash_init_ex(browdata->htab, 0, NULL, - persistent ? browscap_entry_dtor_persistent : browscap_entry_dtor, persistent, 0); + zend_hash_init(browdata->htab, 0, NULL, + persistent ? browscap_entry_dtor_persistent : browscap_entry_dtor, persistent); browdata->kv_size = 16 * 1024; browdata->kv_used = 0; diff --git a/ext/standard/password.c b/ext/standard/password.c index ea28ee6145cf0..de21569a44c8a 100644 --- a/ext/standard/password.c +++ b/ext/standard/password.c @@ -592,8 +592,8 @@ PHP_FUNCTION(password_get_info) add_assoc_string(return_value, "algoName", algo->name); if (algo->get_info && (FAILURE == algo->get_info(&options, hash))) { - zval_dtor(&options); - zval_dtor(return_value); + zval_ptr_dtor_nogc(&options); + zval_ptr_dtor_nogc(return_value); RETURN_NULL(); } add_assoc_zval(return_value, "options", &options); diff --git a/ext/standard/scanf.c b/ext/standard/scanf.c index 1464008243fb9..9f6986ab166e7 100644 --- a/ext/standard/scanf.c +++ b/ext/standard/scanf.c @@ -906,7 +906,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format, __buf[0] = sch; __buf[1] = '\0'; current = args[objIndex++]; - zval_dtor(*current); + zval_ptr_dtor_nogc(*current); ZVAL_STRINGL( *current, __buf, 1); } else { add_index_stringl(return_value, objIndex++, &sch, 1); diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 1c49b26ac7db1..eb450efe5444c 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -1245,13 +1245,9 @@ PHP_FUNCTION(stream_filter_remove) RETURN_FALSE; } - if (zend_list_close(Z_RES_P(zfilter)) == FAILURE) { - php_error_docref(NULL, E_WARNING, "Could not invalidate filter, not removing"); - RETURN_FALSE; - } else { - php_stream_filter_remove(filter, 1); - RETURN_TRUE; - } + zend_list_close(Z_RES_P(zfilter)); + php_stream_filter_remove(filter, 1); + RETURN_TRUE; } /* }}} */ diff --git a/ext/standard/string.c b/ext/standard/string.c index 9a877ce13871a..b8572671fa2bf 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -26,19 +26,8 @@ # include #endif -/* - * This define is here because some versions of libintl redefine setlocale - * to point to libintl_setlocale. That's a ridiculous thing to do as far - * as I am concerned, but with this define and the subsequent undef we - * limit the damage to just the actual setlocale() call in this file - * without turning zif_setlocale into zif_libintl_setlocale. -Rasmus - */ -#define php_my_setlocale setlocale #ifdef HAVE_LIBINTL # include /* For LC_MESSAGES */ - #ifdef setlocale - # undef setlocale - #endif #endif #include "scanf.h" @@ -2897,7 +2886,7 @@ static zend_string* php_char_to_str_ex(zend_string *str, char from, char *to, si { zend_string *result; size_t char_count = 0; - char lc_from = 0; + int lc_from = 0; const char *source, *source_end= ZSTR_VAL(str) + ZSTR_LEN(str); char *target; @@ -4611,116 +4600,111 @@ PHP_FUNCTION(strip_tags) } /* }}} */ +static zend_string *try_setlocale_str(zend_long cat, zend_string *loc) { + const char *retval; + + if (!strcmp("0", ZSTR_VAL(loc))) { + loc = NULL; + } else { + if (ZSTR_LEN(loc) >= 255) { + php_error_docref(NULL, E_WARNING, "Specified locale name is too long"); + return NULL; + } + } + +# ifndef PHP_WIN32 + retval = setlocale(cat, loc ? ZSTR_VAL(loc) : NULL); +# else + if (loc) { + /* BC: don't try /^[a-z]{2}_[A-Z]{2}($|\..*)/ except for /^u[ks]_U[KS]$/ */ + char *locp = ZSTR_VAL(loc); + if (ZSTR_LEN(loc) >= 5 && locp[2] == '_' + && locp[0] >= 'a' && locp[0] <= 'z' && locp[1] >= 'a' && locp[1] <= 'z' + && locp[3] >= 'A' && locp[3] <= 'Z' && locp[4] >= 'A' && locp[4] <= 'Z' + && (locp[5] == '\0' || locp[5] == '.') + && !(locp[0] == 'u' && (locp[1] == 'k' || locp[1] == 's') + && locp[3] == 'U' && (locp[4] == 'K' || locp[4] == 'S') + && locp[5] == '\0') + ) { + retval = NULL; + } else { + retval = setlocale(cat, ZSTR_VAL(loc)); + } + } else { + retval = setlocale(cat, NULL); + } +# endif + zend_update_current_locale(); + if (!retval) { + return NULL; + } + + if (loc) { + /* Remember if locale was changed */ + size_t len = strlen(retval); + + BG(locale_changed) = 1; + if (cat == LC_CTYPE || cat == LC_ALL) { + if (BG(ctype_string)) { + zend_string_release_ex(BG(ctype_string), 0); + } + if (len == 1 && *retval == 'C') { + /* C locale is represented as NULL. */ + BG(ctype_string) = NULL; + return ZSTR_CHAR('C'); + } else if (len == ZSTR_LEN(loc) && !memcmp(ZSTR_VAL(loc), retval, len)) { + BG(ctype_string) = zend_string_copy(loc); + return zend_string_copy(BG(ctype_string)); + } else { + BG(ctype_string) = zend_string_init(retval, len, 0); + return zend_string_copy(BG(ctype_string)); + } + } else if (len == ZSTR_LEN(loc) && !memcmp(ZSTR_VAL(loc), retval, len)) { + return zend_string_copy(loc); + } + } + return zend_string_init(retval, strlen(retval), 0); +} + +static zend_string *try_setlocale_zval(zend_long cat, zval *loc_zv) { + zend_string *loc_str = zval_try_get_string(loc_zv); + zend_string *result = try_setlocale_str(cat, loc_str); + zend_string_release_ex(loc_str, 0); + return result; +} + /* {{{ Set locale information */ PHP_FUNCTION(setlocale) { - zval *args = NULL; - zval *plocale; - zend_string *loc; - const char *retval; zend_long cat; - int num_args, i = 0; - uint32_t idx; + zval *args = NULL; + int num_args; ZEND_PARSE_PARAMETERS_START(2, -1) Z_PARAM_LONG(cat) Z_PARAM_VARIADIC('+', args, num_args) ZEND_PARSE_PARAMETERS_END(); - idx = 0; - while (1) { - if (Z_TYPE(args[0]) == IS_ARRAY) { - while (idx < Z_ARRVAL(args[0])->nNumUsed) { - plocale = &Z_ARRVAL(args[0])->arData[idx].val; - if (Z_TYPE_P(plocale) != IS_UNDEF) { - break; + for (uint32_t i = 0; i < num_args; i++) { + if (Z_TYPE(args[i]) == IS_ARRAY) { + zval *elem; + ZEND_HASH_FOREACH_VAL_IND(Z_ARRVAL(args[i]), elem) { + zend_string *result = try_setlocale_zval(cat, elem); + if (EG(exception)) { + RETURN_THROWS(); } - idx++; - } - if (idx >= Z_ARRVAL(args[0])->nNumUsed) { - break; - } - } else { - plocale = &args[i]; - } - - loc = zval_try_get_string(plocale); - if (UNEXPECTED(!loc)) { - return; - } - - if (!strcmp("0", ZSTR_VAL(loc))) { - zend_string_release_ex(loc, 0); - loc = NULL; + if (result) { + RETURN_STR(result); + } + } ZEND_HASH_FOREACH_END(); } else { - if (ZSTR_LEN(loc) >= 255) { - php_error_docref(NULL, E_WARNING, "Specified locale name is too long"); - zend_string_release_ex(loc, 0); - break; - } - } - -# ifndef PHP_WIN32 - retval = php_my_setlocale(cat, loc ? ZSTR_VAL(loc) : NULL); -# else - if (loc) { - /* BC: don't try /^[a-z]{2}_[A-Z]{2}($|\..*)/ except for /^u[ks]_U[KS]$/ */ - char *locp = ZSTR_VAL(loc); - if (ZSTR_LEN(loc) >= 5 && locp[2] == '_' - && locp[0] >= 'a' && locp[0] <= 'z' && locp[1] >= 'a' && locp[1] <= 'z' - && locp[3] >= 'A' && locp[3] <= 'Z' && locp[4] >= 'A' && locp[4] <= 'Z' - && (locp[5] == '\0' || locp[5] == '.') - && !(locp[0] == 'u' && (locp[1] == 'k' || locp[1] == 's') - && locp[3] == 'U' && (locp[4] == 'K' || locp[4] == 'S') - && locp[5] == '\0') - ) { - retval = NULL; - } else { - retval = php_my_setlocale(cat, ZSTR_VAL(loc)); + zend_string *result = try_setlocale_zval(cat, &args[i]); + if (EG(exception)) { + RETURN_THROWS(); } - } else { - retval = php_my_setlocale(cat, NULL); - } -# endif - zend_update_current_locale(); - if (retval) { - if (loc) { - /* Remember if locale was changed */ - size_t len = strlen(retval); - - BG(locale_changed) = 1; - if (cat == LC_CTYPE || cat == LC_ALL) { - if (BG(ctype_string)) { - zend_string_release_ex(BG(ctype_string), 0); - } - if (len == 1 && *retval == 'C') { - /* C locale is represented as NULL. */ - BG(ctype_string) = NULL; - zend_string_release_ex(loc, 0); - RETURN_CHAR('C'); - } else if (len == ZSTR_LEN(loc) && !memcmp(ZSTR_VAL(loc), retval, len)) { - BG(ctype_string) = zend_string_copy(loc); - RETURN_STR(BG(ctype_string)); - } else { - BG(ctype_string) = zend_string_init(retval, len, 0); - zend_string_release_ex(loc, 0); - RETURN_STR_COPY(BG(ctype_string)); - } - } else if (len == ZSTR_LEN(loc) && !memcmp(ZSTR_VAL(loc), retval, len)) { - RETURN_STR(loc); - } - zend_string_release_ex(loc, 0); + if (result) { + RETURN_STR(result); } - RETURN_STRING(retval); - } - if (loc) { - zend_string_release_ex(loc, 0); - } - - if (Z_TYPE(args[0]) == IS_ARRAY) { - idx++; - } else { - if (++i >= num_args) break; } } diff --git a/ext/standard/tests/file/stream_copy_to_stream.phpt b/ext/standard/tests/file/stream_copy_to_stream.phpt index b0c2d1384665d..1f34b843347ca 100644 --- a/ext/standard/tests/file/stream_copy_to_stream.phpt +++ b/ext/standard/tests/file/stream_copy_to_stream.phpt @@ -5,7 +5,7 @@ stream_copy_to_stream() tests define('WIN', substr(PHP_OS, 0, 3) == 'WIN'); $initial_file = __DIR__.'/bug38086.txt'; -$new_file = __DIR__.'/bug38086_1.txt'; +$new_file = __DIR__.'/stream_copy_to_stream.txt'; $src = fopen($initial_file, 'r'); stream_filter_append($src, "string.rot13", STREAM_FILTER_READ); diff --git a/ext/standard/tests/strings/bug79986.phpt b/ext/standard/tests/strings/bug79986.phpt new file mode 100644 index 0000000000000..fcbc72148c242 --- /dev/null +++ b/ext/standard/tests/strings/bug79986.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #79986 (str_ireplace bug with diacritics characters) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +11 22 33 diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re index 1fc0e0dcda9ba..e7a48d4d8e0d3 100644 --- a/ext/standard/var_unserializer.re +++ b/ext/standard/var_unserializer.re @@ -597,7 +597,7 @@ string_key: if (!zend_verify_prop_assignable_by_ref(info, data, /* strict */ 1)) { zval_ptr_dtor(data); ZVAL_UNDEF(data); - zval_dtor(&key); + zval_ptr_dtor_nogc(&key); goto failure; } if (Z_ISREF_P(data)) { diff --git a/ext/tokenizer/tokenizer.c b/ext/tokenizer/tokenizer.c index 2656ce8f73940..d12b5edba8ded 100644 --- a/ext/tokenizer/tokenizer.c +++ b/ext/tokenizer/tokenizer.c @@ -358,10 +358,7 @@ static zend_bool tokenize(zval *return_value, zend_string *source, zend_class_en ZVAL_STR_COPY(&source_zval, source); zend_save_lexical_state(&original_lex_state); - if (zend_prepare_string_for_scanning(&source_zval, "") == FAILURE) { - zend_restore_lexical_state(&original_lex_state); - return 0; - } + zend_prepare_string_for_scanning(&source_zval, ""); LANG_SCNG(yy_state) = yycINITIAL; zend_hash_init(&interned_strings, 0, NULL, NULL, 0); @@ -484,6 +481,8 @@ static zend_bool tokenize_parse( zval *return_value, zend_string *source, zend_class_entry *token_class) { zval source_zval; + struct event_context ctx; + zval token_stream; zend_lex_state original_lex_state; zend_bool original_in_compilation; zend_bool success; @@ -494,30 +493,27 @@ static zend_bool tokenize_parse( CG(in_compilation) = 1; zend_save_lexical_state(&original_lex_state); - if ((success = (zend_prepare_string_for_scanning(&source_zval, "") == SUCCESS))) { - struct event_context ctx; - zval token_stream; - array_init(&token_stream); - - ctx.tokens = &token_stream; - ctx.token_class = token_class; + zend_prepare_string_for_scanning(&source_zval, ""); + array_init(&token_stream); - CG(ast) = NULL; - CG(ast_arena) = zend_arena_create(1024 * 32); - LANG_SCNG(yy_state) = yycINITIAL; - LANG_SCNG(on_event) = on_event; - LANG_SCNG(on_event_context) = &ctx; + ctx.tokens = &token_stream; + ctx.token_class = token_class; - if((success = (zendparse() == SUCCESS))) { - ZVAL_COPY_VALUE(return_value, &token_stream); - } else { - zval_ptr_dtor(&token_stream); - } + CG(ast) = NULL; + CG(ast_arena) = zend_arena_create(1024 * 32); + LANG_SCNG(yy_state) = yycINITIAL; + LANG_SCNG(on_event) = on_event; + LANG_SCNG(on_event_context) = &ctx; - zend_ast_destroy(CG(ast)); - zend_arena_destroy(CG(ast_arena)); + if((success = (zendparse() == SUCCESS))) { + ZVAL_COPY_VALUE(return_value, &token_stream); + } else { + zval_ptr_dtor(&token_stream); } + zend_ast_destroy(CG(ast)); + zend_arena_destroy(CG(ast_arena)); + /* restore compiler and scanner global states */ zend_restore_lexical_state(&original_lex_state); CG(in_compilation) = original_in_compilation; diff --git a/ext/xmlreader/php_xmlreader.c b/ext/xmlreader/php_xmlreader.c index efed79a2395fd..7b2619540956e 100644 --- a/ext/xmlreader/php_xmlreader.c +++ b/ext/xmlreader/php_xmlreader.c @@ -175,7 +175,7 @@ zval *xmlreader_write_property(zend_object *object, zend_string *name, zval *val hnd = zend_hash_find_ptr(obj->prop_handler, name); } if (hnd != NULL) { - php_error_docref(NULL, E_WARNING, "Cannot write to read-only property"); + zend_throw_error(NULL, "Cannot write to read-only property"); } else { value = zend_std_write_property(object, name, value, cache_slot); } @@ -391,8 +391,8 @@ static void php_xmlreader_string_arg(INTERNAL_FUNCTION_PARAMETERS, xmlreader_rea } if (!name_len) { - php_error_docref(NULL, E_WARNING, "Argument cannot be an empty string"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } id = ZEND_THIS; @@ -480,8 +480,8 @@ static void php_xmlreader_set_relaxng_schema(INTERNAL_FUNCTION_PARAMETERS, int t } if (source != NULL && !source_len) { - php_error_docref(NULL, E_WARNING, "Schema data source is required"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } id = ZEND_THIS; @@ -506,15 +506,16 @@ static void php_xmlreader_set_relaxng_schema(INTERNAL_FUNCTION_PARAMETERS, int t intern->schema = schema; RETURN_TRUE; + } else { + php_error_docref(NULL, E_WARNING, "Schema contains errors"); + RETURN_FALSE; } + } else { + zend_throw_error(NULL, "Schema must be set prior to reading"); + RETURN_THROWS(); } - - php_error_docref(NULL, E_WARNING, "Unable to set schema. This must be set prior to reading or schema contains errors."); - - RETURN_FALSE; #else - php_error_docref(NULL, E_WARNING, "No Schema support built into libxml."); - + php_error_docref(NULL, E_WARNING, "No schema support built into libxml"); RETURN_FALSE; #endif } @@ -585,9 +586,14 @@ PHP_METHOD(XMLReader, getAttributeNs) RETURN_THROWS(); } - if (name_len == 0 || ns_uri_len == 0) { - php_error_docref(NULL, E_WARNING, "Attribute Name and Namespace URI cannot be empty"); - RETURN_FALSE; + if (name_len == 0) { + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); + } + + if (ns_uri_len == 0) { + zend_argument_value_error(2, "cannot be empty"); + RETURN_THROWS(); } id = ZEND_THIS; @@ -622,8 +628,8 @@ PHP_METHOD(XMLReader, getParserProperty) retval = xmlTextReaderGetParserProp(intern->ptr,property); } if (retval == -1) { - php_error_docref(NULL, E_WARNING, "Invalid parser property"); - RETURN_FALSE; + zend_argument_value_error(1, "must be a valid parser property"); + RETURN_THROWS(); } RETURN_BOOL(retval); @@ -660,8 +666,8 @@ PHP_METHOD(XMLReader, moveToAttribute) } if (name_len == 0) { - php_error_docref(NULL, E_WARNING, "Attribute Name is required"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } id = ZEND_THIS; @@ -719,9 +725,14 @@ PHP_METHOD(XMLReader, moveToAttributeNs) RETURN_THROWS(); } - if (name_len == 0 || ns_uri_len == 0) { - php_error_docref(NULL, E_WARNING, "Attribute Name and Namespace URI cannot be empty"); - RETURN_FALSE; + if (name_len == 0) { + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); + } + + if (ns_uri_len == 0) { + zend_argument_value_error(2, "cannot be empty"); + RETURN_THROWS(); } id = ZEND_THIS; @@ -772,17 +783,17 @@ PHP_METHOD(XMLReader, read) id = ZEND_THIS; intern = Z_XMLREADER_P(id); - if (intern != NULL && intern->ptr != NULL) { - retval = xmlTextReaderRead(intern->ptr); - if (retval == -1) { - RETURN_FALSE; - } else { - RETURN_BOOL(retval); - } + if (intern == NULL || intern->ptr == NULL) { + zend_throw_error(NULL, "Data must be loaded before reading"); + RETURN_THROWS(); } - php_error_docref(NULL, E_WARNING, "Load Data before trying to read"); - RETURN_FALSE; + retval = xmlTextReaderRead(intern->ptr); + if (retval == -1) { + RETURN_FALSE; + } else { + RETURN_BOOL(retval); + } } /* }}} */ @@ -816,8 +827,7 @@ PHP_METHOD(XMLReader, next) } } - php_error_docref(NULL, E_WARNING, "Load Data before trying to read"); - RETURN_FALSE; + zend_throw_error(NULL, "Data must be loaded before reading"); } /* }}} */ @@ -848,8 +858,8 @@ PHP_METHOD(XMLReader, open) } if (!source_len) { - php_error_docref(NULL, E_WARNING, "Empty string supplied as input"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } valid_file = _xmlreader_get_valid_file_path(source, resolved_path, MAXPATHLEN ); @@ -920,8 +930,8 @@ PHP_METHOD(XMLReader, setSchema) } if (source != NULL && !source_len) { - php_error_docref(NULL, E_WARNING, "Schema data source is required"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } id = ZEND_THIS; @@ -932,15 +942,16 @@ PHP_METHOD(XMLReader, setSchema) if (retval == 0) { RETURN_TRUE; + } else { + php_error_docref(NULL, E_WARNING, "Schema contains errors"); + RETURN_FALSE; } + } else { + zend_throw_error(NULL, "Schema must be set prior to reading"); + RETURN_THROWS(); } - - php_error_docref(NULL, E_WARNING, "Unable to set schema. This must be set prior to reading or schema contains errors."); - - RETURN_FALSE; #else - php_error_docref(NULL, E_WARNING, "No Schema support built into libxml."); - + php_error_docref(NULL, E_WARNING, "No schema support built into libxml"); RETURN_FALSE; #endif } @@ -967,8 +978,8 @@ PHP_METHOD(XMLReader, setParserProperty) retval = xmlTextReaderSetParserProp(intern->ptr,property, value); } if (retval == -1) { - php_error_docref(NULL, E_WARNING, "Invalid parser property"); - RETURN_FALSE; + zend_argument_value_error(1, "must be a valid parser property"); + RETURN_THROWS(); } RETURN_TRUE; @@ -1022,8 +1033,8 @@ PHP_METHOD(XMLReader, XML) } if (!source_len) { - php_error_docref(NULL, E_WARNING, "Empty string supplied as input"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } inputbfr = xmlParserInputBufferCreateMem(source, source_len, XML_CHAR_ENCODING_NONE); @@ -1105,7 +1116,7 @@ PHP_METHOD(XMLReader, expand) node = xmlTextReaderExpand(intern->ptr); if (node == NULL) { - php_error_docref(NULL, E_WARNING, "An Error Occurred while expanding "); + php_error_docref(NULL, E_WARNING, "An Error Occurred while expanding"); RETURN_FALSE; } else { nodec = xmlDocCopyNode(node, docp, 1); @@ -1117,8 +1128,8 @@ PHP_METHOD(XMLReader, expand) } } } else { - php_error_docref(NULL, E_WARNING, "Load Data before trying to expand"); - RETURN_FALSE; + zend_throw_error(NULL, "Data must be loaded before expanding"); + RETURN_THROWS(); } #else php_error(E_WARNING, "DOM support is not enabled"); diff --git a/ext/xmlreader/php_xmlreader.stub.php b/ext/xmlreader/php_xmlreader.stub.php index 9de30e5a7afd9..582919d49721f 100644 --- a/ext/xmlreader/php_xmlreader.stub.php +++ b/ext/xmlreader/php_xmlreader.stub.php @@ -7,7 +7,7 @@ class XMLReader /** @return bool */ public function close() {} - /** @return string|null|false */ + /** @return string|null */ public function getAttribute(string $name) {} /** @return string|null */ @@ -22,7 +22,7 @@ public function getParserProperty(int $property) {} /** @return bool */ public function isValid() {} - /** @return string|null|false */ + /** @return string|null */ public function lookupNamespace(string $prefix) {} /** @return bool */ diff --git a/ext/xmlreader/php_xmlreader_arginfo.h b/ext/xmlreader/php_xmlreader_arginfo.h index 749d8066f41cd..0690d414163e5 100644 --- a/ext/xmlreader/php_xmlreader_arginfo.h +++ b/ext/xmlreader/php_xmlreader_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 8bdec18c4ad8574fb1d3e4baca928949d5ec2438 */ + * Stub hash: 90e6d525ba87399c54f36965ebf18dbf65084617 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_XMLReader_close, 0, 0, 0) ZEND_END_ARG_INFO() diff --git a/ext/xmlreader/tests/001.phpt b/ext/xmlreader/tests/001.phpt index c10c1a51635a9..cf255860556f4 100644 --- a/ext/xmlreader/tests/001.phpt +++ b/ext/xmlreader/tests/001.phpt @@ -17,10 +17,15 @@ while ($reader->read()) { } $xmlstring = ''; $reader = new XMLReader(); -$reader->XML($xmlstring); + +try { + $reader->XML($xmlstring); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + ?> ---EXPECTF-- +--EXPECT-- books books - -Warning: XMLReader::XML(): Empty string supplied as input in %s on line %d +XMLReader::XML(): Argument #1 ($source) cannot be empty diff --git a/ext/xmlreader/tests/002.phpt b/ext/xmlreader/tests/002.phpt index 6d12f02204759..803c8c7243aa6 100644 --- a/ext/xmlreader/tests/002.phpt +++ b/ext/xmlreader/tests/002.phpt @@ -10,7 +10,11 @@ $xmlstring = ' file_put_contents($filename, $xmlstring); $reader = new XMLReader(); -if ($reader->open('')) exit(); +try { + $reader->open(''); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} $reader = new XMLReader(); if (!$reader->open($filename)) { @@ -31,7 +35,7 @@ $reader->close(); unlink($filename); ?> ---EXPECTF-- -Warning: XMLReader::open(): Empty string supplied as input in %s on line %d +--EXPECT-- +XMLReader::open(): Argument #1 ($URI) cannot be empty books books diff --git a/ext/xmlreader/tests/003-get-errors.phpt b/ext/xmlreader/tests/003-get-errors.phpt index a10529118f87e..e616bbc63ce70 100644 --- a/ext/xmlreader/tests/003-get-errors.phpt +++ b/ext/xmlreader/tests/003-get-errors.phpt @@ -31,8 +31,12 @@ while ($reader->read()) { echo $reader->value . "\n"; // Test for call with an empty string argument - $attr = $reader->getAttribute(''); - var_dump($attr); + try { + $reader->getAttribute(''); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } + // Ensure that node pointer has not changed position echo $reader->name . ": "; echo $reader->value . "\n"; @@ -61,13 +65,11 @@ $reader->close(); ---EXPECTF-- +--EXPECT-- book bool(true) num: 1 - -Warning: XMLReader::getAttribute(): Argument cannot be an empty string in %s on line %d -bool(false) +XMLReader::getAttribute(): Argument #1 ($name) cannot be empty num: 1 NULL num: 1 diff --git a/ext/xmlreader/tests/003-move-errors.phpt b/ext/xmlreader/tests/003-move-errors.phpt index a00dbaf52442b..24431b6a7e2a0 100644 --- a/ext/xmlreader/tests/003-move-errors.phpt +++ b/ext/xmlreader/tests/003-move-errors.phpt @@ -31,8 +31,12 @@ while ($reader->read()) { echo $reader->value . "\n"; // Test for call with an empty string argument - $attr = $reader->moveToAttribute(''); - var_dump($attr); + try { + $reader->moveToAttribute(''); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } + // Ensure that node pointer has not changed position echo $reader->name . ": "; echo $reader->value . "\n"; @@ -60,13 +64,11 @@ $reader->close(); ---EXPECTF-- +--EXPECT-- book bool(true) num: 1 - -Warning: XMLReader::moveToAttribute(): Attribute Name is required in %s on line %d -bool(false) +XMLReader::moveToAttribute(): Argument #1 ($name) cannot be empty num: 1 bool(false) num: 1 diff --git a/ext/xmlreader/tests/003.phpt b/ext/xmlreader/tests/003.phpt index c52c932c974a2..9ecf9d62da7ca 100644 --- a/ext/xmlreader/tests/003.phpt +++ b/ext/xmlreader/tests/003.phpt @@ -68,14 +68,18 @@ while ($reader->read()) { var_dump($reader->moveToAttributeNo(20)); var_dump($reader->moveToAttribute('missing-attribute')); - var_dump($reader->moveToAttribute('')); + try { + $reader->moveToAttribute(''); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } } } $reader->close(); unlink($filename); ?> ---EXPECTF-- +--EXPECT-- num: 1 idx: 2 num: 1 @@ -84,6 +88,4 @@ num: 1 idx: 2 bool(false) bool(false) - -Warning: XMLReader::moveToAttribute(): Attribute Name is required in %s on line %d -bool(false) +XMLReader::moveToAttribute(): Argument #1 ($name) cannot be empty diff --git a/ext/xmlreader/tests/007.phpt b/ext/xmlreader/tests/007.phpt index 796b9fa05c9d4..6b8cab43f0f7f 100644 --- a/ext/xmlreader/tests/007.phpt +++ b/ext/xmlreader/tests/007.phpt @@ -42,13 +42,15 @@ $reader->close(); $reader = new XMLReader(); $reader->XML($xmlstring); -if ($reader->setRelaxNGSchema('')) { - echo 'failed'; +try { + $reader->setRelaxNGSchema(''); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; } + $reader->close(); ?> ---EXPECTF-- +--EXPECT-- file relaxNG: ok string relaxNG: ok - -Warning: XMLReader::setRelaxNGSchema(): Schema data source is required in %s on line %d +XMLReader::setRelaxNGSchema(): Argument #1 ($filename) cannot be empty diff --git a/ext/xmlreader/tests/014.phpt b/ext/xmlreader/tests/014.phpt index fca94d2b1f3ef..67c0e9fb93a6c 100644 --- a/ext/xmlreader/tests/014.phpt +++ b/ext/xmlreader/tests/014.phpt @@ -24,12 +24,24 @@ while ($reader->read()) { // Find a node to try modifying if ($reader->nodeType == XMLREADER::ELEMENT && $reader->name == 'book') { // Try to set the value of the element from book1 to movie1 - $reader->value = 'movie1'; + try { + $reader->value = 'movie1'; + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } // Try to set the value of the first "num" attribute from "1" to "num attribute 1" $attr = $reader->moveToFirstAttribute(); - $reader->value = 'num attribute 1'; + try { + $reader->value = 'num attribute 1'; + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } // Try to set the name of the first attribute from "num" to "number" - $reader->name = 'number'; + try { + $reader->name = 'number'; + } catch (Error $exception) { + echo $exception->getMessage() . "\n"; + } } } } @@ -41,9 +53,7 @@ $reader->close(); ---EXPECTF-- -Warning: main(): Cannot write to read-only property in %s on line %d - -Warning: main(): Cannot write to read-only property in %s on line %d - -Warning: main(): Cannot write to read-only property in %s on line %d +--EXPECT-- +Cannot write to read-only property +Cannot write to read-only property +Cannot write to read-only property diff --git a/ext/xmlreader/tests/015-get-errors.phpt b/ext/xmlreader/tests/015-get-errors.phpt index 5f17326b1b6aa..850d042a4b0c8 100644 --- a/ext/xmlreader/tests/015-get-errors.phpt +++ b/ext/xmlreader/tests/015-get-errors.phpt @@ -26,8 +26,12 @@ while ($reader->read()) { $attr = $reader->moveToNextAttribute(); // Test for missing namespace argument - $attr = $reader->getAttributeNs('idx', null); - var_dump($attr); + try { + $attr = $reader->getAttributeNs('idx', null); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } + echo $reader->name . ": "; echo $reader->value . "\n"; } @@ -41,7 +45,6 @@ $reader->close(); ---EXPECTF-- -Warning: XMLReader::getAttributeNs(): Attribute Name and Namespace URI cannot be empty in %s on line %d -bool(false) +--EXPECT-- +XMLReader::getAttributeNs(): Argument #2 ($namespaceURI) cannot be empty ns1:num: 1 diff --git a/ext/xmlreader/tests/015-move-errors.phpt b/ext/xmlreader/tests/015-move-errors.phpt index 5263b555b6ea8..2b5580d7ea4fd 100644 --- a/ext/xmlreader/tests/015-move-errors.phpt +++ b/ext/xmlreader/tests/015-move-errors.phpt @@ -24,7 +24,11 @@ while ($reader->read()) { // Find the book node if ($reader->nodeType == XMLREADER::ELEMENT && $reader->name == 'book') { // Test for missing namespace argument - $attr = $reader->moveToAttributeNs('idx', null); + try { + $reader->moveToAttributeNs('idx', null); + } catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; + } } } } @@ -36,5 +40,5 @@ $reader->close(); ---EXPECTF-- -Warning: XMLReader::moveToAttributeNs(): Attribute Name and Namespace URI cannot be empty in %s on line %d +--EXPECT-- +XMLReader::moveToAttributeNs(): Argument #2 ($namespaceURI) cannot be empty diff --git a/ext/xmlreader/tests/expand_error.phpt b/ext/xmlreader/tests/expand_error.phpt index 2813e836d9f76..59ab0365b6043 100644 --- a/ext/xmlreader/tests/expand_error.phpt +++ b/ext/xmlreader/tests/expand_error.phpt @@ -13,7 +13,13 @@ $xmlstring = ' new book'; $reader = new XMLReader(); -var_dump($reader->expand()); + +try { + $reader->expand(); +} catch (Error $exception) { + echo $exception->getMessage() . "\n"; +} + $reader->close(); $reader = new XMLReader(); @@ -22,8 +28,7 @@ var_dump($reader->expand()); $reader->close(); ?> --EXPECTF-- -Warning: XMLReader::expand(): Load Data before trying to expand in %s on line %d -bool(false) +Data must be loaded before expanding -Warning: XMLReader::expand(): An Error Occurred while expanding in %s on line %d +Warning: XMLReader::expand(): An Error Occurred while expanding in %s on line %d bool(false) diff --git a/ext/xmlreader/tests/next_basic.phpt b/ext/xmlreader/tests/next_basic.phpt index e0663c23d3509..70d540c2c20ba 100644 --- a/ext/xmlreader/tests/next_basic.phpt +++ b/ext/xmlreader/tests/next_basic.phpt @@ -9,8 +9,19 @@ $xml = ' '; $reader = new XMLReader(); -$reader->read(); -$reader->next(); + +try { + $reader->read(); +} catch (Error $exception) { + echo $exception->getMessage() . "\n"; +} + +try { + $reader->next(); +} catch (Error $exception) { + echo $exception->getMessage() . "\n"; +} + $reader->close(); $reader->XML($xml); @@ -28,10 +39,9 @@ echo $reader->name . PHP_EOL; $reader->close(); ?> ---EXPECTF-- -Warning: XMLReader::read(): Load Data before trying to read in %s on line %d - -Warning: XMLReader::next(): Load Data before trying to read in %s on line %d +--EXPECT-- +Data must be loaded before reading +Data must be loaded before reading node1 bool(true) node3 diff --git a/ext/xmlreader/tests/schema-bad.xsd b/ext/xmlreader/tests/schema-bad.xsd new file mode 100644 index 0000000000000..d72af314604e3 --- /dev/null +++ b/ext/xmlreader/tests/schema-bad.xsd @@ -0,0 +1 @@ +asd diff --git a/ext/xmlreader/tests/setParserProperty_error.phpt b/ext/xmlreader/tests/setParserProperty_error.phpt index 755a4e4772c4b..9bdb0baa03259 100644 --- a/ext/xmlreader/tests/setParserProperty_error.phpt +++ b/ext/xmlreader/tests/setParserProperty_error.phpt @@ -10,9 +10,12 @@ $xml = 'new bookXML($xml); -var_dump($reader->setParserProperty(-1, true)); +try { + $reader->setParserProperty(-1, true); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} $reader->close(); ?> ---EXPECTF-- -Warning: XMLReader::setParserProperty(): Invalid parser property in %s on line %d -bool(false) +--EXPECT-- +XMLReader::setParserProperty(): Argument #1 ($property) must be a valid parser property diff --git a/ext/xmlreader/tests/setSchema_error.phpt b/ext/xmlreader/tests/setSchema_error.phpt index 31bd4d6e3ed96..2984455de8bba 100644 --- a/ext/xmlreader/tests/setSchema_error.phpt +++ b/ext/xmlreader/tests/setSchema_error.phpt @@ -6,24 +6,38 @@ XMLReader: setSchema Error setSchema('')); +try { + $reader->setSchema(''); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} $reader->close(); $reader = new XMLReader(); -var_dump($reader->setSchema('schema-missing-file.xsd')); +try { + $reader->setSchema('schema-missing-file.xsd'); +} catch (Error $exception) { + echo $exception->getMessage() . "\n"; +} $reader->close(); $reader = new XMLReader(); -var_dump($reader->setSchema('schema-empty.xsd')); +try { + $reader->setSchema('schema-empty.xsd'); +} catch (Error $exception) { + echo $exception->getMessage() . "\n"; +} + +$reader = new XMLReader(); +$reader->XML(<< + +EOF); +var_dump(@$reader->setSchema('schema-bad.xsd')); $reader->close(); ?> ---EXPECTF-- - -Warning: XMLReader::setSchema(): Schema data source is required in %s on line %d -bool(false) - -Warning: XMLReader::setSchema(): Unable to set schema. This must be set prior to reading or schema contains errors. in %s on line %d -bool(false) - -Warning: XMLReader::setSchema(): Unable to set schema. This must be set prior to reading or schema contains errors. in %s on line %d +--EXPECT-- +XMLReader::setSchema(): Argument #1 ($filename) cannot be empty +Schema must be set prior to reading +Schema must be set prior to reading bool(false) diff --git a/ext/xmlwriter/php_xmlwriter.stub.php b/ext/xmlwriter/php_xmlwriter.stub.php index ee4a85eb4dd3d..54cdd4ff5607c 100644 --- a/ext/xmlwriter/php_xmlwriter.stub.php +++ b/ext/xmlwriter/php_xmlwriter.stub.php @@ -206,7 +206,7 @@ public function startDtdEntity(string $name, bool $isparam): bool {} public function endDtdEntity(): bool {} /** @alias xmlwriter_write_dtd_entity */ - public function writeDtdEntity(string $name, string $content, bool $isparam, string $publicId = UNKNOWN, string $systemId = UNKNOWN, string $ndataid = UNKNOWN): bool {} + public function writeDtdEntity(string $name, string $content, bool $isparam = false, string $publicId = UNKNOWN, string $systemId = UNKNOWN, string $ndataid = UNKNOWN): bool {} /** @alias xmlwriter_output_memory */ public function outputMemory(bool $flush = true): string {} diff --git a/ext/xmlwriter/php_xmlwriter_arginfo.h b/ext/xmlwriter/php_xmlwriter_arginfo.h index c59a4e6073fed..cebddf6372fb1 100644 --- a/ext/xmlwriter/php_xmlwriter_arginfo.h +++ b/ext/xmlwriter/php_xmlwriter_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: c4717d4f5dafe071fb78799993db1e733d45470a */ + * Stub hash: 9323f768ddea26f104b699a9c0ce54e3560b3b32 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_xmlwriter_open_uri, 0, 1, XMLWriter, MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, uri, IS_STRING, 0) @@ -310,10 +310,10 @@ ZEND_END_ARG_INFO() #define arginfo_class_XMLWriter_endDtdEntity arginfo_class_XMLWriter_openMemory -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_XMLWriter_writeDtdEntity, 0, 3, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_XMLWriter_writeDtdEntity, 0, 2, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, content, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, isparam, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, isparam, _IS_BOOL, 0, "false") ZEND_ARG_TYPE_INFO(0, publicId, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, systemId, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, ndataid, IS_STRING, 0) diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index de3a695d96401..c1a569afec4a7 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -52,11 +52,12 @@ static int le_zip_entry; } /* }}} */ -/* {{{ PHP_ZIP_STAT_PATH(za, path, path_len, flags, sb) */ +/* {{{ PHP_ZIP_STAT_PATH(za, path, path_len, flags, sb) + This is always used for the first argument*/ #define PHP_ZIP_STAT_PATH(za, path, path_len, flags, sb) \ - if (path_len < 1) { \ - php_error_docref(NULL, E_NOTICE, "Empty string as entry name"); \ - RETURN_FALSE; \ + if (path_len == 0) { \ + zend_argument_value_error(1, "cannot be empty"); \ + RETURN_THROWS(); \ } \ if (zip_stat(za, path, flags, &sb) != 0) { \ RETURN_FALSE; \ @@ -348,24 +349,41 @@ static int php_zip_parse_options(HashTable *options, zip_options *opts) #endif if ((option = zend_hash_str_find(options, "remove_all_path", sizeof("remove_all_path") - 1)) != NULL) { + if (Z_TYPE_P(option) != IS_FALSE && Z_TYPE_P(option) != IS_TRUE) { + php_error_docref(NULL, E_WARNING, "Option \"remove_all_path\" must be of type bool, %s given", + zend_zval_type_name(option)); + } opts->remove_all_path = zval_get_long(option); } if ((option = zend_hash_str_find(options, "comp_method", sizeof("comp_method") - 1)) != NULL) { + if (Z_TYPE_P(option) != IS_LONG) { + php_error_docref(NULL, E_WARNING, "Option \"comp_method\" must be of type int, %s given", + zend_zval_type_name(option)); + } opts->comp_method = zval_get_long(option); if ((option = zend_hash_str_find(options, "comp_flags", sizeof("comp_flags") - 1)) != NULL) { + if (Z_TYPE_P(option) != IS_LONG) { + php_error_docref(NULL, E_WARNING, "Option \"comp_flags\" must be of type int, %s given", + zend_zval_type_name(option)); + } opts->comp_flags = zval_get_long(option); } } #ifdef HAVE_ENCRYPTION if ((option = zend_hash_str_find(options, "enc_method", sizeof("enc_method") - 1)) != NULL) { + if (Z_TYPE_P(option) != IS_LONG) { + php_error_docref(NULL, E_WARNING, "Option \"enc_method\" must be of type int, %s given", + zend_zval_type_name(option)); + } opts->enc_method = zval_get_long(option); if ((option = zend_hash_str_find(options, "enc_password", sizeof("enc_password") - 1)) != NULL) { if (Z_TYPE_P(option) != IS_STRING) { - php_error_docref(NULL, E_WARNING, "enc_password option expected to be a string"); + zend_type_error("Option \"enc_password\" must be of type string, %s given", + zend_zval_type_name(option)); return -1; } opts->enc_password = Z_STRVAL_P(option); @@ -375,18 +393,18 @@ static int php_zip_parse_options(HashTable *options, zip_options *opts) if ((option = zend_hash_str_find(options, "remove_path", sizeof("remove_path") - 1)) != NULL) { if (Z_TYPE_P(option) != IS_STRING) { - php_error_docref(NULL, E_WARNING, "remove_path option expected to be a string"); + zend_type_error("Option \"remove_path\" must be of type string, %s given", + zend_zval_type_name(option)); return -1; } - if (Z_STRLEN_P(option) < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string given as remove_path option"); + if (Z_STRLEN_P(option) == 0) { + zend_value_error("Option \"remove_path\" cannot be empty"); return -1; } if (Z_STRLEN_P(option) >= MAXPATHLEN) { - php_error_docref(NULL, E_WARNING, "remove_path string is too long (max: %d, %zd given)", - MAXPATHLEN - 1, Z_STRLEN_P(option)); + zend_value_error("Option \"remove_path\" must be less than %d bytes", MAXPATHLEN - 1); return -1; } opts->remove_path_len = Z_STRLEN_P(option); @@ -395,18 +413,18 @@ static int php_zip_parse_options(HashTable *options, zip_options *opts) if ((option = zend_hash_str_find(options, "add_path", sizeof("add_path") - 1)) != NULL) { if (Z_TYPE_P(option) != IS_STRING) { - php_error_docref(NULL, E_WARNING, "add_path option expected to be a string"); + zend_type_error("Option \"add_path\" must be of type string, %s given", + zend_zval_type_name(option)); return -1; } - if (Z_STRLEN_P(option) < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string given as the add_path option"); + if (Z_STRLEN_P(option) == 0) { + zend_value_error("Option \"add_path\" cannot be empty"); return -1; } if (Z_STRLEN_P(option) >= MAXPATHLEN) { - php_error_docref(NULL, E_WARNING, "add_path string too long (max: %d, %zd given)", - MAXPATHLEN - 1, Z_STRLEN_P(option)); + zend_value_error("Option \"add_path\" must be less than %d bytes", MAXPATHLEN - 1); return -1; } opts->add_path_len = Z_STRLEN_P(option); @@ -415,7 +433,8 @@ static int php_zip_parse_options(HashTable *options, zip_options *opts) if ((option = zend_hash_str_find(options, "flags", sizeof("flags") - 1)) != NULL) { if (Z_TYPE_P(option) != IS_LONG) { - php_error_docref(NULL, E_WARNING, "flags option expected to be a integer"); + zend_type_error("Option \"flags\" must be of type int, %s given", + zend_zval_type_name(option)); return -1; } opts->flags = Z_LVAL_P(option); @@ -599,6 +618,7 @@ int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_v } if ((GLOB_AVAILABLE_FLAGS & flags) != flags) { + php_error_docref(NULL, E_WARNING, "At least one of the passed flags is invalid or not supported on this platform"); return -1; } @@ -1134,8 +1154,8 @@ PHP_FUNCTION(zip_open) } if (ZSTR_LEN(filename) == 0) { - php_error_docref(NULL, E_WARNING, "Empty string as source"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } if (ZIP_OPENBASEDIR_CHECKPATH(ZSTR_VAL(filename))) { @@ -1270,7 +1290,8 @@ PHP_FUNCTION(zip_entry_close) RETURN_THROWS(); } - RETURN_BOOL(SUCCESS == zend_list_close(Z_RES_P(zip_entry))); + zend_list_close(Z_RES_P(zip_entry)); + RETURN_TRUE; } /* }}} */ @@ -1414,8 +1435,8 @@ PHP_METHOD(ZipArchive, open) ze_obj = Z_ZIP_P(self); if (ZSTR_LEN(filename) == 0) { - php_error_docref(NULL, E_WARNING, "Empty string as source"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } if (ZIP_OPENBASEDIR_CHECKPATH(ZSTR_VAL(filename))) { @@ -1677,11 +1698,11 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /* } if (ZSTR_LEN(pattern) == 0) { - php_error_docref(NULL, E_NOTICE, "Empty string as pattern"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } if (options && zend_hash_num_elements(options) > 0 && (php_zip_parse_options(options, &opts) < 0)) { - RETURN_FALSE; + RETURN_THROWS(); } if (type == 1) { @@ -1795,8 +1816,8 @@ PHP_METHOD(ZipArchive, addFile) } if (ZSTR_LEN(filename) == 0) { - php_error_docref(NULL, E_NOTICE, "Empty string as filename"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } if (entry_name_len == 0) { @@ -1828,13 +1849,13 @@ PHP_METHOD(ZipArchive, replaceFile) } if (ZSTR_LEN(filename) == 0) { - php_error_docref(NULL, E_NOTICE, "Empty string as filename"); - RETURN_FALSE; + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } if (index < 0) { - php_error_docref(NULL, E_NOTICE, "Invalid negative index"); - RETURN_FALSE; + zend_argument_value_error(2, "must be greater than or equal to 0"); + RETURN_THROWS(); } if (php_zip_add_file(Z_ZIP_P(self), ZSTR_VAL(filename), ZSTR_LEN(filename), @@ -2008,8 +2029,8 @@ PHP_METHOD(ZipArchive, setArchiveComment) ZIP_FROM_OBJECT(intern, self); if (comment_len > 0xffff) { - php_error_docref(NULL, E_WARNING, "Comment must not exceed 65535 bytes"); - RETURN_FALSE; + zend_argument_value_error(1, "must be less than 65535 bytes"); + RETURN_THROWS(); } if (zip_set_archive_comment(intern, (const char *)comment, comment_len)) { @@ -2057,15 +2078,16 @@ PHP_METHOD(ZipArchive, setCommentName) RETURN_THROWS(); } - if (name_len < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string as entry name"); + if (name_len == 0) { + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } ZIP_FROM_OBJECT(intern, self); if (comment_len > 0xffff) { - php_error_docref(NULL, E_WARNING, "Comment must not exceed 65535 bytes"); - RETURN_FALSE; + zend_argument_value_error(2, "must be less than 65535 bytes"); + RETURN_THROWS(); } idx = zip_name_locate(intern, name, 0); @@ -2094,8 +2116,8 @@ PHP_METHOD(ZipArchive, setCommentIndex) ZIP_FROM_OBJECT(intern, self); if (comment_len > 0xffff) { - php_error_docref(NULL, E_WARNING, "Comment must not exceed 65535 bytes"); - RETURN_FALSE; + zend_argument_value_error(2, "must be less than 65535 bytes"); + RETURN_THROWS(); } PHP_ZIP_STAT_INDEX(intern, index, 0, sb); @@ -2123,11 +2145,13 @@ PHP_METHOD(ZipArchive, setExternalAttributesName) ZIP_FROM_OBJECT(intern, self); - if (name_len < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string as entry name"); + if (name_len == 0) { + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } idx = zip_name_locate(intern, name, 0); + if (idx < 0) { RETURN_FALSE; } @@ -2182,11 +2206,13 @@ PHP_METHOD(ZipArchive, getExternalAttributesName) ZIP_FROM_OBJECT(intern, self); - if (name_len < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string as entry name"); + if (name_len == 0) { + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } idx = zip_name_locate(intern, name, 0); + if (idx < 0) { RETURN_FALSE; } @@ -2247,11 +2273,13 @@ PHP_METHOD(ZipArchive, setEncryptionName) ZIP_FROM_OBJECT(intern, self); - if (name_len < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string as entry name"); + if (name_len == 0) { + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } idx = zip_name_locate(intern, name, 0); + if (idx < 0) { RETURN_FALSE; } @@ -2306,12 +2334,13 @@ PHP_METHOD(ZipArchive, getCommentName) ZIP_FROM_OBJECT(intern, self); - if (name_len < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string as entry name"); - RETURN_FALSE; + if (name_len == 0) { + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } idx = zip_name_locate(intern, name, 0); + if (idx < 0) { RETURN_FALSE; } @@ -2346,7 +2375,7 @@ PHP_METHOD(ZipArchive, getCommentIndex) /* {{{ Set the compression of a file in zip, using its name */ PHP_METHOD(ZipArchive, setCompressionName) - { +{ struct zip *intern; zval *this = ZEND_THIS; size_t name_len; @@ -2361,11 +2390,13 @@ PHP_METHOD(ZipArchive, setCompressionName) ZIP_FROM_OBJECT(intern, this); - if (name_len < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string as entry name"); + if (name_len == 0) { + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } idx = zip_name_locate(intern, name, 0); + if (idx < 0) { RETURN_FALSE; } @@ -2404,7 +2435,7 @@ PHP_METHOD(ZipArchive, setCompressionIndex) #ifdef HAVE_SET_MTIME /* {{{ Set the modification time of a file in zip, using its name */ PHP_METHOD(ZipArchive, setMtimeName) - { +{ struct zip *intern; zval *this = ZEND_THIS; size_t name_len; @@ -2419,11 +2450,13 @@ PHP_METHOD(ZipArchive, setMtimeName) ZIP_FROM_OBJECT(intern, this); - if (name_len < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string as entry name"); + if (name_len == 0) { + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } idx = zip_name_locate(intern, name, 0); + if (idx < 0) { RETURN_FALSE; } @@ -2531,9 +2564,9 @@ PHP_METHOD(ZipArchive, renameIndex) ZIP_FROM_OBJECT(intern, self); - if (new_name_len < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string as new entry name"); - RETURN_FALSE; + if (new_name_len == 0) { + zend_argument_value_error(2, "cannot be empty"); + RETURN_THROWS(); } if (zip_file_rename(intern, index, (const char *)new_name, 0) != 0) { @@ -2559,9 +2592,9 @@ PHP_METHOD(ZipArchive, renameName) ZIP_FROM_OBJECT(intern, self); - if (new_name_len < 1) { - php_error_docref(NULL, E_NOTICE, "Empty string as new entry name"); - RETURN_FALSE; + if (new_name_len == 0) { + zend_argument_value_error(2, "cannot be empty"); + RETURN_THROWS(); } PHP_ZIP_STAT_PATH(intern, name, name_len, 0, sb); @@ -2886,19 +2919,12 @@ PHP_METHOD(ZipArchive, registerProgressCallback) struct zip *intern; zval *self = ZEND_THIS; double rate; - zval *callback; + zend_fcall_info fci; + zend_fcall_info_cache fcc; ze_zip_object *obj; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "dz", &rate, &callback) == FAILURE) { - return; - } - - /* callable? */ - if (!zend_is_callable(callback, 0, NULL)) { - zend_string *callback_name = zend_get_callable_name(callback); - php_error_docref(NULL, E_WARNING, "Invalid callback '%s'", ZSTR_VAL(callback_name)); - zend_string_release_ex(callback_name, 0); - RETURN_FALSE; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "df", &rate, &fci, &fcc) == FAILURE) { + RETURN_THROWS(); } ZIP_FROM_OBJECT(intern, self); @@ -2909,7 +2935,7 @@ PHP_METHOD(ZipArchive, registerProgressCallback) _php_zip_progress_callback_free(obj); /* register */ - ZVAL_COPY(&obj->progress_callback, callback); + ZVAL_COPY(&obj->progress_callback, &fci.function_name); if (zip_register_progress_callback_with_state(intern, rate, _php_zip_progress_callback, _php_zip_progress_callback_free, obj)) { RETURN_FALSE; } @@ -2939,30 +2965,22 @@ PHP_METHOD(ZipArchive, registerCancelCallback) { struct zip *intern; zval *self = ZEND_THIS; - zval *callback; + zend_fcall_info fci; + zend_fcall_info_cache fcc; ze_zip_object *obj; - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &callback) == FAILURE) { - return; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "f", &fci, &fcc) == FAILURE) { + RETURN_THROWS(); } ZIP_FROM_OBJECT(intern, self); - /* callable? */ - if (!zend_is_callable(callback, 0, NULL)) { - zend_string *callback_name = zend_get_callable_name(callback); - php_error_docref(NULL, E_WARNING, "Invalid callback '%s'", ZSTR_VAL(callback_name)); - zend_string_release_ex(callback_name, 0); - RETURN_FALSE; - } - obj = Z_ZIP_P(self); /* free if called twice */ _php_zip_cancel_callback_free(obj); /* register */ - ZVAL_COPY(&obj->cancel_callback, callback); + ZVAL_COPY(&obj->cancel_callback, &fci.function_name); if (zip_register_cancel_callback_with_state(intern, _php_zip_cancel_callback, _php_zip_cancel_callback_free, obj)) { RETURN_FALSE; } diff --git a/ext/zip/tests/oo_getcomment.phpt b/ext/zip/tests/oo_getcomment.phpt index 6f54105cc88d2..8687167a40e93 100644 --- a/ext/zip/tests/oo_getcomment.phpt +++ b/ext/zip/tests/oo_getcomment.phpt @@ -16,16 +16,20 @@ if (!$zip->open($file)) { echo $zip->getArchiveComment() . "\n"; $idx = $zip->locateName('foo'); -echo $zip->getCommentName('foo') . "\n"; -echo $zip->getCommentIndex($idx); +var_dump($zip->getCommentName('foo')); +var_dump($zip->getCommentIndex($idx)); -echo $zip->getCommentName('') . "\n"; +try { + echo $zip->getCommentName('') . "\n"; +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} $zip->close(); ?> ---EXPECTF-- +--EXPECT-- Zip archive comment -foo comment -foo comment -Notice: ZipArchive::getCommentName(): Empty string as entry name in %s on line %d +string(11) "foo comment" +string(11) "foo comment" +ZipArchive::getCommentName(): Argument #1 ($name) cannot be empty diff --git a/ext/zip/tests/oo_open.phpt b/ext/zip/tests/oo_open.phpt index 2dffdc0d889f7..a7e8d308186df 100644 --- a/ext/zip/tests/oo_open.phpt +++ b/ext/zip/tests/oo_open.phpt @@ -25,7 +25,11 @@ if (!$r) { @unlink($dirname . 'nofile'); $zip = new ZipArchive; -$zip->open(''); +try { + $zip->open(''); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} if (!$zip->open($dirname . 'test.zip')) { exit("failed 1\n"); @@ -37,9 +41,8 @@ if ($zip->status == ZIPARCHIVE::ER_OK) { echo "failed\n"; } ?> ---EXPECTF-- +--EXPECT-- ER_OPEN: ok create: ok - -Warning: ZipArchive::open(): Empty string as source in %s on line %d +ZipArchive::open(): Argument #1 ($filename) cannot be empty OK diff --git a/ext/zip/tests/oo_setcomment_error.phpt b/ext/zip/tests/oo_setcomment_error.phpt index 78d8d3dc35602..74a582a6f8efe 100644 --- a/ext/zip/tests/oo_setcomment_error.phpt +++ b/ext/zip/tests/oo_setcomment_error.phpt @@ -20,21 +20,28 @@ $zip->addFromString('entry2.txt', 'entry #2'); $longComment = str_repeat('a', 0x10000); -var_dump($zip->setArchiveComment($longComment)); -var_dump($zip->setCommentName('entry1.txt', $longComment)); -var_dump($zip->setCommentIndex(1, $longComment)); +try { + var_dump($zip->setArchiveComment($longComment)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} +try { + var_dump($zip->setCommentName('entry1.txt', $longComment)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} +try { + var_dump($zip->setCommentIndex(1, $longComment)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} $zip->close(); ?> ---EXPECTF-- -Warning: ZipArchive::setArchiveComment(): Comment must not exceed 65535 bytes in %s on line %d -bool(false) - -Warning: ZipArchive::setCommentName(): Comment must not exceed 65535 bytes in %s on line %d -bool(false) - -Warning: ZipArchive::setCommentIndex(): Comment must not exceed 65535 bytes in %s on line %d -bool(false) +--EXPECT-- +ZipArchive::setArchiveComment(): Argument #1 ($comment) must be less than 65535 bytes +ZipArchive::setCommentName(): Argument #2 ($comment) must be less than 65535 bytes +ZipArchive::setCommentIndex(): Argument #2 ($comment) must be less than 65535 bytes --CLEAN-- getMessage() . \PHP_EOL; +} echo "Test case 2:\n"; $zip = zip_open("/non_exisitng_directory/test_procedural.zip"); @@ -19,8 +23,7 @@ echo is_resource($zip) ? "OK" : "Failure"; --EXPECTF-- Test case 1: Deprecated: Function zip_open() is deprecated in %s on line %d - -Warning: zip_open(): Empty string as source in %s on line %d +zip_open(): Argument #1 ($filename) cannot be empty Test case 2: Deprecated: Function zip_open() is deprecated in %s on line %d diff --git a/main/SAPI.c b/main/SAPI.c index e30d8d780cbeb..01ec31f72218f 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -54,7 +54,7 @@ static void _type_dtor(zval *zv) static void sapi_globals_ctor(sapi_globals_struct *sapi_globals) { memset(sapi_globals, 0, sizeof(*sapi_globals)); - zend_hash_init_ex(&sapi_globals->known_post_content_types, 8, NULL, _type_dtor, 1, 0); + zend_hash_init(&sapi_globals->known_post_content_types, 8, NULL, _type_dtor, 1); php_setup_sapi_content_types(); } diff --git a/main/main.c b/main/main.c index 9ac65da922758..c9cb9b2d8563b 100644 --- a/main/main.c +++ b/main/main.c @@ -268,7 +268,8 @@ static PHP_INI_MH(OnChangeMemoryLimit) } else { PG(memory_limit) = Z_L(1)<<30; /* effectively, no limit */ } - return zend_set_memory_limit(PG(memory_limit)); + zend_set_memory_limit(PG(memory_limit)); + return SUCCESS; } /* }}} */ @@ -1520,13 +1521,13 @@ static size_t php_zend_stream_fsizer(void *handle) /* {{{ */ } /* }}} */ -static int php_stream_open_for_zend(const char *filename, zend_file_handle *handle) /* {{{ */ +static zend_result php_stream_open_for_zend(const char *filename, zend_file_handle *handle) /* {{{ */ { return php_stream_open_for_zend_ex(filename, handle, USE_PATH|REPORT_ERRORS|STREAM_OPEN_FOR_INCLUDE); } /* }}} */ -PHPAPI int php_stream_open_for_zend_ex(const char *filename, zend_file_handle *handle, int mode) /* {{{ */ +PHPAPI zend_result php_stream_open_for_zend_ex(const char *filename, zend_file_handle *handle, int mode) /* {{{ */ { zend_string *opened_path; php_stream *stream = php_stream_open_wrapper((char *)filename, "rb", mode, &opened_path); diff --git a/php.ini-development b/php.ini-development index b352f5056fbb7..54006830a2c06 100644 --- a/php.ini-development +++ b/php.ini-development @@ -1614,6 +1614,10 @@ zend.assertions = 1 ; Default: system ANSI code page ;com.code_page= +; The version of the .NET framework to use. The value of the setting are the first three parts +; of the framework's version number, separated by dots, and prefixed with "v", e.g. "v4.0.30319". +;com.dotnet_version= + [mbstring] ; language for internal character representation. ; This affects mb_send_mail() and mbstring.detect_order. diff --git a/php.ini-production b/php.ini-production index 61960ef807c5f..47a5c5e13b20b 100644 --- a/php.ini-production +++ b/php.ini-production @@ -1618,6 +1618,10 @@ zend.assertions = -1 ; Default: system ANSI code page ;com.code_page= +; The version of the .NET framework to use. The value of the setting are the first three parts +; of the framework's version number, separated by dots, and prefixed with "v", e.g. "v4.0.30319". +;com.dotnet_version= + [mbstring] ; language for internal character representation. ; This affects mb_send_mail() and mbstring.detect_order. diff --git a/run-tests.php b/run-tests.php index af9f309bc6dac..8d62c8337599c 100755 --- a/run-tests.php +++ b/run-tests.php @@ -942,7 +942,7 @@ function save_or_mail_results(): void flush(); $user_input = fgets($fp, 10); - $just_save_results = (strtolower($user_input[0]) == 's'); + $just_save_results = (!empty($user_input) && strtolower($user_input[0]) === 's'); } if ($just_save_results || !getenv('NO_INTERACTION') || TRAVIS_CI) { diff --git a/sapi/cli/tests/bug62294.phpt b/sapi/cli/tests/bug62294.phpt index b300729939f07..04d0d8b60e4d7 100644 --- a/sapi/cli/tests/bug62294.phpt +++ b/sapi/cli/tests/bug62294.phpt @@ -4,7 +4,7 @@ Bug #62294: register_shutdown_function() does not handle exit code correctly diff --git a/sapi/fpm/config.m4 b/sapi/fpm/config.m4 index 9d2b8c7349c25..7c2fdec122028 100644 --- a/sapi/fpm/config.m4 +++ b/sapi/fpm/config.m4 @@ -571,7 +571,7 @@ if test "$PHP_FPM" != "no"; then if test "x$PHP_FPM_APPARMOR" != "xno" ; then AC_CHECK_HEADERS([sys/apparmor.h]) - AC_CHECK_LIB(apparmor, change_hat, [ + AC_CHECK_LIB(apparmor, aa_change_profile, [ PHP_ADD_LIBRARY(apparmor) AC_DEFINE(HAVE_APPARMOR, 1, [ AppArmor confinement available ]) ],[ diff --git a/win32/signal.c b/win32/signal.c index 41936f840fe74..23a5acbff9ef7 100644 --- a/win32/signal.c +++ b/win32/signal.c @@ -110,7 +110,7 @@ PHP_FUNCTION(sapi_windows_set_ctrl_handler) } if (!ZEND_FCI_INITIALIZED(fci)) { - zval_dtor(&ctrl_handler); + zval_ptr_dtor(&ctrl_handler); ZVAL_UNDEF(&ctrl_handler); if (!SetConsoleCtrlHandler(NULL, add)) { RETURN_FALSE; @@ -125,7 +125,7 @@ PHP_FUNCTION(sapi_windows_set_ctrl_handler) RETURN_FALSE; } - zval_dtor(&ctrl_handler); + zval_ptr_dtor_nogc(&ctrl_handler); ZVAL_COPY(&ctrl_handler, &fci.function_name); RETURN_TRUE;