Bug 885758 - Add ExclusiveContext for use by threads with exclusive access to their compartment, r=billm.
This commit is contained in:
@@ -37,9 +37,9 @@ using mozilla::ArrayLength;
|
||||
using mozilla::RangedPtr;
|
||||
|
||||
const char *
|
||||
js_AtomToPrintableString(JSContext *cx, JSAtom *atom, JSAutoByteString *bytes)
|
||||
js::AtomToPrintableString(ExclusiveContext *cx, JSAtom *atom, JSAutoByteString *bytes)
|
||||
{
|
||||
return js_ValueToPrintable(cx, StringValue(atom), bytes);
|
||||
return js_ValueToPrintable(cx->asJSContext(), StringValue(atom), bytes);
|
||||
}
|
||||
|
||||
const char * const js::TypeStrings[] = {
|
||||
@@ -232,11 +232,11 @@ enum OwnCharsBehavior
|
||||
*/
|
||||
JS_ALWAYS_INLINE
|
||||
static JSAtom *
|
||||
AtomizeAndTakeOwnership(JSContext *cx, jschar *tbchars, size_t length, InternBehavior ib)
|
||||
AtomizeAndTakeOwnership(ExclusiveContext *cx, jschar *tbchars, size_t length, InternBehavior ib)
|
||||
{
|
||||
JS_ASSERT(tbchars[length] == 0);
|
||||
|
||||
if (JSAtom *s = cx->runtime()->staticStrings.lookup(tbchars, length)) {
|
||||
if (JSAtom *s = cx->staticStrings().lookup(tbchars, length)) {
|
||||
js_free(tbchars);
|
||||
return s;
|
||||
}
|
||||
@@ -247,7 +247,7 @@ AtomizeAndTakeOwnership(JSContext *cx, jschar *tbchars, size_t length, InternBeh
|
||||
* unchanged, we need to re-lookup the table position because a last-ditch
|
||||
* GC will potentially free some table entries.
|
||||
*/
|
||||
AtomSet& atoms = cx->runtime()->atoms;
|
||||
AtomSet& atoms = cx->atoms();
|
||||
AtomSet::AddPtr p = atoms.lookupForAdd(AtomHasher::Lookup(tbchars, length));
|
||||
SkipRoot skipHash(cx, &p); /* Prevent the hash from being poisoned. */
|
||||
if (p) {
|
||||
@@ -269,7 +269,7 @@ AtomizeAndTakeOwnership(JSContext *cx, jschar *tbchars, size_t length, InternBeh
|
||||
|
||||
if (!atoms.relookupOrAdd(p, AtomHasher::Lookup(tbchars, length),
|
||||
AtomStateEntry(atom, bool(ib)))) {
|
||||
JS_ReportOutOfMemory(cx); /* SystemAllocPolicy does not report OOM. */
|
||||
js_ReportOutOfMemory(cx); /* SystemAllocPolicy does not report OOM. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -280,9 +280,9 @@ AtomizeAndTakeOwnership(JSContext *cx, jschar *tbchars, size_t length, InternBeh
|
||||
template <AllowGC allowGC>
|
||||
JS_ALWAYS_INLINE
|
||||
static JSAtom *
|
||||
AtomizeAndCopyChars(JSContext *cx, const jschar *tbchars, size_t length, InternBehavior ib)
|
||||
AtomizeAndCopyChars(ExclusiveContext *cx, const jschar *tbchars, size_t length, InternBehavior ib)
|
||||
{
|
||||
if (JSAtom *s = cx->runtime()->staticStrings.lookup(tbchars, length))
|
||||
if (JSAtom *s = cx->staticStrings().lookup(tbchars, length))
|
||||
return s;
|
||||
|
||||
/*
|
||||
@@ -292,7 +292,7 @@ AtomizeAndCopyChars(JSContext *cx, const jschar *tbchars, size_t length, InternB
|
||||
* GC will potentially free some table entries.
|
||||
*/
|
||||
|
||||
AtomSet& atoms = cx->runtime()->atoms;
|
||||
AtomSet& atoms = cx->atoms();
|
||||
AtomSet::AddPtr p = atoms.lookupForAdd(AtomHasher::Lookup(tbchars, length));
|
||||
SkipRoot skipHash(cx, &p); /* Prevent the hash from being poisoned. */
|
||||
if (p) {
|
||||
@@ -311,7 +311,7 @@ AtomizeAndCopyChars(JSContext *cx, const jschar *tbchars, size_t length, InternB
|
||||
|
||||
if (!atoms.relookupOrAdd(p, AtomHasher::Lookup(tbchars, length),
|
||||
AtomStateEntry(atom, bool(ib)))) {
|
||||
JS_ReportOutOfMemory(cx); /* SystemAllocPolicy does not report OOM. */
|
||||
js_ReportOutOfMemory(cx); /* SystemAllocPolicy does not report OOM. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -320,7 +320,8 @@ AtomizeAndCopyChars(JSContext *cx, const jschar *tbchars, size_t length, InternB
|
||||
|
||||
template <AllowGC allowGC>
|
||||
JSAtom *
|
||||
js::AtomizeString(JSContext *cx, JSString *str, js::InternBehavior ib /* = js::DoNotInternAtom */)
|
||||
js::AtomizeString(ExclusiveContext *cx, JSString *str,
|
||||
js::InternBehavior ib /* = js::DoNotInternAtom */)
|
||||
{
|
||||
if (str->isAtom()) {
|
||||
JSAtom &atom = str->asAtom();
|
||||
@@ -328,7 +329,7 @@ js::AtomizeString(JSContext *cx, JSString *str, js::InternBehavior ib /* = js::D
|
||||
if (ib != InternAtom || js::StaticStrings::isStatic(&atom))
|
||||
return &atom;
|
||||
|
||||
AtomSet::Ptr p = cx->runtime()->atoms.lookup(AtomHasher::Lookup(&atom));
|
||||
AtomSet::Ptr p = cx->atoms().lookup(AtomHasher::Lookup(&atom));
|
||||
JS_ASSERT(p); /* Non-static atom must exist in atom state set. */
|
||||
JS_ASSERT(p->asPtr() == &atom);
|
||||
JS_ASSERT(ib == InternAtom);
|
||||
@@ -336,7 +337,7 @@ js::AtomizeString(JSContext *cx, JSString *str, js::InternBehavior ib /* = js::D
|
||||
return &atom;
|
||||
}
|
||||
|
||||
const jschar *chars = str->getChars(cx);
|
||||
const jschar *chars = str->getChars(cx->asJSContext());
|
||||
if (!chars)
|
||||
return NULL;
|
||||
|
||||
@@ -346,7 +347,7 @@ js::AtomizeString(JSContext *cx, JSString *str, js::InternBehavior ib /* = js::D
|
||||
if (!allowGC)
|
||||
return NULL;
|
||||
|
||||
JSLinearString *linear = str->ensureLinear(cx);
|
||||
JSLinearString *linear = str->ensureLinear(cx->asJSContext());
|
||||
if (!linear)
|
||||
return NULL;
|
||||
|
||||
@@ -355,13 +356,13 @@ js::AtomizeString(JSContext *cx, JSString *str, js::InternBehavior ib /* = js::D
|
||||
}
|
||||
|
||||
template JSAtom *
|
||||
js::AtomizeString<CanGC>(JSContext *cx, JSString *str, js::InternBehavior ib);
|
||||
js::AtomizeString<CanGC>(ExclusiveContext *cx, JSString *str, InternBehavior ib);
|
||||
|
||||
template JSAtom *
|
||||
js::AtomizeString<NoGC>(JSContext *cx, JSString *str, js::InternBehavior ib);
|
||||
js::AtomizeString<NoGC>(ExclusiveContext *cx, JSString *str, InternBehavior ib);
|
||||
|
||||
JSAtom *
|
||||
js::Atomize(JSContext *cx, const char *bytes, size_t length, InternBehavior ib)
|
||||
js::Atomize(ExclusiveContext *cx, const char *bytes, size_t length, InternBehavior ib)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
@@ -379,7 +380,11 @@ js::Atomize(JSContext *cx, const char *bytes, size_t length, InternBehavior ib)
|
||||
*/
|
||||
jschar inflated[ATOMIZE_BUF_MAX];
|
||||
size_t inflatedLength = ATOMIZE_BUF_MAX - 1;
|
||||
InflateStringToBuffer(cx, bytes, length, inflated, &inflatedLength);
|
||||
if (!InflateStringToBuffer(cx->maybeJSContext(),
|
||||
bytes, length, inflated, &inflatedLength))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return AtomizeAndCopyChars<CanGC>(cx, inflated, inflatedLength, ib);
|
||||
}
|
||||
|
||||
@@ -391,7 +396,7 @@ js::Atomize(JSContext *cx, const char *bytes, size_t length, InternBehavior ib)
|
||||
|
||||
template <AllowGC allowGC>
|
||||
JSAtom *
|
||||
js::AtomizeChars(JSContext *cx, const jschar *chars, size_t length, InternBehavior ib)
|
||||
js::AtomizeChars(ExclusiveContext *cx, const jschar *chars, size_t length, InternBehavior ib)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
@@ -402,14 +407,16 @@ js::AtomizeChars(JSContext *cx, const jschar *chars, size_t length, InternBehavi
|
||||
}
|
||||
|
||||
template JSAtom *
|
||||
js::AtomizeChars<CanGC>(JSContext *cx, const jschar *chars, size_t length, InternBehavior ib);
|
||||
js::AtomizeChars<CanGC>(ExclusiveContext *cx,
|
||||
const jschar *chars, size_t length, InternBehavior ib);
|
||||
|
||||
template JSAtom *
|
||||
js::AtomizeChars<NoGC>(JSContext *cx, const jschar *chars, size_t length, InternBehavior ib);
|
||||
js::AtomizeChars<NoGC>(ExclusiveContext *cx,
|
||||
const jschar *chars, size_t length, InternBehavior ib);
|
||||
|
||||
template <AllowGC allowGC>
|
||||
bool
|
||||
js::IndexToIdSlow(JSContext *cx, uint32_t index,
|
||||
js::IndexToIdSlow(ExclusiveContext *cx, uint32_t index,
|
||||
typename MaybeRooted<jsid, allowGC>::MutableHandleType idp)
|
||||
{
|
||||
JS_ASSERT(index > JSID_INT_MAX);
|
||||
@@ -427,14 +434,14 @@ js::IndexToIdSlow(JSContext *cx, uint32_t index,
|
||||
}
|
||||
|
||||
template bool
|
||||
js::IndexToIdSlow<CanGC>(JSContext *cx, uint32_t index, MutableHandleId idp);
|
||||
js::IndexToIdSlow<CanGC>(ExclusiveContext *cx, uint32_t index, MutableHandleId idp);
|
||||
|
||||
template bool
|
||||
js::IndexToIdSlow<NoGC>(JSContext *cx, uint32_t index, FakeMutableHandle<jsid> idp);
|
||||
js::IndexToIdSlow<NoGC>(ExclusiveContext *cx, uint32_t index, FakeMutableHandle<jsid> idp);
|
||||
|
||||
template <AllowGC allowGC>
|
||||
JSAtom *
|
||||
js::ToAtom(JSContext *cx, typename MaybeRooted<Value, allowGC>::HandleType v)
|
||||
js::ToAtom(ExclusiveContext *cx, typename MaybeRooted<Value, allowGC>::HandleType v)
|
||||
{
|
||||
if (!v.isString()) {
|
||||
JSString *str = js::ToStringSlow<allowGC>(cx, v);
|
||||
@@ -453,10 +460,10 @@ js::ToAtom(JSContext *cx, typename MaybeRooted<Value, allowGC>::HandleType v)
|
||||
}
|
||||
|
||||
template JSAtom *
|
||||
js::ToAtom<CanGC>(JSContext *cx, HandleValue v);
|
||||
js::ToAtom<CanGC>(ExclusiveContext *cx, HandleValue v);
|
||||
|
||||
template JSAtom *
|
||||
js::ToAtom<NoGC>(JSContext *cx, Value v);
|
||||
js::ToAtom<NoGC>(ExclusiveContext *cx, Value v);
|
||||
|
||||
template<XDRMode mode>
|
||||
bool
|
||||
|
||||
Reference in New Issue
Block a user