Skip to content

Commit

Permalink
Compatible with PHP8.2RC1
Browse files Browse the repository at this point in the history
phacility#68 Compatible with PHP8.2RC1
  • Loading branch information
longxinH committed Sep 4, 2022
1 parent 38e6f97 commit f8ec210
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
8 changes: 8 additions & 0 deletions extension/php_xhprof.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ ZEND_DLEXPORT zend_op_array* hp_compile_string(zval *source_string, char *filena
/* Pointer to the original execute function */
static void (*_zend_execute_ex) (zend_execute_data *execute_data);
ZEND_DLEXPORT void hp_execute_ex (zend_execute_data *execute_data);
#elif PHP_VERSION_ID >= 80200
/* Pointer to the original compile string function (used by eval) */
static zend_op_array * (*_zend_compile_string) (zend_string *source_string, const char *filename, zend_compile_position position);
ZEND_DLEXPORT zend_op_array* hp_compile_string(zend_string *source_string, const char *filename, zend_compile_position position);

static zend_observer_fcall_handlers tracer_observer(zend_execute_data *execute_data);
static void tracer_observer_begin(zend_execute_data *ex);
static void tracer_observer_end(zend_execute_data *ex, zval *return_value);
#else
/* Pointer to the original compile string function (used by eval) */
static zend_op_array * (*_zend_compile_string) (zend_string *source_string, const char *filename);
Expand Down
29 changes: 27 additions & 2 deletions extension/xhprof.c
Original file line number Diff line number Diff line change
Expand Up @@ -995,11 +995,23 @@ void hp_mode_sampled_endfn_cb(hp_entry_t **entries)

#if PHP_VERSION_ID >= 80000
static void tracer_observer_begin(zend_execute_data *execute_data) {
#if PHP_VERSION_ID >= 80200
if (execute_data->func->type == ZEND_INTERNAL_FUNCTION) {
return;
}
#endif

begin_profiling(NULL, execute_data);
}

static void tracer_observer_end(zend_execute_data *ex, zval *return_value) {
static void tracer_observer_end(zend_execute_data *execute_data, zval *return_value) {
if (XHPROF_G(entries)) {
#if PHP_VERSION_ID >= 80200
if (execute_data->func->type == ZEND_INTERNAL_FUNCTION) {
return;
}
#endif

end_profiling();
}
}
Expand Down Expand Up @@ -1069,7 +1081,6 @@ ZEND_DLEXPORT void hp_execute_internal(zend_execute_data *execute_data, zval *re
if (is_profiling == 1 && XHPROF_G(entries)) {
end_profiling();
}

}

/**
Expand Down Expand Up @@ -1114,14 +1125,20 @@ ZEND_DLEXPORT zend_op_array* hp_compile_file(zend_file_handle *file_handle, int
*/
#if PHP_VERSION_ID < 80000
ZEND_DLEXPORT zend_op_array* hp_compile_string(zval *source_string, char *filename)
#elif PHP_VERSION_ID >= 80200
ZEND_DLEXPORT zend_op_array* hp_compile_string(zend_string *source_string, const char *filename, zend_compile_position position)
#else
ZEND_DLEXPORT zend_op_array* hp_compile_string(zend_string *source_string, const char *filename)
#endif
{
int is_profiling = 1;

if (!XHPROF_G(enabled)) {
#if PHP_VERSION_ID >= 80200
return _zend_compile_string(source_string, filename, position);
#else
return _zend_compile_string(source_string, filename);
#endif
}

zend_string *function_name;
Expand All @@ -1130,7 +1147,11 @@ ZEND_DLEXPORT zend_op_array* hp_compile_string(zend_string *source_string, const
function_name = strpprintf(0, "eval::%s", filename);

is_profiling = begin_profiling(function_name, NULL);
#if PHP_VERSION_ID >= 80200
op_array = _zend_compile_string(source_string, filename, position);
#else
op_array = _zend_compile_string(source_string, filename);
#endif

if (is_profiling == 1 && XHPROF_G(entries)) {
end_profiling();
Expand Down Expand Up @@ -1222,6 +1243,10 @@ static void hp_stop()

/* Stop profiling */
XHPROF_G(enabled) = 0;

if (XHPROF_G(root)) {
zend_string_release(XHPROF_G(root));
}
}


Expand Down

0 comments on commit f8ec210

Please sign in to comment.