author | Benjamin Peterson <benjamin@python.org> |
Tue, 20 Nov 2012 11:29:42 -0600 | |
changeset 113794 | b1cb8ff6e836e1bb684910da15f220eeb887f52d |
parent 113793 | 5387f2b5423fd907bdc47f8b72fcebe0d36754d6 |
child 113795 | 19c1fef93710c212064f8dc0ae1a96151561b4c5 |
push id | 23890 |
push user | ryanvm@gmail.com |
push date | Wed, 21 Nov 2012 02:43:32 +0000 |
treeherder | mozilla-central@4f19e7fd8bea [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jorendorff |
bugs | 795104 |
milestone | 20.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -6459,17 +6459,17 @@ Parser::atomNode(ParseNodeKind kind, JSO node->setOp(op); const Token &tok = tokenStream.currentToken(); node->pn_atom = tok.atom(); // Large strings are fast to parse but slow to compress. Stop compression on // them, so we don't wait for a long time for compression to finish at the // end of compilation. const size_t HUGE_STRING = 50000; - if (sct && kind == PNK_STRING && node->pn_atom->length() >= HUGE_STRING) + if (sct && sct->active() && kind == PNK_STRING && node->pn_atom->length() >= HUGE_STRING) sct->abort(); return node; } ParseNode * Parser::primaryExpr(TokenKind tt, bool afterDoubleDot) {
--- a/js/src/jsapi-tests/Makefile.in +++ b/js/src/jsapi-tests/Makefile.in @@ -52,16 +52,17 @@ CPPSRCS = \ testParseJSON.cpp \ testPropCache.cpp \ testRegExp.cpp \ testResolveRecursion.cpp \ testSameValue.cpp \ testScriptInfo.cpp \ testScriptObject.cpp \ testSetProperty.cpp \ + testSourcePolicy.cpp \ testStringBuffer.cpp \ testTrap.cpp \ testTypedArrays.cpp \ testVersion.cpp \ testXDR.cpp \ testProfileStrings.cpp \ testJSEvaluateScript.cpp \ testErrorCopying.cpp \
new file mode 100644 --- /dev/null +++ b/js/src/jsapi-tests/testSourcePolicy.cpp @@ -0,0 +1,23 @@ +/* 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 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "tests.h" + +BEGIN_TEST(testBug795104) +{ + JS::CompileOptions opts(cx); + opts.setSourcePolicy(JS::CompileOptions::NO_SOURCE); + const size_t strLen = 60002; + char *s = static_cast<char *>(JS_malloc(cx, strLen)); + CHECK(s); + s[0] = '"'; + memset(s + 1, 'x', strLen - 2); + s[strLen - 1] = '"'; + CHECK(JS::Evaluate(cx, global, opts, s, strLen, NULL)); + CHECK(JS::CompileFunction(cx, global, opts, "f", 0, NULL, s, strLen)); + JS_free(cx, s); + + return true; +} +END_TEST(testBug795104)
--- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -1251,31 +1251,32 @@ ScriptSource::setSource(const jschar *sr data.source = const_cast<jschar *>(src); } bool SourceCompressionToken::complete() { JS_ASSERT_IF(!ss, !chars); #ifdef JS_THREADSAFE - if (ss) { + if (active()) { cx->runtime->sourceCompressorThread.waitOnCompression(this); - JS_ASSERT(!ss); + JS_ASSERT(!active()); } if (oom) { JS_ReportOutOfMemory(cx); return false; } #endif return true; } void SourceCompressionToken::abort() { + JS_ASSERT(active()); #ifdef JS_THREADSAFE cx->runtime->sourceCompressorThread.abort(this); #endif } void ScriptSource::destroy(JSRuntime *rt) {
--- a/js/src/jsscript.h +++ b/js/src/jsscript.h @@ -1197,16 +1197,17 @@ struct SourceCompressionToken : cx(cx), ss(NULL), chars(NULL), oom(false) {} ~SourceCompressionToken() { complete(); } bool complete(); void abort(); + bool active() const { return !!ss; } }; extern void CallDestroyScriptHook(FreeOp *fop, js::RawScript script); extern const char * SaveScriptFilename(JSContext *cx, const char *filename);