aboutsummaryrefslogtreecommitdiffstats
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-08-18 12:44:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-08-18 12:44:30 +0000
commitb82a4f6e047ab08a5cfeea1c8417041ec409cdd0 (patch)
tree8561c686428b0d3e7817ce7e127c28f33231488c /vm_insnhelper.c
parent5f1ecd3688e8f4c082efc2d5863fb358268f8a80 (diff)
downloadruby-b82a4f6e047ab08a5cfeea1c8417041ec409cdd0.tar.gz
vm_insnhelper.c: vm_cfp_consistent_p
* vm_insnhelper.c (vm_cfp_consistent_p): extracted the conditions for cfp consistency. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 03b9d49e0e..69925c07ea 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1833,10 +1833,20 @@ vm_profile_show_result(void)
#define VM_PROFILE_ATEXIT()
#endif
+static inline int
+vm_cfp_consistent_p(rb_thread_t *th, const rb_control_frame_t *reg_cfp)
+{
+ const int ov_flags = RAISED_STACKOVERFLOW;
+ if (LIKELY(reg_cfp == th->ec.cfp + 1)) return TRUE;
+ if (rb_thread_raised_p(th, ov_flags)) {
+ rb_thread_raised_reset(th, ov_flags);
+ return TRUE;
+ }
+ return FALSE;
+}
+
#define CHECK_CFP_CONSISTENCY(func) \
- (LIKELY(reg_cfp == th->ec.cfp + 1) ? (void) 0 : \
- rb_thread_raised_p(th, RAISED_STACKOVERFLOW) ? \
- rb_thread_raised_reset(th, RAISED_STACKOVERFLOW) : \
+ (LIKELY(vm_cfp_consistent_p(th, reg_cfp)) ? (void)0 : \
rb_bug(func ": cfp consistency error (%p, %p)", reg_cfp, th->ec.cfp+1))
static inline