summaryrefslogtreecommitdiff
path: root/eval_intern.h
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-10-14 14:21:57 +0900
committerKoichi Sasada <ko1@atdot.net>2020-10-14 16:36:55 +0900
commitae693fff748c68ca2500bbc2c0a8802d50f269dc (patch)
treee96405ea3df4d2c03dce9cbe52503118005fc346 /eval_intern.h
parent0714cb760c2b16f7d40e563b6ab9894553baf32c (diff)
fix releasing timing.
(1) recorded_lock_rec > current_lock_rec should not be occurred on rb_ec_vm_lock_rec_release(). (2) should be release VM lock at EXEC_TAG(), not POP_TAG(). (3) some refactoring.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3655
Diffstat (limited to 'eval_intern.h')
-rw-r--r--eval_intern.h26
1 files changed, 13 insertions, 13 deletions
diff --git a/eval_intern.h b/eval_intern.h
index 0e5a8ae692..48e9c890c7 100644
--- a/eval_intern.h
+++ b/eval_intern.h
@@ -127,16 +127,6 @@ LONG WINAPI rb_w32_stack_overflow_handler(struct _EXCEPTION_POINTERS *);
rb_fiber_start(); \
} while (0)
-void rb_ec_vm_lock_rec_release(rb_execution_context_t *ec, int lock_rec);
-
-static inline void
-rb_ec_vm_lock_rec_check(rb_execution_context_t *ec, int lock_rec)
-{
- if (rb_ec_vm_lock_rec(ec) != lock_rec) {
- rb_ec_vm_lock_rec_release(ec, lock_rec);
- }
-}
-
#define EC_PUSH_TAG(ec) do { \
rb_execution_context_t * const _ec = (ec); \
struct rb_vm_tag _tag; \
@@ -146,7 +136,6 @@ rb_ec_vm_lock_rec_check(rb_execution_context_t *ec, int lock_rec)
_tag.lock_rec = rb_ec_vm_lock_rec(_ec); \
#define EC_POP_TAG() \
- rb_ec_vm_lock_rec_check(_ec, _tag.lock_rec); \
_ec->tag = _tag.prev; \
} while (0)
@@ -169,12 +158,23 @@ rb_ec_vm_lock_rec_check(rb_execution_context_t *ec, int lock_rec)
# define VAR_NOCLOBBERED(var) var
#endif
+static inline void
+rb_ec_vm_lock_rec_check(const rb_execution_context_t *ec, unsigned int recorded_lock_rec)
+{
+ unsigned int current_lock_rec = rb_ec_vm_lock_rec(ec);
+ if (current_lock_rec != recorded_lock_rec) {
+ rb_ec_vm_lock_rec_release(ec, recorded_lock_rec, current_lock_rec);
+ }
+}
+
/* clear ec->tag->state, and return the value */
static inline int
rb_ec_tag_state(const rb_execution_context_t *ec)
{
- enum ruby_tag_type state = ec->tag->state;
- ec->tag->state = TAG_NONE;
+ struct rb_vm_tag *tag = ec->tag;
+ enum ruby_tag_type state = tag->state;
+ tag->state = TAG_NONE;
+ rb_ec_vm_lock_rec_check(ec, tag->lock_rec);
return state;
}