mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1027528 part 9 - Make more code work with Latin1 strings. r=terrence
This commit is contained in:
parent
6d852cdaf6
commit
bdb2f89f1d
@ -4380,11 +4380,11 @@ class ShellSourceHook: public SourceHook {
|
||||
if (!*src)
|
||||
return false;
|
||||
|
||||
const jschar *chars = JS_GetStringCharsZ(cx, str);
|
||||
if (!chars)
|
||||
JSLinearString *linear = str->ensureLinear(cx);
|
||||
if (!linear)
|
||||
return false;
|
||||
|
||||
PodCopy(*src, chars, *length);
|
||||
CopyChars(*src, *linear);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@ -4969,13 +4969,19 @@ PrintHelpString(JSContext *cx, jsval v)
|
||||
{
|
||||
JSString *str = v.toString();
|
||||
JS::Anchor<JSString *> a_str(str);
|
||||
const jschar *chars = JS_GetStringCharsZ(cx, str);
|
||||
if (!chars)
|
||||
|
||||
JSLinearString *linear = str->ensureLinear(cx);
|
||||
if (!linear)
|
||||
return false;
|
||||
|
||||
for (const jschar *p = chars; *p; p++)
|
||||
fprintf(gOutFile, "%c", char(*p));
|
||||
|
||||
JS::AutoCheckCannotGC nogc;
|
||||
if (linear->hasLatin1Chars()) {
|
||||
for (const Latin1Char *p = linear->latin1Chars(nogc); *p; p++)
|
||||
fprintf(gOutFile, "%c", char(*p));
|
||||
} else {
|
||||
for (const jschar *p = linear->twoByteChars(nogc); *p; p++)
|
||||
fprintf(gOutFile, "%c", char(*p));
|
||||
}
|
||||
fprintf(gOutFile, "\n");
|
||||
|
||||
return true;
|
||||
|
@ -274,16 +274,8 @@ SPSProfiler::allocProfileString(JSScript *script, JSFunction *maybeFun)
|
||||
// Note: this profiler string is regexp-matched by
|
||||
// browser/devtools/profiler/cleopatra/js/parserWorker.js.
|
||||
|
||||
// Determine if the function (if any) has an explicit or guessed name.
|
||||
bool hasAtom = maybeFun && maybeFun->displayAtom();
|
||||
|
||||
// Get the function name, if any, and its length.
|
||||
const jschar *atom = nullptr;
|
||||
size_t lenAtom = 0;
|
||||
if (hasAtom) {
|
||||
atom = maybeFun->displayAtom()->charsZ();
|
||||
lenAtom = maybeFun->displayAtom()->length();
|
||||
}
|
||||
// Get the function name, if any.
|
||||
JSAtom *atom = maybeFun ? maybeFun->displayAtom() : nullptr;
|
||||
|
||||
// Get the script filename, if any, and its length.
|
||||
const char *filename = script->filename();
|
||||
@ -298,8 +290,8 @@ SPSProfiler::allocProfileString(JSScript *script, JSFunction *maybeFun)
|
||||
|
||||
// Determine the required buffer size.
|
||||
size_t len = lenFilename + lenLineno + 1; // +1 for the ":" separating them.
|
||||
if (hasAtom)
|
||||
len += lenAtom + 3; // +3 for the " (" and ")" it adds.
|
||||
if (atom)
|
||||
len += atom->length() + 3; // +3 for the " (" and ")" it adds.
|
||||
|
||||
// Allocate the buffer.
|
||||
char *cstr = js_pod_malloc<char>(len + 1);
|
||||
@ -308,10 +300,15 @@ SPSProfiler::allocProfileString(JSScript *script, JSFunction *maybeFun)
|
||||
|
||||
// Construct the descriptive string.
|
||||
DebugOnly<size_t> ret;
|
||||
if (hasAtom)
|
||||
ret = JS_snprintf(cstr, len + 1, "%hs (%s:%llu)", atom, filename, lineno);
|
||||
else
|
||||
if (atom) {
|
||||
JS::AutoCheckCannotGC nogc;
|
||||
if (atom->hasLatin1Chars())
|
||||
ret = JS_snprintf(cstr, len + 1, "%s (%s:%llu)", atom->latin1Chars(nogc), filename, lineno);
|
||||
else
|
||||
ret = JS_snprintf(cstr, len + 1, "%hs (%s:%llu)", atom->twoByteChars(nogc), filename, lineno);
|
||||
} else {
|
||||
ret = JS_snprintf(cstr, len + 1, "%s:%llu", filename, lineno);
|
||||
}
|
||||
|
||||
MOZ_ASSERT(ret == len, "Computed length should match actual length!");
|
||||
|
||||
|
@ -25,7 +25,12 @@ namespace js {
|
||||
/* static */ HashNumber
|
||||
SavedFrame::HashPolicy::hash(const Lookup &lookup)
|
||||
{
|
||||
return AddToHash(HashString(lookup.source->chars(), lookup.source->length()),
|
||||
JSAtom *source = lookup.source;
|
||||
JS::AutoCheckCannotGC nogc;
|
||||
uint32_t hash = source->hasLatin1Chars()
|
||||
? HashString(source->latin1Chars(nogc), source->length())
|
||||
: HashString(source->twoByteChars(nogc), source->length());
|
||||
return AddToHash(hash,
|
||||
lookup.line,
|
||||
lookup.column,
|
||||
lookup.functionDisplayName,
|
||||
|
Loading…
Reference in New Issue
Block a user