Skip to content

Commit 837699e

Browse files
committed
Take file and line in GC VM locks
This commit adds file and line to GC VM locking functions for debugging purposes and adds upper case macros to pass __FILE__ and __LINE__.
1 parent c962735 commit 837699e

File tree

4 files changed

+75
-68
lines changed

4 files changed

+75
-68
lines changed

gc.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -131,45 +131,45 @@
131131
#include "shape.h"
132132

133133
unsigned int
134-
rb_gc_vm_lock(void)
134+
rb_gc_vm_lock(const char *file, int line)
135135
{
136136
unsigned int lev = 0;
137-
RB_VM_LOCK_ENTER_LEV(&lev);
137+
rb_vm_lock_enter(&lev, file, line);
138138
return lev;
139139
}
140140

141141
void
142-
rb_gc_vm_unlock(unsigned int lev)
142+
rb_gc_vm_unlock(unsigned int lev, const char *file, int line)
143143
{
144-
RB_VM_LOCK_LEAVE_LEV(&lev);
144+
rb_vm_lock_leave(&lev, file, line);
145145
}
146146

147147
unsigned int
148-
rb_gc_cr_lock(void)
148+
rb_gc_cr_lock(const char *file, int line)
149149
{
150150
unsigned int lev;
151-
RB_VM_LOCK_ENTER_CR_LEV(GET_RACTOR(), &lev);
151+
rb_vm_lock_enter_cr(GET_RACTOR(), &lev, file, line);
152152
return lev;
153153
}
154154

155155
void
156-
rb_gc_cr_unlock(unsigned int lev)
156+
rb_gc_cr_unlock(unsigned int lev, const char *file, int line)
157157
{
158-
RB_VM_LOCK_LEAVE_CR_LEV(GET_RACTOR(), &lev);
158+
rb_vm_lock_leave_cr(GET_RACTOR(), &lev, file, line);
159159
}
160160

161161
unsigned int
162-
rb_gc_vm_lock_no_barrier(void)
162+
rb_gc_vm_lock_no_barrier(const char *file, int line)
163163
{
164164
unsigned int lev = 0;
165-
RB_VM_LOCK_ENTER_LEV_NB(&lev);
165+
rb_vm_lock_enter_nb(&lev, file, line);
166166
return lev;
167167
}
168168

169169
void
170-
rb_gc_vm_unlock_no_barrier(unsigned int lev)
170+
rb_gc_vm_unlock_no_barrier(unsigned int lev, const char *file, int line)
171171
{
172-
RB_VM_LOCK_LEAVE_LEV_NB(&lev);
172+
rb_vm_lock_leave_nb(&lev, file, line);
173173
}
174174

175175
void
@@ -1783,9 +1783,9 @@ generate_next_object_id(void)
17831783
// 64bit atomics are available
17841784
return SIZET2NUM(RUBY_ATOMIC_SIZE_FETCH_ADD(object_id_counter, 1) * OBJ_ID_INCREMENT);
17851785
#else
1786-
unsigned int lock_lev = rb_gc_vm_lock();
1786+
unsigned int lock_lev = RB_GC_VM_LOCK();
17871787
VALUE id = ULL2NUM(++object_id_counter * OBJ_ID_INCREMENT);
1788-
rb_gc_vm_unlock(lock_lev);
1788+
RB_GC_VM_UNLOCK(lock_lev);
17891789
return id;
17901790
#endif
17911791
}
@@ -1867,7 +1867,7 @@ class_object_id(VALUE klass)
18671867
{
18681868
VALUE id = RUBY_ATOMIC_VALUE_LOAD(RCLASS(klass)->object_id);
18691869
if (!id) {
1870-
unsigned int lock_lev = rb_gc_vm_lock();
1870+
unsigned int lock_lev = RB_GC_VM_LOCK();
18711871
id = generate_next_object_id();
18721872
VALUE existing_id = RUBY_ATOMIC_VALUE_CAS(RCLASS(klass)->object_id, 0, id);
18731873
if (existing_id) {
@@ -1876,7 +1876,7 @@ class_object_id(VALUE klass)
18761876
else if (RB_UNLIKELY(id2ref_tbl)) {
18771877
st_insert(id2ref_tbl, id, klass);
18781878
}
1879-
rb_gc_vm_unlock(lock_lev);
1879+
RB_GC_VM_UNLOCK(lock_lev);
18801880
}
18811881
return id;
18821882
}
@@ -1946,9 +1946,9 @@ object_id(VALUE obj)
19461946
}
19471947

19481948
if (UNLIKELY(rb_gc_multi_ractor_p() && rb_ractor_shareable_p(obj))) {
1949-
unsigned int lock_lev = rb_gc_vm_lock();
1949+
unsigned int lock_lev = RB_GC_VM_LOCK();
19501950
VALUE id = object_id0(obj);
1951-
rb_gc_vm_unlock(lock_lev);
1951+
RB_GC_VM_UNLOCK(lock_lev);
19521952
return id;
19531953
}
19541954

@@ -1983,7 +1983,7 @@ object_id_to_ref(void *objspace_ptr, VALUE object_id)
19831983
{
19841984
rb_objspace_t *objspace = objspace_ptr;
19851985

1986-
unsigned int lev = rb_gc_vm_lock();
1986+
unsigned int lev = RB_GC_VM_LOCK();
19871987

19881988
if (!id2ref_tbl) {
19891989
rb_gc_vm_barrier(); // stop other ractors
@@ -2007,7 +2007,7 @@ object_id_to_ref(void *objspace_ptr, VALUE object_id)
20072007
VALUE obj;
20082008
bool found = st_lookup(id2ref_tbl, object_id, &obj) && !rb_gc_impl_garbage_object_p(objspace, obj);
20092009

2010-
rb_gc_vm_unlock(lev);
2010+
RB_GC_VM_UNLOCK(lev);
20112011

20122012
if (found) {
20132013
return obj;

0 commit comments

Comments
 (0)