aboutsummaryrefslogtreecommitdiffstats
path: root/vm_core.h
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-10-14 02:03:21 +0900
committerKoichi Sasada <ko1@atdot.net>2020-10-14 14:02:06 +0900
commitc3ba3fa8d01aa3970dc1f4e3dc0090ae171e9e35 (patch)
tree7aaff45d1eb07dc41297d1661f528a5449609469 /vm_core.h
parentd7de342e414b29bea7eff444ae33e44445afb9a5 (diff)
downloadruby-c3ba3fa8d01aa3970dc1f4e3dc0090ae171e9e35.tar.gz
support exception when lock_rec > 0
If a ractor getting a VM lock (monitor) raises an exception, unlock can be skipped. To release VM lock correctly on exception (or other jumps with JUMP_TAG), EC_POP_TAG() releases VM lock.
Diffstat (limited to 'vm_core.h')
-rw-r--r--vm_core.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/vm_core.h b/vm_core.h
index 44f85ff3a0..f783bd5b99 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -794,6 +794,7 @@ struct rb_vm_tag {
rb_jmpbuf_t buf;
struct rb_vm_tag *prev;
enum ruby_tag_type state;
+ int lock_rec;
};
STATIC_ASSERT(rb_vm_tag_buf_offset, offsetof(struct rb_vm_tag, buf) > 0);
@@ -1797,6 +1798,19 @@ rb_current_vm(void)
return ruby_current_vm_ptr;
}
+static inline int
+rb_ec_vm_lock_rec(rb_execution_context_t *ec)
+{
+ rb_vm_t *vm = rb_ec_vm_ptr(ec);
+
+ if (vm->ractor.sync.lock_owner != rb_ec_ractor_ptr(ec)) {
+ return 0;
+ }
+ else {
+ return vm->ractor.sync.lock_rec;
+ }
+}
+
#else
#error "unsupported thread model"
#endif