Skip to content

Commit ef88e64

Browse files
committed
% Code refactoring according to the PR.
1 parent fdd756a commit ef88e64

File tree

9 files changed

+13
-83
lines changed

9 files changed

+13
-83
lines changed

Zend/zend.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@
4141
#include "Optimizer/zend_optimizer.h"
4242
#include "php.h"
4343
#include "php_globals.h"
44-
#ifdef PHP_ASYNC_API
4544
#include "zend_async_API.h"
46-
#endif
4745

4846
// FIXME: Breaks the declaration of the function below
4947
#undef zenderror
@@ -1335,11 +1333,7 @@ ZEND_API void zend_activate(void) /* {{{ */
13351333
void zend_call_destructors(void) /* {{{ */
13361334
{
13371335
zend_try {
1338-
#ifdef PHP_ASYNC_API
1339-
shutdown_destructors_async();
1340-
#else
13411336
shutdown_destructors();
1342-
#endif
13431337
} zend_end_try();
13441338
}
13451339
/* }}} */
@@ -1356,11 +1350,9 @@ ZEND_API void zend_deactivate(void) /* {{{ */
13561350
/* shutdown_executor() takes care of its own bailout handling */
13571351
shutdown_executor();
13581352

1359-
#ifdef PHP_ASYNC_API
13601353
// The execution of the True Async API should end here,
13611354
// after the GC has been run.
13621355
ZEND_ASYNC_ENGINE_SHUTDOWN();
1363-
#endif
13641356

13651357
zend_try {
13661358
zend_ini_deactivate();
@@ -1959,18 +1951,13 @@ ZEND_API zend_result zend_execute_script(int type, zval *retval, zend_file_handl
19591951
if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
19601952
zend_user_exception_handler();
19611953
}
1962-
#ifdef PHP_ASYNC_API
1954+
19631955
// If we are inside a coroutine,
19641956
// we do not call the final error handler,
19651957
// as the exception will be handled higher up in the method ZEND_ASYNC_RUN_SCHEDULER_AFTER_MAIN
19661958
if (false == ZEND_ASYNC_CURRENT_COROUTINE && EG(exception)) {
19671959
ret = zend_exception_error(EG(exception), E_ERROR);
19681960
}
1969-
#else
1970-
if (EG(exception)) {
1971-
ret = zend_exception_error(EG(exception), E_ERROR);
1972-
}
1973-
#endif
19741961
}
19751962
zend_destroy_static_vars(op_array);
19761963
destroy_op_array(op_array);

Zend/zend_exceptions.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
#include "zend_dtrace.h"
2929
#include "zend_smart_str.h"
3030
#include "zend_exceptions_arginfo.h"
31-
#ifdef PHP_ASYNC_API
3231
#include "zend_cancellation_exception_arginfo.h"
33-
#endif
3432
#include "zend_observer.h"
3533

3634
#define ZEND_EXCEPTION_MESSAGE_OFF 0
@@ -45,9 +43,7 @@ ZEND_API zend_class_entry *zend_ce_throwable;
4543
ZEND_API zend_class_entry *zend_ce_exception;
4644
ZEND_API zend_class_entry *zend_ce_error_exception;
4745
ZEND_API zend_class_entry *zend_ce_error;
48-
#ifdef PHP_ASYNC_API
4946
ZEND_API zend_class_entry *zend_ce_cancellation_exception;
50-
#endif
5147
ZEND_API zend_class_entry *zend_ce_compile_error;
5248
ZEND_API zend_class_entry *zend_ce_parse_error;
5349
ZEND_API zend_class_entry *zend_ce_type_error;
@@ -101,9 +97,6 @@ static int zend_implement_throwable(zend_class_entry *interface, zend_class_entr
10197

10298
static inline zend_class_entry *i_get_exception_base(zend_object *object) /* {{{ */
10399
{
104-
#ifndef PHP_ASYNC_API
105-
return instanceof_function(object->ce, zend_ce_exception) ? zend_ce_exception : zend_ce_error;
106-
#else
107100
zend_class_entry *instance_ce = object->ce;
108101

109102
do
@@ -121,7 +114,6 @@ static inline zend_class_entry *i_get_exception_base(zend_object *object) /* {{{
121114
} while (instance_ce != NULL);
122115

123116
return NULL;
124-
#endif
125117
}
126118
/* }}} */
127119

Zend/zend_execute.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ ZEND_API extern zend_class_entry *(*zend_autoload)(zend_string *name, zend_strin
4040
void init_executor(void);
4141
void shutdown_executor(void);
4242
void shutdown_destructors(void);
43-
#ifdef PHP_ASYNC_API
44-
void shutdown_destructors_async(void);
45-
#endif
4643
ZEND_API void zend_shutdown_executor_values(bool fast_shutdown);
4744

4845
ZEND_API void zend_init_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value);

Zend/zend_execute_API.c

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
#include <sys/syscall.h>
5050
#endif
5151

52+
#include "zend_async_API.h"
53+
5254
ZEND_API void (*zend_execute_ex)(zend_execute_data *execute_data);
5355
ZEND_API void (*zend_execute_internal)(zend_execute_data *execute_data, zval *return_value);
5456
ZEND_API zend_class_entry *(*zend_autoload)(zend_string *name, zend_string *lc_name);
@@ -199,14 +201,12 @@ void init_executor(void) /* {{{ */
199201
EG(filename_override) = NULL;
200202
EG(lineno_override) = -1;
201203

202-
#ifdef PHP_ASYNC_API
203204
EG(shutdown_context) = (zend_shutdown_context_t) {
204205
.is_started = false,
205206
.coroutine = NULL,
206207
.num_elements = 0,
207208
.idx = 0
208209
};
209-
#endif
210210

211211
zend_max_execution_timer_init();
212212
zend_fiber_init();
@@ -257,29 +257,7 @@ static ZEND_COLD void zend_throw_or_error(int fetch_type, zend_class_entry *exce
257257
}
258258
/* }}} */
259259

260-
void shutdown_destructors(void) /* {{{ */
261-
{
262-
if (CG(unclean_shutdown)) {
263-
EG(symbol_table).pDestructor = zend_unclean_zval_ptr_dtor;
264-
}
265-
zend_try {
266-
uint32_t symbols;
267-
do {
268-
symbols = zend_hash_num_elements(&EG(symbol_table));
269-
zend_hash_reverse_apply(&EG(symbol_table), (apply_func_t) zval_call_destructor);
270-
} while (symbols != zend_hash_num_elements(&EG(symbol_table)));
271-
zend_objects_store_call_destructors(&EG(objects_store));
272-
} zend_catch {
273-
/* if we couldn't destruct cleanly, mark all objects as destructed anyway */
274-
zend_objects_store_mark_destructed(&EG(objects_store));
275-
} zend_end_try();
276-
}
277-
/* }}} */
278-
279-
#ifdef PHP_ASYNC_API
280-
#include "zend_async_API.h"
281-
282-
static void shutdown_destructors_coroutine_dtor(zend_coroutine_t *coroutine)
260+
static void shutdown_destructors_coroutine_dtor(zend_coroutine_t *coroutine) /* {{{ */
283261
{
284262
zend_shutdown_context_t *shutdown_context = &EG(shutdown_context);
285263

@@ -318,7 +296,7 @@ static bool shutdown_destructors_context_switch_handler(
318296
return false;
319297
}
320298

321-
void shutdown_destructors_async(void) /* {{{ */
299+
void shutdown_destructors(void) /* {{{ */
322300
{
323301
zend_coroutine_t *coroutine = ZEND_ASYNC_CURRENT_COROUTINE;
324302
bool should_continue = false;
@@ -400,7 +378,6 @@ void shutdown_destructors_async(void) /* {{{ */
400378
shutdown_context->is_started = false;
401379
}
402380
/* }}} */
403-
#endif
404381

405382
/* Free values held by the executor. */
406383
ZEND_API void zend_shutdown_executor_values(bool fast_shutdown)

Zend/zend_gc.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@
6868
*/
6969
#include "zend.h"
7070
#include "zend_API.h"
71-
#ifdef PHP_ASYNC_API
7271
#include "zend_async_API.h"
73-
#endif
7472
#include "zend_compile.h"
7573
#include "zend_errors.h"
7674
#include "zend_fibers.h"

configure.ac

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,16 +1046,6 @@ PHP_ARG_ENABLE([undefined-sanitizer],,
10461046
[Enable undefined sanitizer])],
10471047
[no],
10481048
[no])
1049-
PHP_ARG_ENABLE([async-api],,
1050-
[AS_HELP_STRING([--disable-async-api],
1051-
[Disable async API support])],
1052-
[yes],
1053-
[no])
1054-
1055-
AS_VAR_IF([PHP_ASYNC_API], [yes], [
1056-
AC_DEFINE([PHP_ASYNC_API], [1], [Define to 1 if async API support is enabled.])
1057-
])
1058-
10591049

10601050
dnl Extension configuration.
10611051
dnl ----------------------------------------------------------------------------
@@ -1796,10 +1786,8 @@ PHP_ADD_SOURCES([Zend], m4_normalize([
17961786
]),
17971787
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 $fiber_asm_cflag])
17981788

1799-
if test "$PHP_ASYNC_API" = "yes"; then
18001789
PHP_ADD_SOURCES([Zend], m4_normalize([zend_async_API.c]),
18011790
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 $fiber_asm_cflag])
1802-
fi
18031791

18041792
PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/scripts/Makefile.frag],
18051793
[$abs_srcdir/scripts],

main/main.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,10 +2614,9 @@ PHPAPI bool php_execute_script_ex(zend_file_handle *primary_file, zval *retval)
26142614
if (append_file_p && result) {
26152615
result = zend_execute_script(ZEND_REQUIRE, NULL, append_file_p) == SUCCESS;
26162616
}
2617-
#ifdef PHP_ASYNC_API
2618-
ZEND_ASYNC_RUN_SCHEDULER_AFTER_MAIN();
2619-
ZEND_ASYNC_INITIALIZE;
2620-
#endif
2617+
2618+
ZEND_ASYNC_RUN_SCHEDULER_AFTER_MAIN();
2619+
ZEND_ASYNC_INITIALIZE;
26212620
} zend_catch {
26222621
result = false;
26232622
} zend_end_try();
@@ -2789,10 +2788,8 @@ PHPAPI void php_reserve_tsrm_memory(void)
27892788
TSRM_ALIGNED_SIZE(zend_mm_globals_size()) +
27902789
TSRM_ALIGNED_SIZE(zend_gc_globals_size()) +
27912790
TSRM_ALIGNED_SIZE(sizeof(php_core_globals)) +
2792-
TSRM_ALIGNED_SIZE(sizeof(sapi_globals_struct))
2793-
#ifdef PHP_ASYNC_API
2794-
+ TSRM_ALIGNED_SIZE(sizeof(zend_async_globals_t))
2795-
#endif
2791+
TSRM_ALIGNED_SIZE(sizeof(sapi_globals_struct)) +
2792+
TSRM_ALIGNED_SIZE(sizeof(zend_async_globals_t))
27962793
);
27972794
}
27982795
/* }}} */

win32/build/config.w32

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,4 @@ ARG_ENABLE('vs-link-compat', 'Allow linking of libraries built with compatible v
410410

411411
ARG_ENABLE("async-api", "Disable async API support", "yes");
412412

413-
if (PHP_ASYNC_API == "yes") {
414-
AC_DEFINE('PHP_ASYNC_API', 1);
415-
ADD_SOURCES("Zend", "zend_async_API.c");
416-
}
413+
ADD_SOURCES("Zend", "zend_async_API.c");

win32/build/confutils.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,11 +1997,8 @@ function write_summary()
19971997
} else {
19981998
ar[k++] = ['Static analyzer', 'disabled'];
19991999
}
2000-
if (typeof PHP_ASYNC_API !== "undefined" && PHP_ASYNC_API == "yes") {
2001-
ar[k++] = ['True Async API', 'Yes'];
2002-
} else {
2003-
ar[k++] = ['True Async API', 'No'];
2004-
}
2000+
2001+
ar[k++] = ['True Async API', 'Yes'];
20052002

20062003
output_as_table(["",""], ar);
20072004
STDOUT.WriteBlankLines(2);

0 commit comments

Comments
 (0)