Bug 1804637 - Fix a problem with the test mark queue r=sfink

This doesn't fix the failing test case, although it does survive two more GC
slices with this patch.

This saves and restores state related to the test mark queue while doing
non-incremental marking for later marking validation. Without this we do the
test queue marking as part of non-incremental marking and then don't do it for
the actual marking, leading to a discrepancy.

Differential Revision: https://phabricator.services.mozilla.com/D164246
This commit is contained in:
Jon Coppeard 2022-12-13 17:30:09 +00:00
parent ef91f9e9cd
commit f172c55b56
2 changed files with 17 additions and 2 deletions

View File

@ -2959,7 +2959,10 @@ bool GCRuntime::appendTestMarkQueue(const JS::Value& value) {
return testMarkQueue.append(value);
}
void GCRuntime::clearTestMarkQueue() { testMarkQueue.clear(); }
void GCRuntime::clearTestMarkQueue() {
testMarkQueue.clear();
queuePos = 0;
}
size_t GCRuntime::testMarkQueuePos() const { return queuePos; }

View File

@ -4,6 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/Maybe.h"
#include "mozilla/Sprintf.h"
#include <algorithm>
@ -558,6 +559,12 @@ void js::gc::MarkingValidator::nonIncrementalMark(AutoGCSession& session) {
}
}
/* Save and restore test mark queue state. */
#ifdef DEBUG
size_t savedQueuePos = gc->queuePos;
mozilla::Maybe<MarkColor> savedQueueColor = gc->queueMarkColor;
#endif
/*
* After this point, the function should run to completion, so we shouldn't
* do anything fallible.
@ -654,6 +661,11 @@ void js::gc::MarkingValidator::nonIncrementalMark(AutoGCSession& session) {
}
}
#ifdef DEBUG
gc->queuePos = savedQueuePos;
gc->queueMarkColor = savedQueueColor;
#endif
gc->incrementalState = state;
}
@ -709,7 +721,7 @@ void js::gc::MarkingValidator::validate() {
ok = false;
const char* color = TenuredCell::getColor(bitmap, cell).name();
fprintf(stderr,
"%p: cell not marked, but would be marked by %s "
"%p: cell not marked, but would be marked %s by "
"non-incremental marking\n",
cell, color);
# ifdef DEBUG