зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1211939 - Don't call JSRuntime::onOutOfMemory from helper threads. r=jonco
This commit is contained in:
Родитель
e9fd48c65a
Коммит
d3a0b9cc9d
|
@ -142,6 +142,8 @@ struct Zone : public JS::shadow::Zone,
|
|||
void onTooMuchMalloc();
|
||||
|
||||
void* onOutOfMemory(js::AllocFunction allocFunc, size_t nbytes, void* reallocPtr = nullptr) {
|
||||
if (!CurrentThreadCanAccessRuntime(runtime_))
|
||||
return nullptr;
|
||||
return runtimeFromMainThread()->onOutOfMemory(allocFunc, nbytes, reallocPtr);
|
||||
}
|
||||
void reportAllocationOverflow() { js::ReportAllocationOverflow(nullptr); }
|
||||
|
|
|
@ -163,7 +163,9 @@ class ExclusiveContext : public ContextFriendFields,
|
|||
}
|
||||
|
||||
void* onOutOfMemory(js::AllocFunction allocFunc, size_t nbytes, void* reallocPtr = nullptr) {
|
||||
return runtime_->onOutOfMemory(allocFunc, nbytes, reallocPtr, maybeJSContext());
|
||||
if (!isJSContext())
|
||||
return nullptr;
|
||||
return runtime_->onOutOfMemory(allocFunc, nbytes, reallocPtr, asJSContext());
|
||||
}
|
||||
|
||||
/* Clear the pending exception (if any) due to OOM. */
|
||||
|
|
|
@ -760,6 +760,7 @@ JSRuntime::onOutOfMemory(AllocFunction allocFunc, size_t nbytes, void* reallocPt
|
|||
JSContext* maybecx)
|
||||
{
|
||||
MOZ_ASSERT_IF(allocFunc != AllocFunction::Realloc, !reallocPtr);
|
||||
MOZ_ASSERT(CurrentThreadCanAccessRuntime(this));
|
||||
|
||||
if (isHeapBusy())
|
||||
return nullptr;
|
||||
|
|
Загрузка…
Ссылка в новой задаче