author | Boris Zbarsky <bzbarsky@mit.edu> |
Wed, 21 Mar 2018 23:18:51 -0400 | |
changeset 409453 | ac47fbb2abd04f58681242bdfbbdeaf9b02e68e5 |
parent 409452 | 4d642b71d6f4f852eb2ee66cf72408965c3cd42a |
child 409454 | f36074b393300a3e8053943e0a91453550ca8075 |
push id | 33687 |
push user | apavel@mozilla.com |
push date | Thu, 22 Mar 2018 09:31:48 +0000 |
treeherder | mozilla-central@7771df14ea18 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | peterv |
bugs | 1442360 |
milestone | 61.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -70,18 +70,16 @@ #include "nsIScriptError.h" #include "mozilla/dom/MediaDevices.h" #include "MediaManager.h" #include "nsIDOMGlobalPropertyInitializer.h" #include "nsJSUtils.h" -#include "nsScriptNameSpaceManager.h" - #include "mozilla/dom/NavigatorBinding.h" #include "mozilla/dom/Promise.h" #include "nsIUploadChannel2.h" #include "mozilla/dom/FormData.h" #include "nsIDocShell.h" #include "mozilla/dom/WorkerPrivate.h"
--- a/dom/base/moz.build +++ b/dom/base/moz.build @@ -88,17 +88,16 @@ EXPORTS += [ 'nsIDOMClassInfo.h', 'nsIGlobalObject.h', 'nsImageLoadingContent.h', 'nsIMutationObserver.h', 'nsINode.h', 'nsINodeList.h', 'nsIScriptContext.h', 'nsIScriptGlobalObject.h', - 'nsIScriptNameSpaceManager.h', 'nsIScriptObjectPrincipal.h', 'nsIScriptTimeoutHandler.h', 'nsIStyleSheetLinkingElement.h', 'nsITimeoutHandler.h', 'nsJSEnvironment.h', 'nsJSUtils.h', 'nsLineBreaker.h', 'nsMappedAttributeElement.h', @@ -327,17 +326,16 @@ UNIFIED_SOURCES += [ 'nsNodeUtils.cpp', 'nsOpenURIInFrameParams.cpp', 'nsPerformanceMetrics.cpp', 'nsPlainTextSerializer.cpp', 'nsPropertyTable.cpp', 'nsQueryContentEventResult.cpp', 'nsRange.cpp', 'nsScreen.cpp', - 'nsScriptNameSpaceManager.cpp', 'nsStructuredCloneContainer.cpp', 'nsStubAnimationObserver.cpp', 'nsStubDocumentObserver.cpp', 'nsStubMutationObserver.cpp', 'nsStyledElement.cpp', 'nsStyleLinkElement.cpp', 'nsSyncLoadService.cpp', 'nsTextFragment.cpp',
--- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -42,19 +42,16 @@ #include "nsIDOMDocument.h" #include "nsIDOMEvent.h" #include "nsIDOMEventListener.h" #include "nsContentUtils.h" #include "nsIDOMGlobalPropertyInitializer.h" #include "mozilla/Attributes.h" #include "mozilla/Telemetry.h" -// Window scriptable helper includes -#include "nsScriptNameSpaceManager.h" - // DOM base includes #include "nsIDOMWindow.h" #include "nsPIDOMWindow.h" // DOM core includes #include "nsError.h" // Event related includes @@ -165,75 +162,17 @@ nsWindowSH::GlobalResolve(nsGlobalWindow if (NS_WARN_IF(!shim)) { return NS_ERROR_OUT_OF_MEMORY; } FillPropertyDescriptor(desc, obj, JS::ObjectValue(*shim), /* readOnly = */ false); return NS_OK; } #endif - nsScriptNameSpaceManager *nameSpaceManager = GetNameSpaceManager(); - NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED); - - // Note - Our only caller is nsGlobalWindow::DoResolve, which checks that - // JSID_IS_STRING(id) is true. - nsAutoJSString name; - if (!name.init(cx, JSID_TO_STRING(id))) { - return NS_ERROR_OUT_OF_MEMORY; - } - - const char16_t *class_name = nullptr; - const nsGlobalNameStruct *name_struct = - nameSpaceManager->LookupName(name, &class_name); - - if (!name_struct) { - return NS_OK; - } - - // The class_name had better match our name - MOZ_ASSERT(name.Equals(class_name)); - - NS_ENSURE_TRUE(class_name, NS_ERROR_UNEXPECTED); - - nsresult rv = NS_OK; - - if (name_struct->mType == nsGlobalNameStruct::eTypeProperty) { - // Before defining a global property, check for a named subframe of the - // same name. If it exists, we don't want to shadow it. - if (nsCOMPtr<nsPIDOMWindowOuter> childWin = aWin->GetChildWindow(name)) { - return NS_OK; - } - - nsCOMPtr<nsISupports> native(do_CreateInstance(name_struct->mCID, &rv)); - NS_ENSURE_SUCCESS(rv, rv); - - JS::Rooted<JS::Value> prop_val(cx, JS::UndefinedValue()); // Property value. - - nsCOMPtr<nsIDOMGlobalPropertyInitializer> gpi(do_QueryInterface(native)); - if (gpi) { - rv = gpi->Init(aWin->AsInner(), &prop_val); - NS_ENSURE_SUCCESS(rv, rv); - } - - if (prop_val.isPrimitive() && !prop_val.isNull()) { - rv = nsContentUtils::WrapNative(cx, native, &prop_val, true); - } - - NS_ENSURE_SUCCESS(rv, rv); - - if (!JS_WrapValue(cx, &prop_val)) { - return NS_ERROR_UNEXPECTED; - } - - FillPropertyDescriptor(desc, obj, prop_val, false); - - return NS_OK; - } - - return rv; + return NS_OK; } struct InterfaceShimEntry { const char *geckoName; const char *domName; }; // We add shims from Components.interfaces.nsIDOMFoo to window.Foo for each
--- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -46,17 +46,16 @@ #include "nsIDocShellTreeOwner.h" #include "nsIDocumentLoader.h" #include "nsIInterfaceRequestorUtils.h" #include "nsIPermissionManager.h" #include "nsIScriptContext.h" #include "nsIScriptTimeoutHandler.h" #include "nsITimeoutHandler.h" #include "nsIController.h" -#include "nsScriptNameSpaceManager.h" #include "nsISlowScriptDebug.h" #include "nsWindowMemoryReporter.h" #include "nsWindowSizes.h" #include "WindowNamedPropertiesHandler.h" #include "nsFrameSelection.h" #include "nsNetUtil.h" #include "nsVariant.h" #include "nsPrintfCString.h" @@ -2934,30 +2933,17 @@ nsGlobalWindowInner::MayResolve(jsid aId if (aId == XPCJSRuntime::Get()->GetStringID(XPCJSContext::IDX_CONTROLLERS) || aId == XPCJSRuntime::Get()->GetStringID(XPCJSContext::IDX_CONTROLLERS_CLASS)) { // We only resolve .controllers/.Controllers in release builds and on non-chrome // windows, but let's not worry about any of that stuff. return true; } - if (WebIDLGlobalNameHash::MayResolve(aId)) { - return true; - } - - nsScriptNameSpaceManager *nameSpaceManager = PeekNameSpaceManager(); - if (!nameSpaceManager) { - // Really shouldn't happen. Fail safe. - return true; - } - - nsAutoString name; - AssignJSFlatString(name, JSID_TO_FLAT_STRING(aId)); - - return nameSpaceManager->LookupName(name); + return WebIDLGlobalNameHash::MayResolve(aId); } void nsGlobalWindowInner::GetOwnPropertyNames(JSContext* aCx, JS::AutoIdVector& aNames, bool aEnumerableOnly, ErrorResult& aRv) { if (aEnumerableOnly) { // The names we would return from here get defined on the window via one of @@ -2969,50 +2955,34 @@ nsGlobalWindowInner::GetOwnPropertyNames // // So in the aEnumerableOnly case we have nothing to do. return; } // "Components" is marked as enumerable but only resolved on demand :-/. //aNames.AppendElement(NS_LITERAL_STRING("Components")); - nsScriptNameSpaceManager* nameSpaceManager = GetNameSpaceManager(); - if (nameSpaceManager) { - JS::Rooted<JSObject*> wrapper(aCx, GetWrapper()); - - // There are actually two ways we can get called here: For normal - // enumeration or for Xray enumeration. In the latter case, we want to - // return all possible WebIDL names, because we don't really support - // deleting these names off our Xray; trying to resolve them will just make - // them come back. In the former case, we want to avoid returning deleted - // names. But the JS engine already knows about the non-deleted - // already-resolved names, so we can just return the so-far-unresolved ones. - // - // We can tell which case we're in by whether aCx is in our wrapper's - // compartment. If not, we're in the Xray case. - WebIDLGlobalNameHash::NameType nameType = - js::IsObjectInContextCompartment(wrapper, aCx) ? - WebIDLGlobalNameHash::UnresolvedNamesOnly : - WebIDLGlobalNameHash::AllNames; - if (!WebIDLGlobalNameHash::GetNames(aCx, wrapper, nameType, aNames)) { - aRv.NoteJSContextException(aCx); - } - - for (auto i = nameSpaceManager->GlobalNameIter(); !i.Done(); i.Next()) { - const GlobalNameMapEntry* entry = i.Get(); - // Just append all of these; even if they get deleted our resolve hook - // just goes ahead and recreates them. - JSString* str = JS_AtomizeUCStringN(aCx, - entry->mKey.BeginReading(), - entry->mKey.Length()); - if (!str || !aNames.append(NON_INTEGER_ATOM_TO_JSID(str))) { - aRv.NoteJSContextException(aCx); - return; - } - } + JS::Rooted<JSObject*> wrapper(aCx, GetWrapper()); + + // There are actually two ways we can get called here: For normal + // enumeration or for Xray enumeration. In the latter case, we want to + // return all possible WebIDL names, because we don't really support + // deleting these names off our Xray; trying to resolve them will just make + // them come back. In the former case, we want to avoid returning deleted + // names. But the JS engine already knows about the non-deleted + // already-resolved names, so we can just return the so-far-unresolved ones. + // + // We can tell which case we're in by whether aCx is in our wrapper's + // compartment. If not, we're in the Xray case. + WebIDLGlobalNameHash::NameType nameType = + js::IsObjectInContextCompartment(wrapper, aCx) ? + WebIDLGlobalNameHash::UnresolvedNamesOnly : + WebIDLGlobalNameHash::AllNames; + if (!WebIDLGlobalNameHash::GetNames(aCx, wrapper, nameType, aNames)) { + aRv.NoteJSContextException(aCx); } } /* static */ bool nsGlobalWindowInner::IsPrivilegedChromeWindow(JSContext* aCx, JSObject* aObj) { // For now, have to deal with XPConnect objects here. return xpc::WindowOrNull(aObj)->IsChromeWindow() &&
--- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -44,17 +44,16 @@ #include "mozilla/dom/power/PowerManagerService.h" #include "nsIDocShellTreeOwner.h" #include "nsIInterfaceRequestorUtils.h" #include "nsIPermissionManager.h" #include "nsIScriptContext.h" #include "nsIScriptTimeoutHandler.h" #include "nsITimeoutHandler.h" #include "nsIController.h" -#include "nsScriptNameSpaceManager.h" #include "nsISlowScriptDebug.h" #include "nsWindowMemoryReporter.h" #include "nsWindowSizes.h" #include "WindowNamedPropertiesHandler.h" #include "nsFrameSelection.h" #include "nsNetUtil.h" #include "nsVariant.h" #include "nsPrintfCString.h"
deleted file mode 100644 --- a/dom/base/nsIScriptNameSpaceManager.h +++ /dev/null @@ -1,10 +0,0 @@ -/* -*- 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 http://mozilla.org/MPL/2.0/. */ - -#ifndef nsIScriptNameSpaceManager_h__ -#define nsIScriptNameSpaceManager_h__ - -#endif /* nsIScriptNameSpaceManager_h__ */
--- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -48,17 +48,16 @@ #include "jsapi.h" #include "js/Wrapper.h" #include "js/SliceBudget.h" #include "nsIArray.h" #include "nsIObjectInputStream.h" #include "nsIObjectOutputStream.h" #include "WrapperFactory.h" #include "nsGlobalWindow.h" -#include "nsScriptNameSpaceManager.h" #include "mozilla/AutoRestore.h" #include "mozilla/MainThreadIdlePeriod.h" #include "mozilla/StaticPtr.h" #include "mozilla/dom/DOMException.h" #include "mozilla/dom/DOMExceptionBinding.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/ErrorEvent.h" #include "mozilla/dom/FetchUtil.h" @@ -194,17 +193,16 @@ static uint32_t sRemovedPurples = 0; static uint32_t sForgetSkippableBeforeCC = 0; static uint32_t sPreviousSuspectedCount = 0; static uint32_t sCleanupsSinceLastGC = UINT32_MAX; static bool sNeedsFullCC = false; static bool sNeedsFullGC = false; static bool sNeedsGCAfterCC = false; static bool sIncrementalCC = false; static int32_t sActiveIntersliceGCBudget = 5; // ms; -static nsScriptNameSpaceManager *gNameSpaceManager; static PRTime sFirstCollectionTime; static bool sIsInitialized; static bool sDidShutdown; static bool sShuttingDown; // nsJSEnvironmentObserver observes the memory-pressure notifications @@ -2462,17 +2460,16 @@ mozilla::dom::StartupJSEnvironment() sLoadingInProgress = false; sCCollectedWaitingForGC = 0; sCCollectedZonesWaitingForGC = 0; sLikelyShortLivingObjectsNeedingGC = 0; sPostGCEventsToConsole = false; sNeedsFullCC = false; sNeedsFullGC = true; sNeedsGCAfterCC = false; - gNameSpaceManager = nullptr; sIsInitialized = false; sDidShutdown = false; sShuttingDown = false; gCCStats.Init(); } static void SetGCParameter(JSGCParamKey aParam, uint32_t aValue) @@ -2800,46 +2797,21 @@ nsJSContext::EnsureStatics() obs->AddObserver(observer, "user-interaction-inactive", false); obs->AddObserver(observer, "user-interaction-active", false); obs->AddObserver(observer, "quit-application", false); obs->AddObserver(observer, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false); sIsInitialized = true; } -nsScriptNameSpaceManager* -mozilla::dom::GetNameSpaceManager() -{ - if (sDidShutdown) - return nullptr; - - if (!gNameSpaceManager) { - gNameSpaceManager = new nsScriptNameSpaceManager; - NS_ADDREF(gNameSpaceManager); - - nsresult rv = gNameSpaceManager->Init(); - NS_ENSURE_SUCCESS(rv, nullptr); - } - - return gNameSpaceManager; -} - -nsScriptNameSpaceManager* -mozilla::dom::PeekNameSpaceManager() -{ - return gNameSpaceManager; -} - void mozilla::dom::ShutdownJSEnvironment() { KillTimers(); - NS_IF_RELEASE(gNameSpaceManager); - sShuttingDown = true; sDidShutdown = true; } // A fast-array class for JS. This class supports both nsIJSScriptArray and // nsIArray. If it is JS itself providing and consuming this class, all work // can be done via nsIJSScriptArray, and avoid the conversion of elements // to/from nsISupports.
--- a/dom/base/nsJSEnvironment.h +++ b/dom/base/nsJSEnvironment.h @@ -15,17 +15,16 @@ #include "nsIXPConnect.h" #include "nsIArray.h" #include "mozilla/Attributes.h" #include "mozilla/TimeStamp.h" #include "nsThreadUtils.h" #include "xpcpublic.h" class nsICycleCollectorListener; -class nsScriptNameSpaceManager; class nsIDocShell; namespace mozilla { template <class> class Maybe; struct CycleCollectorResults; } // namespace mozilla // The amount of time we wait between a request to GC (due to leaving @@ -163,22 +162,16 @@ private: }; namespace mozilla { namespace dom { void StartupJSEnvironment(); void ShutdownJSEnvironment(); -// Get the NameSpaceManager, creating if necessary -nsScriptNameSpaceManager* GetNameSpaceManager(); - -// Peek the NameSpaceManager, without creating it. -nsScriptNameSpaceManager* PeekNameSpaceManager(); - // Runnable that's used to do async error reporting class AsyncErrorReporter final : public mozilla::Runnable { public: // aWindow may be null if this error report is not associated with a window explicit AsyncErrorReporter(xpc::ErrorReport* aReport) : Runnable("dom::AsyncErrorReporter") , mReport(aReport)
deleted file mode 100644 --- a/dom/base/nsScriptNameSpaceManager.cpp +++ /dev/null @@ -1,290 +0,0 @@ -/* -*- 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 http://mozilla.org/MPL/2.0/. */ - -#include "nsScriptNameSpaceManager.h" -#include "nsCOMPtr.h" -#include "nsIComponentManager.h" -#include "nsIComponentRegistrar.h" -#include "nsICategoryManager.h" -#include "nsIServiceManager.h" -#include "nsXPCOM.h" -#include "nsISupportsPrimitives.h" -#include "nsIScriptNameSpaceManager.h" -#include "nsIScriptContext.h" -#include "nsIInterfaceInfoManager.h" -#include "nsIInterfaceInfo.h" -#include "xptinfo.h" -#include "nsString.h" -#include "nsReadableUtils.h" -#include "nsHashKeys.h" -#include "nsDOMClassInfo.h" -#include "nsCRT.h" -#include "nsIObserverService.h" -#include "nsISimpleEnumerator.h" -#include "mozilla/dom/BindingUtils.h" -#include "mozilla/dom/WebIDLGlobalNameHash.h" -#include "mozilla/MemoryReporting.h" -#include "mozilla/Preferences.h" -#include "mozilla/Services.h" - -#define NS_INTERFACE_PREFIX "nsI" -#define NS_DOM_INTERFACE_PREFIX "nsIDOM" - -using namespace mozilla; -using namespace mozilla::dom; - -static PLDHashNumber -GlobalNameHashHashKey(const void *key) -{ - const nsAString *str = static_cast<const nsAString *>(key); - return HashString(*str); -} - -static bool -GlobalNameHashMatchEntry(const PLDHashEntryHdr *entry, const void *key) -{ - const GlobalNameMapEntry *e = - static_cast<const GlobalNameMapEntry *>(entry); - const nsAString *str = static_cast<const nsAString *>(key); - - return str->Equals(e->mKey); -} - -static void -GlobalNameHashClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry) -{ - GlobalNameMapEntry *e = static_cast<GlobalNameMapEntry *>(entry); - - // An entry is being cleared, let the key (nsString) do its own - // cleanup. - e->mKey.~nsString(); - - // This will set e->mGlobalName.mType to - // nsGlobalNameStruct::eTypeNotInitialized - memset(&e->mGlobalName, 0, sizeof(nsGlobalNameStruct)); -} - -static void -GlobalNameHashInitEntry(PLDHashEntryHdr *entry, const void *key) -{ - GlobalNameMapEntry *e = static_cast<GlobalNameMapEntry *>(entry); - const nsAString *keyStr = static_cast<const nsAString *>(key); - - // Initialize the key in the entry with placement new - new (&e->mKey) nsString(*keyStr); - - // This will set e->mGlobalName.mType to - // nsGlobalNameStruct::eTypeNotInitialized - memset(&e->mGlobalName, 0, sizeof(nsGlobalNameStruct)); -} - -NS_IMPL_ISUPPORTS( - nsScriptNameSpaceManager, - nsIObserver, - nsISupportsWeakReference, - nsIMemoryReporter) - -static const PLDHashTableOps hash_table_ops = -{ - GlobalNameHashHashKey, - GlobalNameHashMatchEntry, - PLDHashTable::MoveEntryStub, - GlobalNameHashClearEntry, - GlobalNameHashInitEntry -}; - -#define GLOBALNAME_HASHTABLE_INITIAL_LENGTH 32 - -nsScriptNameSpaceManager::nsScriptNameSpaceManager() - : mGlobalNames(&hash_table_ops, sizeof(GlobalNameMapEntry), - GLOBALNAME_HASHTABLE_INITIAL_LENGTH) -{ -} - -nsScriptNameSpaceManager::~nsScriptNameSpaceManager() -{ - UnregisterWeakMemoryReporter(this); -} - -nsGlobalNameStruct * -nsScriptNameSpaceManager::AddToHash(const char *aKey, - const char16_t **aClassName) -{ - NS_ConvertASCIItoUTF16 key(aKey); - auto entry = static_cast<GlobalNameMapEntry*>(mGlobalNames.Add(&key, fallible)); - if (!entry) { - return nullptr; - } - - WebIDLGlobalNameHash::Remove(aKey, key.Length()); - - if (aClassName) { - *aClassName = entry->mKey.get(); - } - - return &entry->mGlobalName; -} - -void -nsScriptNameSpaceManager::RemoveFromHash(const nsAString *aKey) -{ - mGlobalNames.Remove(aKey); -} - -nsresult -nsScriptNameSpaceManager::FillHash(nsICategoryManager *aCategoryManager, - const char *aCategory) -{ - nsCOMPtr<nsISimpleEnumerator> e; - nsresult rv = aCategoryManager->EnumerateCategory(aCategory, - getter_AddRefs(e)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr<nsISupports> entry; - while (NS_SUCCEEDED(e->GetNext(getter_AddRefs(entry)))) { - rv = AddCategoryEntryToHash(aCategoryManager, aCategory, entry); - if (NS_FAILED(rv)) { - return rv; - } - } - - return NS_OK; -} - - -nsresult -nsScriptNameSpaceManager::Init() -{ - RegisterWeakMemoryReporter(this); - - nsresult rv = NS_OK; - - nsCOMPtr<nsICategoryManager> cm = - do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - // Initial filling of the has table has been done. - // Now, listen for changes. - nsCOMPtr<nsIObserverService> serv = - mozilla::services::GetObserverService(); - - if (serv) { - serv->AddObserver(this, NS_XPCOM_CATEGORY_ENTRY_ADDED_OBSERVER_ID, true); - serv->AddObserver(this, NS_XPCOM_CATEGORY_ENTRY_REMOVED_OBSERVER_ID, true); - } - - return NS_OK; -} - -const nsGlobalNameStruct* -nsScriptNameSpaceManager::LookupName(const nsAString& aName, - const char16_t **aClassName) -{ - auto entry = static_cast<GlobalNameMapEntry*>(mGlobalNames.Search(&aName)); - - if (entry) { - if (aClassName) { - *aClassName = entry->mKey.get(); - } - return &entry->mGlobalName; - } - - if (aClassName) { - *aClassName = nullptr; - } - return nullptr; -} - -nsresult -nsScriptNameSpaceManager::OperateCategoryEntryHash(nsICategoryManager* aCategoryManager, - const char* aCategory, - nsISupports* aEntry, - bool aRemove) -{ - MOZ_ASSERT(aCategoryManager); - return NS_OK; -} - -nsresult -nsScriptNameSpaceManager::AddCategoryEntryToHash(nsICategoryManager* aCategoryManager, - const char* aCategory, - nsISupports* aEntry) -{ - return OperateCategoryEntryHash(aCategoryManager, aCategory, aEntry, - /* aRemove = */ false); -} - -nsresult -nsScriptNameSpaceManager::RemoveCategoryEntryFromHash(nsICategoryManager* aCategoryManager, - const char* aCategory, - nsISupports* aEntry) -{ - return OperateCategoryEntryHash(aCategoryManager, aCategory, aEntry, - /* aRemove = */ true); -} - -NS_IMETHODIMP -nsScriptNameSpaceManager::Observe(nsISupports* aSubject, const char* aTopic, - const char16_t* aData) -{ - if (!aData) { - return NS_OK; - } - - if (!strcmp(aTopic, NS_XPCOM_CATEGORY_ENTRY_ADDED_OBSERVER_ID)) { - nsCOMPtr<nsICategoryManager> cm = - do_GetService(NS_CATEGORYMANAGER_CONTRACTID); - if (!cm) { - return NS_OK; - } - - return AddCategoryEntryToHash(cm, NS_ConvertUTF16toUTF8(aData).get(), - aSubject); - } else if (!strcmp(aTopic, NS_XPCOM_CATEGORY_ENTRY_REMOVED_OBSERVER_ID)) { - nsCOMPtr<nsICategoryManager> cm = - do_GetService(NS_CATEGORYMANAGER_CONTRACTID); - if (!cm) { - return NS_OK; - } - - return RemoveCategoryEntryFromHash(cm, NS_ConvertUTF16toUTF8(aData).get(), - aSubject); - } - - // TODO: we could observe NS_XPCOM_CATEGORY_CLEARED_OBSERVER_ID - // but we are safe without it. See bug 600460. - - return NS_OK; -} - -MOZ_DEFINE_MALLOC_SIZE_OF(ScriptNameSpaceManagerMallocSizeOf) - -NS_IMETHODIMP -nsScriptNameSpaceManager::CollectReports( - nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) -{ - MOZ_COLLECT_REPORT( - "explicit/script-namespace-manager", KIND_HEAP, UNITS_BYTES, - SizeOfIncludingThis(ScriptNameSpaceManagerMallocSizeOf), - "Memory used for the script namespace manager."); - - return NS_OK; -} - -size_t -nsScriptNameSpaceManager::SizeOfIncludingThis( - mozilla::MallocSizeOf aMallocSizeOf) const -{ - size_t n = 0; - - n += mGlobalNames.ShallowSizeOfExcludingThis(aMallocSizeOf); - for (auto iter = mGlobalNames.ConstIter(); !iter.Done(); iter.Next()) { - auto entry = static_cast<GlobalNameMapEntry*>(iter.Get()); - n += entry->SizeOfExcludingThis(aMallocSizeOf); - } - - return n; -}
deleted file mode 100644 --- a/dom/base/nsScriptNameSpaceManager.h +++ /dev/null @@ -1,145 +0,0 @@ -/* -*- 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 http://mozilla.org/MPL/2.0/. */ - -#ifndef nsScriptNameSpaceManager_h__ -#define nsScriptNameSpaceManager_h__ - -#include "mozilla/MemoryReporting.h" -#include "nsBaseHashtable.h" -#include "nsIMemoryReporter.h" -#include "nsIScriptNameSpaceManager.h" -#include "nsString.h" -#include "nsID.h" -#include "PLDHashTable.h" -#include "nsDOMClassInfo.h" -#include "nsIObserver.h" -#include "nsWeakReference.h" -#include "xpcpublic.h" - -struct nsGlobalNameStruct -{ - enum nametype { - eTypeNotInitialized, - eTypeProperty, - } mType; - - union { - nsCID mCID; // eTypeProperty - }; -}; - -class GlobalNameMapEntry : public PLDHashEntryHdr -{ -public: - // Our hash table ops don't care about the order of these members. - nsString mKey; - nsGlobalNameStruct mGlobalName; - - size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { - // Measurement of the following members may be added later if DMD finds it - // is worthwhile: - // - mGlobalName - return mKey.SizeOfExcludingThisIfUnshared(aMallocSizeOf); - } -}; - -class nsICategoryManager; - -class nsScriptNameSpaceManager : public nsIObserver, - public nsSupportsWeakReference, - public nsIMemoryReporter -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIOBSERVER - NS_DECL_NSIMEMORYREPORTER - - nsScriptNameSpaceManager(); - - nsresult Init(); - - // Returns a nsGlobalNameStruct for aName, or null if one is not - // found. The returned nsGlobalNameStruct is only guaranteed to be - // valid until the next call to any of the methods in this class. - // It also returns a pointer to the string buffer of the classname - // in the nsGlobalNameStruct. - const nsGlobalNameStruct* LookupName(const nsAString& aName, - const char16_t **aClassName = nullptr); - - class NameIterator : public PLDHashTable::Iterator - { - public: - typedef PLDHashTable::Iterator Base; - explicit NameIterator(PLDHashTable* aTable) : Base(aTable) {} - NameIterator(NameIterator&& aOther) : Base(mozilla::Move(aOther.mTable)) {} - - const GlobalNameMapEntry* Get() const - { - return static_cast<const GlobalNameMapEntry*>(Base::Get()); - } - - private: - NameIterator() = delete; - NameIterator(const NameIterator&) = delete; - NameIterator& operator=(const NameIterator&) = delete; - NameIterator& operator=(const NameIterator&&) = delete; - }; - - NameIterator GlobalNameIter() { return NameIterator(&mGlobalNames); } - - size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; - -private: - virtual ~nsScriptNameSpaceManager(); - - // Adds a new entry to the hash and returns the nsGlobalNameStruct - // that aKey will be mapped to. If mType in the returned - // nsGlobalNameStruct is != eTypeNotInitialized, an entry for aKey - // already existed. - nsGlobalNameStruct *AddToHash(const char *aKey, - const char16_t **aClassName = nullptr); - - // Removes an existing entry from the hash. - void RemoveFromHash(const nsAString *aKey); - - nsresult FillHash(nsICategoryManager *aCategoryManager, - const char *aCategory); - - /** - * Add a new category entry into the hash table. - * Only some categories can be added (see the beginning of the definition). - * The other ones will be ignored. - * - * @aCategoryManager Instance of the category manager service. - * @aCategory Category where the entry comes from. - * @aEntry The entry that should be added. - */ - nsresult AddCategoryEntryToHash(nsICategoryManager* aCategoryManager, - const char* aCategory, - nsISupports* aEntry); - - /** - * Remove an existing category entry from the hash table. - * Only some categories can be removed (see the beginning of the definition). - * The other ones will be ignored. - * - * @aCategory Category where the entry will be removed from. - * @aEntry The entry that should be removed. - */ - nsresult RemoveCategoryEntryFromHash(nsICategoryManager* aCategoryManager, - const char* aCategory, - nsISupports* aEntry); - - // common helper for AddCategoryEntryToHash and RemoveCategoryEntryFromHash - nsresult OperateCategoryEntryHash(nsICategoryManager* aCategoryManager, - const char* aCategory, - nsISupports* aEntry, - bool aRemove); - - PLDHashTable mGlobalNames; -}; - -#endif /* nsScriptNameSpaceManager_h__ */
--- a/js/src/devtools/rootAnalysis/annotations.js +++ b/js/src/devtools/rootAnalysis/annotations.js @@ -198,21 +198,16 @@ var ignoreFunctions = { // FIXME! "NS_DebugBreak": true, // These are a little overzealous -- these destructors *can* GC if they end // up wrapping a pending exception. See bug 898815 for the heavyweight fix. "void js::AutoCompartment::~AutoCompartment(int32)" : true, "void JSAutoCompartment::~JSAutoCompartment(int32)" : true, - // The nsScriptNameSpaceManager functions can't actually GC. They - // just use a PLDHashTable which has function pointers, which makes the - // analysis think maybe they can. - "nsGlobalNameStruct* nsScriptNameSpaceManager::LookupName(nsAString*, uint16**)": true, - // Similar to heap snapshot mock classes, and GTests below. This posts a // synchronous runnable when a GTest fails, and we are pretty sure that the // particular runnable it posts can't even GC, but the analysis isn't // currently smart enough to determine that. In either case, this is (a) // only in GTests, and (b) only when the Gtest has already failed. We have // static and dynamic checks for no GC in the non-test code, and in the test // code we fall back to only the dynamic checks. "void test::RingbufferDumper::OnTestPartResult(testing::TestPartResult*)" : true,
--- a/js/xpconnect/src/xpcpublic.h +++ b/js/xpconnect/src/xpcpublic.h @@ -24,17 +24,16 @@ #include "mozilla/fallible.h" #include "nsMathUtils.h" #include "nsStringBuffer.h" #include "mozilla/dom/BindingDeclarations.h" #include "mozilla/Preferences.h" class nsGlobalWindowInner; class nsIPrincipal; -class nsScriptNameSpaceManager; class nsIHandleReportCallback; namespace mozilla { namespace dom { class Exception; } }
--- a/layout/build/nsLayoutModule.cpp +++ b/layout/build/nsLayoutModule.cpp @@ -28,17 +28,16 @@ #include "nsIDocumentEncoder.h" #include "nsIFactory.h" #include "nsIIdleService.h" #include "nsHTMLStyleSheet.h" #include "nsILayoutDebugger.h" #include "nsNameSpaceManager.h" #include "nsIObserver.h" #include "nsIObserverService.h" -#include "nsIScriptNameSpaceManager.h" #include "nsIScriptError.h" #include "nsISelection.h" #include "nsCaret.h" #include "nsPlainTextSerializer.h" #include "nsXMLContentSerializer.h" #include "nsXHTMLContentSerializer.h" #include "nsContentAreaDragDrop.h" #include "nsBox.h" @@ -63,17 +62,16 @@ // view stuff #include "nsContentCreatorFunctions.h" #include "nsHostObjectURI.h" #include "nsGlobalWindowCommands.h" #include "nsIControllerCommandTable.h" #include "nsJSProtocolHandler.h" -#include "nsScriptNameSpaceManager.h" #include "nsIControllerContext.h" #include "nsZipArchive.h" #include "mozilla/Attributes.h" #include "mozilla/dom/DOMRequest.h" #include "mozilla/dom/LocalStorageManager.h" #include "mozilla/dom/network/UDPSocketChild.h" #include "mozilla/dom/quota/QuotaManagerService.h" #include "mozilla/dom/ServiceWorkerManager.h"