summaryrefslogtreecommitdiff
path: root/typd_mlc.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-06-14 09:56:38 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-06-14 11:02:43 +0300
commitb75f1aa68cbcf6a46dc38203b267faab44a24061 (patch)
treefbb789f4007940becbd7c4c17913e53c2dcc103a /typd_mlc.c
parent8fcba09859cd9da25d3eb446080c1682edcd6bbc (diff)
downloadbdwgc-b75f1aa68cbcf6a46dc38203b267faab44a24061.tar.gz
Reduce lock scope in GC_calloc_explicitly_typed
(fix of commit 8fcba0985) Issue #449 (bdwgc). * typd_mlc.c (GC_calloc_explicitly_typed): If descr_type is LEAF then acquire the allocation lock just before writing to *lp; update comment.
Diffstat (limited to 'typd_mlc.c')
-rw-r--r--typd_mlc.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/typd_mlc.c b/typd_mlc.c
index 645ec756..c43145b6 100644
--- a/typd_mlc.c
+++ b/typd_mlc.c
@@ -537,19 +537,19 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_calloc_explicitly_typed(size_t n,
(struct LeafDescriptor *)((word *)op + nwords -
(BYTES_TO_WORDS(sizeof(struct LeafDescriptor)) + 1));
- /* Hold the allocation lock while writing a complex descriptor */
- /* to the object to ensure that the descriptor is seen by */
- /* GC_array_mark_proc as expected. */
- /* TODO: It should be possible to replace locking with the atomic */
- /* operations (with the release barrier here) but, in this case, */
- /* avoiding the acquire barrier in GC_array_mark_proc and its */
- /* callee seems to be tricky as GC_mark_some might be invoked */
- /* with the world running. */
- LOCK();
lp -> ld_tag = LEAF_TAG;
lp -> ld_size = leaf.ld_size;
lp -> ld_nelements = leaf.ld_nelements;
lp -> ld_descriptor = leaf.ld_descriptor;
+ /* Hold the allocation lock while writing the descriptor word */
+ /* to the object to ensure that the descriptor contents are seen */
+ /* by GC_array_mark_proc as expected. */
+ /* TODO: It should be possible to replace locking with the atomic */
+ /* operations (with the release barrier here) but, in this case, */
+ /* avoiding the acquire barrier in GC_array_mark_proc seems to */
+ /* be tricky as GC_mark_some might be invoked with the world */
+ /* running. */
+ LOCK();
((word *)op)[nwords - 1] = (word)lp;
UNLOCK();
} else {