Skip to content

Commit

Permalink
Bug 1726804 - Refactor definition and usage of GECKO_PROCESS_TYPE() r…
Browse files Browse the repository at this point in the history
…=nika,firefox-build-system-reviewers,mhentges

Differential Revision: https://phabricator.services.mozilla.com/D121388
  • Loading branch information
Alexandre Lissy committed Nov 19, 2021
1 parent fea7d30 commit 60d1060
Show file tree
Hide file tree
Showing 21 changed files with 473 additions and 166 deletions.
1 change: 1 addition & 0 deletions build/common_virtualenv_packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,5 @@ pth:toolkit/components/telemetry/tests/marionette/harness
pth:tools
pth:tools/moztreedocs
pth:xpcom/ds/tools
pth:xpcom/geckoprocesstypes_generator
pth:xpcom/idl-parser
69 changes: 32 additions & 37 deletions dom/base/ChromeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,17 +864,20 @@ static WebIDLProcType ProcTypeToWebIDL(mozilla::ProcType aType) {
PROCTYPE_TO_WEBIDL_CASE(WebCOOPCOEP, WithCoopCoep);
PROCTYPE_TO_WEBIDL_CASE(WebServiceWorker, WebServiceWorker);
PROCTYPE_TO_WEBIDL_CASE(WebLargeAllocation, WebLargeAllocation);
PROCTYPE_TO_WEBIDL_CASE(Browser, Browser);
PROCTYPE_TO_WEBIDL_CASE(IPDLUnitTest, IpdlUnitTest);
PROCTYPE_TO_WEBIDL_CASE(GMPlugin, GmpPlugin);
PROCTYPE_TO_WEBIDL_CASE(GPU, Gpu);
PROCTYPE_TO_WEBIDL_CASE(VR, Vr);
PROCTYPE_TO_WEBIDL_CASE(RDD, Rdd);
PROCTYPE_TO_WEBIDL_CASE(Socket, Socket);
PROCTYPE_TO_WEBIDL_CASE(RemoteSandboxBroker, RemoteSandboxBroker);
#ifdef MOZ_ENABLE_FORKSERVER
PROCTYPE_TO_WEBIDL_CASE(ForkServer, ForkServer);
#endif
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
process_bin_type, procinfo_typename, \
webidl_typename, allcaps_name) \
PROCTYPE_TO_WEBIDL_CASE(procinfo_typename, webidl_typename);
#define SKIP_PROCESS_TYPE_CONTENT
#ifndef MOZ_ENABLE_FORKSERVER
# define SKIP_PROCESS_TYPE_FORKSERVER
#endif // MOZ_ENABLE_FORKSERVER
#include "mozilla/GeckoProcessTypes.h"
#undef SKIP_PROCESS_TYPE_CONTENT
#ifndef MOZ_ENABLE_FORKSERVER
# undef SKIP_PROCESS_TYPE_FORKSERVER
#endif // MOZ_ENABLE_FORKSERVER
#undef GECKO_PROCESS_TYPE
PROCTYPE_TO_WEBIDL_CASE(Preallocated, Preallocated);
PROCTYPE_TO_WEBIDL_CASE(Unknown, Unknown);
}
Expand Down Expand Up @@ -945,36 +948,28 @@ already_AddRefed<Promise> ChromeUtils::RequestProcInfo(GlobalObject& aGlobal,
// These processes are handled separately.
return;
}
case GeckoProcessType::GeckoProcessType_Default:
type = mozilla::ProcType::Browser;
break;
case GeckoProcessType::GeckoProcessType_GMPlugin:
type = mozilla::ProcType::GMPlugin;
break;
case GeckoProcessType::GeckoProcessType_GPU:
type = mozilla::ProcType::GPU;
break;
case GeckoProcessType::GeckoProcessType_VR:
type = mozilla::ProcType::VR;
break;
case GeckoProcessType::GeckoProcessType_RDD:
type = mozilla::ProcType::RDD;
break;
case GeckoProcessType::GeckoProcessType_Socket:
type = mozilla::ProcType::Socket;
break;
case GeckoProcessType::GeckoProcessType_RemoteSandboxBroker:
type = mozilla::ProcType::RemoteSandboxBroker;
break;
#ifdef MOZ_ENABLE_FORKSERVER
case GeckoProcessType::GeckoProcessType_ForkServer:
type = mozilla::ProcType::ForkServer;
break;
#endif
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
process_bin_type, procinfo_typename, \
webidl_typename, allcaps_name) \
case GeckoProcessType::GeckoProcessType_##enum_name: { \
type = mozilla::ProcType::procinfo_typename; \
break; \
}
#define SKIP_PROCESS_TYPE_CONTENT
#ifndef MOZ_ENABLE_FORKSERVER
# define SKIP_PROCESS_TYPE_FORKSERVER
#endif // MOZ_ENABLE_FORKSERVER
#include "mozilla/GeckoProcessTypes.h"
#ifndef MOZ_ENABLE_FORKSERVER
# undef SKIP_PROCESS_TYPE_FORKSERVER
#endif // MOZ_ENABLE_FORKSERVER
#undef SKIP_PROCESS_TYPE_CONTENT
#undef GECKO_PROCESS_TYPE
default:
// Leave the default Unknown value in |type|.
break;
}

requests.EmplaceBack(
/* aPid = */ childPid,
/* aProcessType = */ type,
Expand Down
9 changes: 5 additions & 4 deletions ipc/glue/CrashReporterHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,11 @@ void CrashReporterHost::RecordCrashWithTelemetry(GeckoProcessType aProcessType,
nsCString key;

switch (aProcessType) {
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, xre_name, \
bin_type) \
case GeckoProcessType_##enum_name: \
key.AssignLiteral(string_name); \
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
process_bin_type, procinfo_typename, \
webidl_typename, allcaps_name) \
case GeckoProcessType_##enum_name: \
key.AssignLiteral(string_name); \
break;
#include "mozilla/GeckoProcessTypes.h"
#undef GECKO_PROCESS_TYPE
Expand Down
2 changes: 2 additions & 0 deletions js/src/make-source-package.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ def parse_version(topsrc_dir):
+ /toolkit/crashreporter/tools/symbolstore.py
+ /toolkit/mozapps/installer/package-name.mk
+ /xpcom/geckoprocesstypes_generator/**
# SpiderMonkey itself
+ /js/src/**
Expand Down
6 changes: 6 additions & 0 deletions python/mozbuild/mozbuild/action/test_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@
"pattern": "**",
"dest": "tools/mozterm",
},
{
"source": buildconfig.topsrcdir,
"base": "xpcom/geckoprocesstypes_generator",
"pattern": "**",
"dest": "tools/geckoprocesstypes_generator",
},
{
"source": buildconfig.topsrcdir,
"base": "third_party/python/six",
Expand Down
1 change: 1 addition & 0 deletions testing/config/mozbase_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
../tools/mozterm
../tools/geckoprocesstypes_generator

../mozbase/manifestparser
../mozbase/mozcrash
Expand Down
1 change: 1 addition & 0 deletions testing/config/mozbase_source_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
--editable ../../python/mozterm
--editable ../../xpcom/geckoprocesstypes_generator

--editable ../mozbase/manifestparser
--editable ../mozbase/mozcrash
Expand Down
13 changes: 4 additions & 9 deletions testing/mozbase/mozleak/mozleak/leaklog.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import os
import re

from geckoprocesstypes import process_types


def _get_default_logger():
from mozlog import get_default_logger
Expand Down Expand Up @@ -183,16 +185,9 @@ def process_leak_log(

# This list is based on XRE_GeckoProcessTypeToString. ipdlunittest processes likely
# are not going to produce leak logs we will ever see.

knownProcessTypes = [
"default",
"forkserver",
"gmplugin",
"gpu",
"plugin",
"rdd",
"socket",
"tab",
"vr",
p.string_name for p in process_types if p.string_name != "ipdlunittest"
]

for processType in knownProcessTypes:
Expand Down
1 change: 1 addition & 0 deletions testing/tools/mach_test_package_initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"reftest",
"tools/mach",
"tools/mozterm",
"tools/geckoprocesstypes_generator",
"tools/six",
"tools/wptserve",
"web-platform",
Expand Down
27 changes: 15 additions & 12 deletions toolkit/components/processtools/ProcInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,21 @@ enum class ProcType {
WebLargeAllocation,
WebCOOPCOEP,
WebServiceWorker,
// the rest matches GeckoProcessTypes.h
Browser, // Default is named Browser here
IPDLUnitTest,
GMPlugin,
GPU,
VR,
RDD,
Socket,
RemoteSandboxBroker,
#ifdef MOZ_ENABLE_FORKSERVER
ForkServer,
#endif
// the rest matches GeckoProcessTypes.h
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
process_bin_type, procinfo_typename, \
webidl_typename, allcaps_name) \
procinfo_typename,
#define SKIP_PROCESS_TYPE_CONTENT
#ifndef MOZ_ENABLE_FORKSERVER
# define SKIP_PROCESS_TYPE_FORKSERVER
#endif // MOZ_ENABLE_FORKSERVER
#include "mozilla/GeckoProcessTypes.h"
#undef SKIP_PROCESS_TYPE_CONTENT
#ifndef MOZ_ENABLE_FORKSERVER
# undef SKIP_PROCESS_TYPE_FORKSERVER
#endif // MOZ_ENABLE_FORKSERVER
#undef GECKO_PROCESS_TYPE
Preallocated,
// Unknown type of process
Unknown,
Expand Down
41 changes: 18 additions & 23 deletions toolkit/xre/nsAppRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -973,22 +973,15 @@ nsXULAppInfo::GetWidgetToolkit(nsACString& aResult) {
// Ensure that the GeckoProcessType enum, defined in xpcom/build/nsXULAppAPI.h,
// is synchronized with the const unsigned longs defined in
// xpcom/system/nsIXULRuntime.idl.
#define SYNC_ENUMS(a, b) \
static_assert(nsIXULRuntime::PROCESS_TYPE_##a == \
static_cast<int>(GeckoProcessType_##b), \
"GeckoProcessType in nsXULAppAPI.h not synchronized with " \
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
process_bin_type, procinfo_typename, \
webidl_typename, allcaps_name) \
static_assert(nsIXULRuntime::PROCESS_TYPE_##allcaps_name == \
static_cast<int>(GeckoProcessType_##enum_name), \
"GeckoProcessType in nsXULAppAPI.h not synchronized with " \
"nsIXULRuntime.idl");

SYNC_ENUMS(DEFAULT, Default)
SYNC_ENUMS(CONTENT, Content)
SYNC_ENUMS(IPDLUNITTEST, IPDLUnitTest)
SYNC_ENUMS(GMPLUGIN, GMPlugin)
SYNC_ENUMS(GPU, GPU)
SYNC_ENUMS(VR, VR)
SYNC_ENUMS(RDD, RDD)
SYNC_ENUMS(SOCKET, Socket)
SYNC_ENUMS(SANDBOX_BROKER, RemoteSandboxBroker)
SYNC_ENUMS(FORKSERVER, ForkServer)
#include "mozilla/GeckoProcessTypes.h"
#undef GECKO_PROCESS_TYPE

// .. and ensure that that is all of them:
static_assert(GeckoProcessType_ForkServer + 1 == GeckoProcessType_End,
Expand Down Expand Up @@ -5630,10 +5623,11 @@ bool XRE_IsE10sParentProcess() {
#endif
}

#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, xre_name, \
bin_type) \
bool XRE_Is##xre_name##Process() { \
return XRE_GetProcessType() == GeckoProcessType_##enum_name; \
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
process_bin_type, procinfo_typename, \
webidl_typename, allcaps_name) \
bool XRE_Is##proc_typename##Process() { \
return XRE_GetProcessType() == GeckoProcessType_##enum_name; \
}
#include "mozilla/GeckoProcessTypes.h"
#undef GECKO_PROCESS_TYPE
Expand Down Expand Up @@ -5738,10 +5732,11 @@ mozilla::BinPathType XRE_GetChildProcBinPathType(
}

switch (aProcessType) {
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, xre_name, \
bin_type) \
case GeckoProcessType_##enum_name: \
return BinPathType::bin_type;
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
process_bin_type, procinfo_typename, \
webidl_typename, allcaps_name) \
case GeckoProcessType_##enum_name: \
return BinPathType::process_bin_type;
#include "mozilla/GeckoProcessTypes.h"
#undef GECKO_PROCESS_TYPE
default:
Expand Down
7 changes: 4 additions & 3 deletions toolkit/xre/nsEmbedFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,10 @@ void XRE_TermEmbedding() {

const char* XRE_GeckoProcessTypeToString(GeckoProcessType aProcessType) {
switch (aProcessType) {
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, xre_name, \
bin_type) \
case GeckoProcessType::GeckoProcessType_##enum_name: \
#define GECKO_PROCESS_TYPE(enum_value, enum_name, string_name, proc_typename, \
process_bin_type, procinfo_typename, \
webidl_typename, allcaps_name) \
case GeckoProcessType::GeckoProcessType_##enum_name: \
return string_name;
#include "mozilla/GeckoProcessTypes.h"
#undef GECKO_PROCESS_TYPE
Expand Down
71 changes: 0 additions & 71 deletions xpcom/build/GeckoProcessTypes.h

This file was deleted.

34 changes: 34 additions & 0 deletions xpcom/build/gen_process_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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/.

from geckoprocesstypes import process_types


def main(output):
output.write(
"""\
/* THIS FILE IS GENERATED BY GeckoProcessTypes - DO NOT EDIT */
"""
)

for p in process_types:
output.write(
"""
#ifndef SKIP_PROCESS_TYPE_%(allcaps_name)s
GECKO_PROCESS_TYPE(%(enum_value)d, %(enum_name)s, "%(string_name)s", """
"""%(proc_typename)s, %(process_bin_type)s, %(procinfo_typename)s, """
"""%(webidl_typename)s, %(allcaps_name)s)
#endif // SKIP_PROCESS_TYPE_%(allcaps_name)s
"""
% {
"enum_value": p.enum_value,
"enum_name": p.enum_name,
"string_name": p.string_name,
"proc_typename": p.proc_typename,
"process_bin_type": p.process_bin_type,
"procinfo_typename": p.procinfo_typename,
"webidl_typename": p.webidl_typename,
"allcaps_name": p.allcaps_name,
}
)
Loading

0 comments on commit 60d1060

Please sign in to comment.