Bug 644241, part 1 - Remove script stack quota. r=igor

This commit is contained in:
Alon Zakai 2011-06-03 17:54:26 -07:00
Родитель 011184c05f
Коммит 7c246895a1
43 изменённых файлов: 145 добавлений и 299 удалений

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

@ -295,7 +295,6 @@ nsInProcessTabChildGlobal::InitTabChildGlobal()
nsContentUtils::GetSecurityManager()->GetSystemPrincipal(getter_AddRefs(mPrincipal));
JS_SetNativeStackQuota(cx, 128 * sizeof(size_t) * 1024);
JS_SetScriptStackQuota(cx, 25 * sizeof(size_t) * 1024 * 1024);
JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_JIT | JSOPTION_ANONFUNFIX | JSOPTION_PRIVATE_IS_NSISUPPORTS);
JS_SetVersion(cx, JSVERSION_LATEST);

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

@ -844,7 +844,6 @@ TabChild::InitTabChildGlobal()
nsContentUtils::GetSecurityManager()->GetSystemPrincipal(getter_AddRefs(mPrincipal));
JS_SetNativeStackQuota(cx, 128 * sizeof(size_t) * 1024);
JS_SetScriptStackQuota(cx, 25 * sizeof(size_t) * 1024 * 1024);
JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_JIT | JSOPTION_ANONFUNFIX | JSOPTION_PRIVATE_IS_NSISUPPORTS);
JS_SetVersion(cx, JSVERSION_LATEST);

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

@ -673,8 +673,7 @@ DOMWorkerErrorReporter(JSContext* aCx,
}
// Don't call the error handler if we're out of stack space.
if (errorNumber != JSMSG_SCRIPT_STACK_QUOTA &&
errorNumber != JSMSG_OVER_RECURSED) {
if (errorNumber != JSMSG_OVER_RECURSED) {
// Try the onerror handler for the worker's scope.
nsRefPtr<nsDOMWorkerScope> scope = worker->GetInnerScope();
NS_ASSERTION(scope, "Null scope!");
@ -1071,7 +1070,6 @@ nsDOMThreadService::CreateJSContext()
NS_ENSURE_SUCCESS(rv, nsnull);
JS_SetNativeStackQuota(cx, 256*1024);
JS_SetScriptStackQuota(cx, 100*1024*1024);
JS_SetOptions(cx,
JS_GetOptions(cx) | JSOPTION_METHODJIT | JSOPTION_JIT |

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

@ -652,7 +652,7 @@ check-malloc-function-usage: $(filter-out %jsalloc.h %jscntxt.h %jsutil.h, $(ALL
# We desire these numbers to go down, not up. See "User guide to memory
# management within SpiderMonkey" in jsutil.h.
$(srcdir)/config/check_source_count.py OffTheBooks:: 55 \
$(srcdir)/config/check_source_count.py OffTheBooks:: 53 \
"in Makefile.in" "{cx,rt}->{new_,new_array,malloc_,calloc_,realloc_}" $^
# This should go to zero, if possible.
$(srcdir)/config/check_source_count.py UnwantedForeground:: 34 \

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

@ -1,29 +0,0 @@
const numFatArgs = Math.pow(2,19) - 1024;
function fun(x) {
if (x <= 0)
return 0;
return fun(x-1);
}
function fatStack() {
return fun(10000);
}
function assertRightFailure(e) {
assertEq(e.toString() == "InternalError: script stack space quota is exhausted" ||
e.toString() == "InternalError: too much recursion",
true);
}
exception = false;
try {
fatStack.apply(null, new Array(numFatArgs));
} catch (e) {
assertRightFailure(e);
exception = true;
}
assertEq(exception, true);
// No more trace recursion w/ JM
checkStats({traceCompleted:0});

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

@ -103,7 +103,7 @@ MSG_DEF(JSMSG_BAD_FORMAL, 20, 0, JSEXN_SYNTAXERR, "malformed formal
MSG_DEF(JSMSG_CANT_DELETE, 21, 1, JSEXN_TYPEERR, "property {0} is non-configurable and can't be deleted")
MSG_DEF(JSMSG_NOT_FUNCTION, 22, 1, JSEXN_TYPEERR, "{0} is not a function")
MSG_DEF(JSMSG_NOT_CONSTRUCTOR, 23, 1, JSEXN_TYPEERR, "{0} is not a constructor")
MSG_DEF(JSMSG_SCRIPT_STACK_QUOTA, 24, 0, JSEXN_INTERNALERR, "script stack space quota is exhausted")
MSG_DEF(JSMSG_INVALID_DATE, 24, 0, JSEXN_RANGEERR, "invalid date")
MSG_DEF(JSMSG_TOO_DEEP, 25, 1, JSEXN_INTERNALERR, "{0} nested too deeply")
MSG_DEF(JSMSG_OVER_RECURSED, 26, 0, JSEXN_INTERNALERR, "too much recursion")
MSG_DEF(JSMSG_IN_NOT_OBJECT, 27, 1, JSEXN_TYPEERR, "invalid 'in' operand {0}")
@ -349,4 +349,4 @@ MSG_DEF(JSMSG_NON_NATIVE_SCOPE, 266, 0, JSEXN_TYPEERR, "non-native scope o
MSG_DEF(JSMSG_STRICT_FUNCTION_STATEMENT, 267, 0, JSEXN_SYNTAXERR, "in strict mode code, functions may be declared only at top level or immediately within another function")
MSG_DEF(JSMSG_INVALID_FOR_IN_INIT, 268, 0, JSEXN_SYNTAXERR, "for-in loop let declaration may not have an initializer")
MSG_DEF(JSMSG_CLEARED_SCOPE, 269, 0, JSEXN_TYPEERR, "attempt to run compile-and-go script on a cleared scope")
MSG_DEF(JSMSG_INVALID_DATE, 270, 0, JSEXN_RANGEERR, "invalid date")

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

@ -292,7 +292,7 @@ Script::analyze(JSContext *cx, JSScript *script)
JS_ASSERT(!code && !locals);
this->script = script;
JS_InitArenaPool(&pool, "script_analyze", 256, 8, NULL);
JS_InitArenaPool(&pool, "script_analyze", 256, 8);
unsigned length = script->length;
unsigned nfixed = localCount();

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

@ -2799,12 +2799,6 @@ JS_SetNativeStackQuota(JSContext *cx, size_t stackSize)
#endif
}
JS_PUBLIC_API(void)
JS_SetScriptStackQuota(JSContext *cx, size_t quota)
{
cx->scriptStackQuota = quota;
}
/************************************************************************/
JS_PUBLIC_API(void)

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

@ -1917,22 +1917,6 @@ JS_SetThreadStackLimit(JSContext *cx, jsuword limitAddr);
extern JS_PUBLIC_API(void)
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 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
* context callback.
*/
extern JS_PUBLIC_API(void)
JS_SetScriptStackQuota(JSContext *cx, size_t quota);
#define JS_DEFAULT_SCRIPT_STACK_QUOTA ((size_t) 0x8000000)
/************************************************************************/
/*

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

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
@ -65,7 +65,7 @@ static JSArenaStats *arena_stats_list;
JS_PUBLIC_API(void)
JS_InitArenaPool(JSArenaPool *pool, const char *name, size_t size,
size_t align, size_t *quotap)
size_t align)
{
if (align == 0)
align = JS_ARENA_DEFAULT_ALIGN;
@ -75,7 +75,6 @@ JS_InitArenaPool(JSArenaPool *pool, const char *name, size_t size,
JS_ARENA_ALIGN(pool, &pool->first + 1);
pool->current = &pool->first;
pool->arenasize = size;
pool->quotap = quotap;
#ifdef JS_ARENAMETER
memset(&pool->stats, 0, sizeof pool->stats);
pool->stats.name = strdup(name);
@ -160,18 +159,9 @@ JS_ArenaAllocate(JSArenaPool *pool, size_t nb)
gross = hdrsz + JS_MAX(nb, pool->arenasize);
if (gross < nb)
return NULL;
if (pool->quotap) {
if (gross > *pool->quotap)
return NULL;
b = (JSArena *) OffTheBooks::malloc_(gross);
if (!b)
return NULL;
*pool->quotap -= gross;
} else {
b = (JSArena *) OffTheBooks::malloc_(gross);
if (!b)
return NULL;
}
b = (JSArena *) OffTheBooks::malloc_(gross);
if (!b)
return NULL;
b->next = NULL;
b->limit = (jsuword)b + gross;
@ -226,19 +216,9 @@ JS_ArenaRealloc(JSArenaPool *pool, void *p, size_t size, size_t incr)
hdrsz = sizeof *a + extra + pool->mask; /* header and alignment slop */
gross = hdrsz + aoff;
JS_ASSERT(gross > aoff);
if (pool->quotap) {
growth = gross - (a->limit - (jsuword) a);
if (growth > *pool->quotap)
return NULL;
a = (JSArena *) OffTheBooks::realloc_(a, gross);
if (!a)
return NULL;
*pool->quotap -= growth;
} else {
a = (JSArena *) OffTheBooks::realloc_(a, gross);
if (!a)
return NULL;
}
a = (JSArena *) OffTheBooks::realloc_(a, gross);
if (!a)
return NULL;
#ifdef JS_ARENAMETER
pool->stats.nreallocs++;
#endif
@ -314,8 +294,6 @@ FreeArenaList(JSArenaPool *pool, JSArena *head)
do {
*ap = a->next;
if (pool->quotap)
*pool->quotap += a->limit - (jsuword) a;
JS_CLEAR_ARENA(a);
JS_COUNT_ARENA(pool,--);
UnwantedForeground::free_(a);

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

@ -88,8 +88,6 @@ struct JSArenaPool {
JSArena *current; /* arena from which to allocate space */
size_t arenasize; /* net exact size of a new arena */
jsuword mask; /* alignment mask (power-of-2 - 1) */
size_t *quotap; /* pointer to the quota on pool allocation
size or null if pool is unlimited */
#ifdef JS_ARENAMETER
JSArenaStats stats;
#endif
@ -210,7 +208,7 @@ struct JSArenaPool {
*/
extern JS_PUBLIC_API(void)
JS_InitArenaPool(JSArenaPool *pool, const char *name, size_t size,
size_t align, size_t *quotap);
size_t align);
/*
* Free the arenas in pool. The user may continue to allocate from pool

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

@ -675,7 +675,7 @@ js_alloc_temp_space(void *priv, size_t size)
JS_ARENA_ALLOCATE(space, &parser->context->tempPool, size);
if (!space)
js_ReportOutOfScriptQuota(parser->context);
js_ReportOutOfMemory(parser->context);
return space;
}
@ -707,7 +707,7 @@ js_alloc_temp_entry(void *priv, const void *key)
JS_ARENA_ALLOCATE_TYPE(ale, JSAtomListElement, &parser->context->tempPool);
if (!ale) {
js_ReportOutOfScriptQuota(parser->context);
js_ReportOutOfMemory(parser->context);
return NULL;
}
return &ale->entry;

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

@ -317,15 +317,12 @@ js_NewContext(JSRuntime *rt, size_t stackChunkSize)
#if JS_STACK_GROWTH_DIRECTION > 0
cx->stackLimit = (jsuword) -1;
#endif
cx->scriptStackQuota = JS_DEFAULT_SCRIPT_STACK_QUOTA;
JS_STATIC_ASSERT(JSVERSION_DEFAULT == 0);
JS_ASSERT(cx->findVersion() == JSVERSION_DEFAULT);
VOUCH_DOES_NOT_REQUIRE_STACK();
JS_InitArenaPool(&cx->tempPool, "temp", TEMP_POOL_CHUNK_SIZE, sizeof(jsdouble),
&cx->scriptStackQuota);
JS_InitArenaPool(&cx->regExpPool, "regExp", TEMP_POOL_CHUNK_SIZE, sizeof(int),
&cx->scriptStackQuota);
JS_InitArenaPool(&cx->tempPool, "temp", TEMP_POOL_CHUNK_SIZE, sizeof(jsdouble));
JS_InitArenaPool(&cx->regExpPool, "regExp", TEMP_POOL_CHUNK_SIZE, sizeof(int));
JS_ASSERT(cx->resolveFlags == 0);
@ -830,13 +827,6 @@ js_ReportOutOfMemory(JSContext *cx)
}
}
void
js_ReportOutOfScriptQuota(JSContext *maybecx)
{
if (maybecx)
JS_ReportErrorNumber(maybecx, js_GetErrorMessage, NULL, JSMSG_SCRIPT_STACK_QUOTA);
}
JS_FRIEND_API(void)
js_ReportOverRecursed(JSContext *maybecx)
{

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

@ -1081,9 +1081,6 @@ struct JSContext
/* Limit pointer for checking native stack consumption during recursion. */
jsuword stackLimit;
/* Quota on the size of arenas used to compile and execute scripts. */
size_t scriptStackQuota;
/* Data shared by threads in an address space. */
JSRuntime *const runtime;
@ -2331,12 +2328,6 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
extern void
js_ReportOutOfMemory(JSContext *cx);
/*
* Report that cx->scriptStackQuota is exhausted.
*/
void
js_ReportOutOfScriptQuota(JSContext *maybecx);
/* JS_CHECK_RECURSION is used outside JS, so JS_FRIEND_API. */
JS_FRIEND_API(void)
js_ReportOverRecursed(JSContext *maybecx);

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

@ -174,7 +174,7 @@ EmitCheck(JSContext *cx, JSCodeGenerator *cg, JSOp op, ptrdiff_t delta)
JS_ARENA_GROW_CAST(base, jsbytecode *, cg->codePool, size, incr);
}
if (!base) {
js_ReportOutOfScriptQuota(cx);
js_ReportOutOfMemory(cx);
return -1;
}
CG_BASE(cg) = base;
@ -524,7 +524,7 @@ AddJumpTarget(AddJumpTargetArgs *args, JSJumpTarget **jtp)
JS_ARENA_ALLOCATE_CAST(jt, JSJumpTarget *, &args->cx->tempPool,
sizeof *jt);
if (!jt) {
js_ReportOutOfScriptQuota(args->cx);
js_ReportOutOfMemory(args->cx);
return 0;
}
}
@ -980,7 +980,7 @@ OptimizeSpanDeps(JSContext *cx, JSCodeGenerator *cg)
incr = BYTECODE_SIZE(length) - size;
JS_ARENA_GROW_CAST(base, jsbytecode *, cg->codePool, size, incr);
if (!base) {
js_ReportOutOfScriptQuota(cx);
js_ReportOutOfMemory(cx);
return JS_FALSE;
}
CG_BASE(cg) = base;
@ -4602,7 +4602,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
void *cg2space;
JS_ARENA_ALLOCATE_TYPE(cg2space, JSCodeGenerator, cg->codePool);
if (!cg2space) {
js_ReportOutOfScriptQuota(cx);
js_ReportOutOfMemory(cx);
return JS_FALSE;
}
JSCodeGenerator *cg2 =
@ -7301,7 +7301,7 @@ AllocSrcNote(JSContext *cx, JSCodeGenerator *cg)
CG_NOTE_MASK(cg) = (CG_NOTE_MASK(cg) << 1) | 1;
}
if (!CG_NOTES(cg)) {
js_ReportOutOfScriptQuota(cx);
js_ReportOutOfMemory(cx);
return -1;
}
}
@ -7399,7 +7399,7 @@ GrowSrcNotes(JSContext *cx, JSCodeGenerator *cg)
size = SRCNOTE_SIZE(CG_NOTE_MASK(cg) + 1);
JS_ARENA_GROW_CAST(CG_NOTES(cg), jssrcnote *, pool, size, size);
if (!CG_NOTES(cg)) {
js_ReportOutOfScriptQuota(cx);
js_ReportOutOfMemory(cx);
return JS_FALSE;
}
CG_NOTE_MASK(cg) = (CG_NOTE_MASK(cg) << 1) | 1;
@ -7637,7 +7637,7 @@ NewTryNote(JSContext *cx, JSCodeGenerator *cg, JSTryNoteKind kind,
JS_ARENA_ALLOCATE_TYPE(tryNode, JSTryNode, &cx->tempPool);
if (!tryNode) {
js_ReportOutOfScriptQuota(cx);
js_ReportOutOfMemory(cx);
return JS_FALSE;
}

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

@ -2519,7 +2519,7 @@ Function(JSContext *cx, uintN argc, Value *vp)
AutoArenaAllocator aaa(&cx->tempPool);
jschar *cp = aaa.alloc<jschar>(args_length + 1);
if (!cp) {
js_ReportOutOfScriptQuota(cx);
js_ReportOutOfMemory(cx);
return false;
}
jschar *collected_args = cp;

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

@ -626,7 +626,7 @@ SprintEnsureBuffer(Sprinter *sp, size_t len)
JS_ARENA_GROW_CAST(base, char *, sp->pool, sp->size, nb);
}
if (!base) {
js_ReportOutOfScriptQuota(sp->context);
js_ReportOutOfMemory(sp->context);
return JS_FALSE;
}
sp->base = base;
@ -849,7 +849,7 @@ js_NewPrinter(JSContext *cx, const char *name, JSFunction *fun,
if (!jp)
return NULL;
INIT_SPRINTER(cx, &jp->sprinter, &jp->pool, 0);
JS_InitArenaPool(&jp->pool, name, 256, 1, &cx->scriptStackQuota);
JS_InitArenaPool(&jp->pool, name, 256, 1);
jp->indent = indent;
jp->pretty = !!pretty;
jp->grouped = !!grouped;
@ -1854,7 +1854,7 @@ InitSprintStack(JSContext *cx, SprintStack *ss, JSPrinter *jp, uintN depth)
opcodesz = depth * sizeof(jsbytecode);
JS_ARENA_ALLOCATE(space, &cx->tempPool, offsetsz + opcodesz);
if (!space) {
js_ReportOutOfScriptQuota(cx);
js_ReportOutOfMemory(cx);
return JS_FALSE;
}
ss->offsets = (ptrdiff_t *) space;

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

@ -252,7 +252,7 @@ Parser::newObjectBox(JSObject *obj)
JSObjectBox *objbox;
JS_ARENA_ALLOCATE_TYPE(objbox, JSObjectBox, &context->tempPool);
if (!objbox) {
js_ReportOutOfScriptQuota(context);
js_ReportOutOfMemory(context);
return NULL;
}
objbox->traceLink = traceListHead;
@ -278,7 +278,7 @@ Parser::newFunctionBox(JSObject *obj, JSParseNode *fn, JSTreeContext *tc)
JSFunctionBox *funbox;
JS_ARENA_ALLOCATE_TYPE(funbox, JSFunctionBox, &context->tempPool);
if (!funbox) {
js_ReportOutOfScriptQuota(context);
js_ReportOutOfMemory(context);
return NULL;
}
funbox->traceLink = traceListHead;
@ -682,7 +682,7 @@ NewOrRecycledNode(JSTreeContext *tc)
JS_ARENA_ALLOCATE_TYPE(pn, JSParseNode, &cx->tempPool);
if (!pn)
js_ReportOutOfScriptQuota(cx);
js_ReportOutOfMemory(cx);
} else {
tc->parser->nodeList = pn->pn_next;
}
@ -926,10 +926,8 @@ Compiler::compileScript(JSContext *cx, JSObject *scopeChain, StackFrame *callerF
if (!compiler.init(chars, length, filename, lineno, version))
return NULL;
JS_InitArenaPool(&codePool, "code", 1024, sizeof(jsbytecode),
&cx->scriptStackQuota);
JS_InitArenaPool(&notePool, "note", 1024, sizeof(jssrcnote),
&cx->scriptStackQuota);
JS_InitArenaPool(&codePool, "code", 1024, sizeof(jsbytecode));
JS_InitArenaPool(&notePool, "note", 1024, sizeof(jssrcnote));
Parser &parser = compiler.parser;
TokenStream &tokenStream = parser.tokenStream;
@ -1823,10 +1821,8 @@ Compiler::compileFunctionBody(JSContext *cx, JSFunction *fun, JSPrincipals *prin
/* No early return from after here until the js_FinishArenaPool calls. */
JSArenaPool codePool, notePool;
JS_InitArenaPool(&codePool, "code", 1024, sizeof(jsbytecode),
&cx->scriptStackQuota);
JS_InitArenaPool(&notePool, "note", 1024, sizeof(jssrcnote),
&cx->scriptStackQuota);
JS_InitArenaPool(&codePool, "code", 1024, sizeof(jsbytecode));
JS_InitArenaPool(&notePool, "note", 1024, sizeof(jssrcnote));
Parser &parser = compiler.parser;
TokenStream &tokenStream = parser.tokenStream;

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

@ -179,7 +179,7 @@ Bindings::getLocalNameArray(JSContext *cx, JSArenaPool *pool)
JS_ASSERT(SIZE_MAX / size_t(n) > sizeof *names);
JS_ARENA_ALLOCATE_CAST(names, jsuword *, pool, size_t(n) * sizeof *names);
if (!names) {
js_ReportOutOfScriptQuota(cx);
js_ReportOutOfMemory(cx);
return NULL;
}
@ -391,7 +391,7 @@ js_XDRScript(JSXDRState *xdr, JSScript **scriptp)
JS_ARENA_ALLOCATE_CAST(bitmap, uint32 *, &cx->tempPool,
bitmapLength * sizeof *bitmap);
if (!bitmap) {
js_ReportOutOfScriptQuota(cx);
js_ReportOutOfMemory(cx);
return false;
}

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

@ -141,8 +141,6 @@ static PRUintn gStackBaseThreadIndex;
static jsuword gStackBase;
#endif
static size_t gScriptStackQuota = JS_DEFAULT_SCRIPT_STACK_QUOTA;
/*
* Limit the timeout to 30 minutes to prevent an overflow on platfoms
* that represent the time internally in microseconds using 32-bit int.
@ -390,7 +388,6 @@ static void
SetContextOptions(JSContext *cx)
{
JS_SetNativeStackQuota(cx, gMaxStackSize);
JS_SetScriptStackQuota(cx, gScriptStackQuota);
JS_SetOperationCallback(cx, ShellOperationCallback);
}
@ -3112,21 +3109,6 @@ StringsAreUTF8(JSContext *cx, uintN argc, jsval *vp)
return JS_TRUE;
}
static JSBool
StackQuota(JSContext *cx, uintN argc, jsval *vp)
{
uint32 n;
if (argc == 0)
return JS_NewNumberValue(cx, (double) gScriptStackQuota, vp);
if (!JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[0], &n))
return JS_FALSE;
gScriptStackQuota = n;
JS_SetScriptStackQuota(cx, gScriptStackQuota);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
static const char* badUTF8 = "...\xC0...";
static const char* bigUTF8 = "...\xFB\xBF\xBF\xBF\xBF...";
static const jschar badSurrogate[] = { 'A', 'B', 'C', 0xDEEE, 'D', 'E', 0 };
@ -4851,7 +4833,6 @@ static JSFunctionSpec shell_functions[] = {
JS_FN("untrap", Untrap, 2,0),
JS_FN("line2pc", LineToPC, 0,0),
JS_FN("pc2line", PCToLine, 0,0),
JS_FN("stackQuota", StackQuota, 0,0),
JS_FN("stringsAreUTF8", StringsAreUTF8, 0,0),
JS_FN("testUTF8", TestUTF8, 1,0),
JS_FN("throwError", ThrowError, 0,0),
@ -4980,7 +4961,6 @@ static const char *const shell_help_messages[] = {
"untrap(fun[, pc]) Remove a trap",
"line2pc([fun,] line) Map line number to PC",
"pc2line(fun[, pc]) Map PC to line number",
"stackQuota([number]) Query/set script stack quota",
"stringsAreUTF8() Check if strings are UTF-8 encoded",
"testUTF8(mode) Perform UTF-8 tests (modes are 1 to 4)",
"throwError() Throw an error from JS_ReportError",

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

@ -80,12 +80,12 @@ script regress-375406.js
script regress-378492.js
script regress-380833.js
script regress-383255.js
script regress-394941.js
silentfail script regress-394941.js
script regress-407323.js
script regress-426520.js
script regress-453915.js
script regress-458679-01.js
script regress-458679-02.js
silentfail script regress-458679-01.js
silentfail script regress-458679-02.js
script regress-460180.js
script regress-465063.js
script regress-470619.js

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

@ -40,14 +40,12 @@
var BUGNUMBER = 319872;
var summary = 'Do not Crash in jsxml.c';
var actual = 'No Crash';
var expect = /(No Crash|InternalError: script stack space quota is exhausted|InternalError: allocation size overflow)/;
var expect = /(No Crash|InternalError: allocation size overflow)/;
printBugNumber(BUGNUMBER);
START(summary);
printStatus ("Expect either no error, out of memory or catchable script stack " +
"space quota is exhausted error");
printStatus ("Expect either no error or out of memory");
expectExitCode(0);
expectExitCode(3);
expectExitCode(5);
try

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

@ -40,7 +40,10 @@
var summary = 'Infinite recursion should throw catchable exception';
var BUGNUMBER = 394941;
var actual = '';
var expect = /InternalError: (script stack space quota is exhausted|too much recursion)/;
var expect = /InternalError: too much recursion/;
expectExitCode(0);
expectExitCode(5);
/*
* use the reportMatch so that the test will pass on 1.8

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

@ -45,6 +45,9 @@ var expect = '';
printBugNumber(BUGNUMBER);
START(summary);
expectExitCode(0);
expectExitCode(5);
try
{
var x = "<";

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

@ -45,6 +45,9 @@ var expect = '';
printBugNumber(BUGNUMBER);
START(summary);
expectExitCode(0);
expectExitCode(5);
function stringOfLength(n)
{
if (n == 0) {

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

@ -48,7 +48,7 @@ script 13.4.4.7.js
script 13.4.4.8.js
script 13.4.4.9.js
script regress-291930.js
script regress-324422-1.js
silentfail script regress-324422-1.js
skip script regress-324422-2.js # slow
skip script regress-324688.js # bug 528404 - disable due to random timeouts
script regress-336921.js

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

@ -46,6 +46,9 @@ var expect = 'No Crash';
printBugNumber(BUGNUMBER);
START(summary);
expectExitCode(0);
expectExitCode(5);
if (typeof document == 'undefined')
{
printStatus ("Expect possible out of memory error");
@ -61,16 +64,7 @@ for (var icount = 0; icount < 20; icount++)
printStatus(str.length);
try
{
var x = new XML('<root>' + str + '</root>');
}
catch(ex)
{
expect = 'InternalError: script stack space quota is exhausted';
actual = ex + '';
print('Caught ' + ex);
}
var x = new XML('<root>' + str + '</root>');
TEST(1, expect, actual);

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

@ -44,10 +44,10 @@ var expect = 'No Crash';
printBugNumber(BUGNUMBER);
START(summary);
printStatus ("Expect out of memory or script stack space quota is exhausted error");
printStatus ("Expect out of memory error");
expectExitCode(0);
expectExitCode(3);
expectExitCode(5);
try
{

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

@ -6,5 +6,5 @@ script empty-lookahead.js
script exec.js
script exec-lastIndex-ToInteger.js
script regress-576828.js
skip-if(!xulRuntime.shell&&(Android||xulRuntime.OS=="WINNT")) script regress-617935.js
silentfail skip-if(!xulRuntime.shell&&(Android||xulRuntime.OS=="WINNT")) script regress-617935.js
script instance-property-storage-introspection.js

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

@ -5,6 +5,9 @@
* Author: Christian Holler <decoder@own-hero.net>
*/
expectExitCode(0);
expectExitCode(5);
/* Length of 32 */
var foo = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";

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

@ -19,7 +19,7 @@ script regress-345961.js
script regress-348810.js
script regress-350256-01.js
script regress-350256-02.js
script regress-350256-03.js
silentfail script regress-350256-03.js
script regress-360681-01.js
script regress-360681-02.js
script regress-364104.js

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

@ -41,6 +41,8 @@ var summary = 'Array.apply maximum arguments: 2^19-1024';
var actual = '';
var expect = '';
expectExitCode(0);
expectExitCode(5);
//-----------------------------------------------------------------------------
test(Math.pow(2, 19)-1024);
@ -52,34 +54,23 @@ function test(length)
printBugNumber(BUGNUMBER);
printStatus (summary);
try
{
var a = new Array();
a[length - 2] = 'length-2';
a[length - 1] = 'length-1';
var a = new Array();
a[length - 2] = 'length-2';
a[length - 1] = 'length-1';
var b = Array.apply(null, a);
var b = Array.apply(null, a);
expect = length + ',length-2,length-1';
actual = b.length + "," + b[length - 2] + "," + b[length - 1];
reportCompare(expect, actual, summary);
function f() {
return arguments.length + "," + arguments[length - 2] + "," +
arguments[length - 1];
}
expect = length + ',length-2,length-1';
actual = f.apply(null, a);
expect = length + ',length-2,length-1';
actual = b.length + "," + b[length - 2] + "," + b[length - 1];
reportCompare(expect, actual, summary);
function f() {
return arguments.length + "," + arguments[length - 2] + "," +
arguments[length - 1];
}
catch(ex)
{
expect = 'InternalError: script stack space quota is exhausted';
actual = ex + '';
print(actual);
}
expect = length + ',length-2,length-1';
actual = f.apply(null, a);
reportCompare(expect, actual, summary);

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

@ -7,9 +7,9 @@ script regress-178389.js
script regress-222029-001.js
script regress-222029-002.js
script regress-292215.js
script regress-338001.js
script regress-338121-01.js
script regress-338121-02.js
script regress-338121-03.js
silentfail script regress-338001.js
silentfail script regress-338121-01.js
silentfail script regress-338121-02.js
silentfail script regress-338121-03.js
script regress-344052.js
script regress-364023.js

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

@ -39,7 +39,7 @@
var BUGNUMBER = 338001;
var summary = 'integer overflow in jsfun.c:Function';
var actual = 'No Crash';
var expect = /No Crash|InternalError: allocation size overflow|InternalError: script stack space quota is exhausted/;
var expect = /No Crash|InternalError: allocation size overflow/;
printBugNumber(BUGNUMBER);
printStatus (summary);

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

@ -44,26 +44,20 @@ var expect = 'No Crash';
printBugNumber(BUGNUMBER);
printStatus (summary);
try
{
var fe="v";
expectExitCode(0);
expectExitCode(5);
for (i=0; i<25; i++)
fe += fe;
var fe="v";
var fu=new Function(
fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe,
fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe,
"done"
);
for (i=0; i<25; i++)
fe += fe;
print('Done');
}
catch(ex)
{
expect = 'InternalError: script stack space quota is exhausted';
actual = ex + '';
print(actual);
}
var fu=new Function(
fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe,
fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe,
"done"
);
print('Done');
reportCompare(expect, actual, summary);

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

@ -44,30 +44,24 @@ var expect = 'No Crash';
printBugNumber(BUGNUMBER);
printStatus (summary);
try
{
var fe="vv";
expectExitCode(0);
expectExitCode(5);
for (i=0; i<24; i++)
fe += fe;
var fe="vv";
var fu=new Function(
fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe,
fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe,
"done"
);
for (i=0; i<24; i++)
fe += fe;
var fu=new Function(
fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe,
fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe,
"done"
);
//alert("fu="+fu);
//print("fu="+fu);
var fuout = 'fu=' + fu;
var fuout = 'fu=' + fu;
print('Done');
}
catch(ex)
{
expect = 'InternalError: script stack space quota is exhausted';
actual = ex + '';
print(actual);
}
print('Done');
reportCompare(expect, actual, summary);

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

@ -44,31 +44,26 @@ var expect = 'No Crash';
printBugNumber(BUGNUMBER);
printStatus (summary);
try
{
var fe="vv";
expectExitCode(0);
expectExitCode(5);
for (i=0; i<24; i++)
fe += fe;
var fe="vv";
var fu=new Function(
fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe,
fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe,
fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe,
fe, fe, fe,
"done"
);
for (i=0; i<24; i++)
fe += fe;
var fu=new Function(
fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe,
fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe,
fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe, fe,
fe, fe, fe,
"done"
);
//alert("fu="+fu);
//print("fu="+fu);
var fuout = 'fu=' + fu;
}
catch(ex)
{
expect = 'InternalError: script stack space quota is exhausted';
actual = ex + '';
print('Caught ' + ex);
}
var fuout = 'fu=' + fu;
print('Done');
reportCompare(expect, actual, summary);

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

@ -91,7 +91,7 @@ script regress-275378.js
script regress-276103.js
script regress-278873.js
script regress-280769-1.js
script regress-280769-2.js
silentfail script regress-280769-2.js
script regress-280769-3.js
script regress-280769-4.js
script regress-280769-5.js

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

@ -40,13 +40,16 @@
var BUGNUMBER = 280769;
var summary = 'Do not overflow 64K boundary in treeDepth';
var actual = 'No Crash';
var expect = /No Crash|InternalError: allocation size overflow|InternalError: script stack space quota is exhausted/;
var expect = /No Crash|InternalError: allocation size overflow/;
var status;
var result;
printBugNumber(BUGNUMBER);
printStatus (summary);
expectExitCode(0);
expectExitCode(5);
status = summary + ' ' + inSection(1) + ' (new RegExp("0|...|99999") ';
try

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

@ -39,7 +39,7 @@
var BUGNUMBER = 336409;
var summary = 'Integer overflow in js_obj_toSource';
var actual = 'No Crash';
var expect = /(No Crash|InternalError: script stack space quota is exhausted|InternalError: allocation size overflow)/;
var expect = /(No Crash|InternalError: allocation size overflow)/;
printBugNumber(BUGNUMBER);
printStatus (summary);

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

@ -39,7 +39,7 @@
var BUGNUMBER = 336410;
var summary = 'Integer overflow in array_toSource';
var actual = 'No Crash';
var expect = /(No Crash|InternalError: script stack space quota is exhausted|InternalError: allocation size overflow)/;
var expect = /(No Crash|InternalError: allocation size overflow)/;
printBugNumber(BUGNUMBER);
printStatus (summary);

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

@ -55,30 +55,21 @@ function test()
expectExitCode(0);
expectExitCode(5);
try
function v()
{
function v()
{
var meg="";
var r="";
var i;
print("don't interrupt the script. let it go.");
for(i=0;i<1024*1024;i++) meg += "v";
for(i=0;i<1024/8;i++) r += meg;
var o={f1: r, f2: r, f3: r,f4: r,f5: r, f6: r, f7: r, f8: r,f9: r};
print('done obj');
var rr=r.toSource();
print('done toSource()');
}
var meg="";
var r="";
var i;
print("don't interrupt the script. let it go.");
for(i=0;i<1024*1024;i++) meg += "v";
for(i=0;i<1024/8;i++) r += meg;
var o={f1: r, f2: r, f3: r,f4: r,f5: r, f6: r, f7: r, f8: r,f9: r};
print('done obj');
var rr=r.toSource();
print('done toSource()');
}
v();
}
catch(ex)
{
expect = 'InternalError: script stack space quota is exhausted';
actual = ex + '';
print(actual);
}
v();
reportCompare(expect, actual, summary);

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

@ -1579,10 +1579,6 @@ XPCJSRuntime::OnJSContextNew(JSContext *cx)
return JS_FALSE;
JS_SetNativeStackQuota(cx, 128 * sizeof(size_t) * 1024);
PRUint64 totalMemory = PR_GetPhysicalMemorySize();
size_t quota = PR_MIN(PR_UINT32_MAX, PR_MAX(25 * sizeof(size_t) * 1024 * 1024,
totalMemory / 4));
JS_SetScriptStackQuota(cx, quota);
// we want to mark the global object ourselves since we use a different color
JS_ToggleOptions(cx, JSOPTION_UNROOTED_GLOBAL);