Commit 193ccd13 authored by Iulian Moraru's avatar Iulian Moraru
Browse files

Backed out 5 changesets (bug 1672121) for various crashes on mozalloc_handle_oom. CLOSED TREE

Backed out changeset 117756828ea7 (bug 1672121)
Backed out changeset 046e37035dbc (bug 1672121)
Backed out changeset de44a280103b (bug 1672121)
Backed out changeset 4acf4539a7b4 (bug 1672121)
Backed out changeset 8001b5433e38 (bug 1672121)
parent b50fdd0f
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -486,8 +486,7 @@ void CCGCScheduler::EnsureGCRunner(TimeDuration aDelay) {
      "CCGCScheduler::EnsureGCRunner", aDelay,
      TimeDuration::FromMilliseconds(
          StaticPrefs::javascript_options_gc_delay_interslice()),
      mActiveIntersliceGCBudget, true, [this] { return mDidShutdown; },
      [this](uint32_t) { mInterruptRequested = true; });
      mActiveIntersliceGCBudget, true, [this] { return mDidShutdown; });
}

// nsJSEnvironmentObserver observes the user-interaction-inactive notifications
@@ -595,7 +594,8 @@ js::SliceBudget CCGCScheduler::ComputeCCSliceBudget(

  if (aCCBeginTime.IsNull()) {
    // If no CC is in progress, use the standard slice time.
    return js::SliceBudget(js::TimeBudget(baseBudget));
    return js::SliceBudget(js::TimeBudget(baseBudget),
                           kNumCCNodesBetweenTimeChecks);
  }

  // Only run a limited slice if we're within the max running time.
@@ -624,8 +624,9 @@ js::SliceBudget CCGCScheduler::ComputeCCSliceBudget(
  // Note: We may have already overshot the deadline, in which case
  // baseBudget will be negative and we will end up returning
  // laterSliceBudget.
  return js::SliceBudget(js::TimeBudget(
      std::max({delaySliceBudget, laterSliceBudget, baseBudget})));
  return js::SliceBudget(js::TimeBudget(std::max(
                             {delaySliceBudget, laterSliceBudget, baseBudget})),
                         kNumCCNodesBetweenTimeChecks);
}

TimeDuration CCGCScheduler::ComputeInterSliceGCBudget(TimeStamp aDeadline,
+3 −11
Original line number Diff line number Diff line
@@ -61,6 +61,9 @@ static const TimeDuration kMaxCCLockedoutTime = TimeDuration::FromSeconds(30);
// Trigger a CC if the purple buffer exceeds this size when we check it.
static const uint32_t kCCPurpleLimit = 200;

// How many cycle collected nodes to traverse between time checks.
static const int64_t kNumCCNodesBetweenTimeChecks = 1000;

// Actions performed by the GCRunner state machine.
enum class GCRunnerAction {
  WaitToMajorGC,  // We want to start a new major GC
@@ -109,8 +112,6 @@ struct CCRunnerStep {

class CCGCScheduler {
 public:
  CCGCScheduler() : mInterruptRequested(false) {}

  static bool CCRunnerFired(TimeStamp aDeadline);

  // Parameter setting
@@ -153,11 +154,6 @@ class CCGCScheduler {
  void KillCCRunner();
  void KillAllTimersAndRunners();

  js::SliceBudget CreateGCSliceBudget(JS::GCReason aReason, int64_t aMillis) {
    return js::SliceBudget(mozilla::TimeDuration::FromMilliseconds(aMillis),
                           &mInterruptRequested);
  }

  /*
   * aDelay is the delay before the first time the idle task runner runs.
   * Then it runs every
@@ -442,10 +438,6 @@ class CCGCScheduler {
  // The parent process is ready for us to do a major GC.
  bool mReadyForMajorGC = false;

  // Set when the IdleTaskRunner requests the current task be interrupted.
  // Cleared when the GC slice budget has detected the interrupt request.
  mozilla::Atomic<bool> mInterruptRequested;

  // When a shrinking GC has been requested but we back-out, if this is true
  // we run a non-shrinking GC.
  bool mWantAtLeastRegularGC = false;
+1 −7
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@
#include "mozilla/ContentEvents.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "nsCycleCollectionNoteRootCallback.h"
#include "mozilla/IdleTaskRunner.h"
#include "nsViewManager.h"
#include "mozilla/EventStateManager.h"
#include "mozilla/ProfilerLabels.h"
@@ -1922,11 +1923,6 @@ static bool ConsumeStream(JSContext* aCx, JS::HandleObject aObj,
                                       nullptr);
}

static js::SliceBudget CreateGCSliceBudget(JS::GCReason aReason,
                                           int64_t aMillis) {
  return sScheduler.CreateGCSliceBudget(aReason, aMillis);
}

void nsJSContext::EnsureStatics() {
  if (sIsInitialized) {
    if (!nsContentUtils::XPConnect()) {
@@ -1943,8 +1939,6 @@ void nsJSContext::EnsureStatics() {

  sPrevGCSliceCallback = JS::SetGCSliceCallback(jsapi.cx(), DOMGCSliceCallback);

  JS::SetCreateGCSliceBudgetCallback(jsapi.cx(), CreateGCSliceBudget);

  JS::InitDispatchToEventLoop(jsapi.cx(), DispatchToEventLoop, nullptr);
  JS::InitConsumeStreamCallback(jsapi.cx(), ConsumeStream,
                                FetchUtil::ReportJSStreamError);
+1 −4
Original line number Diff line number Diff line
@@ -13,7 +13,6 @@
#include "nsThreadUtils.h"
#include "nsITimer.h"
#include "nsIThread.h"
#include "nsXPCOMPrivate.h"  // for gXPCOMThreadsShutDown

namespace mozilla::ipc {

@@ -73,10 +72,8 @@ IdleSchedulerParent::IdleSchedulerParent() {
                  CalculateNumIdleTasks();
                });

            if (MOZ_LIKELY(!gXPCOMThreadsShutDown)) {
            thread->Dispatch(runnable, NS_DISPATCH_NORMAL);
          }
          }
        });
    NS_DispatchBackgroundTask(runnable.forget(), NS_DISPATCH_EVENT_MAY_BLOCK);
  }
+0 −15
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

#include "js/GCAnnotations.h"
#include "js/shadow/Zone.h"
#include "js/SliceBudget.h"
#include "js/TypeDecls.h"
#include "js/UniquePtr.h"
#include "js/Utility.h"
@@ -889,20 +888,6 @@ typedef void (*DoCycleCollectionCallback)(JSContext* cx);
extern JS_PUBLIC_API DoCycleCollectionCallback
SetDoCycleCollectionCallback(JSContext* cx, DoCycleCollectionCallback callback);

using CreateSliceBudgetCallback = js::SliceBudget (*)(JS::GCReason reason,
                                                      int64_t millis);

/**
 * Called when generating a GC slice budget. It allows the embedding to control
 * the duration of slices and potentially check an interrupt flag as well. For
 * internally triggered GCs, the given millis parameter is the JS engine's
 * internal scheduling decision, which the embedding can choose to ignore.
 * (Otherwise, it will be the value that was passed to eg
 * JS::IncrementalGCSlice()).
 */
extern JS_PUBLIC_API void SetCreateGCSliceBudgetCallback(
    JSContext* cx, CreateSliceBudgetCallback cb);

/**
 * Incremental GC defaults to enabled, but may be disabled for testing or in
 * embeddings that have not yet implemented barriers on their native classes.
Loading