Backed out changesets 00edef0582f1 and 7796f1b42487 (bug 965712) for making OSX mochitest-dt more timeout-prone in the debugger tests.

CLOSED TREE
This commit is contained in:
Ryan VanderMeulen 2014-04-30 15:56:36 -04:00
parent a8b592efb4
commit 9c2a462b26
5 changed files with 55 additions and 119 deletions

View File

@ -1,2 +0,0 @@
var result = "D1D1D1D1D1D1D1D1D1D1".replace(/d1/ig,1);
assertEq(result, "1111111111");

View File

@ -1063,53 +1063,46 @@ struct ManualCmp {
template <class InnerMatch>
static int
MemChrMatch(const jschar *text, uint32_t textlen, const jschar *pat, uint32_t patlen)
UnrolledMatch(const jschar *text, uint32_t textlen, const jschar *pat, uint32_t patlen)
{
/*
* Use the very efficient memchr to find the character that matches the
* first pattern character. The only caveat is that memchr uses 8 bit chars,
* while spidermonkey uses 16 bit chars.
*/
JS_ASSERT(patlen > 0 && textlen > 0);
const jschar *textend = text + textlen - (patlen - 1);
const jschar p0 = *pat;
const jschar *const patNext = pat + 1;
const typename InnerMatch::Extent extent = InnerMatch::computeExtent(pat, patlen);
uint8_t fixup;
/* Treat input as 8 bit strings */
const char *text8 = (const char *)text;
const char *pat8 = (const char *)pat;
/*
* Indexing on 8 bits. So the indexes get twice as big.
* Currently this isn't a problem since max string size is 28bit.
*/
JS_ASSERT(textlen < UINT32_MAX/2);
uint32_t i = 0;
uint32_t n = (textlen - patlen)*2;
while (i <= n) {
/* Find the first 8 bits of the pattern in the text. */
const char* pos = reinterpret_cast<const char *>(memchr(text8 + i, pat8[0], n - i + 1));
if (pos == nullptr)
return -1;
i = static_cast<uint32_t>(pos - text8);
/* Ignore when it matched the upper 8 bits of the 16bits text. */
if (i%2 != 0) {
i++;
continue;
}
/*
* Test the upper 8 bits of the first character of the pattern.
* On success test the full text using normal 16bit character compares,
* starting at the second 16 bit character.
*/
if (pat8[1] == text8[i+1]) {
if (InnerMatch::match(pat + 1, text + i/2 + 1, extent))
return i/2;
}
i += 2;
const jschar *t = text;
switch ((textend - t) & 7) {
case 0: if (*t++ == p0) { fixup = 8; goto match; }
case 7: if (*t++ == p0) { fixup = 7; goto match; }
case 6: if (*t++ == p0) { fixup = 6; goto match; }
case 5: if (*t++ == p0) { fixup = 5; goto match; }
case 4: if (*t++ == p0) { fixup = 4; goto match; }
case 3: if (*t++ == p0) { fixup = 3; goto match; }
case 2: if (*t++ == p0) { fixup = 2; goto match; }
case 1: if (*t++ == p0) { fixup = 1; goto match; }
}
while (t != textend) {
if (t[0] == p0) { t += 1; fixup = 8; goto match; }
if (t[1] == p0) { t += 2; fixup = 7; goto match; }
if (t[2] == p0) { t += 3; fixup = 6; goto match; }
if (t[3] == p0) { t += 4; fixup = 5; goto match; }
if (t[4] == p0) { t += 5; fixup = 4; goto match; }
if (t[5] == p0) { t += 6; fixup = 3; goto match; }
if (t[6] == p0) { t += 7; fixup = 2; goto match; }
if (t[7] == p0) { t += 8; fixup = 1; goto match; }
t += 8;
continue;
do {
if (*t++ == p0) {
match:
if (!InnerMatch::match(patNext, t, extent))
goto failed_match;
return t - text - 1;
}
failed_match:;
} while (--fixup > 0);
}
return -1;
}
@ -1165,10 +1158,10 @@ StringMatch(const jschar *text, uint32_t textlen,
*/
return
#if !defined(__linux__)
patlen > 128 ? MemChrMatch<MemCmp>(text, textlen, pat, patlen)
patlen > 128 ? UnrolledMatch<MemCmp>(text, textlen, pat, patlen)
:
#endif
MemChrMatch<ManualCmp>(text, textlen, pat, patlen);
UnrolledMatch<ManualCmp>(text, textlen, pat, patlen);
}
static const size_t sRopeMatchThresholdRatioLog2 = 5;
@ -1180,13 +1173,6 @@ js::StringHasPattern(const jschar *text, uint32_t textlen,
return StringMatch(text, textlen, pat, patlen) != -1;
}
int
js::StringFindPattern(const jschar *text, uint32_t textlen,
const jschar *pat, uint32_t patlen)
{
return StringMatch(text, textlen, pat, patlen);
}
// When an algorithm does not need a string represented as a single linear
// array of characters, this range utility may be used to traverse the string a
// sequence of linear arrays of characters. This avoids flattening ropes.
@ -1751,12 +1737,6 @@ HasRegExpMetaChars(const jschar *chars, size_t length)
return false;
}
bool
js::StringHasRegExpMetaChars(const jschar *chars, size_t length)
{
return HasRegExpMetaChars(chars, length);
}
namespace {
/*

View File

@ -213,13 +213,6 @@ extern bool
StringHasPattern(const jschar *text, uint32_t textlen,
const jschar *pat, uint32_t patlen);
extern int
StringFindPattern(const jschar *text, uint32_t textlen,
const jschar *pat, uint32_t patlen);
extern bool
StringHasRegExpMetaChars(const jschar *chars, size_t length);
} /* namespace js */
extern size_t

View File

@ -8,8 +8,6 @@
#include "mozilla/MemoryReporting.h"
#include "jsstr.h"
#include "frontend/TokenStream.h"
#include "vm/MatchPairs.h"
#include "vm/RegExpStatics.h"
@ -379,7 +377,7 @@ RegExpObject::toString(JSContext *cx) const
/* RegExpShared */
RegExpShared::RegExpShared(JSAtom *source, RegExpFlag flags, uint64_t gcNumber)
: source(source), flags(flags), parenCount(0), canStringMatch(false),
: source(source), flags(flags), parenCount(0),
#if ENABLE_YARR_JIT
codeBlock(),
#endif
@ -440,9 +438,6 @@ RegExpShared::checkSyntax(ExclusiveContext *cx, TokenStream *tokenStream, JSLine
bool
RegExpShared::compile(JSContext *cx, bool matchOnly)
{
TraceLogger *logger = TraceLoggerForMainThread(cx->runtime());
AutoTraceLog logCompile(logger, TraceLogger::YarrCompile);
if (!sticky())
return compile(cx, *source, matchOnly);
@ -471,12 +466,6 @@ RegExpShared::compile(JSContext *cx, bool matchOnly)
bool
RegExpShared::compile(JSContext *cx, JSLinearString &pattern, bool matchOnly)
{
if (!ignoreCase() && !StringHasRegExpMetaChars(pattern.chars(), pattern.length())) {
canStringMatch = true;
parenCount = 0;
return true;
}
/* Parse the pattern. */
ErrorCode yarrError;
YarrPattern yarrPattern(pattern, ignoreCase(), multiline(), &yarrError);
@ -518,7 +507,7 @@ RegExpShared::compile(JSContext *cx, JSLinearString &pattern, bool matchOnly)
bool
RegExpShared::compileIfNecessary(JSContext *cx)
{
if (hasCode() || hasBytecode() || canStringMatch)
if (hasCode() || hasBytecode())
return true;
return compile(cx, false);
}
@ -526,7 +515,7 @@ RegExpShared::compileIfNecessary(JSContext *cx)
bool
RegExpShared::compileMatchOnlyIfNecessary(JSContext *cx)
{
if (hasMatchOnlyCode() || hasBytecode() || canStringMatch)
if (hasMatchOnlyCode() || hasBytecode())
return true;
return compile(cx, true);
}
@ -537,9 +526,12 @@ RegExpShared::execute(JSContext *cx, const jschar *chars, size_t length,
{
TraceLogger *logger = TraceLoggerForMainThread(cx->runtime());
/* Compile the code at point-of-use. */
if (!compileIfNecessary(cx))
return RegExpRunStatus_Error;
{
/* Compile the code at point-of-use. */
AutoTraceLog logCompile(logger, TraceLogger::YarrCompile);
if (!compileIfNecessary(cx))
return RegExpRunStatus_Error;
}
/* Ensure sufficient memory for output vector. */
if (!matches.initArray(pairCount()))
@ -563,20 +555,6 @@ RegExpShared::execute(JSContext *cx, const jschar *chars, size_t length,
unsigned *outputBuf = matches.rawBuf();
unsigned result;
if (canStringMatch) {
int res = StringFindPattern(chars+start, length-start, source->chars(), source->length());
if (res == -1)
return RegExpRunStatus_Success_NotFound;
outputBuf[0] = res + start;
outputBuf[1] = outputBuf[0] + source->length();
matches.displace(displacement);
matches.checkAgainst(origLength);
*lastIndex = matches[0].limit;
return RegExpRunStatus_Success;
}
#if ENABLE_YARR_JIT
if (codeBlock.isFallBack()) {
AutoTraceLog logInterpret(logger, TraceLogger::YarrInterpret);
@ -612,9 +590,12 @@ RegExpShared::executeMatchOnly(JSContext *cx, const jschar *chars, size_t length
{
TraceLogger *logger = js::TraceLoggerForMainThread(cx->runtime());
/* Compile the code at point-of-use. */
if (!compileMatchOnlyIfNecessary(cx))
return RegExpRunStatus_Error;
{
/* Compile the code at point-of-use. */
AutoTraceLog logCompile(logger, TraceLogger::YarrCompile);
if (!compileMatchOnlyIfNecessary(cx))
return RegExpRunStatus_Error;
}
#ifdef DEBUG
const size_t origLength = length;
@ -629,17 +610,6 @@ RegExpShared::executeMatchOnly(JSContext *cx, const jschar *chars, size_t length
start = 0;
}
if (canStringMatch) {
int res = StringFindPattern(chars+start, length-start, source->chars(), source->length());
if (res == -1)
return RegExpRunStatus_Success_NotFound;
match = MatchPair(res + start, res + start + source->length());
match.displace(displacement);
*lastIndex = match.limit;
return RegExpRunStatus_Success;
}
#if ENABLE_YARR_JIT
if (!codeBlock.isFallBack()) {
AutoTraceLog logJIT(logger, TraceLogger::YarrJIT);

View File

@ -145,7 +145,6 @@ class RegExpShared
RegExpFlag flags;
unsigned parenCount;
bool canStringMatch;
#if ENABLE_YARR_JIT
/* Note: Native code is valid only if |codeBlock.isFallBack() == false|. */
@ -205,11 +204,7 @@ class RegExpShared
/* Accessors */
size_t getParenCount() const {
JS_ASSERT(isCompiled() || canStringMatch);
return parenCount;
}
size_t getParenCount() const { JS_ASSERT(isCompiled()); return parenCount; }
void incRef() { activeUseCount++; }
void decRef() { JS_ASSERT(activeUseCount > 0); activeUseCount--; }