Bug 1570883 - GlobalHelperThreadState should clear the LifoAlloc on JSContexts that haven't been used since the last free event. r=jandem

In the event of a JSContext having gone unused between the last triggerFreeUnusedMemory() and the current one, GlobalHelperThreadState should free the temp LifoAlloc from the main thread. This isn't safe for ContextData and requires tempLifoAlloc to take a different type.

Differential Revision: https://phabricator.services.mozilla.com/D40732

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kristen Wright 2019-08-07 16:09:44 +00:00
Родитель 75d85e4a0c
Коммит 28cbbdfccb
3 изменённых файлов: 9 добавлений и 3 удалений

Просмотреть файл

@ -1372,9 +1372,15 @@ void GlobalHelperThreadState::triggerFreeUnusedMemory() {
AutoLockHelperThreadState lock;
for (auto& context : helperContexts_) {
context->setFreeUnusedMemory(true);
if (context->shouldFreeUnusedMemory() && context->contextAvailable(lock)) {
// This context hasn't been used since the last time freeUnusedMemory
// was set. Free the temp LifoAlloc from the main thread.
context->tempLifoAllocNoCheck().freeAll();
context->setFreeUnusedMemory(false);
} else {
context->setFreeUnusedMemory(true);
}
}
notifyAll(PRODUCER, lock);
}
static inline bool IsHelperThreadSimulatingOOM(js::ThreadType threadType) {

Просмотреть файл

@ -1520,4 +1520,3 @@ AutoUnsafeCallWithABI::~AutoUnsafeCallWithABI() {
MOZ_ASSERT_IF(checkForPendingException_, !JS_IsExceptionPending(cx_));
}
#endif

Просмотреть файл

@ -661,6 +661,7 @@ struct JSContext : public JS::RootingContext,
public:
js::LifoAlloc& tempLifoAlloc() { return tempLifoAlloc_.ref(); }
const js::LifoAlloc& tempLifoAlloc() const { return tempLifoAlloc_.ref(); }
js::LifoAlloc& tempLifoAllocNoCheck() { return tempLifoAlloc_.refNoCheck(); }
js::ContextData<uint32_t> debuggerMutations;