From bdd84063729dc06d32c454fdd70628e991627e9c Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 16 Jun 2020 11:27:34 +0300 Subject: [PATCH] Added JIT debug flag to dump the size of generated code (opcache.jit_debug=0x200) --- ext/opcache/jit/zend_jit.c | 4 ++++ ext/opcache/jit/zend_jit.h | 1 + 2 files changed, 5 insertions(+) diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 70102e58fe..cb6a1e7ce3 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -3833,6 +3833,10 @@ ZEND_EXT_API int zend_jit_startup(void *buf, size_t size, zend_bool reattached) ZEND_EXT_API void zend_jit_shutdown(void) { + if (JIT_G(debug) & ZEND_JIT_DEBUG_SIZE) { + fprintf(stderr, "\nJIT memory usage: %d\n", (char*)*dasm_ptr - (char*)dasm_buf); + } + #ifdef HAVE_OPROFILE if (JIT_G(debug) & ZEND_JIT_DEBUG_OPROFILE) { zend_jit_oprofile_shutdown(); diff --git a/ext/opcache/jit/zend_jit.h b/ext/opcache/jit/zend_jit.h index 810f678d6c..406e0edece 100644 --- a/ext/opcache/jit/zend_jit.h +++ b/ext/opcache/jit/zend_jit.h @@ -53,6 +53,7 @@ #define ZEND_JIT_DEBUG_VTUNE (1<<7) #define ZEND_JIT_DEBUG_GDB (1<<8) +#define ZEND_JIT_DEBUG_SIZE (1<<9) #define ZEND_JIT_DEBUG_TRACE_START (1<<12) #define ZEND_JIT_DEBUG_TRACE_STOP (1<<13) -- 2.40.0