mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1032726 part 2 - Make GetArrayIndexFromId work with Latin1 strings. r=bz,terrence
--HG-- extra : rebase_source : b6f8fe3df3946dfe05f5467c22c4fb157b6dcbf2
This commit is contained in:
parent
4f5617c4c2
commit
7ee62a47c5
@ -9375,7 +9375,9 @@ class CGProxyNamedOperation(CGProxySpecialOperation):
|
|||||||
unwrapString = fill(
|
unwrapString = fill(
|
||||||
"""
|
"""
|
||||||
if (MOZ_LIKELY(JSID_IS_ATOM(${idName}))) {
|
if (MOZ_LIKELY(JSID_IS_ATOM(${idName}))) {
|
||||||
${argName}.Rebind(js::GetAtomChars(JSID_TO_ATOM(${idName})), js::GetAtomLength(JSID_TO_ATOM(${idName})));
|
JS::AutoCheckCannotGC nogc;
|
||||||
|
JSAtom* atom = JSID_TO_ATOM(${idName});
|
||||||
|
${argName}.Rebind(js::GetTwoByteAtomChars(nogc, atom), js::GetAtomLength(atom));
|
||||||
} else {
|
} else {
|
||||||
nameVal = js::IdToValue(${idName});
|
nameVal = js::IdToValue(${idName});
|
||||||
$*{unwrapString}
|
$*{unwrapString}
|
||||||
|
@ -155,7 +155,15 @@ GetArrayIndexFromId(JSContext* cx, JS::Handle<jsid> id)
|
|||||||
}
|
}
|
||||||
if (MOZ_LIKELY(JSID_IS_ATOM(id))) {
|
if (MOZ_LIKELY(JSID_IS_ATOM(id))) {
|
||||||
JSAtom* atom = JSID_TO_ATOM(id);
|
JSAtom* atom = JSID_TO_ATOM(id);
|
||||||
jschar s = *js::GetAtomChars(atom);
|
jschar s;
|
||||||
|
{
|
||||||
|
JS::AutoCheckCannotGC nogc;
|
||||||
|
if (js::AtomHasLatin1Chars(atom)) {
|
||||||
|
s = *js::GetLatin1AtomChars(nogc, atom);
|
||||||
|
} else {
|
||||||
|
s = *js::GetTwoByteAtomChars(nogc, atom);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (MOZ_LIKELY((unsigned)s >= 'a' && (unsigned)s <= 'z'))
|
if (MOZ_LIKELY((unsigned)s >= 'a' && (unsigned)s <= 'z'))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -761,25 +761,42 @@ GetObjectSlot(JSObject *obj, size_t slot)
|
|||||||
return reinterpret_cast<const shadow::Object *>(obj)->slotRef(slot);
|
return reinterpret_cast<const shadow::Object *>(obj)->slotRef(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const jschar *
|
|
||||||
GetAtomChars(JSAtom *atom)
|
|
||||||
{
|
|
||||||
using shadow::Atom;
|
|
||||||
Atom *atom_ = reinterpret_cast<Atom *>(atom);
|
|
||||||
JS_ASSERT(!(atom_->flags & Atom::LATIN1_CHARS_BIT));
|
|
||||||
if (atom_->flags & Atom::INLINE_CHARS_BIT) {
|
|
||||||
char *p = reinterpret_cast<char *>(atom);
|
|
||||||
return reinterpret_cast<const jschar *>(p + offsetof(Atom, inlineStorageTwoByte));
|
|
||||||
}
|
|
||||||
return atom_->nonInlineCharsTwoByte;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline size_t
|
inline size_t
|
||||||
GetAtomLength(JSAtom *atom)
|
GetAtomLength(JSAtom *atom)
|
||||||
{
|
{
|
||||||
return reinterpret_cast<shadow::Atom*>(atom)->length;
|
return reinterpret_cast<shadow::Atom*>(atom)->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
AtomHasLatin1Chars(JSAtom *atom)
|
||||||
|
{
|
||||||
|
return reinterpret_cast<shadow::Atom *>(atom)->flags & shadow::Atom::LATIN1_CHARS_BIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const JS::Latin1Char *
|
||||||
|
GetLatin1AtomChars(const JS::AutoCheckCannotGC &nogc, JSAtom *atom)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(AtomHasLatin1Chars(atom));
|
||||||
|
|
||||||
|
using shadow::Atom;
|
||||||
|
Atom *atom_ = reinterpret_cast<Atom *>(atom);
|
||||||
|
if (atom_->flags & Atom::INLINE_CHARS_BIT)
|
||||||
|
return atom_->inlineStorageLatin1;
|
||||||
|
return atom_->nonInlineCharsLatin1;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const jschar *
|
||||||
|
GetTwoByteAtomChars(const JS::AutoCheckCannotGC &nogc, JSAtom *atom)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(!AtomHasLatin1Chars(atom));
|
||||||
|
|
||||||
|
using shadow::Atom;
|
||||||
|
Atom *atom_ = reinterpret_cast<Atom *>(atom);
|
||||||
|
if (atom_->flags & Atom::INLINE_CHARS_BIT)
|
||||||
|
return atom_->inlineStorageTwoByte;
|
||||||
|
return atom_->nonInlineCharsTwoByte;
|
||||||
|
}
|
||||||
|
|
||||||
inline JSLinearString *
|
inline JSLinearString *
|
||||||
AtomToLinearString(JSAtom *atom)
|
AtomToLinearString(JSAtom *atom)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user