|
1 | | -mod tls_allocation_profiling_stats; |
2 | | - |
3 | 1 | #[cfg(php_zend_mm_set_custom_handlers_ex)] |
4 | 2 | pub mod allocation_ge84; |
5 | 3 | #[cfg(not(php_zend_mm_set_custom_handlers_ex))] |
6 | 4 | pub mod allocation_le83; |
7 | 5 |
|
8 | | -pub use tls_allocation_profiling_stats::*; |
9 | | - |
10 | 6 | use crate::bindings::{self as zend}; |
11 | 7 | use crate::profiling::Profiler; |
12 | 8 | use crate::{RefCellExt, REQUEST_LOCALS}; |
13 | 9 | use libc::size_t; |
14 | 10 | use log::{debug, error, trace}; |
15 | 11 | use rand::rngs::ThreadRng; |
16 | 12 | use rand_distr::{Distribution, Poisson}; |
| 13 | +use std::cell::RefCell; |
17 | 14 | use std::ffi::c_void; |
18 | 15 | use std::sync::atomic::{AtomicU64, Ordering}; |
19 | 16 |
|
@@ -88,6 +85,23 @@ pub fn collect_allocation(len: size_t) { |
88 | 85 | } |
89 | 86 | } |
90 | 87 |
|
| 88 | +thread_local! { |
| 89 | + static ALLOCATION_PROFILING_STATS: RefCell<AllocationProfilingStats> = |
| 90 | + RefCell::new(AllocationProfilingStats::new()); |
| 91 | +} |
| 92 | + |
| 93 | +pub fn alloc_prof_ginit() { |
| 94 | + #[cfg(not(php_zend_mm_set_custom_handlers_ex))] |
| 95 | + allocation_le83::alloc_prof_ginit(); |
| 96 | + #[cfg(php_zend_mm_set_custom_handlers_ex)] |
| 97 | + allocation_ge84::alloc_prof_ginit(); |
| 98 | +} |
| 99 | + |
| 100 | +pub fn alloc_prof_gshutdown() { |
| 101 | + #[cfg(php_zend_mm_set_custom_handlers_ex)] |
| 102 | + allocation_ge84::alloc_prof_gshutdown(); |
| 103 | +} |
| 104 | + |
91 | 105 | #[cfg(not(php_zend_mm_set_custom_handlers_ex))] |
92 | 106 | pub fn alloc_prof_startup() { |
93 | 107 | allocation_le83::alloc_prof_startup(); |
|
0 commit comments