mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 10:15:41 +00:00
Bug 1211939 - Don't call JSRuntime::onOutOfMemory from helper threads. r=jonco
This commit is contained in:
parent
e9fd48c65a
commit
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;
|
||||
|
Loading…
Reference in New Issue
Block a user