summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-29 05:32:57 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-29 05:32:57 (GMT)
commit645116ff25e42b1cfb065ad98e13818c8c5c2a8d (patch)
tree47ed734b95ca72ec176b056b766a0561ef441723 /vm.c
parent1be5cb6371048a35d9fb2859ca8a865e982608cf (diff)
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 3b684f1..279c1ea 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);
}