summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-01 02:13:06 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-01 02:13:06 +0000
commitafb02bbe92e55f877d50ed8705c95a41d541458d (patch)
tree8012de32b7703a09be9d25ecfa1915990f1679a4 /variable.c
parentd3c6187a4d968549b689757bb360e482bd881e07 (diff)
* variable.c (rb_class_path_no_cache): add a function to get the class
path without caching the computed path. Some classes are frozen, and will raise an exception without this. * probes.d (cmethod-entry, cmethod-return): separate cmethods from regular methods to match set trace func. * probes_helper.h: refactor macros. Fix probes to avoid calling #inspect when profiling. * insns.def: update for use with new macros. * vm_eval.c: ditto * vm_insnhelper.c: ditto * test/dtrace/test_singleton_function.rb: fix test for new output. * test/dtrace/test_cmethod.rb: test the cmethod probes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/variable.c b/variable.c
index 601efb955d..ebe532f28a 100644
--- a/variable.c
+++ b/variable.c
@@ -211,8 +211,10 @@ rb_mod_name(VALUE mod)
return path;
}
+typedef VALUE (*path_cache_func)(VALUE obj, ID id, VALUE val);
+
static VALUE
-rb_tmp_class_path(VALUE klass, int *permanent)
+rb_tmp_class_path(VALUE klass, int *permanent, path_cache_func cache_path)
{
VALUE path = classname(klass, permanent);
st_data_t n = (st_data_t)path;
@@ -233,12 +235,17 @@ rb_tmp_class_path(VALUE klass, int *permanent)
s = "Module";
}
else {
- s = rb_class2name(RBASIC(klass)->klass);
+ int perm;
+ VALUE path;
+
+ path = rb_tmp_class_path(RBASIC(klass)->klass, &perm, cache_path);
+ s = RSTRING_PTR(path);
}
}
path = rb_sprintf("#<%s:%p>", s, (void*)klass);
OBJ_FREEZE(path);
- rb_ivar_set(klass, tmp_classpath, path);
+
+ cache_path(klass, tmp_classpath, path);
*permanent = 0;
return path;
@@ -249,7 +256,22 @@ VALUE
rb_class_path(VALUE klass)
{
int permanent;
- VALUE path = rb_tmp_class_path(klass, &permanent);
+ VALUE path = rb_tmp_class_path(klass, &permanent, rb_ivar_set);
+ if (!NIL_P(path)) path = rb_str_dup(path);
+ return path;
+}
+
+static VALUE
+null_cache(VALUE obj, ID id, VALUE val)
+{
+ return Qnil;
+}
+
+VALUE
+rb_class_path_no_cache(VALUE klass)
+{
+ int permanent;
+ VALUE path = rb_tmp_class_path(klass, &permanent, null_cache);
if (!NIL_P(path)) path = rb_str_dup(path);
return path;
}
@@ -265,7 +287,7 @@ rb_set_class_path_string(VALUE klass, VALUE under, VALUE name)
}
else {
int permanent;
- str = rb_str_dup(rb_tmp_class_path(under, &permanent));
+ str = rb_str_dup(rb_tmp_class_path(under, &permanent, rb_ivar_set));
rb_str_cat2(str, "::");
rb_str_append(str, name);
OBJ_FREEZE(str);
@@ -288,7 +310,7 @@ rb_set_class_path(VALUE klass, VALUE under, const char *name)
}
else {
int permanent;
- str = rb_str_dup(rb_tmp_class_path(under, &permanent));
+ str = rb_str_dup(rb_tmp_class_path(under, &permanent, rb_ivar_set));
rb_str_cat2(str, "::");
rb_str_cat2(str, name);
if (!permanent) {