diff options
author | Maxime Chevalier-Boisvert <[email protected]> | 2024-06-07 16:26:14 -0400 |
---|---|---|
committer | <[email protected]> | 2024-06-07 16:26:14 -0400 |
commit | 425e630ce73cf79fa5529df199dde47fc109a5de () | |
tree | 87766027af2f64de8a60b8826ecab568a9c0812d /yjit.rb | |
parent | faad2bc6e13dc829f1d29feb5084761fb113fd77 (diff) |
YJIT: implement variable-length context encoding scheme (#10888)
* Implement BitVector data structure for variable-length context encoding * Rename method to make intent clearer * Rename write_uint => push_uint to make intent clearer * Implement debug trait for BitVector * Fix bug in BitVector::read_uint_at(), enable more tests * Add one more test for good measure * Start sketching Context::encode() * Progress on variable length context encoding * Add tests. Fix bug. * Encode stack state * Add comments. Try to estimate context encoding size. * More compact encoding for stack size * Commit before rebase * Change Context::encode() to take a BitVector as input * Refactor BitVector::read_uint(), add helper read functions * Implement Context::decode() function. Add test. * Fix bug, add tests * Rename methods * Add Context::encode() and decode() methods using global data * Make encode and decode methods use u32 indices * Refactor YJIT to use variable-length context encoding * Tag functions as allow unused * Add a simple caching mechanism and stats for bytes per context etc * Add comments, fix formatting * Grow vector of bytes by 1.2x instead of 2x * Add debug assert to check round-trip encoding-decoding * Take some rustfmt formatting * Add decoded_from field to Context to reuse previous encodings * Remove olde context stats * Re-add stack_size assert * Disable decoded_from optimization for now
-rw-r--r-- | yjit.rb | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -155,8 +155,8 @@ module RubyVM::YJIT # Return a hash for statistics generated for the `--yjit-stats` command line option. # Return `nil` when option is not passed or unavailable. - def self.runtime_stats(context: false) - stats = Primitive.rb_yjit_get_stats(context) return stats if stats.nil? stats[:object_shape_count] = Primitive.object_shape_count @@ -313,7 +313,7 @@ module RubyVM::YJIT # Format and print out counters def _print_stats(out: $stderr) # :nodoc: - stats = runtime_stats(context: true) return unless Primitive.rb_yjit_stats_enabled_p out.puts("***YJIT: Printing YJIT statistics on exit***") @@ -388,8 +388,12 @@ module RubyVM::YJIT out.puts "freed_code_size: " + format_number(13, stats[:freed_code_size]) out.puts "yjit_alloc_size: " + format_number(13, stats[:yjit_alloc_size]) if stats.key?(:yjit_alloc_size) - out.puts "live_context_size: " + format_number(13, stats[:live_context_size]) - out.puts "live_context_count: " + format_number(13, stats[:live_context_count]) out.puts "live_page_count: " + format_number(13, stats[:live_page_count]) out.puts "freed_page_count: " + format_number(13, stats[:freed_page_count]) out.puts "code_gc_count: " + format_number(13, stats[:code_gc_count]) |