Bug 927516 - Bump Ion script size limit for DOM workers. r=bhackett

This commit is contained in:
Jan de Mooij 2013-11-19 21:10:34 +01:00
parent 6eeb0d3c51
commit ed37da0a3d
6 changed files with 44 additions and 3 deletions

View File

@ -805,6 +805,8 @@ CreateJSContextForWorker(WorkerPrivate* aWorkerPrivate, JSRuntime* aRuntime)
}
}
JS_SetIsWorkerRuntime(aRuntime);
JS_SetNativeStackQuota(aRuntime, WORKER_CONTEXT_NATIVE_STACK_LIMIT);
// Security policy:

View File

@ -1740,10 +1740,15 @@ CheckScript(JSContext *cx, JSScript *script, bool osr)
// Longer scripts can only be compiled off thread, as these compilations
// can be expensive and stall the main thread for too long.
static const uint32_t MAX_OFF_THREAD_SCRIPT_SIZE = 100000;
static const uint32_t MAX_MAIN_THREAD_SCRIPT_SIZE = 2000;
static const uint32_t MAX_OFF_THREAD_SCRIPT_SIZE = 100 * 1000;
static const uint32_t MAX_MAIN_THREAD_SCRIPT_SIZE = 2 * 1000;
static const uint32_t MAX_MAIN_THREAD_LOCALS_AND_ARGS = 256;
// DOM Worker runtimes don't have off thread compilation, but can also compile
// larger scripts since this doesn't stall the main thread.
static const uint32_t MAX_DOM_WORKER_SCRIPT_SIZE = 16 * 1000;
static const uint32_t MAX_DOM_WORKER_LOCALS_AND_ARGS = 2048;
static MethodStatus
CheckScriptSize(JSContext *cx, JSScript* script)
{
@ -1757,6 +1762,21 @@ CheckScriptSize(JSContext *cx, JSScript* script)
}
uint32_t numLocalsAndArgs = analyze::TotalSlots(script);
if (cx->runtime()->isWorkerRuntime()) {
// DOM Workers don't have off thread compilation enabled. Since workers
// don't block the browser's event loop, allow them to compile larger
// scripts.
JS_ASSERT(!OffThreadIonCompilationEnabled(cx->runtime()));
if (script->length > MAX_DOM_WORKER_SCRIPT_SIZE ||
numLocalsAndArgs > MAX_DOM_WORKER_LOCALS_AND_ARGS)
{
return Method_CantCompile;
}
return Method_Compiled;
}
if (script->length > MAX_MAIN_THREAD_SCRIPT_SIZE ||
numLocalsAndArgs > MAX_MAIN_THREAD_LOCALS_AND_ARGS)
{

View File

@ -73,6 +73,12 @@ JS_GetAnonymousString(JSRuntime *rt)
return rt->atomState.anonymous;
}
JS_FRIEND_API(void)
JS_SetIsWorkerRuntime(JSRuntime *rt)
{
rt->setIsWorkerRuntime();
}
JS_FRIEND_API(JSObject *)
JS_FindCompilationScope(JSContext *cx, JSObject *objArg)
{

View File

@ -48,6 +48,9 @@ JS_SetGrayGCRootsTracer(JSRuntime *rt, JSTraceDataOp traceOp, void *data);
extern JS_FRIEND_API(JSString *)
JS_GetAnonymousString(JSRuntime *rt);
extern JS_FRIEND_API(void)
JS_SetIsWorkerRuntime(JSRuntime *rt);
extern JS_FRIEND_API(JSObject *)
JS_FindCompilationScope(JSContext *cx, JSObject *obj);

View File

@ -286,7 +286,8 @@ JSRuntime::JSRuntime(JSUseHelperThreads useHelperThreads)
useHelperThreads_(useHelperThreads),
requestedHelperThreadCount(-1),
useHelperThreadsForIonCompilation_(true),
useHelperThreadsForParsing_(true)
useHelperThreadsForParsing_(true),
isWorkerRuntime_(false)
#ifdef DEBUG
, enteredPolicy(nullptr)
#endif

View File

@ -1695,6 +1695,9 @@ struct JSRuntime : public JS::shadow::Runtime,
bool useHelperThreadsForIonCompilation_;
bool useHelperThreadsForParsing_;
// True iff this is a DOM Worker runtime.
bool isWorkerRuntime_;
public:
bool useHelperThreads() const {
@ -1735,6 +1738,12 @@ struct JSRuntime : public JS::shadow::Runtime,
bool useHelperThreadsForParsing() const {
return useHelperThreadsForParsing_;
}
void setIsWorkerRuntime() {
isWorkerRuntime_ = true;
}
bool isWorkerRuntime() const {
return isWorkerRuntime_;
}
#ifdef DEBUG
public: