diff options
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -66,6 +66,8 @@ MJIT_FUNC_EXPORTED #endif VALUE vm_exec(rb_execution_context_t *, bool); +extern const char *const rb_debug_counter_names[]; + PUREFUNC(static inline const VALUE *VM_EP_LEP(const VALUE *)); static inline const VALUE * VM_EP_LEP(const VALUE *ep) @@ -578,6 +580,8 @@ rb_dtrace_setup(rb_execution_context_t *ec, VALUE klass, ID id, * :global_cvar_state=>27 * } * + * If <tt>USE_DEBUG_COUNTER</tt> is enabled, debug counters will be included. + * * The contents of the hash are implementation specific and may be changed in * the future. * @@ -622,6 +626,21 @@ vm_stat(int argc, VALUE *argv, VALUE self) SET(next_shape_id, (rb_serial_t)GET_VM()->next_shape_id); #undef SET +#if USE_DEBUG_COUNTER + ruby_debug_counter_show_at_exit(FALSE); + for (size_t i = 0; i < RB_DEBUG_COUNTER_MAX; i++) { + const VALUE name = rb_sym_intern_ascii_cstr(rb_debug_counter_names[i]); + const VALUE boxed_value = SIZET2NUM(rb_debug_counter[i]); + + if (key == name) { + return boxed_value; + } + else if (hash != Qnil) { + rb_hash_aset(hash, name, boxed_value); + } + } +#endif + if (!NIL_P(key)) { /* matched key should return above */ rb_raise(rb_eArgError, "unknown key: %"PRIsVALUE, rb_sym2str(key)); } |