[Git][ghc/ghc][wip/T25039] rts/CheckUnload: Don't prepare to unload if we can't unload
Ben Gamari (@bgamari)
gitlab at gitlab.haskell.org
Wed Dec 11 14:47:40 UTC 2024
Ben Gamari pushed to branch wip/T25039 at Glasgow Haskell Compiler / GHC
Commits:
140272d0 by Ben Gamari at 2024-12-11T09:47:31-05:00
rts/CheckUnload: Don't prepare to unload if we can't unload
Previously `prepareUnloadCheck` would move the `objects` list to
`old_objects` even when profiling (where we cannot unload). This caused
us to vacate the `objects` list during major GCs, losing track of loaded
objects. Fix this by ensuring that `prepareUnloadCheck` and
`checkUnload` both use the same short-cutting logic.
- - - - -
1 changed file:
- rts/CheckUnload.c
Changes:
=====================================
rts/CheckUnload.c
=====================================
@@ -166,7 +166,7 @@ ObjectCode *loaded_objects;
static OCSectionIndices *global_s_indices = NULL;
// Is it safe for us to unload code?
-static bool safeToUnload(void)
+static bool tryToUnload(void)
{
if (RtsFlags.ProfFlags.doHeapProfile != NO_HEAP_PROFILING) {
// We mustn't unload anything as the heap census may contain
@@ -174,7 +174,8 @@ static bool safeToUnload(void)
// See #24512.
return false;
}
- return true;
+
+ return global_s_indices != NULL;
}
static OCSectionIndices *createOCSectionIndices(void)
@@ -432,7 +433,7 @@ static bool markObjectLive(void *data STG_UNUSED, StgWord key, const void *value
void markObjectCode(const void *addr)
{
- if (global_s_indices == NULL) {
+ if (!tryToUnload()) {
return;
}
@@ -450,7 +451,7 @@ void markObjectCode(const void *addr)
// unloading.
bool prepareUnloadCheck(void)
{
- if (global_s_indices == NULL) {
+ if (!tryToUnload()) {
return false;
}
@@ -472,7 +473,7 @@ void checkUnload(void)
// code (loaded_objects). Mark the roots first, then unload any unmarked
// objects.
- if (global_s_indices != NULL && safeToUnload()) {
+ if (tryToUnload()) {
OCSectionIndices *s_indices = global_s_indices;
ASSERT(s_indices->sorted);
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/140272d0278c4aea72b673623bafaabb6546247a
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/140272d0278c4aea72b673623bafaabb6546247a
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20241211/171d9ca6/attachment-0001.html>
More information about the ghc-commits
mailing list