author | Coroiu Cristina <ccoroiu@mozilla.com> |
Fri, 15 Feb 2019 01:00:33 +0200 | |
changeset 520216 | 1a199fcf0ef6e0c7b106e1820e8fb12c08e2dbab |
parent 520215 | 32240c1876469d81df538053257013664a9e83bb |
child 520217 | 426ca85d23038f08ebe29ce16db8fd484062f1f9 |
child 520322 | b9744b9a4d03b238187c975f54745462bac0c1a3 |
push id | 2032 |
push user | ffxbld-merge |
push date | Mon, 13 May 2019 09:36:57 +0000 |
treeherder | mozilla-release@455c1065dcbe [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
bugs | 1524688 |
milestone | 67.0a1 |
backs out | 042a975d3971e60f1edbaa8338332c0daa596b90 abaf68fe399ba6871f254b32ca6660892ff09da1 |
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/browser/base/content/test/static/browser_all_files_referenced.js +++ b/browser/base/content/test/static/browser_all_files_referenced.js @@ -638,20 +638,16 @@ add_task(async function checkAllTheFiles } return true; }); // Wait for all manifest to be parsed await throttledMapPromises(manifestURIs, parseManifest); - for (let jsm of Components.manager.getComponentJSMs()) { - gReferencesFromCode.set(jsm, null); - } - // manifest.json is a common name, it is used for WebExtension manifests // but also for other things. To tell them apart, we have to actually // read the contents. This will populate gExtensionRoots with all // embedded extension APIs, and return any manifest.json files that aren't // webextensions. let nonWebextManifests = (await Promise.all(jsonManifests.map(parseJsonManifest))) .filter(uri => !!uri); uris.push(...nonWebextManifests);
--- a/build/docs/defining-xpcom-components.rst +++ b/build/docs/defining-xpcom-components.rst @@ -97,22 +97,16 @@ Class definitions may have the following The fully-qualified name of a constructor function to call in order to create instances of this class. This function must be declared in one of the headers listed in the ``headers`` property, must take no arguments, and must return ``already_AddRefed<iface>`` where ``iface`` is the interface provided in the ``type`` property. This property is incompatible with ``legacy_constructor``. -``jsm`` (optional) - If provided, must be the URL of a JavaScript module which contains a - JavaScript implementation of the component. The ``constructor`` property - must contain the name of an exported function which can be constructed to - create a new instance of the component. - ``legacy_constructor`` (optional) This property is deprecated, and should not be used in new code. The fully-qualified name of a constructor function to call in order to create instances of this class. This function must be declared in one of the headers listed in the ``headers`` property, and must have the signature ``nsresult(nsISupports* aOuter, const nsID& aIID, void** aResult)``, and behave equivalently to ``nsIFactory::CreateInstance``.
--- a/xpcom/components/StaticComponents.cpp.in +++ b/xpcom/components/StaticComponents.cpp.in @@ -4,42 +4,34 @@ * 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 "StaticComponents.h" #include "mozilla/PerfectHash.h" #include "mozilla/ResultExtensions.h" #include "mozilla/StaticPtr.h" -#include "mozilla/UniquePtr.h" -#include "mozilla/dom/ScriptSettings.h" -#include "mozJSComponentLoader.h" #include "nsCOMPtr.h" #include "nsComponentManager.h" -#include "nsContentUtils.h" #include "nsIFactory.h" #include "nsISupports.h" #include "nsString.h" -#include "nsStringEnumerator.h" // Cleanup pollution from zipstruct.h #undef UNSUPPORTED // Public includes //# @includes@ // Relative includes //# @relative_includes@ //# @decls@ namespace mozilla { - -using dom::AutoJSAPI; - namespace xpcom { static constexpr uint32_t kNoContractID = 0xffffffff; namespace { // Template helpers for constructor function sanity checks. template <typename T> struct RemoveAlreadyAddRefed { @@ -65,20 +57,16 @@ static const char gStrings[] = const StaticCategory gStaticCategories[kStaticCategoryCount] = { //# @categories@ }; const StaticCategoryEntry gStaticCategoryEntries[] = { //# @category_entries@ }; -const StringOffset gComponentJSMs[] = { -//# @component_jsms@ -}; - /** * Returns a nsCString corresponding to the given entry in the `gStrings` string * table. The resulting nsCString points directly to static storage, and does * not incur any memory allocation overhead. */ static inline nsCString GetString(const StringOffset& aOffset) { const char* str = &gStrings[aOffset.mOffset]; nsCString result; @@ -90,47 +78,16 @@ nsCString ContractEntry::ContractID() co return GetString(mContractID); } bool ContractEntry::Matches(const nsACString& aContractID) const { return aContractID == ContractID() && Module().Active(); } -static nsresult ConstructJSMComponent(const nsACString& aURI, - const char* aConstructor, - nsISupports** aResult) { - if (!nsComponentManagerImpl::JSLoaderReady()) { - return NS_ERROR_NOT_AVAILABLE; - } - - AutoJSAPI jsapi; - MOZ_ALWAYS_TRUE(jsapi.Init(xpc::PrivilegedJunkScope())); - JSContext* cx = jsapi.cx(); - - JS::RootedObject global(cx); - JS::RootedObject exports(cx); - MOZ_TRY(mozJSComponentLoader::Get()->Import(cx, aURI, &global, &exports)); - - JS::RootedValue ctor(cx); - if (!JS_GetProperty(cx, exports, aConstructor, &ctor) || - !ctor.isObject()) { - return NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED; - } - - JS::RootedObject inst(cx); - if (!JS::Construct(cx, ctor, JS::HandleValueArray::empty(), &inst)) { - return NS_ERROR_FAILURE; - } - - return nsContentUtils::XPConnect()->WrapJS(cx, inst, NS_GET_IID(nsISupports), - (void**)aResult); -} - - //# @module_cid_table@ //# @module_contract_id_table@ static inline bool CalledInit(size_t aIdx) { return GetBit(gInitCalled, aIdx); } @@ -269,30 +226,16 @@ nsCString StaticCategory::Name() const { const nsACString& aContractID, bool aInvalid) { if (const ContractEntry* entry = LookupContractID(aContractID)) { entry->SetInvalid(aInvalid); return true; } return false; } -/* static */ already_AddRefed<nsIUTF8StringEnumerator> -StaticComponents::GetComponentJSMs() { - auto jsms = MakeUnique<nsTArray<nsCString>>(MOZ_ARRAY_LENGTH(gComponentJSMs)); - - for (const auto& entry : gComponentJSMs) { - jsms->AppendElement(GetString(entry)); - } - - nsCOMPtr<nsIUTF8StringEnumerator> result; - MOZ_ALWAYS_SUCCEEDS(NS_NewAdoptingUTF8StringEnumerator(getter_AddRefs(result), - jsms.release())); - return result.forget(); -} - /* static */ void StaticComponents::Shutdown() { CallUnloadFuncs(); } /* static */ const nsID& Components::GetCID(ModuleID aID) { return gStaticModules[size_t(aID)].CID(); }
--- a/xpcom/components/StaticComponents.h +++ b/xpcom/components/StaticComponents.h @@ -12,17 +12,16 @@ #include "nsID.h" #include "nsStringFwd.h" #include "nscore.h" #include "mozilla/Components.h" #include "StaticComponentData.h" class nsIFactory; -class nsIUTF8StringEnumerator; class nsISupports; namespace mozilla { namespace xpcom { struct ContractEntry; struct StaticModule; @@ -204,18 +203,16 @@ class StaticComponents final { /** * Marks a static contract ID entry invalid (or unsets the invalid bit if * aInvalid is false). See `CategoryEntry::Invalid()`. */ static bool InvalidateContractID(const nsACString& aContractID, bool aInvalid = true); - static already_AddRefed<nsIUTF8StringEnumerator> GetComponentJSMs(); - /** * Calls any module unload from manifests whose components have been loaded. */ static void Shutdown(); }; } // namespace xpcom } // namespace mozilla
--- a/xpcom/components/gen_static_components.py +++ b/xpcom/components/gen_static_components.py @@ -213,18 +213,16 @@ class ModuleEntry(object): # `CallInitFunc(init_idx)` call will be genrated before calling this # module's constructor. self.init_idx = init_idx self.constructor = data.get('constructor', None) self.legacy_constructor = data.get('legacy_constructor', None) self.init_method = data.get('init_method', []) - self.jsm = data.get('jsm', None) - self.external = data.get('external', not (self.headers or self.legacy_constructor)) self.singleton = data.get('singleton', False) self.overridable = data.get('overridable', False) if 'name' in data: self.anonymous = False self.name = data['name'] @@ -233,25 +231,17 @@ class ModuleEntry(object): self.name = 'Anonymous%03d' % ModuleEntry.next_anon_id ModuleEntry.next_anon_id += 1 def error(str_): raise Exception("Error defining component %s (%s): %s" % ( str(self.cid), ', '.join(map(repr, self.contract_ids)), str_)) - if self.jsm: - if not self.constructor: - error("JavaScript components must specify a constructor") - - for prop in ('init_method', 'legacy_constructor', 'headers'): - if getattr(self, prop): - error("JavaScript components may not specify a '%s' " - "property" % prop) - elif self.external: + if self.external: if self.constructor or self.legacy_constructor: error("Externally-constructed components may not specify " "'constructor' or 'legacy_constructor' properties") if self.init_method: error("Externally-constructed components may not specify " "'init_method' properties") if self.type == 'nsISupports': error("Externally-constructed components must specify a type " @@ -304,24 +294,17 @@ class ModuleEntry(object): if self.init_idx is not None: res += ' MOZ_TRY(CallInitFunc(%d));\n' % self.init_idx if self.legacy_constructor: res += (' return /* legacy */ %s(nullptr, aIID, aResult);\n' % self.legacy_constructor) return res - if self.jsm: - res += ( - ' nsCOMPtr<nsISupports> inst;\n' - ' MOZ_TRY(ConstructJSMComponent(NS_LITERAL_CSTRING(%s),\n' - ' %s,\n' - ' getter_AddRefs(inst)));' - '\n' % (json.dumps(self.jsm), json.dumps(self.constructor))) - elif self.external: + if self.external: res += (' nsCOMPtr<nsISupports> inst = ' 'mozCreateComponent<%s>();\n' % self.type) else: res += ' RefPtr<%s> inst = ' % self.type if not self.constructor: res += 'new %s();\n' % self.type else: @@ -562,18 +545,16 @@ def gen_substs(manifests): for clas in manifest['Classes']: modules.append(ModuleEntry(clas, init_idx)) contracts = [] contract_map = {} categories = defaultdict(list) - jsms = set() - types = set() for mod in modules: headers |= set(mod.headers) for contract_id in mod.contract_ids: if contract_id in contract_map: raise Exception('Duplicate contract ID: %s' % contract_id) @@ -585,19 +566,16 @@ def gen_substs(manifests): for category, entries in mod.categories.items(): for entry in to_list(entries): categories[category].append((entry, mod.contract_id, mod.processes)) if mod.type and not mod.headers: types.add(mod.type) - if mod.jsm: - jsms.add(mod.jsm) - cid_phf = PerfectHash(modules, PHF_SIZE, key=lambda module: module.cid.bytes) contract_phf = PerfectHash(contracts, PHF_SIZE, key=lambda entry: entry.contract) substs = {} @@ -608,19 +586,16 @@ def gen_substs(manifests): substs['module_count'] = len(modules) substs['contract_count'] = len(contracts) gen_module_funcs(substs, module_funcs) gen_includes(substs, headers) - substs['component_jsms'] = '\n'.join(' %s,' % strings.entry_to_cxx(jsm) - for jsm in sorted(jsms)) + '\n' - substs['decls'] = gen_decls(types) substs['constructors'] = gen_constructors(cid_phf.entries) substs['component_getters'] = gen_getters(cid_phf.entries) substs['module_cid_table'] = cid_phf.cxx_codegen( name='ModuleByCID',
--- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -526,18 +526,16 @@ nsresult nsComponentManagerImpl::Init() break; } if (loadChromeManifests) { // This needs to be called very early, before anything in nsLayoutModule is // used, and before any calls are made into the JS engine. nsLayoutModuleInitialize(); - mJSLoaderReady = true; - // The overall order in which chrome.manifests are expected to be treated // is the following: // - greDir // - greDir's omni.ja // - appDir // - appDir's omni.ja InitializeModuleLocations(); @@ -2007,24 +2005,16 @@ nsComponentManagerImpl::RemoveBootstrapp // Remove reference. nsComponentManagerImpl::sModuleLocations->RemoveElement( elem, ComponentLocationComparator()); rv = cr->CheckForNewChrome(); return rv; } - -NS_IMETHODIMP -nsComponentManagerImpl::GetComponentJSMs(nsIUTF8StringEnumerator** aJSMs) { - nsCOMPtr<nsIUTF8StringEnumerator> result = StaticComponents::GetComponentJSMs(); - result.forget(aJSMs); - return NS_OK; -} - NS_IMETHODIMP nsComponentManagerImpl::GetManifestLocations(nsIArray** aLocations) { NS_ENSURE_ARG_POINTER(aLocations); *aLocations = nullptr; if (!sModuleLocations) { return NS_ERROR_NOT_INITIALIZED; }
--- a/xpcom/components/nsComponentManager.h +++ b/xpcom/components/nsComponentManager.h @@ -161,18 +161,16 @@ class nsComponentManagerImpl final : pub mozilla::Maybe<EntryWrapper> LookupByContractID( const nsACString& aContractID); mozilla::Maybe<EntryWrapper> LookupByContractID( const MutexLock&, const nsACString& aContractID); nsresult GetService(mozilla::xpcom::ModuleID, const nsIID& aIID, void** aResult); - static bool JSLoaderReady() { return gComponentManager->mJSLoaderReady; } - static void InitializeStaticModules(); static void InitializeModuleLocations(); struct ComponentLocation { NSLocationType type; mozilla::FileLocation location; }; @@ -278,18 +276,16 @@ class nsComponentManagerImpl final : pub inline PendingServiceInfo* AddPendingService(const nsCID& aServiceCID, PRThread* aThread); inline void RemovePendingService(const nsCID& aServiceCID); inline PRThread* GetPendingServiceThread(const nsCID& aServiceCID) const; nsTArray<PendingServiceInfo> mPendingServices; - bool mJSLoaderReady = false; - size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; private: ~nsComponentManagerImpl(); nsresult GetServiceLocked(MutexLock& aLock, EntryWrapper& aEntry, const nsIID& aIID, void** aResult); };
--- a/xpcom/components/nsIComponentManager.idl +++ b/xpcom/components/nsIComponentManager.idl @@ -7,17 +7,16 @@ * The nsIComponentManager interface. */ #include "nsISupports.idl" interface nsIFile; interface nsIFactory; interface nsIArray; -interface nsIUTF8StringEnumerator; [scriptable, uuid(d604ffc3-1ba3-4f6c-b65f-1ed4199364c3)] interface nsIComponentManager : nsISupports { /** * getClassObject * * Returns the factory object that can be used to create instances of @@ -92,22 +91,16 @@ interface nsIComponentManager : nsISuppo void removeBootstrappedManifestLocation(in nsIFile aLocation); /** * getManifestLocations * * Get an array of nsIURIs of all registered and builtin manifest locations. */ nsIArray getManifestLocations(); - - /** - * Returns a list of JSM URLs which are used to create components. This - * should only be used in automation. - */ - nsIUTF8StringEnumerator getComponentJSMs(); }; %{ C++ #ifdef MOZILLA_INTERNAL_API #include "nsComponentManagerUtils.h" #endif %} C++