Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions profiling/src/allocation/allocation_ge84.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::allocation::{
allocation_profiling_stats_should_collect, collect_allocation, untrack_allocation,
allocation_profiling_stats_should_collect, collect_allocation, current_execute_data,
untrack_allocation,
};
use crate::bindings as zend;
use crate::PROFILER_NAME;
Expand Down Expand Up @@ -306,7 +307,7 @@ unsafe fn alloc_prof_malloc_impl(len: size_t) -> *mut c_void {

// during startup, minit, rinit, ... current_execute_data is null
// we are only interested in allocations during userland operations
if zend::ddog_php_prof_get_current_execute_data().is_null() {
if current_execute_data().is_null() {
return ptr;
}

Expand Down Expand Up @@ -505,7 +506,7 @@ unsafe fn alloc_prof_realloc_no_untrack_impl(prev_ptr: *mut c_void, len: size_t)
unsafe fn alloc_prof_realloc_sample(ptr: *mut c_void, len: size_t) -> *mut c_void {
// during startup, minit, rinit, ... current_execute_data is null
// we are only interested in allocations during userland operations
if zend::ddog_php_prof_get_current_execute_data().is_null() {
if current_execute_data().is_null() {
return ptr;
}

Expand Down
7 changes: 4 additions & 3 deletions profiling/src/allocation/allocation_le83.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::allocation::{
allocation_profiling_stats_should_collect, collect_allocation, untrack_allocation,
allocation_profiling_stats_should_collect, collect_allocation, current_execute_data,
untrack_allocation,
};
use crate::bindings::{
self as zend, datadog_php_install_handler, datadog_php_zif_handler,
Expand Down Expand Up @@ -300,7 +301,7 @@ unsafe extern "C" fn alloc_prof_malloc(len: size_t) -> *mut c_void {

// during startup, minit, rinit, ... current_execute_data is null
// we are only interested in allocations during userland operations
if zend::ddog_php_prof_get_current_execute_data().is_null() {
if current_execute_data().is_null() {
return ptr;
}

Expand Down Expand Up @@ -431,7 +432,7 @@ unsafe fn alloc_prof_realloc_no_untrack_impl(prev_ptr: *mut c_void, len: size_t)
unsafe fn alloc_prof_realloc_sample(ptr: *mut c_void, len: size_t) -> *mut c_void {
// during startup, minit, rinit, ... current_execute_data is null
// we are only interested in allocations during userland operations
if zend::ddog_php_prof_get_current_execute_data().is_null() {
if current_execute_data().is_null() {
return ptr;
}

Expand Down
9 changes: 9 additions & 0 deletions profiling/src/allocation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ pub(crate) unsafe fn get_zend_mm_state() -> *mut Cell<ZendMMState> {
ptr::addr_of_mut!((*globals).zend_mm_state)
}

#[inline(always)]
pub(crate) unsafe fn current_execute_data() -> *mut zend::zend_execute_data {
#[cfg(not(php_zts))]
return ptr::addr_of!(zend::executor_globals.current_execute_data).read();

#[cfg(php_zts)]
zend::ddog_php_prof_get_current_execute_data()
}

/// Macros for accessing ZendMMState from PHP globals.
/// These are shared between PHP 8.3- and 8.4+ implementations.
/// They are exported at the crate root and can be used in submodules.
Expand Down
Loading