author Jan de Mooij <>
Sat, 12 Jan 2019 10:50:04 +0000
changeset 453631 cfa1c48c717048f00eb4811b5719cd716eb1e5b3
parent 448947 6f3709b3878117466168c40affa7bca0b60cf75b
child 472056 e1993a1f09ac53cd1a04fdf6a87f8cad8e44f73e
permissions -rw-r--r--
Bug 1518753 part 5 - Stop using JSProtoKey for initial shapes. r=tcampbell I added this optimization in bug 1299107 to share more shapes across compartments. Unfortunately this doesn't play well with same-compartment realms (ICs can misbehave) because it relies on compartments being isolated from each other. I think we should remove this optimization: * Fixing the IC issue is impossible without deoptimizing everything. * I added it mainly for chrome globals. The shared-JSM-global work has eliminated the need for this there. * Same-compartment realms win memory back by eliminating CCWs etc. * It's quite a lot of complicated code. Differential Revision:

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at */

#ifndef gfxCrashReporterUtils_h__
#define gfxCrashReporterUtils_h__

#include "nsString.h"

namespace mozilla {

/** \class ScopedGfxFeatureReporter
 * On creation, adds "FeatureName?" to AppNotes
 * On destruction, adds "FeatureName-", or "FeatureName+" if you called
 * SetSuccessful().
 * Any such string is added at most once to AppNotes, and is subsequently
 * skipped.
 * This ScopedGfxFeatureReporter class is designed to be fool-proof to use in
 * functions that have many exit points. We don't want to encourage having
 * function with many exit points. It just happens that our graphics features
 * initialization functions are like that.
class ScopedGfxFeatureReporter {
  explicit ScopedGfxFeatureReporter(const char *aFeature, bool aForce = false)
      : mFeature(aFeature), mStatusChar('-'), mStatusNumber(0) {
    WriteAppNote(aForce ? '!' : '?', 0);
  ~ScopedGfxFeatureReporter() { WriteAppNote(mStatusChar, mStatusNumber); }
  void SetSuccessful() { mStatusChar = '+'; }
  void SetSuccessful(int32_t aNumber) {
    mStatusChar = '+';
    mStatusNumber = aNumber;

  static void AppNote(const nsACString &aMessage);

  class AppNoteWritingRunnable;

  const char *mFeature;
  char mStatusChar;
  int32_t mStatusNumber;

  void WriteAppNote(char statusChar, int32_t statusNumber);

}  // end namespace mozilla

#endif  // gfxCrashReporterUtils_h__