author Andrew McCreight <>
Mon, 22 Apr 2019 16:34:51 +0000
changeset 470376 3073770e06f157040f4c64951b7e8425e1ad7bbe
parent 444674 52a1404ac742b76a5776c41aabc7f9d295e3a08a
permissions -rwxr-xr-x
Bug 1535403 - Take indirection into account for the CC optimizations for the outer window wrapper. r=peterv Most wrapper cached C++ objects are held alive by their wrapper. The cycle collector takes advantage of this in many classes and ignores the C++ object if the wrapper is marked black. However, this is not true for the outer window's wrapper. Instead, the outer window's wrapper keeps the inner window alive. The inner window usually keeps its outer window alive, but not after it has been unlinked. For reasons I do not yet understand, the outer window's wrapper can be kept alive after the inner window it is a proxy for is unlinked. This patch fixes the cycle collector optimization for the outer window by only applying it if the outer window still has a weak reference to the inner window, which it will until the inner no longer holds the outer alive. This in turn fixes, or at least helps fix, window leaks seen intermittently when the lifetime of outer windows and docshells are tied together. The code comment is based on a review comment by peterv. Differential Revision:

/* List of defines generated by configure. Included with preprocessor flag,
 * -include, to avoid long list of -D defines on the compile command-line.
 * Do not edit.


#if defined(__clang__)
#pragma clang diagnostic push
#if __has_warning("-Wreserved-id-macro")
#pragma clang diagnostic ignored "-Wreserved-id-macro"

/* Expands to all the defines from configure. */

 * The c99 defining the limit macros (UINT32_MAX for example), says:
 *   C++ implementations should define these macros only when
 *   __STDC_LIMIT_MACROS is defined before <stdint.h> is included.
 * The same also occurs with __STDC_CONSTANT_MACROS for the constant macros
 * (INT8_C for example) used to specify a literal constant of the proper type,
 * and with __STDC_FORMAT_MACROS for the format macros (PRId32 for example) used
 * with the fprintf function family.
#if !defined(__STDC_FORMAT_MACROS)

#if defined(__clang__)
#pragma clang diagnostic pop

 * Force-include sdkdecls.h for building the chromium sandbox code.
 * CHROMIUM_SANDBOX_BUILD is defined in security/sandbox/
 * Note that this include path relies on the LOCAL_INCLUDES in that file.
#if defined(CHROMIUM_SANDBOX_BUILD) && defined(XP_WIN)
#include "base/win/sdkdecls.h"

#ifdef __MINGW32__
 * MinGW doesn't support __try / __except. There are a few mechanisms available
 * to hack around it and pseudo-support it, but these are untested in Firefox.
 * What is tested (and works) is replacing them with if(true) and else.
#define __try if(true)
#define __except(x) else
#ifdef GetExceptionCode
#undef GetExceptionCode
#define GetExceptionCode() 0

#endif /* __MINGW32__ */
#endif /* defined(CHROMIUM_SANDBOX_BUILD) && defined(XP_WIN) */

#endif /* MOZILLA_CONFIG_H */