Skip to content

Commit bfe54d9

Browse files
authored
Merge pull request ruby#64 from Shopify/ujit-leave-stats
uJIT: Add exit counters for leave and refactor stats printout code
2 parents 224a56a + d9afaa9 commit bfe54d9

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

ujit.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,16 @@ def _print_stats
5959
return unless counters
6060

6161
$stderr.puts("***uJIT: Printing runtime counters from ujit.rb***")
62-
$stderr.puts("opt_send_without_block exit reasons: ")
6362

64-
counters.filter! { |key, _| key.start_with?('oswb_') }
65-
counters.transform_keys! { |key| key.to_s.delete_prefix('oswb_') }
63+
print_counters(counters, prefix: 'oswb_', prompt: 'opt_send_without_block exit reasons: ')
64+
print_counters(counters, prefix: 'leave_', prompt: 'leave exit reasons: ')
65+
end
66+
67+
def print_counters(counters, prefix:, prompt:)
68+
$stderr.puts(prompt)
69+
counters = counters.filter { |key, _| key.start_with?(prefix) }
70+
counters.filter! { |_, value| value > 0 }
71+
counters.transform_keys! { |key| key.to_s.delete_prefix(prefix) }
6672

6773
counters = counters.to_a
6874
counters.sort_by! { |(_, counter_value)| counter_value }

ujit_codegen.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,10 +1605,10 @@ gen_leave(jitstate_t* jit, ctx_t* ctx)
16051605
// if (flags & VM_FRAME_FLAG_FINISH) != 0
16061606
x86opnd_t flags_opnd = mem_opnd(64, REG0, sizeof(VALUE) * VM_ENV_DATA_INDEX_FLAGS);
16071607
test(cb, flags_opnd, imm_opnd(VM_FRAME_FLAG_FINISH));
1608-
jnz_ptr(cb, side_exit);
1608+
jnz_ptr(cb, COUNTED_EXIT(side_exit, leave_se_finish_frame));
16091609

16101610
// Check for interrupts
1611-
ujit_check_ints(cb, side_exit);
1611+
ujit_check_ints(cb, COUNTED_EXIT(side_exit, leave_se_interrupt));
16121612

16131613
// Load the return value
16141614
mov(cb, REG0, ctx_stack_pop(ctx, 1));
@@ -1625,7 +1625,7 @@ gen_leave(jitstate_t* jit, ctx_t* ctx)
16251625
// The SP points one above the topmost value
16261626
add(cb, member_opnd(REG_CFP, rb_control_frame_t, sp), imm_opnd(SIZEOF_VALUE));
16271627
mov(cb, REG_SP, member_opnd(REG_CFP, rb_control_frame_t, sp));
1628-
mov(cb, mem_opnd(64, REG_SP, -SIZEOF_VALUE), REG0);
1628+
mov(cb, mem_opnd(64, REG_SP, -SIZEOF_VALUE), REG0);
16291629

16301630
// If the return address is NULL, fall back to the interpreter
16311631
int FALLBACK_LABEL = cb_new_label(cb, "FALLBACK");

ujit_iface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ UJIT_DECLARE_COUNTERS(
5555
oswb_se_cc_klass_differ,
5656
oswb_se_protected_check_failed,
5757

58+
leave_se_finish_frame,
59+
leave_se_interrupt,
60+
5861
// Member with known name for iterating over counters
5962
last_member
6063
)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy