Bug 990353 - Add a pref for system source discarding. r=bent

This commit is contained in:
Bobby Holley 2014-04-18 23:46:26 -07:00
parent 51af5cebbd
commit 90a7b5cf46
4 changed files with 24 additions and 5 deletions

View File

@ -599,6 +599,13 @@ pref("dom.forms.color", false);
// Turns on gralloc-based direct texturing for Gonk
pref("gfx.gralloc.enabled", false);
// This preference instructs the JS engine to discard the
// source of any privileged JS after compilation. This saves
// memory, but makes things like Function.prototype.toSource()
// fail.
// XXXbholley - we flip this to true in the last patch.
pref("javascript.options.discardSystemSource", false);
// XXXX REMOVE FOR PRODUCTION. Turns on GC and CC logging
pref("javascript.options.mem.log", false);

View File

@ -40,6 +40,7 @@
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/WindowBinding.h"
#include "mozilla/Atomics.h"
#include "mozilla/Attributes.h"
#include "AccessCheck.h"
#include "nsGlobalWindow.h"
@ -84,11 +85,10 @@ const char* const XPCJSRuntime::mStrings[] = {
/***************************************************************************/
struct CX_AND_XPCRT_Data
{
JSContext* cx;
XPCJSRuntime* rt;
};
static mozilla::Atomic<bool> sDiscardSystemSource(false);
bool
xpc::ShouldDiscardSystemSource() { return sDiscardSystemSource; }
static void * const UNMARK_ONLY = nullptr;
static void * const UNMARK_AND_SWEEP = (void *)1;
@ -1552,6 +1552,8 @@ ReloadPrefsCallback(const char *pref, void *data)
"baselinejit.unsafe_eager_compilation");
bool useIonEager = Preferences::GetBool(JS_OPTIONS_DOT_STR "ion.unsafe_eager_compilation");
sDiscardSystemSource = Preferences::GetBool(JS_OPTIONS_DOT_STR "discardSystemSource");
JS::RuntimeOptionsRef(rt).setBaseline(useBaseline)
.setIon(useIon)
. setAsmJS(useAsmJS);

View File

@ -470,6 +470,11 @@ RecordAdoptedNode(JSCompartment *c);
void
RecordDonatedNode(JSCompartment *c);
// This function may be used off-main-thread, in which case it is benignly
// racey.
bool
ShouldDiscardSystemSource();
} // namespace xpc
namespace mozilla {

View File

@ -781,6 +781,11 @@ pref("javascript.options.ion", true);
pref("javascript.options.asmjs", true);
pref("javascript.options.parallel_parsing", true);
pref("javascript.options.ion.parallel_compilation", true);
// This preference instructs the JS engine to discard the
// source of any privileged JS after compilation. This saves
// memory, but makes things like Function.prototype.toSource()
// fail.
pref("javascript.options.discardSystemSource", false);
// This preference limits the memory usage of javascript.
// If you want to change these values for your device,
// please find Bug 417052 comment 17 and Bug 456721