mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1209911 - Remove option to simulate OOM on all threads r=terrence
This commit is contained in:
parent
f33228a71e
commit
1b755fe6ac
@ -73,7 +73,7 @@ namespace oom {
|
||||
* without causing an OOM in the main thread first.
|
||||
*/
|
||||
enum ThreadType {
|
||||
THREAD_TYPE_NONE, // 0
|
||||
THREAD_TYPE_NONE = 0, // 0
|
||||
THREAD_TYPE_MAIN, // 1
|
||||
THREAD_TYPE_ASMJS, // 2
|
||||
THREAD_TYPE_ION, // 3
|
||||
@ -127,7 +127,7 @@ extern JS_PUBLIC_DATA(uint32_t) targetThread;
|
||||
static inline bool
|
||||
IsThreadSimulatingOOM()
|
||||
{
|
||||
return !js::oom::targetThread || js::oom::targetThread == js::oom::GetThreadType();
|
||||
return js::oom::targetThread && js::oom::targetThread == js::oom::GetThreadType();
|
||||
}
|
||||
|
||||
static inline bool
|
||||
@ -203,11 +203,8 @@ struct MOZ_RAII AutoEnterOOMUnsafeRegion
|
||||
}
|
||||
|
||||
~AutoEnterOOMUnsafeRegion() {
|
||||
// TODO: This class is not thread safe. If another thread has modified
|
||||
// OOM_maxAllocations, don't try to restore it.
|
||||
if (OOM_maxAllocations != UINT32_MAX)
|
||||
return;
|
||||
if (oomEnabled_) {
|
||||
MOZ_ASSERT(OOM_maxAllocations == UINT32_MAX);
|
||||
int64_t maxAllocations = OOM_counter + oomAfter_;
|
||||
MOZ_ASSERT(maxAllocations >= 0 && maxAllocations < UINT32_MAX);
|
||||
OOM_maxAllocations = uint32_t(maxAllocations);
|
||||
|
@ -993,25 +993,16 @@ OOMThreadTypes(JSContext* cx, unsigned argc, Value* vp)
|
||||
}
|
||||
|
||||
static bool
|
||||
OOMAfterAllocations(JSContext* cx, unsigned argc, Value* vp)
|
||||
SetupOOMFailure(JSContext* cx, bool failAlways, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
if (args.length() < 1) {
|
||||
JS_ReportError(cx, "count argument required");
|
||||
JS_ReportError(cx, "Count argument required");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length() > 2) {
|
||||
JS_ReportError(cx, "too many arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t targetThread = 0;
|
||||
if (!ToUint32(cx, args.get(1), &targetThread))
|
||||
return false;
|
||||
|
||||
if (targetThread >= js::oom::THREAD_TYPE_MAX) {
|
||||
JS_ReportError(cx, "invalid thread type specified");
|
||||
JS_ReportError(cx, "Too many arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1019,45 +1010,32 @@ OOMAfterAllocations(JSContext* cx, unsigned argc, Value* vp)
|
||||
if (!JS::ToUint32(cx, args.get(0), &count))
|
||||
return false;
|
||||
|
||||
uint32_t targetThread = js::oom::THREAD_TYPE_MAIN;
|
||||
if (args.length() > 1 && !ToUint32(cx, args[1], &targetThread))
|
||||
return false;
|
||||
|
||||
if (targetThread == js::oom::THREAD_TYPE_NONE || targetThread >= js::oom::THREAD_TYPE_MAX) {
|
||||
JS_ReportError(cx, "Invalid thread type specified");
|
||||
return false;
|
||||
}
|
||||
|
||||
HelperThreadState().waitForAllThreads();
|
||||
js::oom::targetThread = targetThread;
|
||||
OOM_maxAllocations = OOM_counter + count;
|
||||
OOM_failAlways = true;
|
||||
OOM_failAlways = failAlways;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
OOMAfterAllocations(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
return SetupOOMFailure(cx, true, argc, vp);
|
||||
}
|
||||
|
||||
static bool
|
||||
OOMAtAllocation(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
if (args.length() < 1) {
|
||||
JS_ReportError(cx, "count argument required");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length() > 2) {
|
||||
JS_ReportError(cx, "too many arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t targetThread = 0;
|
||||
if (!ToUint32(cx, args.get(1), &targetThread))
|
||||
return false;
|
||||
|
||||
if (targetThread >= js::oom::THREAD_TYPE_MAX) {
|
||||
JS_ReportError(cx, "invalid thread type specified");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t count;
|
||||
if (!JS::ToUint32(cx, args.get(0), &count))
|
||||
return false;
|
||||
|
||||
HelperThreadState().waitForAllThreads();
|
||||
js::oom::targetThread = targetThread;
|
||||
OOM_maxAllocations = OOM_counter + count;
|
||||
OOM_failAlways = false;
|
||||
return true;
|
||||
return SetupOOMFailure(cx, false, argc, vp);
|
||||
}
|
||||
|
||||
static bool
|
||||
@ -1065,6 +1043,7 @@ ResetOOMFailure(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
args.rval().setBoolean(OOM_counter >= OOM_maxAllocations);
|
||||
js::oom::targetThread = js::oom::THREAD_TYPE_NONE;
|
||||
OOM_maxAllocations = UINT32_MAX;
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user