aboutsummaryrefslogtreecommitdiffstats
path: root/vm.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-29 05:32:57 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-29 05:32:57 +0000
commit10b36bd40a31ec071cfafe2a345a532d34244a89 (patch)
tree47ed734b95ca72ec176b056b766a0561ef441723 /vm.c
parent6c33be81e6c8a8c0c8723915b924d64a12626874 (diff)
downloadruby-10b36bd40a31ec071cfafe2a345a532d34244a89.tar.gz
RUBY_DTRACE_CREATE_HOOK
* internal.h (RUBY_DTRACE_CREATE_HOOK): macro to call hook at object creation. * vm.c (rb_source_location, rb_source_loc): retrieve source path and line number at once. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/vm.c b/vm.c
index 3b684f1b10..279c1ea8e6 100644
--- a/vm.c
+++ b/vm.c
@@ -1111,6 +1111,29 @@ rb_sourceline(void)
}
}
+VALUE
+rb_source_location(int *pline)
+{
+ rb_thread_t *th = GET_THREAD();
+ rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp);
+
+ if (cfp) {
+ if (pline) *pline = rb_vm_get_sourceline(cfp);
+ return cfp->iseq->body->location.path;
+ }
+ else {
+ return 0;
+ }
+}
+
+const char *
+rb_source_loc(int *pline)
+{
+ VALUE path = rb_source_location(pline);
+ if (!path) return 0;
+ return RSTRING_PTR(path);
+}
+
rb_cref_t *
rb_vm_cref(void)
{
@@ -2428,10 +2451,7 @@ core_hash_from_ary(VALUE ary)
{
VALUE hash = rb_hash_new();
- if (RUBY_DTRACE_HASH_CREATE_ENABLED()) {
- RUBY_DTRACE_HASH_CREATE(RARRAY_LEN(ary), rb_sourcefile(), rb_sourceline());
- }
-
+ RUBY_DTRACE_CREATE_HOOK(HASH, RARRAY_LEN(ary));
return core_hash_merge_ary(hash, ary);
}