Backed out 2 changesets (bug 1530251) for rust failures CLOSED TREE

Backed out changeset e03401a358a6 (bug 1530251)
Backed out changeset 42913778b66a (bug 1530251)
This commit is contained in:
Bogdan Tara 2019-10-02 14:49:23 +03:00
parent e2c099719a
commit f9d30e06a7
15 changed files with 33 additions and 33 deletions

View File

@ -84,7 +84,7 @@ typedef enum JSGCParamKey {
* This will be rounded to the nearest gc::ChunkSize.
*
* Pref: javascript.options.mem.nursery.max_kb
* Default: JS::DefaultNurseryMaxBytes
* Default: JS::DefaultNurseryBytes
*/
JSGC_MAX_NURSERY_BYTES = 2,

View File

@ -118,11 +118,11 @@ enum StackKind {
};
/*
* Default maximum size for the generational nursery in bytes. This is the
* initial value. In the browser this configured by the
* javascript.options.mem.nursery.max_kb pref.
* Default size for the generational nursery in bytes.
* This is the initial nursery size, when running in the browser this is
* updated by JS_SetGCParameter().
*/
const uint32_t DefaultNurseryMaxBytes = 16 * js::gc::ChunkSize;
const uint32_t DefaultNurseryBytes = 16 * js::gc::ChunkSize;
/* Default maximum heap size in bytes to pass to JS_NewContext(). */
const uint32_t DefaultHeapMaxBytes = 32 * 1024 * 1024;

View File

@ -1202,13 +1202,15 @@ void js::gc::DumpArenaInfo() {
#endif // JS_GC_ZEAL
bool GCRuntime::init(uint32_t maxbytes) {
bool GCRuntime::init(uint32_t maxbytes, uint32_t maxNurseryBytes) {
MOZ_ASSERT(SystemPageSize());
{
AutoLockGCBgAlloc lock(rt);
MOZ_ALWAYS_TRUE(tunables.setParameter(JSGC_MAX_BYTES, maxbytes, lock));
MOZ_ALWAYS_TRUE(
tunables.setParameter(JSGC_MAX_NURSERY_BYTES, maxNurseryBytes, lock));
const char* size = getenv("JSGC_MARK_STACK_LIMIT");
if (size) {

View File

@ -240,7 +240,7 @@ class GCRuntime {
public:
explicit GCRuntime(JSRuntime* rt);
MOZ_MUST_USE bool init(uint32_t maxbytes);
MOZ_MUST_USE bool init(uint32_t maxbytes, uint32_t maxNurseryBytes);
void finishRoots();
void finish();

View File

@ -38,7 +38,7 @@ static constexpr float MinHeapGrowthFactor =
GCSchedulingTunables::GCSchedulingTunables()
: gcMaxBytes_(0),
gcMinNurseryBytes_(TuningDefaults::GCMinNurseryBytes),
gcMaxNurseryBytes_(JS::DefaultNurseryMaxBytes),
gcMaxNurseryBytes_(0),
gcZoneAllocThresholdBase_(TuningDefaults::GCZoneAllocThresholdBase),
nonIncrementalFactor_(TuningDefaults::NonIncrementalFactor),
avoidInterruptFactor_(TuningDefaults::AvoidInterruptFactor),
@ -277,7 +277,7 @@ void GCSchedulingTunables::resetParameter(JSGCParamKey key,
case JSGC_MAX_NURSERY_BYTES:
// Reset these togeather to maintain their min <= max invariant.
gcMinNurseryBytes_ = TuningDefaults::GCMinNurseryBytes;
gcMaxNurseryBytes_ = JS::DefaultNurseryMaxBytes;
gcMaxNurseryBytes_ = JS::DefaultNurseryBytes;
break;
case JSGC_HIGH_FREQUENCY_TIME_LIMIT:
highFrequencyThreshold_ =

View File

@ -64,11 +64,10 @@ virtual JSContext* createContext() override {
// OOM. (Actually, this only happens with nursery zeal, because normally
// the nursery will start out with only a single chunk before triggering a
// major GC.)
JSContext* cx = JS_NewContext(1024 * 1024);
JSContext* cx = JS_NewContext(1024 * 1024, js::gc::ChunkSize);
if (!cx) {
return nullptr;
}
JS_SetGCParameter(cx, JSGC_MAX_NURSERY_BYTES, js::gc::ChunkSize);
setNativeStackQuota(cx);
return cx;
}

View File

@ -365,6 +365,7 @@ JS_PUBLIC_API JSObject* JS_GetBoundFunctionTarget(JSFunction* fun) {
/************************************************************************/
JS_PUBLIC_API JSContext* JS_NewContext(uint32_t maxbytes,
uint32_t maxNurseryBytes,
JSRuntime* parentRuntime) {
MOZ_ASSERT(JS::detail::libraryInitState == JS::detail::InitState::Running,
"must call JS_Init prior to creating any JSContexts");
@ -374,7 +375,7 @@ JS_PUBLIC_API JSContext* JS_NewContext(uint32_t maxbytes,
parentRuntime = parentRuntime->parentRuntime;
}
return NewContext(maxbytes, parentRuntime);
return NewContext(maxbytes, maxNurseryBytes, parentRuntime);
}
JS_PUBLIC_API JSContext* JS_NewCooperativeContext(JSContext* siblingContext) {

View File

@ -338,7 +338,8 @@ extern JS_PUBLIC_API bool JS_IsBuiltinFunctionConstructor(JSFunction* fun);
// Create a new context (and runtime) for this thread.
extern JS_PUBLIC_API JSContext* JS_NewContext(
uint32_t maxbytes, JSRuntime* parentRuntime = nullptr);
uint32_t maxbytes, uint32_t maxNurseryBytes = JS::DefaultNurseryBytes,
JSRuntime* parentRuntime = nullptr);
// The methods below for controlling the active context in a cooperatively
// multithreaded runtime are not threadsafe, and the caller must ensure they

View File

@ -4016,14 +4016,12 @@ static bool ShellBuildId(JS::BuildIdCharVector* buildId);
static void WorkerMain(WorkerInput* input) {
MOZ_ASSERT(input->parentRuntime);
JSContext* cx = JS_NewContext(8L * 1024L * 1024L,
JSContext* cx = JS_NewContext(8L * 1024L * 1024L, 2L * 1024L * 1024L,
input->parentRuntime);
if (!cx) {
return;
}
JS_SetGCParameter(cx, JSGC_MAX_NURSERY_BYTES, 2L * 1024L * 1024L);
ShellContext* sc = js_new<ShellContext>(cx);
if (!sc) {
return;
@ -11247,8 +11245,7 @@ int main(int argc, char** argv, char** envp) {
"NUMBER of instructions.",
-1) ||
!op.addIntOption('\0', "nursery-size", "SIZE-MB",
"Set the maximum nursery size in MB",
JS::DefaultNurseryMaxBytes / 1024 / 1024) ||
"Set the maximum nursery size in MB", 16) ||
#ifdef JS_GC_ZEAL
!op.addStringOption('z', "gc-zeal", "LEVEL(;LEVEL)*[,N]",
gc::ZealModeHelpText) ||
@ -11374,15 +11371,14 @@ int main(int argc, char** argv, char** envp) {
return 1;
}
size_t nurseryBytes = JS::DefaultNurseryBytes;
nurseryBytes = op.getIntOption("nursery-size") * 1024L * 1024L;
/* Use the same parameters as the browser in xpcjsruntime.cpp. */
JSContext* const cx = JS_NewContext(JS::DefaultHeapMaxBytes);
JSContext* const cx = JS_NewContext(JS::DefaultHeapMaxBytes, nurseryBytes);
if (!cx) {
return 1;
}
size_t nurseryBytes = op.getIntOption("nursery-size") * 1024L * 1024L;
JS_SetGCParameter(cx, JSGC_MAX_NURSERY_BYTES, nurseryBytes);
auto destroyCx = MakeScopeExit([cx] { JS_DestroyContext(cx); });
UniquePtr<ShellContext> sc = MakeUnique<ShellContext>(cx);

View File

@ -135,7 +135,8 @@ bool JSContext::init(ContextKind kind) {
return true;
}
JSContext* js::NewContext(uint32_t maxBytes, JSRuntime* parentRuntime) {
JSContext* js::NewContext(uint32_t maxBytes, uint32_t maxNurseryBytes,
JSRuntime* parentRuntime) {
AutoNoteSingleThreadedRegion anstr;
MOZ_RELEASE_ASSERT(!TlsContext.get());
@ -162,7 +163,7 @@ JSContext* js::NewContext(uint32_t maxBytes, JSRuntime* parentRuntime) {
return nullptr;
}
if (!runtime->init(cx, maxBytes)) {
if (!runtime->init(cx, maxBytes, maxNurseryBytes)) {
runtime->destroyRuntime();
js_delete(cx);
js_delete(runtime);

View File

@ -1049,7 +1049,8 @@ struct MOZ_RAII AutoResolving {
* Create and destroy functions for JSContext, which is manually allocated
* and exclusively owned.
*/
extern JSContext* NewContext(uint32_t maxBytes, JSRuntime* parentRuntime);
extern JSContext* NewContext(uint32_t maxBytes, uint32_t maxNurseryBytes,
JSRuntime* parentRuntime);
extern void DestroyContext(JSContext* cx);

View File

@ -193,7 +193,8 @@ JSRuntime::~JSRuntime() {
MOZ_ASSERT(numDebuggeeRealmsObservingCoverage_ == 0);
}
bool JSRuntime::init(JSContext* cx, uint32_t maxbytes) {
bool JSRuntime::init(JSContext* cx, uint32_t maxbytes,
uint32_t maxNurseryBytes) {
#ifdef DEBUG
MOZ_ASSERT(!initialized_);
initialized_ = true;
@ -207,7 +208,7 @@ bool JSRuntime::init(JSContext* cx, uint32_t maxbytes) {
defaultFreeOp_ = cx->defaultFreeOp();
if (!gc.init(maxbytes)) {
if (!gc.init(maxbytes, maxNurseryBytes)) {
return false;
}

View File

@ -849,7 +849,7 @@ struct JSRuntime {
// to JSContext remains valid. The final GC triggered here depends on this.
void destroyRuntime();
bool init(JSContext* cx, uint32_t maxbytes);
bool init(JSContext* cx, uint32_t maxbytes, uint32_t maxNurseryBytes);
JSRuntime* thisFromCtor() { return this; }

View File

@ -1100,7 +1100,7 @@ nsresult XPCJSContext::Initialize(XPCJSContext* aPrimaryContext) {
rv = CycleCollectedJSContext::InitializeNonPrimary(aPrimaryContext);
} else {
rv = CycleCollectedJSContext::Initialize(nullptr, JS::DefaultHeapMaxBytes,
JS::DefaultNurseryMaxBytes);
JS::DefaultNurseryBytes);
}
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;

View File

@ -155,13 +155,11 @@ nsresult CycleCollectedJSContext::Initialize(JSRuntime* aParentRuntime,
MOZ_ASSERT(!mJSContext);
mozilla::dom::InitScriptSettings();
mJSContext = JS_NewContext(aMaxBytes, aParentRuntime);
mJSContext = JS_NewContext(aMaxBytes, aMaxNurseryBytes, aParentRuntime);
if (!mJSContext) {
return NS_ERROR_OUT_OF_MEMORY;
}
JS_SetGCParameter(mJSContext, JSGC_MAX_NURSERY_BYTES, aMaxNurseryBytes);
mRuntime = CreateRuntime(mJSContext);
InitializeCommon();