Project

General

Profile

Actions

Feature #9190

closed

Expose serial helper macros

Added by simeonwillbanks (Simeon Willbanks) almost 11 years ago. Updated almost 11 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:58750]

Description

I've defined RubyVM::InstructionHelper with singleton methods #method_serial and #constant_serial. They delegate to helper macros GET_METHOD_SERIAL() and GET_CONSTANT_SERIAL().

With these methods, users have visibility into the method and constant caches. If it makes sense, I hope this patch is included in Ruby 2.1.0.

def constants_busted?(&blk)
starting = RubyVM::InstructionHelper.constant_serial
yield
ending = RubyVM::InstructionHelper.constant_serial
ending > starting
end

busted = constants_busted? do
class Foo; end
end
puts busted.inspect

true

https://github.com/ruby/ruby/pull/462.patch

Thanks for considering; any input is appreciated!

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0