Bug 892187 - Fix spurious uses of ExclusiveContext->asJSContext(), r=billm.

This commit is contained in:
Brian Hackett
2013-07-15 08:12:40 -06:00
parent 3fd0c0e96a
commit 69eee2d4f4
19 changed files with 154 additions and 74 deletions

View File

@@ -36,6 +36,10 @@ using mozilla::RangedPtr;
const char *
js::AtomToPrintableString(ExclusiveContext *cx, JSAtom *atom, JSAutoByteString *bytes)
{
// The only uses for this method when running off the main thread are for
// parse errors/warnings, which will not actually be reported in such cases.
if (!cx->isJSContext())
return "";
return js_ValueToPrintable(cx->asJSContext(), StringValue(atom), bytes);
}
@@ -334,14 +338,21 @@ js::AtomizeString(ExclusiveContext *cx, JSString *str,
return &atom;
}
const jschar *chars = str->getChars(cx->asJSContext());
if (!chars)
return NULL;
const jschar *chars;
if (str->isLinear()) {
chars = str->asLinear().chars();
} else {
if (!cx->shouldBeJSContext())
return NULL;
chars = str->getChars(cx->asJSContext());
if (!chars)
return NULL;
}
if (JSAtom *atom = AtomizeAndCopyChars<NoGC>(cx, chars, str->length(), ib))
return atom;
if (!allowGC)
if (!cx->isJSContext() || !allowGC)
return NULL;
JSLinearString *linear = str->ensureLinear(cx->asJSContext());