Bug 928050 - Don't GC during atomization, r=billm.

This commit is contained in:
Brian Hackett 2013-11-09 19:53:53 -07:00
parent 23130f7a48
commit ce2b2de8da
27 changed files with 85 additions and 172 deletions

View File

@ -774,7 +774,7 @@ HashableValue::setValue(JSContext *cx, HandleValue v)
{
if (v.isString()) {
// Atomize so that hash() and operator==() are fast and infallible.
JSString *str = AtomizeString<CanGC>(cx, v.toString(), DoNotInternAtom);
JSString *str = AtomizeString(cx, v.toString(), DoNotInternAtom);
if (!str)
return false;
value = StringValue(str);

View File

@ -2008,7 +2008,7 @@ TypedDatum::obj_deleteElement(JSContext *cx, HandleObject obj, uint32_t index,
bool *succeeded)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
if (IsOwnId(cx, obj, id))

View File

@ -282,7 +282,7 @@ frontend::CompileScript(ExclusiveContext *cx, LifoAlloc *alloc, HandleObject sco
* Save eval program source in script->atoms[0] for the
* eval cache (see EvalCacheLookup in jsobj.cpp).
*/
JSAtom *atom = AtomizeString<CanGC>(cx, source);
JSAtom *atom = AtomizeString(cx, source);
jsatomid _;
if (!atom || !bce.makeAtomIndex(atom, &_))
return nullptr;

View File

@ -91,7 +91,7 @@ FoldType(ExclusiveContext *cx, ParseNode *pn, ParseNodeKind kind)
case PNK_STRING:
if (pn->isKind(PNK_NUMBER)) {
pn->pn_atom = NumberToAtom<CanGC>(cx, pn->pn_dval);
pn->pn_atom = NumberToAtom(cx, pn->pn_dval);
if (!pn->pn_atom)
return false;
pn->setKind(PNK_STRING);
@ -593,7 +593,7 @@ Fold(ExclusiveContext *cx, ParseNode **pnp,
JS_ASSERT(*chars == 0);
/* Atomize the result string and mutate pn to refer to it. */
pn->pn_atom = AtomizeString<CanGC>(cx, str);
pn->pn_atom = AtomizeString(cx, str);
if (!pn->pn_atom)
return false;
pn->setKind(PNK_STRING);
@ -614,7 +614,7 @@ Fold(ExclusiveContext *cx, ParseNode **pnp,
RootedString str(cx, ConcatStrings<CanGC>(cx, left, right));
if (!str)
return false;
pn->pn_atom = AtomizeString<CanGC>(cx, str);
pn->pn_atom = AtomizeString(cx, str);
if (!pn->pn_atom)
return false;
pn->setKind(PNK_STRING);

View File

@ -909,7 +909,7 @@ TokenStream::newToken(ptrdiff_t adjust)
JS_ALWAYS_INLINE JSAtom *
TokenStream::atomize(ExclusiveContext *cx, CharBuffer &cb)
{
return AtomizeChars<CanGC>(cx, cb.begin(), cb.length());
return AtomizeChars(cx, cb.begin(), cb.length());
}
#ifdef DEBUG
@ -1178,7 +1178,7 @@ TokenStream::getTokenInternal(Modifier modifier)
goto out;
}
JSAtom *atom = AtomizeChars<CanGC>(cx, chars, length);
JSAtom *atom = AtomizeChars(cx, chars, length);
if (!atom)
goto error;
tp->type = TOK_NAME;

View File

@ -478,7 +478,7 @@ DeserializeName(ExclusiveContext *cx, const uint8_t *cursor, PropertyName **name
src = (jschar *)cursor;
}
JSAtom *atom = AtomizeChars<CanGC>(cx, src, length);
JSAtom *atom = AtomizeChars(cx, src, length);
if (!atom)
return nullptr;

View File

@ -617,7 +617,7 @@ GetDynamicName(JSContext *cx, JSObject *scopeChain, JSString *str, Value *vp)
if (str->isAtom()) {
atom = &str->asAtom();
} else {
atom = AtomizeString<NoGC>(cx, str);
atom = AtomizeString(cx, str);
if (!atom) {
vp->setUndefined();
return;

View File

@ -15,7 +15,7 @@ BEGIN_TEST(testStringBuffer_finishString)
JSString *str = JS_NewStringCopyZ(cx, "foopy");
CHECK(str);
JS::Rooted<JSAtom*> atom(cx, js::AtomizeString<js::CanGC>(cx, str));
JS::Rooted<JSAtom*> atom(cx, js::AtomizeString(cx, str));
CHECK(atom);
js::StringBuffer buffer(cx);

View File

@ -2766,7 +2766,7 @@ JS_LookupElement(JSContext *cx, JSObject *objArg, uint32_t index, MutableHandleV
RootedObject obj(cx, objArg);
CHECK_REQUEST(cx);
RootedId id(cx);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
return JS_LookupPropertyById(cx, obj, id, vp);
}
@ -2784,7 +2784,7 @@ JS_LookupUCProperty(JSContext *cx, JSObject *objArg, const jschar *name, size_t
MutableHandleValue vp)
{
RootedObject obj(cx, objArg);
JSAtom *atom = AtomizeChars<CanGC>(cx, name, AUTO_NAMELEN(name, namelen));
JSAtom *atom = AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen));
return atom && JS_LookupPropertyById(cx, obj, AtomToId(atom), vp);
}
@ -2841,7 +2841,7 @@ JS_HasElement(JSContext *cx, JSObject *objArg, uint32_t index, bool *foundp)
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
RootedId id(cx);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
return JS_HasPropertyById(cx, obj, id, foundp);
}
@ -2858,7 +2858,7 @@ JS_PUBLIC_API(bool)
JS_HasUCProperty(JSContext *cx, JSObject *objArg, const jschar *name, size_t namelen, bool *foundp)
{
RootedObject obj(cx, objArg);
JSAtom *atom = AtomizeChars<CanGC>(cx, name, AUTO_NAMELEN(name, namelen));
JSAtom *atom = AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen));
return atom && JS_HasPropertyById(cx, obj, AtomToId(atom), foundp);
}
@ -2897,7 +2897,7 @@ JS_AlreadyHasOwnElement(JSContext *cx, JSObject *objArg, uint32_t index, bool *f
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
RootedId id(cx);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
return JS_AlreadyHasOwnPropertyById(cx, obj, id, foundp);
}
@ -2915,7 +2915,7 @@ JS_AlreadyHasOwnUCProperty(JSContext *cx, JSObject *objArg, const jschar *name,
bool *foundp)
{
RootedObject obj(cx, objArg);
JSAtom *atom = AtomizeChars<CanGC>(cx, name, AUTO_NAMELEN(name, namelen));
JSAtom *atom = AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen));
return atom && JS_AlreadyHasOwnPropertyById(cx, obj, AtomToId(atom), foundp);
}
@ -3039,7 +3039,7 @@ JS_DefineElement(JSContext *cx, JSObject *objArg, uint32_t index, jsval valueArg
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
RootedId id(cx);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
return DefinePropertyById(cx, obj, id, value, GetterWrapper(getter),
SetterWrapper(setter), attrs, 0, 0);
@ -3095,7 +3095,7 @@ DefineUCProperty(JSContext *cx, HandleObject obj, const jschar *name, size_t nam
{
RootedValue value(cx, value_);
AutoRooterGetterSetter gsRoot(cx, attrs, &getter, &setter);
JSAtom *atom = AtomizeChars<CanGC>(cx, name, AUTO_NAMELEN(name, namelen));
JSAtom *atom = AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen));
if (!atom)
return false;
RootedId id(cx, AtomToId(atom));
@ -3357,7 +3357,7 @@ JS_GetUCProperty(JSContext *cx, JSObject *objArg, const jschar *name, size_t nam
MutableHandleValue vp)
{
RootedObject obj(cx, objArg);
JSAtom *atom = AtomizeChars<CanGC>(cx, name, AUTO_NAMELEN(name, namelen));
JSAtom *atom = AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen));
return atom && JS_GetPropertyById(cx, obj, AtomToId(atom), vp);
}
@ -3400,7 +3400,7 @@ JS_SetUCProperty(JSContext *cx, JSObject *objArg, const jschar *name, size_t nam
HandleValue v)
{
RootedObject obj(cx, objArg);
JSAtom *atom = AtomizeChars<CanGC>(cx, name, AUTO_NAMELEN(name, namelen));
JSAtom *atom = AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen));
return atom && JS_SetPropertyById(cx, obj, AtomToId(atom), v);
}
@ -3475,7 +3475,7 @@ JS_DeleteUCProperty2(JSContext *cx, JSObject *objArg, const jschar *name, size_t
assertSameCompartment(cx, obj);
JSAutoResolveFlags rf(cx, 0);
JSAtom *atom = AtomizeChars<CanGC>(cx, name, AUTO_NAMELEN(name, namelen));
JSAtom *atom = AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen));
if (!atom)
return false;
@ -4140,7 +4140,7 @@ JS_DefineUCFunction(JSContext *cx, JSObject *objArg,
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj);
JSAtom *atom = AtomizeChars<CanGC>(cx, name, AUTO_NAMELEN(name, namelen));
JSAtom *atom = AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen));
if (!atom)
return nullptr;
Rooted<jsid> id(cx, AtomToId(atom));
@ -5167,7 +5167,7 @@ JS_InternJSString(JSContext *cx, HandleString str)
{
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
JSAtom *atom = AtomizeString<CanGC>(cx, str, InternAtom);
JSAtom *atom = AtomizeString(cx, str, InternAtom);
JS_ASSERT_IF(atom, JS_StringHasBeenInterned(cx, atom));
return atom;
}
@ -5219,7 +5219,7 @@ JS_InternUCStringN(JSContext *cx, const jschar *s, size_t length)
{
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
JSAtom *atom = AtomizeChars<CanGC>(cx, s, length, InternAtom);
JSAtom *atom = AtomizeChars(cx, s, length, InternAtom);
JS_ASSERT_IF(atom, JS_StringHasBeenInterned(cx, atom));
return atom;
}
@ -6067,13 +6067,13 @@ BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
JS_PUBLIC_API(bool)
JS_IndexToId(JSContext *cx, uint32_t index, MutableHandleId id)
{
return IndexToId(cx, index, id);
return IndexToId(cx, index, id.address());
}
JS_PUBLIC_API(bool)
JS_CharsToId(JSContext* cx, JS::TwoByteChars chars, MutableHandleId idp)
{
RootedAtom atom(cx, AtomizeChars<CanGC>(cx, chars.start().get(), chars.length()));
RootedAtom atom(cx, AtomizeChars(cx, chars.start().get(), chars.length()));
if (!atom)
return false;
#ifdef DEBUG

View File

@ -137,7 +137,7 @@ static bool
DoubleIndexToId(JSContext *cx, double index, MutableHandleId id)
{
if (index == uint32_t(index))
return IndexToId(cx, uint32_t(index), id);
return IndexToId(cx, uint32_t(index), id.address());
Value tmp = DoubleValue(index);
return ValueToId<CanGC>(cx, HandleValue::fromMarkedLocation(&tmp), id);
@ -716,7 +716,7 @@ js::ArraySetLength(typename ExecutionModeTraits<mode>::ContextType cxArg,
// returned from the function before step 15 above.
JSContext *cx = cxArg->asJSContext();
RootedId elementId(cx);
if (!IndexToId(cx, newLen - 1, &elementId))
if (!IndexToId(cx, newLen - 1, elementId.address()))
return false;
return arr->reportNotConfigurable(cx, elementId);
}

View File

@ -230,7 +230,6 @@ AtomIsInterned(JSContext *cx, JSAtom *atom)
* as a new JSAtom's storage without copying. The contract is that the caller no
* longer owns the memory and this method is responsible for freeing the memory.
*/
template <AllowGC allowGC>
JS_ALWAYS_INLINE
static JSAtom *
AtomizeAndTakeOwnership(ExclusiveContext *cx, jschar *tbchars, size_t length, InternBehavior ib)
@ -262,9 +261,10 @@ AtomizeAndTakeOwnership(ExclusiveContext *cx, jschar *tbchars, size_t length, In
AutoCompartment ac(cx, cx->atomsCompartment());
JSFlatString *flat = js_NewString<allowGC>(cx, tbchars, length);
JSFlatString *flat = js_NewString<NoGC>(cx, tbchars, length);
if (!flat) {
js_free(tbchars);
js_ReportOutOfMemory(cx);
return nullptr;
}
@ -280,7 +280,6 @@ AtomizeAndTakeOwnership(ExclusiveContext *cx, jschar *tbchars, size_t length, In
}
/* |tbchars| must not point into an inline or short string. */
template <AllowGC allowGC>
JS_ALWAYS_INLINE
static JSAtom *
AtomizeAndCopyChars(ExclusiveContext *cx, const jschar *tbchars, size_t length, InternBehavior ib)
@ -308,23 +307,23 @@ AtomizeAndCopyChars(ExclusiveContext *cx, const jschar *tbchars, size_t length,
AutoCompartment ac(cx, cx->atomsCompartment());
JSFlatString *flat = js_NewStringCopyN<allowGC>(cx, tbchars, length);
if (!flat)
JSFlatString *flat = js_NewStringCopyN<NoGC>(cx, tbchars, length);
if (!flat) {
js_ReportOutOfMemory(cx);
return nullptr;
}
JSAtom *atom = flat->morphAtomizedStringIntoAtom();
if (!atoms.relookupOrAdd(p, AtomHasher::Lookup(tbchars, length),
AtomStateEntry(atom, bool(ib)))) {
if (allowGC)
js_ReportOutOfMemory(cx); /* SystemAllocPolicy does not report OOM. */
js_ReportOutOfMemory(cx); /* SystemAllocPolicy does not report OOM. */
return nullptr;
}
return atom;
}
template <AllowGC allowGC>
JSAtom *
js::AtomizeString(ExclusiveContext *cx, JSString *str,
js::InternBehavior ib /* = js::DoNotInternAtom */)
@ -349,29 +348,11 @@ js::AtomizeString(ExclusiveContext *cx, JSString *str,
if (!chars)
return nullptr;
if (JSAtom *atom = AtomizeAndCopyChars<NoGC>(cx, chars, str->length(), ib))
return atom;
if (!cx->isJSContext() || !allowGC)
return nullptr;
JSLinearString *linear = str->ensureLinear(cx->asJSContext());
if (!linear)
return nullptr;
JS_ASSERT(linear->length() <= JSString::MAX_LENGTH);
return AtomizeAndCopyChars<CanGC>(cx, linear->chars(), linear->length(), ib);
return AtomizeAndCopyChars(cx, chars, str->length(), ib);
}
template JSAtom *
js::AtomizeString<CanGC>(ExclusiveContext *cx, JSString *str, InternBehavior ib);
template JSAtom *
js::AtomizeString<NoGC>(ExclusiveContext *cx, JSString *str, InternBehavior ib);
template <AllowGC allowGC>
JSAtom *
js::AtomizeMaybeGC(ExclusiveContext *cx, const char *bytes, size_t length, InternBehavior ib)
js::Atomize(ExclusiveContext *cx, const char *bytes, size_t length, InternBehavior ib)
{
CHECK_REQUEST(cx);
@ -389,30 +370,15 @@ js::AtomizeMaybeGC(ExclusiveContext *cx, const char *bytes, size_t length, Inter
*/
jschar inflated[ATOMIZE_BUF_MAX];
InflateStringToBuffer(bytes, length, inflated);
return AtomizeAndCopyChars<allowGC>(cx, inflated, length, ib);
return AtomizeAndCopyChars(cx, inflated, length, ib);
}
jschar *tbcharsZ = InflateString(cx, bytes, &length);
if (!tbcharsZ)
return nullptr;
return AtomizeAndTakeOwnership<allowGC>(cx, tbcharsZ, length, ib);
return AtomizeAndTakeOwnership(cx, tbcharsZ, length, ib);
}
template JSAtom *
js::AtomizeMaybeGC<CanGC>(ExclusiveContext *cx, const char *bytes, size_t length,
InternBehavior ib);
template JSAtom *
js::AtomizeMaybeGC<NoGC>(ExclusiveContext *cx, const char *bytes, size_t length,
InternBehavior ib);
JSAtom *
js::Atomize(ExclusiveContext *cx, const char *bytes, size_t length, InternBehavior ib)
{
return AtomizeMaybeGC<CanGC>(cx, bytes, length, ib);
}
template <AllowGC allowGC>
JSAtom *
js::AtomizeChars(ExclusiveContext *cx, const jschar *chars, size_t length, InternBehavior ib)
{
@ -421,21 +387,11 @@ js::AtomizeChars(ExclusiveContext *cx, const jschar *chars, size_t length, Inter
if (!JSString::validateLength(cx, length))
return nullptr;
return AtomizeAndCopyChars<allowGC>(cx, chars, length, ib);
return AtomizeAndCopyChars(cx, chars, length, ib);
}
template JSAtom *
js::AtomizeChars<CanGC>(ExclusiveContext *cx,
const jschar *chars, size_t length, InternBehavior ib);
template JSAtom *
js::AtomizeChars<NoGC>(ExclusiveContext *cx,
const jschar *chars, size_t length, InternBehavior ib);
template <AllowGC allowGC>
bool
js::IndexToIdSlow(ExclusiveContext *cx, uint32_t index,
typename MaybeRooted<jsid, allowGC>::MutableHandleType idp)
js::IndexToIdSlow(ExclusiveContext *cx, uint32_t index, jsid *idp)
{
JS_ASSERT(index > JSID_INT_MAX);
@ -443,20 +399,14 @@ js::IndexToIdSlow(ExclusiveContext *cx, uint32_t index,
RangedPtr<jschar> end(ArrayEnd(buf), buf, ArrayEnd(buf));
RangedPtr<jschar> start = BackfillIndexInCharBuffer(index, end);
JSAtom *atom = AtomizeChars<allowGC>(cx, start.get(), end - start);
JSAtom *atom = AtomizeChars(cx, start.get(), end - start);
if (!atom)
return false;
idp.set(JSID_FROM_BITS((size_t)atom));
*idp = JSID_FROM_BITS((size_t)atom);
return true;
}
template bool
js::IndexToIdSlow<CanGC>(ExclusiveContext *cx, uint32_t index, MutableHandleId idp);
template bool
js::IndexToIdSlow<NoGC>(ExclusiveContext *cx, uint32_t index, FakeMutableHandle<jsid> idp);
template <AllowGC allowGC>
static JSAtom *
ToAtomSlow(ExclusiveContext *cx, typename MaybeRooted<Value, allowGC>::HandleType arg)
@ -474,11 +424,11 @@ ToAtomSlow(ExclusiveContext *cx, typename MaybeRooted<Value, allowGC>::HandleTyp
}
if (v.isString())
return AtomizeString<allowGC>(cx, v.toString());
return AtomizeString(cx, v.toString());
if (v.isInt32())
return Int32ToAtom<allowGC>(cx, v.toInt32());
return Int32ToAtom(cx, v.toInt32());
if (v.isDouble())
return NumberToAtom<allowGC>(cx, v.toDouble());
return NumberToAtom(cx, v.toDouble());
if (v.isBoolean())
return v.toBoolean() ? cx->names().true_ : cx->names().false_;
if (v.isNull())
@ -497,8 +447,7 @@ js::ToAtom(ExclusiveContext *cx, typename MaybeRooted<Value, allowGC>::HandleTyp
if (str->isAtom())
return &str->asAtom();
JS::Anchor<JSString *> anchor(str);
return AtomizeString<allowGC>(cx, str);
return AtomizeString(cx, str);
}
template JSAtom *
@ -533,7 +482,7 @@ js::XDRAtom(XDRState<mode> *xdr, MutableHandleAtom atomp)
#if IS_LITTLE_ENDIAN
/* Directly access the little endian chars in the XDR buffer. */
const jschar *chars = reinterpret_cast<const jschar *>(xdr->buf.read(nchars * sizeof(jschar)));
atom = AtomizeChars<CanGC>(cx, chars, nchars);
atom = AtomizeChars(cx, chars, nchars);
#else
/*
* We must copy chars to a temporary buffer to convert between little and

View File

@ -199,21 +199,14 @@ enum InternBehavior
InternAtom = true
};
template <AllowGC allowGC>
extern JSAtom *
AtomizeMaybeGC(ExclusiveContext *cx, const char *bytes, size_t length,
js::InternBehavior ib = js::DoNotInternAtom);
extern JSAtom *
Atomize(ExclusiveContext *cx, const char *bytes, size_t length,
js::InternBehavior ib = js::DoNotInternAtom);
template <AllowGC allowGC>
extern JSAtom *
AtomizeChars(ExclusiveContext *cx, const jschar *chars, size_t length,
js::InternBehavior ib = js::DoNotInternAtom);
template <AllowGC allowGC>
extern JSAtom *
AtomizeString(ExclusiveContext *cx, JSString *str, js::InternBehavior ib = js::DoNotInternAtom);

View File

@ -104,22 +104,18 @@ BackfillIndexInCharBuffer(uint32_t index, mozilla::RangedPtr<T> end)
return end;
}
template <AllowGC allowGC>
bool
IndexToIdSlow(ExclusiveContext *cx, uint32_t index,
typename MaybeRooted<jsid, allowGC>::MutableHandleType idp);
IndexToIdSlow(ExclusiveContext *cx, uint32_t index, jsid *idp);
inline bool
IndexToId(ExclusiveContext *cx, uint32_t index, MutableHandleId idp)
IndexToId(ExclusiveContext *cx, uint32_t index, jsid *idp)
{
MaybeCheckStackRoots(cx);
if (index <= JSID_INT_MAX) {
idp.set(INT_TO_JSID(index));
*idp = INT_TO_JSID(index);
return true;
}
return IndexToIdSlow<CanGC>(cx, index, idp);
return IndexToIdSlow(cx, index, idp);
}
inline bool
@ -133,15 +129,6 @@ IndexToIdPure(uint32_t index, jsid *idp)
return false;
}
inline bool
IndexToIdNoGC(JSContext *cx, uint32_t index, jsid *idp)
{
if (IndexToIdPure(index, idp))
return true;
return IndexToIdSlow<NoGC>(cx, index, idp);
}
static JS_ALWAYS_INLINE JSFlatString *
IdToString(JSContext *cx, jsid id)
{

View File

@ -1117,7 +1117,7 @@ bool
js_SuppressDeletedElement(JSContext *cx, HandleObject obj, uint32_t index)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
return js_SuppressDeletedProperty(cx, obj, id);
}

View File

@ -622,18 +622,17 @@ js::Int32ToString<CanGC>(ThreadSafeContext *cx, int32_t si);
template JSFlatString *
js::Int32ToString<NoGC>(ThreadSafeContext *cx, int32_t si);
template <AllowGC allowGC>
JSAtom *
js::Int32ToAtom(ExclusiveContext *cx, int32_t si)
{
if (JSFlatString *str = LookupInt32ToString(cx, si))
return js::AtomizeString<allowGC>(cx, str);
return js::AtomizeString(cx, str);
char buffer[JSShortString::MAX_SHORT_LENGTH + 1];
size_t length;
char *start = BackfillInt32InBuffer(si, buffer, JSShortString::MAX_SHORT_LENGTH + 1, &length);
JSAtom *atom = AtomizeMaybeGC<allowGC>(cx, start, length);
JSAtom *atom = Atomize(cx, start, length);
if (!atom)
return nullptr;
@ -641,12 +640,6 @@ js::Int32ToAtom(ExclusiveContext *cx, int32_t si)
return atom;
}
template JSAtom *
js::Int32ToAtom<CanGC>(ExclusiveContext *cx, int32_t si);
template JSAtom *
js::Int32ToAtom<NoGC>(ExclusiveContext *cx, int32_t si);
/* Returns a non-nullptr pointer to inside cbuf. */
static char *
IntToCString(ToCStringBuf *cbuf, int i, size_t *len, int base = 10)
@ -1393,16 +1386,15 @@ js::NumberToString<CanGC>(ThreadSafeContext *cx, double d);
template JSString *
js::NumberToString<NoGC>(ThreadSafeContext *cx, double d);
template <AllowGC allowGC>
JSAtom *
js::NumberToAtom(ExclusiveContext *cx, double d)
{
int32_t si;
if (mozilla::DoubleIsInt32(d, &si))
return Int32ToAtom<allowGC>(cx, si);
return Int32ToAtom(cx, si);
if (JSFlatString *str = LookupDtoaCache(cx, d))
return AtomizeString<allowGC>(cx, str);
return AtomizeString(cx, str);
ToCStringBuf cbuf;
char *numStr = FracNumberToCString(cx, &cbuf, d);
@ -1413,7 +1405,7 @@ js::NumberToAtom(ExclusiveContext *cx, double d)
JS_ASSERT(!cbuf.dbuf && numStr >= cbuf.sbuf && numStr < cbuf.sbuf + cbuf.sbufSize);
size_t length = strlen(numStr);
JSAtom *atom = AtomizeMaybeGC<allowGC>(cx, numStr, length);
JSAtom *atom = Atomize(cx, numStr, length);
if (!atom)
return nullptr;
@ -1422,12 +1414,6 @@ js::NumberToAtom(ExclusiveContext *cx, double d)
return atom;
}
template JSAtom *
js::NumberToAtom<CanGC>(ExclusiveContext *cx, double d);
template JSAtom *
js::NumberToAtom<NoGC>(ExclusiveContext *cx, double d);
JSFlatString *
js::NumberToString(JSContext *cx, double d)
{

View File

@ -52,7 +52,6 @@ template <js::AllowGC allowGC>
extern JSString *
NumberToString(js::ThreadSafeContext *cx, double d);
template <js::AllowGC allowGC>
extern JSAtom *
NumberToAtom(js::ExclusiveContext *cx, double d);
@ -60,7 +59,6 @@ template <AllowGC allowGC>
extern JSFlatString *
Int32ToString(ThreadSafeContext *cx, int32_t i);
template <AllowGC allowGC>
extern JSAtom *
Int32ToAtom(ExclusiveContext *cx, int32_t si);

View File

@ -1685,7 +1685,7 @@ JSObject::nonNativeSetElement(JSContext *cx, HandleObject obj,
{
if (JS_UNLIKELY(obj->watched())) {
RootedId id(cx);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
WatchpointMap *wpmap = cx->compartment()->watchpointMap;
@ -3323,7 +3323,7 @@ baseops::DefineElement(ExclusiveContext *cx, HandleObject obj, uint32_t index, H
AutoRooterGetterSetter gsRoot(cx, attrs, &getter, &setter);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
return DefineNativeProperty(cx, obj, id, value, getter, setter, attrs, 0, 0);
@ -3913,7 +3913,7 @@ baseops::LookupElement(JSContext *cx, HandleObject obj, uint32_t index,
MutableHandleObject objp, MutableHandleShape propp)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
return LookupPropertyWithFlagsInline<CanGC>(cx, obj, id, cx->resolveFlags, objp, propp);
@ -4488,7 +4488,7 @@ baseops::GetElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint
MutableHandleValue vp)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
/* This call site is hot -- use the always-inlined variant of js_GetPropertyHelper(). */
@ -4869,7 +4869,7 @@ baseops::SetElementHelper(JSContext *cx, HandleObject obj, HandleObject receiver
unsigned defineHow, MutableHandleValue vp, bool strict)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
return baseops::SetPropertyHelper<SequentialExecution>(cx, obj, receiver, id, defineHow, vp,
strict);
@ -4974,7 +4974,7 @@ bool
baseops::DeleteElement(JSContext *cx, HandleObject obj, uint32_t index, bool *succeeded)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
return baseops::DeleteGeneric(cx, obj, id, succeeded);
}

View File

@ -51,7 +51,7 @@ JSObject::deleteProperty(JSContext *cx, js::HandleObject obj, js::HandleProperty
/* static */ inline bool
JSObject::deleteElement(JSContext *cx, js::HandleObject obj, uint32_t index, bool *succeeded)
{
JS::RootedId id(cx);
jsid id;
if (!js::IndexToId(cx, index, &id))
return false;
js::types::MarkTypePropertyConfigured(cx, obj, id);
@ -564,7 +564,7 @@ JSObject::getElement(JSContext *cx, js::HandleObject obj, js::HandleObject recei
return op(cx, obj, receiver, index, vp);
JS::RootedId id(cx);
if (!js::IndexToId(cx, index, &id))
if (!js::IndexToId(cx, index, id.address()))
return false;
return getGeneric(cx, obj, receiver, id, vp);
}
@ -578,7 +578,7 @@ JSObject::getElementNoGC(JSContext *cx, JSObject *obj, JSObject *receiver,
return false;
jsid id;
if (!js::IndexToIdNoGC(cx, index, &id))
if (!js::IndexToId(cx, index, &id))
return false;
return getGenericNoGC(cx, obj, receiver, id, vp);
}
@ -598,7 +598,7 @@ JSObject::getElementIfPresent(JSContext *cx, js::HandleObject obj, js::HandleObj
* doing index-to-id conversions, we can use those here.
*/
JS::RootedId id(cx);
if (!js::IndexToId(cx, index, &id))
if (!js::IndexToId(cx, index, id.address()))
return false;
JS::RootedObject obj2(cx);

View File

@ -688,7 +688,7 @@ Walk(JSContext *cx, HandleObject holder, HandleId name, HandleValue reviver, Mut
RootedId id(cx);
RootedValue newElement(cx);
for (uint32_t i = 0; i < length; i++) {
if (!IndexToId(cx, i, &id))
if (!IndexToId(cx, i, id.address()))
return false;
/* Step 2a(iii)(1). */

View File

@ -96,7 +96,7 @@ JSONParser::readString()
size_t length = current - start;
current++;
JSFlatString *str = (ST == JSONParser::PropertyName)
? AtomizeChars<CanGC>(cx, start.get(), length)
? AtomizeChars(cx, start.get(), length)
: js_NewStringCopyN<CanGC>(cx, start.get(), length);
if (!str)
return token(OOM);

View File

@ -156,7 +156,7 @@ BaseProxyHandler::getElementIfPresent(JSContext *cx, HandleObject proxy, HandleO
uint32_t index, MutableHandleValue vp, bool *present)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
assertEnteredPolicy(cx, proxy, id);
@ -2525,7 +2525,7 @@ Proxy::getElementIfPresent(JSContext *cx, HandleObject proxy, HandleObject recei
JS_CHECK_RECURSION(cx, return false);
RootedId id(cx);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
BaseProxyHandler *handler = proxy->as<ProxyObject>().handler();
@ -2811,7 +2811,7 @@ proxy_LookupElement(JSContext *cx, HandleObject obj, uint32_t index,
MutableHandleObject objp, MutableHandleShape propp)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
return proxy_LookupGeneric(cx, obj, id, objp, propp);
}
@ -2851,7 +2851,7 @@ proxy_DefineElement(JSContext *cx, HandleObject obj, uint32_t index, HandleValue
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
return proxy_DefineGeneric(cx, obj, id, value, getter, setter, attrs);
}
@ -2884,7 +2884,7 @@ proxy_GetElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_
MutableHandleValue vp)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
return proxy_GetGeneric(cx, obj, receiver, id, vp);
}
@ -2924,7 +2924,7 @@ proxy_SetElement(JSContext *cx, HandleObject obj, uint32_t index,
MutableHandleValue vp, bool strict)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
return proxy_SetGeneric(cx, obj, id, vp, strict);
}
@ -2979,7 +2979,7 @@ static bool
proxy_DeleteElement(JSContext *cx, HandleObject obj, uint32_t index, bool *succeeded)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
return proxy_DeleteGeneric(cx, obj, id, succeeded);
}

View File

@ -1704,7 +1704,7 @@ class MOZ_STACK_CLASS StringRegExpGuard
if (!arg)
return false;
fm.patstr = AtomizeString<CanGC>(cx, arg);
fm.patstr = AtomizeString(cx, arg);
if (!fm.patstr)
return false;
}

View File

@ -241,7 +241,7 @@ RegExpObject *
RegExpObject::createNoStatics(ExclusiveContext *cx, const jschar *chars, size_t length, RegExpFlag flags,
TokenStream *tokenStream)
{
RootedAtom source(cx, AtomizeChars<CanGC>(cx, chars, length));
RootedAtom source(cx, AtomizeChars(cx, chars, length));
if (!source)
return nullptr;

View File

@ -364,7 +364,7 @@ with_LookupElement(JSContext *cx, HandleObject obj, uint32_t index,
MutableHandleObject objp, MutableHandleShape propp)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
return with_LookupGeneric(cx, obj, id, objp, propp);
}
@ -398,7 +398,7 @@ with_GetElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t
MutableHandleValue vp)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
if (!IndexToId(cx, index, id.address()))
return false;
return with_GetGeneric(cx, obj, receiver, id, vp);
}

View File

@ -219,7 +219,7 @@ JSFlatString::toPropertyName(JSContext *cx)
#endif
if (isAtom())
return asAtom().asPropertyName();
JSAtom *atom = js::AtomizeString<js::CanGC>(cx, this);
JSAtom *atom = js::AtomizeString(cx, this);
if (!atom)
return nullptr;
return atom->asPropertyName();

View File

@ -75,7 +75,7 @@ StringBuffer::finishAtom()
if (length == 0)
return cx->names().empty;
JSAtom *atom = AtomizeChars<CanGC>(cx, cb.begin(), length);
JSAtom *atom = AtomizeChars(cx, cb.begin(), length);
cb.clear();
return atom;
}

View File

@ -1447,7 +1447,7 @@ JSStructuredCloneReader::readId(jsid *idp)
JSString *str = readString(data);
if (!str)
return false;
JSAtom *atom = AtomizeString<CanGC>(context(), str);
JSAtom *atom = AtomizeString(context(), str);
if (!atom)
return false;
*idp = NON_INTEGER_ATOM_TO_JSID(atom);