Backed out changeset ad5849c18324 (bug 1199203) for build bustage ON A CLOSED TREE

This commit is contained in:
Nigel Babu 2015-09-10 08:26:52 +05:30
Родитель f4d10e47aa
Коммит 33d16f7c15
5 изменённых файлов: 19 добавлений и 126 удалений

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

@ -83,53 +83,16 @@ static MOZ_NEVER_INLINE void js_failedAllocBreakpoint() { asm(""); }
namespace js {
namespace oom {
/*
* To make testing OOM in certain helper threads more effective,
* allow restricting the OOM testing to a certain helper thread
* type. This allows us to fail e.g. in off-thread script parsing
* without causing an OOM in the main thread first.
*/
enum ThreadType {
THREAD_TYPE_NONE, // 0
THREAD_TYPE_MAIN, // 1
THREAD_TYPE_ASMJS, // 2
THREAD_TYPE_ION, // 3
THREAD_TYPE_PARSE, // 4
THREAD_TYPE_COMPRESS, // 5
THREAD_TYPE_GCHELPER, // 6
THREAD_TYPE_GCPARALLEL, // 7
THREAD_TYPE_MAX // Used to check shell function arguments
};
extern JS_PUBLIC_DATA(uint32_t) targetThread;
/*
* Getter/Setter functions to encapsulate mozilla::ThreadLocal,
* implementation is in jsutil.cpp.
*/
extern bool InitThreadType(void);
extern void SetThreadType(ThreadType);
extern uint32_t GetThreadType(void);
static inline bool
OOMThreadCheck()
{
return (!js::oom::targetThread
|| js::oom::targetThread == js::oom::GetThreadType());
}
static inline bool
IsSimulatedOOMAllocation()
{
return OOMThreadCheck() && (OOM_counter == OOM_maxAllocations ||
(OOM_counter > OOM_maxAllocations && OOM_failAlways));
return OOM_counter == OOM_maxAllocations ||
(OOM_counter > OOM_maxAllocations && OOM_failAlways);
}
static inline bool
ShouldFailWithOOM()
{
if (!OOMThreadCheck())
return false;
OOM_counter++;
if (IsSimulatedOOMAllocation()) {
JS_OOM_CALL_BP_FUNC();

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

@ -987,30 +987,15 @@ static bool
OOMAfterAllocations(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (args.length() < 1) {
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))
if (!JS::ToUint32(cx, args[0], &count))
return false;
js::oom::targetThread = targetThread;
OOM_maxAllocations = OOM_counter + count;
OOM_failAlways = true;
return true;
@ -1020,30 +1005,15 @@ static bool
OOMAtAllocation(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (args.length() < 1) {
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))
if (!JS::ToUint32(cx, args[0], &count))
return false;
js::oom::targetThread = targetThread;
OOM_maxAllocations = OOM_counter + count;
OOM_failAlways = false;
return true;
@ -2862,17 +2832,15 @@ static const JSFunctionSpecWithHelp TestingFunctions[] = {
" Stop capturing the JS stack at every allocation."),
#if defined(DEBUG) || defined(JS_OOM_BREAKPOINT)
JS_FN_HELP("oomAfterAllocations", OOMAfterAllocations, 2, 0,
"oomAfterAllocations(count [,threadType])",
JS_FN_HELP("oomAfterAllocations", OOMAfterAllocations, 1, 0,
"oomAfterAllocations(count)",
" After 'count' js_malloc memory allocations, fail every following allocation\n"
" (return nullptr). The optional thread type limits the effect to the\n"
" specified type of helper thread."),
" (return NULL)."),
JS_FN_HELP("oomAtAllocation", OOMAtAllocation, 2, 0,
"oomAtAllocation(count [,threadType])",
JS_FN_HELP("oomAtAllocation", OOMAtAllocation, 1, 0,
"oomAtAllocation(count)",
" After 'count' js_malloc memory allocations, fail the next allocation\n"
" (return nullptr). The optional thread type limits the effect to the\n"
" specified type of helper thread."),
" (return NULL)."),
JS_FN_HELP("resetOOMFailure", ResetOOMFailure, 0, 0,
"resetOOMFailure()",

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

@ -590,10 +590,6 @@ JS_Init(void)
if (!TlsPerThreadData.initialized() && !TlsPerThreadData.init())
return false;
if (!js::oom::InitThreadType())
return false;
js::oom::SetThreadType(js::oom::THREAD_TYPE_MAIN);
jit::ExecutableAllocator::initStatic();
if (!jit::InitializeIon())

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

@ -11,7 +11,6 @@
#include "mozilla/Assertions.h"
#include "mozilla/MathAlgorithms.h"
#include "mozilla/PodOperations.h"
#include "mozilla/ThreadLocal.h"
#include <stdio.h>
@ -33,12 +32,6 @@ using mozilla::PodArrayZero;
JS_PUBLIC_DATA(uint32_t) OOM_maxAllocations = UINT32_MAX;
JS_PUBLIC_DATA(uint32_t) OOM_counter = 0;
JS_PUBLIC_DATA(bool) OOM_failAlways = true;
namespace js {
namespace oom {
JS_PUBLIC_DATA(uint32_t) targetThread = 0;
JS_PUBLIC_DATA(mozilla::ThreadLocal<uint32_t>) threadType;
}
}
#endif
JS_PUBLIC_API(void)
@ -88,25 +81,6 @@ AllTheNonBasicVanillaNewAllocations()
MOZ_CRASH();
}
namespace oom {
bool
InitThreadType(void) {
return threadType.initialized() || threadType.init();
}
void
SetThreadType(ThreadType type) {
threadType.set(type);
}
uint32_t
GetThreadType(void) {
return threadType.get();
}
} // namespace oom
} // namespace js
#endif // __linux__
@ -257,4 +231,3 @@ JS_DumpHistogram(JSBasicStats* bs, FILE* fp)
}
#endif /* JS_BASIC_STATS */

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

@ -1451,26 +1451,19 @@ HelperThread::threadLoop()
}
// Dispatch tasks, prioritizing AsmJS work.
if (HelperThreadState().canStartAsmJSCompile()) {
js::oom::SetThreadType(js::oom::THREAD_TYPE_ASMJS);
if (HelperThreadState().canStartAsmJSCompile())
handleAsmJSWorkload();
} else if (ionCompile) {
js::oom::SetThreadType(js::oom::THREAD_TYPE_ION);
else if (ionCompile)
handleIonWorkload();
} else if (HelperThreadState().canStartParseTask()) {
js::oom::SetThreadType(js::oom::THREAD_TYPE_PARSE);
else if (HelperThreadState().canStartParseTask())
handleParseWorkload();
} else if (HelperThreadState().canStartCompressionTask()) {
js::oom::SetThreadType(js::oom::THREAD_TYPE_COMPRESS);
else if (HelperThreadState().canStartCompressionTask())
handleCompressionWorkload();
} else if (HelperThreadState().canStartGCHelperTask()) {
js::oom::SetThreadType(js::oom::THREAD_TYPE_GCHELPER);
else if (HelperThreadState().canStartGCHelperTask())
handleGCHelperWorkload();
} else if (HelperThreadState().canStartGCParallelTask()) {
js::oom::SetThreadType(js::oom::THREAD_TYPE_GCPARALLEL);
else if (HelperThreadState().canStartGCParallelTask())
handleGCParallelWorkload();
} else {
else
MOZ_CRASH("No task to perform");
}
}
}