Bug 906040 - Bring back the higher recursion limit for chrome scripts in the interpreter. r=luke

This commit is contained in:
Jan de Mooij 2013-08-17 10:42:37 +02:00
parent 64a0f16900
commit e672f24d6d
3 changed files with 14 additions and 4 deletions

View File

@ -1,4 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -75,9 +77,13 @@ BEGIN_TEST(testChromeBuffer)
const char *paramName = "trusted"; const char *paramName = "trusted";
const char *bytes = "try { " const char *bytes = "try { "
" return untrusted(trusted); " " return untrusted(trusted); "
"} catch (e) { " "} catch (e) { "
" return trusted(100); " " try { "
" return trusted(100); "
" } catch(e) { "
" return -1; "
" } "
"} "; "} ";
CHECK(fun = JS_CompileFunction(cx, global, "untrusted", 1, &paramName, CHECK(fun = JS_CompileFunction(cx, global, "untrusted", 1, &paramName,
bytes, strlen(bytes), "", 0)); bytes, strlen(bytes), "", 0));

View File

@ -228,7 +228,10 @@ InterpreterStack::purge(JSRuntime *rt)
uint8_t * uint8_t *
InterpreterStack::allocateFrame(JSContext *cx, size_t size) InterpreterStack::allocateFrame(JSContext *cx, size_t size)
{ {
if (JS_UNLIKELY(frameCount_ >= MAX_FRAMES)) { size_t maxFrames = cx->compartment()->principals == cx->runtime()->trustedPrincipals()
? MAX_FRAMES_TRUSTED
: MAX_FRAMES;
if (JS_UNLIKELY(frameCount_ >= maxFrames)) {
js_ReportOverRecursed(cx); js_ReportOverRecursed(cx);
return NULL; return NULL;
} }

View File

@ -1040,6 +1040,7 @@ class InterpreterStack
// Number of interpreter frames on the stack, for over-recursion checks. // Number of interpreter frames on the stack, for over-recursion checks.
static const size_t MAX_FRAMES = 50 * 1000; static const size_t MAX_FRAMES = 50 * 1000;
static const size_t MAX_FRAMES_TRUSTED = MAX_FRAMES + 1000;
size_t frameCount_; size_t frameCount_;
inline uint8_t *allocateFrame(JSContext *cx, size_t size); inline uint8_t *allocateFrame(JSContext *cx, size_t size);