Skip to content

Commit

Permalink
Merge mozilla-inbound to mozilla-central a=merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Razvan Maries committed Jan 21, 2019
2 parents 599c819 + d86ab4b commit 299b5e7
Show file tree
Hide file tree
Showing 82 changed files with 480 additions and 455 deletions.
2 changes: 1 addition & 1 deletion docshell/base/nsDocShell.cpp
Expand Up @@ -10381,7 +10381,7 @@ nsresult nsDocShell::DoChannelLoad(nsIChannel* aChannel,
// We're about to load a new page and it may take time before necko
// gives back any data, so main thread might have a chance to process a
// collector slice
nsJSContext::MaybeRunNextCollectorSlice(this, JS::gcreason::DOCSHELL);
nsJSContext::MaybeRunNextCollectorSlice(this, JS::GCReason::DOCSHELL);

// Success. Keep the initial ClientSource if it exists.
cleanupInitialClient.release();
Expand Down
2 changes: 1 addition & 1 deletion dom/base/FuzzingFunctions.cpp
Expand Up @@ -22,7 +22,7 @@ namespace mozilla {
namespace dom {

/* static */ void FuzzingFunctions::GarbageCollect(const GlobalObject&) {
nsJSContext::GarbageCollectNow(JS::gcreason::COMPONENT_UTILS,
nsJSContext::GarbageCollectNow(JS::GCReason::COMPONENT_UTILS,
nsJSContext::NonIncrementalGC,
nsJSContext::NonShrinkingGC);
}
Expand Down
4 changes: 2 additions & 2 deletions dom/base/nsDOMWindowUtils.cpp
Expand Up @@ -1037,7 +1037,7 @@ NS_IMETHODIMP
nsDOMWindowUtils::GarbageCollect(nsICycleCollectorListener* aListener) {
AUTO_PROFILER_LABEL("nsDOMWindowUtils::GarbageCollect", GCCC);

nsJSContext::GarbageCollectNow(JS::gcreason::DOM_UTILS);
nsJSContext::GarbageCollectNow(JS::GCReason::DOM_UTILS);
nsJSContext::CycleCollectNow(aListener);

return NS_OK;
Expand All @@ -1051,7 +1051,7 @@ nsDOMWindowUtils::CycleCollect(nsICycleCollectorListener* aListener) {

NS_IMETHODIMP
nsDOMWindowUtils::RunNextCollectorTimer() {
nsJSContext::RunNextCollectorTimer(JS::gcreason::DOM_WINDOW_UTILS);
nsJSContext::RunNextCollectorTimer(JS::GCReason::DOM_WINDOW_UTILS);

return NS_OK;
}
Expand Down
5 changes: 3 additions & 2 deletions dom/base/nsGlobalWindowInner.cpp
Expand Up @@ -6006,10 +6006,11 @@ bool nsGlobalWindowInner::RunTimeoutHandler(Timeout* aTimeout,
nsJSUtils::ExecutionContext exec(aes.cx(), global);
rv = exec.Compile(options, handler->GetHandlerText());

if (rv == NS_OK) {
JS::Rooted<JSScript*> script(aes.cx(), exec.MaybeGetScript());
if (script) {
LoadedScript* initiatingScript = handler->GetInitiatingScript();
if (initiatingScript) {
initiatingScript->AssociateWithScript(exec.GetScript());
initiatingScript->AssociateWithScript(script);
}

rv = exec.ExecScript();
Expand Down
2 changes: 1 addition & 1 deletion dom/base/nsGlobalWindowOuter.cpp
Expand Up @@ -2495,7 +2495,7 @@ void nsGlobalWindowOuter::DetachFromDocShell() {
// When we're about to destroy a top level content window
// (for example a tab), we trigger a full GC by passing null as the last
// param. We also trigger a full GC for chrome windows.
nsJSContext::PokeGC(JS::gcreason::SET_DOC_SHELL,
nsJSContext::PokeGC(JS::GCReason::SET_DOC_SHELL,
(mTopLevelOuterContentWindow || mIsChrome)
? nullptr
: GetWrapperPreserveColor());
Expand Down
32 changes: 15 additions & 17 deletions dom/base/nsJSEnvironment.cpp
Expand Up @@ -324,12 +324,12 @@ nsJSEnvironmentObserver::Observe(nsISupports* aSubject, const char* aTopic,
// slow and it likely won't help us anyway.
return NS_OK;
}
nsJSContext::GarbageCollectNow(JS::gcreason::MEM_PRESSURE,
nsJSContext::GarbageCollectNow(JS::GCReason::MEM_PRESSURE,
nsJSContext::NonIncrementalGC,
nsJSContext::ShrinkingGC);
nsJSContext::CycleCollectNow();
if (NeedsGCAfterCC()) {
nsJSContext::GarbageCollectNow(JS::gcreason::MEM_PRESSURE,
nsJSContext::GarbageCollectNow(JS::GCReason::MEM_PRESSURE,
nsJSContext::NonIncrementalGC,
nsJSContext::ShrinkingGC);
}
Expand Down Expand Up @@ -577,7 +577,7 @@ nsJSContext::~nsJSContext() {

void nsJSContext::Destroy() {
if (mGCOnDestruction) {
PokeGC(JS::gcreason::NSJSCONTEXT_DESTROY, mWindowProxy);
PokeGC(JS::GCReason::NSJSCONTEXT_DESTROY, mWindowProxy);
}

DropJSObjects(this);
Expand Down Expand Up @@ -1079,17 +1079,17 @@ void nsJSContext::SetProcessingScriptTag(bool aFlag) {
void FullGCTimerFired(nsITimer* aTimer, void* aClosure) {
nsJSContext::KillFullGCTimer();
MOZ_ASSERT(!aClosure, "Don't pass a closure to FullGCTimerFired");
nsJSContext::GarbageCollectNow(JS::gcreason::FULL_GC_TIMER,
nsJSContext::GarbageCollectNow(JS::GCReason::FULL_GC_TIMER,
nsJSContext::IncrementalGC);
}

// static
void nsJSContext::GarbageCollectNow(JS::gcreason::Reason aReason,
void nsJSContext::GarbageCollectNow(JS::GCReason aReason,
IsIncremental aIncremental,
IsShrinking aShrinking,
int64_t aSliceMillis) {
AUTO_PROFILER_LABEL_DYNAMIC_CSTR("nsJSContext::GarbageCollectNow", GCCC,
JS::gcreason::ExplainReason(aReason));
JS::ExplainGCReason(aReason));

MOZ_ASSERT_IF(aSliceMillis, aIncremental == IncrementalGC);

Expand All @@ -1113,7 +1113,7 @@ void nsJSContext::GarbageCollectNow(JS::gcreason::Reason aReason,
JSGCInvocationKind gckind = aShrinking == ShrinkingGC ? GC_SHRINK : GC_NORMAL;

if (aIncremental == NonIncrementalGC ||
aReason == JS::gcreason::FULL_GC_TIMER) {
aReason == JS::GCReason::FULL_GC_TIMER) {
sNeedsFullGC = true;
}

Expand All @@ -1139,7 +1139,7 @@ static void FinishAnyIncrementalGC() {

// We're in the middle of an incremental GC, so finish it.
JS::PrepareForIncrementalGC(jsapi.cx());
JS::FinishIncrementalGC(jsapi.cx(), JS::gcreason::CC_FORCED);
JS::FinishIncrementalGC(jsapi.cx(), JS::GCReason::CC_FORCED);
}
}

Expand Down Expand Up @@ -1573,7 +1573,7 @@ void nsJSContext::EndCycleCollectionCallback(CycleCollectorResults& aResults) {
uint32_t ccNowDuration = TimeBetween(gCCStats.mBeginTime, endCCTimeStamp);

if (NeedsGCAfterCC()) {
PokeGC(JS::gcreason::CC_WAITING, nullptr,
PokeGC(JS::GCReason::CC_WAITING, nullptr,
NS_GC_DELAY - std::min(ccNowDuration, kMaxICCDuration));
}

Expand Down Expand Up @@ -1730,8 +1730,7 @@ bool InterSliceGCRunnerFired(TimeStamp aDeadline, void* aData) {
TimeDuration duration = sGCUnnotifiedTotalTime;
uintptr_t reason = reinterpret_cast<uintptr_t>(aData);
nsJSContext::GarbageCollectNow(
aData ? static_cast<JS::gcreason::Reason>(reason)
: JS::gcreason::INTER_SLICE_GC,
aData ? static_cast<JS::GCReason>(reason) : JS::GCReason::INTER_SLICE_GC,
nsJSContext::IncrementalGC, nsJSContext::NonShrinkingGC, budget);

sGCUnnotifiedTotalTime = TimeDuration();
Expand Down Expand Up @@ -1780,7 +1779,7 @@ void GCTimerFired(nsITimer* aTimer, void* aClosure) {
void ShrinkingGCTimerFired(nsITimer* aTimer, void* aClosure) {
nsJSContext::KillShrinkingGCTimer();
sIsCompactingOnUserInactive = true;
nsJSContext::GarbageCollectNow(JS::gcreason::USER_INACTIVE,
nsJSContext::GarbageCollectNow(JS::GCReason::USER_INACTIVE,
nsJSContext::IncrementalGC,
nsJSContext::ShrinkingGC);
}
Expand Down Expand Up @@ -1886,7 +1885,7 @@ uint32_t nsJSContext::CleanupsSinceLastGC() { return sCleanupsSinceLastGC; }
// collection we run on a long timer.

// static
void nsJSContext::RunNextCollectorTimer(JS::gcreason::Reason aReason,
void nsJSContext::RunNextCollectorTimer(JS::GCReason aReason,
mozilla::TimeStamp aDeadline) {
if (sShuttingDown) {
return;
Expand Down Expand Up @@ -1925,7 +1924,7 @@ void nsJSContext::RunNextCollectorTimer(JS::gcreason::Reason aReason,

// static
void nsJSContext::MaybeRunNextCollectorSlice(nsIDocShell* aDocShell,
JS::gcreason::Reason aReason) {
JS::GCReason aReason) {
if (!aDocShell || !XRE_IsContentProcess()) {
return;
}
Expand Down Expand Up @@ -1972,16 +1971,15 @@ void nsJSContext::MaybeRunNextCollectorSlice(nsIDocShell* aDocShell,
}

// static
void nsJSContext::PokeGC(JS::gcreason::Reason aReason, JSObject* aObj,
int aDelay) {
void nsJSContext::PokeGC(JS::GCReason aReason, JSObject* aObj, int aDelay) {
if (sShuttingDown) {
return;
}

if (aObj) {
JS::Zone* zone = JS::GetObjectZone(aObj);
CycleCollectedJSRuntime::Get()->AddZoneWaitingForGC(zone);
} else if (aReason != JS::gcreason::CC_WAITING) {
} else if (aReason != JS::GCReason::CC_WAITING) {
sNeedsFullGC = true;
}

Expand Down
9 changes: 4 additions & 5 deletions dom/base/nsJSEnvironment.h
Expand Up @@ -72,7 +72,7 @@ class nsJSContext : public nsIScriptContext {
// Setup all the statics etc - safe to call multiple times after Startup().
static void EnsureStatics();

static void GarbageCollectNow(JS::gcreason::Reason reason,
static void GarbageCollectNow(JS::GCReason reason,
IsIncremental aIncremental = NonIncrementalGC,
IsShrinking aShrinking = NonShrinkingGC,
int64_t aSliceMillis = 0);
Expand All @@ -97,17 +97,16 @@ class nsJSContext : public nsIScriptContext {

// If there is some pending CC or GC timer/runner, this will run it.
static void RunNextCollectorTimer(
JS::gcreason::Reason aReason,
JS::GCReason aReason,
mozilla::TimeStamp aDeadline = mozilla::TimeStamp());
// If user has been idle and aDocShell is for an iframe being loaded in an
// already loaded top level docshell, this will run a CC or GC
// timer/runner if there is such pending.
static void MaybeRunNextCollectorSlice(nsIDocShell *aDocShell,
JS::gcreason::Reason aReason);
JS::GCReason aReason);

// The GC should probably run soon, in the zone of object aObj (if given).
static void PokeGC(JS::gcreason::Reason aReason, JSObject *aObj,
int aDelay = 0);
static void PokeGC(JS::GCReason aReason, JSObject *aObj, int aDelay = 0);
static void KillGCTimer();

static void PokeShrinkingGC();
Expand Down
4 changes: 4 additions & 0 deletions dom/base/nsJSUtils.cpp
Expand Up @@ -374,6 +374,10 @@ JSScript* nsJSUtils::ExecutionContext::GetScript() {
mScriptUsed = true;
#endif

return MaybeGetScript();
}

JSScript* nsJSUtils::ExecutionContext::MaybeGetScript() {
return mScript;
}

Expand Down
3 changes: 3 additions & 0 deletions dom/base/nsJSUtils.h
Expand Up @@ -175,6 +175,9 @@ class nsJSUtils {
// Get a successfully compiled script.
JSScript* GetScript();

// Get the compiled script if present, or nullptr.
JSScript* MaybeGetScript();

// Execute the compiled script and ignore the return value.
MOZ_MUST_USE nsresult ExecScript();

Expand Down
2 changes: 1 addition & 1 deletion dom/indexedDB/ActorsChild.cpp
Expand Up @@ -129,7 +129,7 @@ void MaybeCollectGarbageOnIPCMessage() {
return;
}

nsJSContext::GarbageCollectNow(JS::gcreason::DOM_IPC);
nsJSContext::GarbageCollectNow(JS::GCReason::DOM_IPC);
nsJSContext::CycleCollectNow();
#endif // BUILD_GC_ON_IPC_MESSAGES
}
Expand Down
2 changes: 1 addition & 1 deletion dom/ipc/ContentChild.cpp
Expand Up @@ -2472,7 +2472,7 @@ mozilla::ipc::IPCResult ContentChild::RecvGarbageCollect() {
if (obs) {
obs->NotifyObservers(nullptr, "child-gc-request", nullptr);
}
nsJSContext::GarbageCollectNow(JS::gcreason::DOM_IPC);
nsJSContext::GarbageCollectNow(JS::GCReason::DOM_IPC);
return IPC_OK();
}

Expand Down
2 changes: 1 addition & 1 deletion dom/script/ScriptLoader.cpp
Expand Up @@ -2444,7 +2444,7 @@ class MOZ_RAII AutoSetProcessingScriptTag {
static nsresult ExecuteCompiledScript(JSContext* aCx,
ScriptLoadRequest* aRequest,
nsJSUtils::ExecutionContext& aExec) {
JS::Rooted<JSScript*> script(aCx, aExec.GetScript());
JS::Rooted<JSScript*> script(aCx, aExec.MaybeGetScript());
if (!script) {
// Compilation succeeds without producing a script if scripting is
// disabled for the global.
Expand Down
34 changes: 19 additions & 15 deletions dom/smil/nsSMILInterval.cpp → dom/smil/SMILInterval.cpp
Expand Up @@ -4,11 +4,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsSMILInterval.h"
#include "SMILInterval.h"

nsSMILInterval::nsSMILInterval() : mBeginFixed(false), mEndFixed(false) {}
namespace mozilla {

nsSMILInterval::nsSMILInterval(const nsSMILInterval& aOther)
SMILInterval::SMILInterval() : mBeginFixed(false), mEndFixed(false) {}

SMILInterval::SMILInterval(const SMILInterval& aOther)
: mBegin(aOther.mBegin),
mEnd(aOther.mEnd),
mBeginFixed(false),
Expand All @@ -25,13 +27,13 @@ nsSMILInterval::nsSMILInterval(const nsSMILInterval& aOther)
"Attempt to copy-construct an interval with fixed endpoints");
}

nsSMILInterval::~nsSMILInterval() {
SMILInterval::~SMILInterval() {
MOZ_ASSERT(mDependentTimes.IsEmpty(),
"Destroying interval without disassociating dependent instance "
"times. Unlink was not called");
}

void nsSMILInterval::Unlink(bool aFiltered) {
void SMILInterval::Unlink(bool aFiltered) {
for (int32_t i = mDependentTimes.Length() - 1; i >= 0; --i) {
if (aFiltered) {
mDependentTimes[i]->HandleFilteredInterval();
Expand All @@ -50,17 +52,17 @@ void nsSMILInterval::Unlink(bool aFiltered) {
mEnd = nullptr;
}

nsSMILInstanceTime* nsSMILInterval::Begin() {
nsSMILInstanceTime* SMILInterval::Begin() {
MOZ_ASSERT(mBegin && mEnd, "Requesting Begin() on un-initialized interval.");
return mBegin;
}

nsSMILInstanceTime* nsSMILInterval::End() {
nsSMILInstanceTime* SMILInterval::End() {
MOZ_ASSERT(mBegin && mEnd, "Requesting End() on un-initialized interval.");
return mEnd;
}

void nsSMILInterval::SetBegin(nsSMILInstanceTime& aBegin) {
void SMILInterval::SetBegin(nsSMILInstanceTime& aBegin) {
MOZ_ASSERT(aBegin.Time().IsDefinite(),
"Attempt to set unresolved or indefinite begin time on interval");
MOZ_ASSERT(!mBeginFixed,
Expand All @@ -74,7 +76,7 @@ void nsSMILInterval::SetBegin(nsSMILInstanceTime& aBegin) {
mBegin = &aBegin;
}

void nsSMILInterval::SetEnd(nsSMILInstanceTime& aEnd) {
void SMILInterval::SetEnd(nsSMILInstanceTime& aEnd) {
MOZ_ASSERT(!mEndFixed, "Attempt to set end time but the end point is fixed");
// As with SetBegin, check we're not making an instance time dependent on
// itself.
Expand All @@ -84,14 +86,14 @@ void nsSMILInterval::SetEnd(nsSMILInstanceTime& aEnd) {
mEnd = &aEnd;
}

void nsSMILInterval::FixBegin() {
void SMILInterval::FixBegin() {
MOZ_ASSERT(mBegin && mEnd, "Fixing begin point on un-initialized interval");
MOZ_ASSERT(!mBeginFixed, "Duplicate calls to FixBegin()");
mBeginFixed = true;
mBegin->AddRefFixedEndpoint();
}

void nsSMILInterval::FixEnd() {
void SMILInterval::FixEnd() {
MOZ_ASSERT(mBegin && mEnd, "Fixing end point on un-initialized interval");
MOZ_ASSERT(mBeginFixed,
"Fixing the end of an interval without a fixed begin");
Expand All @@ -100,27 +102,27 @@ void nsSMILInterval::FixEnd() {
mEnd->AddRefFixedEndpoint();
}

void nsSMILInterval::AddDependentTime(nsSMILInstanceTime& aTime) {
void SMILInterval::AddDependentTime(nsSMILInstanceTime& aTime) {
RefPtr<nsSMILInstanceTime>* inserted =
mDependentTimes.InsertElementSorted(&aTime);
if (!inserted) {
NS_WARNING("Insufficient memory to insert instance time.");
}
}

void nsSMILInterval::RemoveDependentTime(const nsSMILInstanceTime& aTime) {
void SMILInterval::RemoveDependentTime(const nsSMILInstanceTime& aTime) {
#ifdef DEBUG
bool found =
#endif
mDependentTimes.RemoveElementSorted(&aTime);
MOZ_ASSERT(found, "Couldn't find instance time to delete.");
}

void nsSMILInterval::GetDependentTimes(InstanceTimeList& aTimes) {
void SMILInterval::GetDependentTimes(InstanceTimeList& aTimes) {
aTimes = mDependentTimes;
}

bool nsSMILInterval::IsDependencyChainLink() const {
bool SMILInterval::IsDependencyChainLink() const {
if (!mBegin || !mEnd)
return false; // Not yet initialised so it can't be part of a chain

Expand All @@ -132,3 +134,5 @@ bool nsSMILInterval::IsDependencyChainLink() const {
return (mBegin->IsDependent() && mBegin->GetBaseInterval() != this) ||
(mEnd->IsDependent() && mEnd->GetBaseInterval() != this);
}

} // namespace mozilla

0 comments on commit 299b5e7

Please sign in to comment.