vm_method.c: add new ruby::method-cache-clear dtrace probe

* vm_method.c (rb_clear_method_cache_by_class): fire
  ruby::method-cache-clear probe on global or klass-level method cache
  clear [Bug #9190]
* probes.d (provider ruby): new dtrace probe
* doc/dtrace_probes.rdoc: docs for new probe
* test/dtrace/test_method_cache.rb: test for new probe

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tmm1 2013-12-09 22:50:44 +00:00
Родитель 4f7c10f06f
Коммит 4092574257
5 изменённых файлов: 61 добавлений и 1 удалений

Просмотреть файл

@ -1,3 +1,12 @@
Tue Dec 10 07:48:29 2013 Aman Gupta <ruby@tmm1.net>
* vm_method.c (rb_clear_method_cache_by_class): fire
ruby::method-cache-clear probe on global or klass-level method cache
clear [Bug #9190]
* probes.d (provider ruby): new dtrace probe
* doc/dtrace_probes.rdoc: docs for new probe
* test/dtrace/test_method_cache.rb: test for new probe
Tue Dec 10 06:14:11 2013 Eric Hodel <drbrain@segment7.net>
* ext/.document: Remove curses from documentable directories.

Просмотреть файл

@ -169,4 +169,10 @@ with when they are fired and the arguments they take:
[ruby:::gc-sweep-end();]
Fired at the end of a sweep phase.
[ruby:::method-cache-clear(class, sourcefile, lineno);]
Fired when the method cache is cleared.
class is the classname being cleared, or "global" (string)
sourcefile the file being parsed (string)
lineno the line number where the source ended (int)

Просмотреть файл

@ -214,6 +214,17 @@ provider ruby {
Fired at the end of a sweep phase.
*/
probe gc__sweep__end();
/*
ruby:::method-cache-clear(class, filename, lineno);
This probe is fired when the method cache is cleared.
* `class` the name of the class or "global" (a string)
* `filename` the file name where the cache is _being cleared_ (a string)
* `lineno` the line number where the cache is _being cleared_ (an int)
*/
probe method__cache__clear(const char *class, const char *filename, int lineno);
};
#pragma D attributes Stable/Evolving/Common provider ruby provider

Просмотреть файл

@ -0,0 +1,28 @@
require_relative 'helper'
module DTrace
class TestMethodCacheClear < TestCase
def test_method_cache_clear
trap_probe(probe, <<-code) do |_,rbfile,lines|
class String; end
class String; def abc() end end
class Object; def abc() end end
code
assert_not_includes lines, "String #{rbfile} 1\n"
assert_includes lines, "String #{rbfile} 2\n"
assert_includes lines, "global #{rbfile} 3\n"
end
end
private
def probe
<<-eoprobe
ruby$target:::method-cache-clear
/arg1/
{
printf("%s %s %d\\n", copyinstr(arg0), copyinstr(arg1), arg2);
}
eoprobe
end
end
end if defined?(DTrace::TestCase)

Просмотреть файл

@ -61,7 +61,13 @@ void
rb_clear_method_cache_by_class(VALUE klass)
{
if (klass && klass != Qundef) {
if (klass == rb_cBasicObject || klass == rb_cObject || klass == rb_mKernel) {
int global = klass == rb_cBasicObject || klass == rb_cObject || klass == rb_mKernel;
if (RUBY_DTRACE_METHOD_CACHE_CLEAR_ENABLED()) {
RUBY_DTRACE_METHOD_CACHE_CLEAR(global ? "global" : rb_class2name(klass), rb_sourcefile(), rb_sourceline());
}
if (global) {
INC_GLOBAL_METHOD_STATE();
}
else {