Bug 502836 - Fix 'script stack space quota is exhausted' error. r=igor a=blocking-betaN+

This commit is contained in:
Alon Zakai 2010-11-18 14:16:36 -08:00
parent 812bf3c258
commit 127f68f980
2 changed files with 6 additions and 3 deletions

View File

@ -1644,7 +1644,7 @@ JS_SetNativeStackQuota(JSContext *cx, size_t stackSize);
* Set the quota on the number of bytes that stack-like data structures can
* use when the runtime compiles and executes scripts. These structures
* consume heap space, so JS_SetThreadStackLimit does not bound their size.
* The default quota is 32MB which is quite generous.
* The default quota is 128MB which is very generous.
*
* The function must be called before any script compilation or execution API
* calls, i.e. either immediately after JS_NewContext or from JSCONTEXT_NEW
@ -1653,7 +1653,7 @@ JS_SetNativeStackQuota(JSContext *cx, size_t stackSize);
extern JS_PUBLIC_API(void)
JS_SetScriptStackQuota(JSContext *cx, size_t quota);
#define JS_DEFAULT_SCRIPT_STACK_QUOTA ((size_t) 0x2000000)
#define JS_DEFAULT_SCRIPT_STACK_QUOTA ((size_t) 0x8000000)
/************************************************************************/

View File

@ -47,6 +47,7 @@
#include "jsgcchunk.h"
#include "nsIMemoryReporter.h"
#include "mozilla/FunctionTimer.h"
#include "prsystem.h"
/***************************************************************************/
@ -1313,7 +1314,9 @@ XPCJSRuntime::OnJSContextNew(JSContext *cx)
return JS_FALSE;
JS_SetNativeStackQuota(cx, 128 * sizeof(size_t) * 1024);
JS_SetScriptStackQuota(cx, 25 * sizeof(size_t) * 1024 * 1024);
PRInt64 totalMemory = PR_GetPhysicalMemorySize();
JS_SetScriptStackQuota(cx, PR_MAX(25 * sizeof(size_t) * 1024 * 1024,
totalMemory / 4));
// we want to mark the global object ourselves since we use a different color
JS_ToggleOptions(cx, JSOPTION_UNROOTED_GLOBAL);