Bug 1162199 - Use unboxed objects by default, r=jandem.

This commit is contained in:
Brian Hackett 2015-05-14 16:36:37 -06:00
parent 4e7fc3055e
commit 1c8650b5db
6 changed files with 21 additions and 24 deletions

View File

@ -161,6 +161,9 @@ JitOptions::JitOptions()
// The bytecode length limit for small function.
SET_DEFAULT(smallFunctionMaxBytecodeLength_, 100);
// Toggles whether unboxed plain objects can be created by the VM.
SET_DEFAULT(disableUnboxedObjects, false);
}
bool

View File

@ -67,6 +67,9 @@ struct JitOptions
uint32_t osrPcMismatchesBeforeRecompile;
uint32_t smallFunctionMaxBytecodeLength_;
// The options below affect the rest of the VM, and not just the JIT.
bool disableUnboxedObjects;
JitOptions();
bool isSmallFunction(JSScript* script) const;
void setEagerCompilation();

View File

@ -1137,7 +1137,6 @@ class JS_PUBLIC_API(RuntimeOptions) {
ion_(true),
asmJS_(true),
nativeRegExp_(true),
unboxedObjects_(false), // Not enabled by default yet
unboxedArrays_(false), // Ditto
werror_(false),
strictMode_(false),
@ -1182,12 +1181,6 @@ class JS_PUBLIC_API(RuntimeOptions) {
return *this;
}
bool unboxedObjects() const { return unboxedObjects_; }
RuntimeOptions& setUnboxedObjects(bool flag) {
unboxedObjects_ = flag;
return *this;
}
bool unboxedArrays() const { return unboxedArrays_; }
RuntimeOptions& setUnboxedArrays(bool flag) {
unboxedArrays_ = flag;
@ -1239,7 +1232,6 @@ class JS_PUBLIC_API(RuntimeOptions) {
bool ion_ : 1;
bool asmJS_ : 1;
bool nativeRegExp_ : 1;
bool unboxedObjects_ : 1;
bool unboxedArrays_ : 1;
bool werror_ : 1;
bool strictMode_ : 1;

View File

@ -142,7 +142,6 @@ static bool enableBaseline = false;
static bool enableIon = false;
static bool enableAsmJS = false;
static bool enableNativeRegExp = false;
static bool enableUnboxedObjects = false;
static bool enableUnboxedArrays = false;
#ifdef JS_GC_ZEAL
static char gZealStr[128];
@ -6040,16 +6039,17 @@ SetRuntimeOptions(JSRuntime* rt, const OptionParser& op)
enableIon = !op.getBoolOption("no-ion");
enableAsmJS = !op.getBoolOption("no-asmjs");
enableNativeRegExp = !op.getBoolOption("no-native-regexp");
enableUnboxedObjects = op.getBoolOption("unboxed-objects");
enableUnboxedArrays = op.getBoolOption("unboxed-arrays");
JS::RuntimeOptionsRef(rt).setBaseline(enableBaseline)
.setIon(enableIon)
.setAsmJS(enableAsmJS)
.setNativeRegExp(enableNativeRegExp)
.setUnboxedObjects(enableUnboxedObjects)
.setUnboxedArrays(enableUnboxedArrays);
if (op.getBoolOption("no-unboxed-objects"))
jit::js_JitOptions.disableUnboxedObjects = true;
if (const char* str = op.getStringOption("ion-scalar-replacement")) {
if (strcmp(str, "on") == 0)
jit::js_JitOptions.disableScalarReplacement = false;
@ -6253,7 +6253,6 @@ SetWorkerRuntimeOptions(JSRuntime* rt)
.setIon(enableIon)
.setAsmJS(enableAsmJS)
.setNativeRegExp(enableNativeRegExp)
.setUnboxedObjects(enableUnboxedObjects)
.setUnboxedArrays(enableUnboxedArrays);
rt->setOffthreadIonCompilationEnabled(offthreadCompilation);
rt->profilingScripts = enableDisassemblyDumps;
@ -6396,7 +6395,7 @@ main(int argc, char** argv, char** envp)
|| !op.addBoolOption('\0', "no-ion", "Disable IonMonkey")
|| !op.addBoolOption('\0', "no-asmjs", "Disable asm.js compilation")
|| !op.addBoolOption('\0', "no-native-regexp", "Disable native regexp compilation")
|| !op.addBoolOption('\0', "unboxed-objects", "Allow creating unboxed plain objects")
|| !op.addBoolOption('\0', "no-unboxed-objects", "Disable creating unboxed plain objects")
|| !op.addBoolOption('\0', "unboxed-arrays", "Allow creating unboxed arrays")
|| !op.addStringOption('\0', "ion-scalar-replacement", "on/off",
"Scalar Replacement (default: on, off to disable)")

View File

@ -59,6 +59,6 @@ HeapReceiverGuard::trace(JSTracer* trc)
{
if (shape_)
TraceEdge(trc, &shape_, "receiver_guard_shape");
else
if (group_)
TraceEdge(trc, &group_, "receiver_guard_group");
}

View File

@ -1885,26 +1885,26 @@ bool
js::TryConvertToUnboxedLayout(ExclusiveContext* cx, Shape* templateShape,
ObjectGroup* group, PreliminaryObjectArray* objects)
{
// Unboxed objects are nightly only for now. The getenv() call will be
bool isArray = !templateShape;
// Unboxed arrays are nightly only for now. The getenv() call will be
// removed when they are on by default. See bug 1153266.
if (isArray) {
#ifdef NIGHTLY_BUILD
if (templateShape) {
if (!getenv("JS_OPTION_USE_UNBOXED_OBJECTS")) {
if (!group->runtimeFromAnyThread()->options().unboxedObjects())
if (!getenv("JS_OPTION_USE_UNBOXED_ARRAYS")) {
if (!group->runtimeFromAnyThread()->options().unboxedArrays())
return true;
}
#else
return true;
#endif
} else {
if (!group->runtimeFromAnyThread()->options().unboxedArrays())
if (jit::js_JitOptions.disableUnboxedObjects)
return true;
}
#else
return true;
#endif
MOZ_ASSERT_IF(templateShape, !templateShape->getObjectFlags());
bool isArray = !templateShape;
if (group->runtimeFromAnyThread()->isSelfHostingGlobal(cx->global()))
return true;