|
26 | 26 | #include <sys/stat.h>
|
27 | 27 | #include <fcntl.h>
|
28 | 28 |
|
| 29 | +#if !defined(__APPLE__) |
29 | 30 | #if defined(__linux__)
|
30 | 31 | #include <sys/syscall.h>
|
31 | 32 | #elif defined(__darwin__)
|
@@ -274,3 +275,45 @@ static void zend_jit_perf_map_register(const char *name, void *start, size_t siz
|
274 | 275 | }
|
275 | 276 | fprintf(fp, "%zx %zx %s\n", (size_t)(uintptr_t)start, size, name);
|
276 | 277 | }
|
| 278 | +#else |
| 279 | +#include <os/log.h> |
| 280 | +#include <os/signpost.h> |
| 281 | + |
| 282 | +static os_log_t jitdump_fd; |
| 283 | +static os_signpost_id_t jitdump_sp = OS_SIGNPOST_ID_NULL; |
| 284 | + |
| 285 | +static void zend_jit_perf_jitdump_open(void) |
| 286 | +{ |
| 287 | + /** |
| 288 | + * The `os_log_t` list per namespace is maintained by the os |
| 289 | + * and are not deallocated by (and not deallocatable) |
| 290 | + * but are reusable. |
| 291 | + */ |
| 292 | + jitdump_fd = os_log_create("net.php.opcache.jit", OS_LOG_CATEGORY_POINTS_OF_INTEREST); |
| 293 | + jitdump_sp = os_signpost_id_generate(jitdump_fd); |
| 294 | + |
| 295 | + if (jitdump_sp != OS_SIGNPOST_ID_NULL && jitdump_sp != OS_SIGNPOST_ID_INVALID) { |
| 296 | + os_signpost_interval_begin(jitdump_fd, jitdump_sp, "zend_jitdump"); |
| 297 | + } |
| 298 | +} |
| 299 | + |
| 300 | +static void zend_jit_perf_jitdump_close(void) |
| 301 | +{ |
| 302 | + if (jitdump_sp != OS_SIGNPOST_ID_NULL && jitdump_sp != OS_SIGNPOST_ID_INVALID) { |
| 303 | + os_signpost_interval_end(jitdump_fd, jitdump_sp, "zend_jitdump"); |
| 304 | + } |
| 305 | +} |
| 306 | + |
| 307 | +static void zend_jit_perf_jitdump_register(const char *name, void *start, size_t size) |
| 308 | +{ |
| 309 | +} |
| 310 | + |
| 311 | +static void zend_jit_perf_map_register(const char *name, void *start, size_t size) |
| 312 | +{ |
| 313 | + os_signpost_id_t map = os_signpost_id_make_with_pointer(jitdump_fd, start); |
| 314 | + if (map != OS_SIGNPOST_ID_NULL && map != OS_SIGNPOST_ID_INVALID) { |
| 315 | + os_signpost_event_emit(jitdump_fd, map, "zend_jitdump_name", "%s", name); |
| 316 | + os_signpost_event_emit(jitdump_fd, map, "zend_jitdump_size", "%lu", size); |
| 317 | + } |
| 318 | +} |
| 319 | +#endif |
0 commit comments