diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-29 22:28:16 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-29 22:28:16 +0000 |
commit | 4db83403982100df21c3c6c18b1cef29dd379e6a (patch) | |
tree | fe3430360cc21c68ee978fb61d6255e789c2bce2 /compile.c | |
parent | 2dc5e62545eb18feb85b1fa321f19904704cc76f (diff) |
[EXPERIMENTAL: NEED DISCUSS]
* vm_trace.c: add events
* :thread_begin - hook at thread beggining.
* :thead_end - hook at thread ending.
* :b_call - hook at block enter.
* :b_return - hook at block leave.
This change slow down block invocation.
Please try and give us feedback until 2.0 code freeze.
* include/ruby/ruby.h: ditto.
* compile.c (rb_iseq_compile_node): ditto.
* insns.def: ditto.
* thread.c: ditto.
* vm.c: ditto.
* include/ruby/debug.h: add a comment.
* test/ruby/test_settracefunc.rb: add a tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 55 |
1 files changed, 30 insertions, 25 deletions
@@ -475,31 +475,36 @@ rb_iseq_compile_node(VALUE self, NODE *node) iseq_set_arguments(iseq, ret, node->nd_args); switch (iseq->type) { - case ISEQ_TYPE_BLOCK: { - LABEL *start = iseq->compile_data->start_label = NEW_LABEL(0); - LABEL *end = iseq->compile_data->end_label = NEW_LABEL(0); - - ADD_LABEL(ret, start); - COMPILE(ret, "block body", node->nd_body); - ADD_LABEL(ret, end); - - /* wide range catch handler must put at last */ - ADD_CATCH_ENTRY(CATCH_TYPE_REDO, start, end, 0, start); - ADD_CATCH_ENTRY(CATCH_TYPE_NEXT, start, end, 0, end); - break; - } - case ISEQ_TYPE_CLASS: { - ADD_TRACE(ret, FIX2INT(iseq->location.first_lineno), RUBY_EVENT_CLASS); - COMPILE(ret, "scoped node", node->nd_body); - ADD_TRACE(ret, nd_line(node), RUBY_EVENT_END); - break; - } - case ISEQ_TYPE_METHOD: { - ADD_TRACE(ret, FIX2INT(iseq->location.first_lineno), RUBY_EVENT_CALL); - COMPILE(ret, "scoped node", node->nd_body); - ADD_TRACE(ret, nd_line(node), RUBY_EVENT_RETURN); - break; - } + case ISEQ_TYPE_BLOCK: + { + LABEL *start = iseq->compile_data->start_label = NEW_LABEL(0); + LABEL *end = iseq->compile_data->end_label = NEW_LABEL(0); + + ADD_LABEL(ret, start); + ADD_TRACE(ret, FIX2INT(iseq->location.first_lineno), RUBY_EVENT_B_CALL); + COMPILE(ret, "block body", node->nd_body); + ADD_TRACE(ret, nd_line(node), RUBY_EVENT_B_RETURN); + ADD_LABEL(ret, end); + + /* wide range catch handler must put at last */ + ADD_CATCH_ENTRY(CATCH_TYPE_REDO, start, end, 0, start); + ADD_CATCH_ENTRY(CATCH_TYPE_NEXT, start, end, 0, end); + break; + } + case ISEQ_TYPE_CLASS: + { + ADD_TRACE(ret, FIX2INT(iseq->location.first_lineno), RUBY_EVENT_CLASS); + COMPILE(ret, "scoped node", node->nd_body); + ADD_TRACE(ret, nd_line(node), RUBY_EVENT_END); + break; + } + case ISEQ_TYPE_METHOD: + { + ADD_TRACE(ret, FIX2INT(iseq->location.first_lineno), RUBY_EVENT_CALL); + COMPILE(ret, "scoped node", node->nd_body); + ADD_TRACE(ret, nd_line(node), RUBY_EVENT_RETURN); + break; + } default: { COMPILE(ret, "scoped node", node->nd_body); break; |