From e2fc01efa54a8df00c19de0b7f9dfc2f26e62e86 Mon Sep 17 00:00:00 2001 From: ko1 Date: Thu, 6 Apr 2017 02:56:23 +0000 Subject: fix TracePoint#return_value with non-local exits * vm.c: get return_value from imemo_throw_data object (THROW_DATA_VAL()). imemo_throw_data (TAG_BREAK) contains returned value. However, imemo_throw_data (TAG_BREAK) can skip several frames so that we need to use it only once (at most internal frame). To record it, we introduced THROW_DATA_CONSUMED and check it. * internal.h: define THROW_DATA_CONSUMED flag. * test/ruby/test_settracefunc.rb: add tests for [Bug #13369] * vm_insnhelper.h: add THROW_DATA_CONSUMED_P() and THROW_DATA_CONSUMED_SET(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_insnhelper.h | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'vm_insnhelper.h') diff --git a/vm_insnhelper.h b/vm_insnhelper.h index 33e3f434cd..9790230e9e 100644 --- a/vm_insnhelper.h +++ b/vm_insnhelper.h @@ -196,18 +196,6 @@ THROW_DATA_NEW(VALUE val, const rb_control_frame_t *cf, VALUE st) return (struct vm_throw_data *)rb_imemo_new(imemo_throw_data, val, (VALUE)cf, st, 0); } -static inline void -THROW_DATA_CATCH_FRAME_SET(struct vm_throw_data *obj, const rb_control_frame_t *cfp) -{ - obj->catch_frame = cfp; -} - -static inline void -THROW_DATA_STATE_SET(struct vm_throw_data *obj, int st) -{ - obj->throw_state = (VALUE)st; -} - static inline VALUE THROW_DATA_VAL(const struct vm_throw_data *obj) { @@ -220,10 +208,38 @@ THROW_DATA_CATCH_FRAME(const struct vm_throw_data *obj) return obj->catch_frame; } -static int +static inline int THROW_DATA_STATE(const struct vm_throw_data *obj) { return (int)obj->throw_state; } +static inline int +THROW_DATA_CONSUMED_P(const struct vm_throw_data *obj) +{ + VM_ASSERT(THROW_DATA_P(obj)); + return obj->flags & THROW_DATA_CONSUMED; +} + +static inline void +THROW_DATA_CATCH_FRAME_SET(struct vm_throw_data *obj, const rb_control_frame_t *cfp) +{ + obj->catch_frame = cfp; +} + +static inline void +THROW_DATA_STATE_SET(struct vm_throw_data *obj, int st) +{ + obj->throw_state = (VALUE)st; +} + +static inline void +THROW_DATA_CONSUMED_SET(struct vm_throw_data *obj) +{ + if (THROW_DATA_P(obj) && + THROW_DATA_STATE(obj) == TAG_BREAK) { + obj->flags |= THROW_DATA_CONSUMED; + } +} + #endif /* RUBY_INSNHELPER_H */ -- cgit v1.2.1