Bug 1028867 - Add a --latin1-strings shell flag. r=luke

This commit is contained in:
Jan de Mooij 2014-06-25 10:12:20 +02:00
parent f4a6dcee86
commit 573bbd0f3d
4 changed files with 18 additions and 5 deletions

View File

@ -2958,7 +2958,7 @@ EvalInWorker(JSContext *cx, unsigned argc, jsval *vp)
jschar *chars = (jschar *) js_malloc(str->length() * sizeof(jschar));
if (!chars)
return false;
PodCopy(chars, str->chars(), str->length());
CopyChars(chars, *str);
WorkerInput *input = js_new<WorkerInput>(cx->runtime(), chars, str->length());
if (!input)
@ -4528,6 +4528,11 @@ ToLatin1(JSContext *cx, unsigned argc, Value *vp)
return true;
}
if (args[0].toString()->hasLatin1Chars()) {
args.rval().set(args[0]);
return true;
}
JSLinearString *s = &args[0].toString()->asLinear();
s->debugUnsafeConvertToLatin1();
args.rval().setString(s);
@ -6313,6 +6318,7 @@ main(int argc, char **argv, char **envp)
"to test JIT codegen (no-op on platforms other than x86 and x64).")
|| !op.addBoolOption('\0', "fuzzing-safe", "Don't expose functions that aren't safe for "
"fuzzers to call")
|| !op.addBoolOption('\0', "latin1-strings", "Enable Latin1 strings (default: off)")
#ifdef DEBUG
|| !op.addBoolOption('\0', "dump-entrained-variables", "Print variables which are "
"unnecessarily entrained by inner functions")
@ -6385,6 +6391,11 @@ main(int argc, char **argv, char **envp)
#endif // DEBUG
// Set this option before initializing the JSRuntime, so that Latin1 strings
// are used for strings allocated during initialization.
if (op.getBoolOption("latin1-strings"))
js::EnableLatin1Strings = true;
#ifdef JS_THREADSAFE
// The fake thread count must be set before initializing the Runtime,
// which spins up the thread pool.

View File

@ -14,7 +14,7 @@ TBPL_FLAGS = [
[], # no flags, normal baseline and ion
['--ion-eager', '--ion-offthread-compile=off'], # implies --baseline-eager
['--ion-eager', '--ion-offthread-compile=off', '--ion-check-range-analysis', '--no-sse3'],
['--baseline-eager'],
['--baseline-eager', '--latin1-strings'],
['--baseline-eager', '--no-fpu'],
['--no-baseline', '--no-ion'],
]

View File

@ -868,6 +868,8 @@ AutoStableStringChars::initTwoByte(JSContext *cx, JSString *s)
return true;
}
bool js::EnableLatin1Strings = false;
#ifdef DEBUG
void
JSAtom::dump()

View File

@ -519,9 +519,6 @@ class JSString : public js::gc::BarrieredCell<JSString>
void operator=(const JSString &other) MOZ_DELETE;
};
/* Temporary flag to enable Latin1 strings (bug 998392). */
static const bool EnableLatin1Strings = false;
class JSRope : public JSString
{
template <typename CharT>
@ -1002,6 +999,9 @@ JS_STATIC_ASSERT(sizeof(JSAtom) == sizeof(JSString));
namespace js {
/* Temporary flag to enable Latin1 strings (bug 998392). */
extern bool EnableLatin1Strings;
/*
* Thread safe RAII wrapper for inspecting the contents of JSStrings. The
* thread safe operations such as |getCharsNonDestructive| require allocation