diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 4944cf79be5..05a9f898d19 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -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) /************************************************************************/ diff --git a/js/src/xpconnect/src/xpcjsruntime.cpp b/js/src/xpconnect/src/xpcjsruntime.cpp index 462249da751..b1d9d7cc68e 100644 --- a/js/src/xpconnect/src/xpcjsruntime.cpp +++ b/js/src/xpconnect/src/xpcjsruntime.cpp @@ -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);