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

This commit is contained in:
Bobby Holley 2014-04-22 14:08:28 -07:00
Родитель 9766fa5987
Коммит 2a54864f28
4 изменённых файлов: 24 добавлений и 5 удалений

Просмотреть файл

@ -601,6 +601,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);

Просмотреть файл

@ -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;
@ -1560,6 +1560,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);

Просмотреть файл

@ -478,6 +478,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 {

Просмотреть файл

@ -785,6 +785,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