Improve terminology used in code (#38960)
authorStephen Toub <stoub@microsoft.com>
Thu, 9 Jul 2020 16:41:15 +0000 (12:41 -0400)
committerGitHub <noreply@github.com>
Thu, 9 Jul 2020 16:41:15 +0000 (12:41 -0400)
* Improve terminology used in code

* Address PR feedback

* Update src/libraries/System.Private.CoreLib/src/System/Resources/RuntimeResourceSet.cs

Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
src/coreclr/src/jit/compiler.cpp
src/coreclr/src/jit/phase.cpp
src/coreclr/src/tools/r2rtest/Commands/CompileSerpCommand.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs
src/libraries/System.Private.CoreLib/src/System/Resources/RuntimeResourceSet.cs
src/mono/mono/metadata/native-library.c
src/mono/mono/mini/interp/transform.c
src/mono/mono/mini/mini-exceptions.c
src/mono/mono/mini/mini-runtime.c
src/mono/mono/sgen/sgen-gc.c

index 375a65a..a6e4ee7 100644 (file)
@@ -3413,7 +3413,7 @@ bool Compiler::compStressCompileHelper(compStressArea stressArea, unsigned weigh
         }
 
         // This stress mode name did not match anything in the stress
-        // mode whitelist. If user has requested only enable mode,
+        // mode allowlist. If user has requested only enable mode,
         // don't allow this stress mode to turn on.
         const bool onlyEnableMode = JitConfig.JitStressModeNamesOnly() != 0;
 
index 7a552cc..f1fd245 100644 (file)
@@ -74,7 +74,7 @@ void Phase::PrePhase()
 
     // To help in the incremental conversion of jit activity to phases
     // without greatly increasing dump size or checked jit time, we
-    // currently whitelist the phases that do pre-phase checks and
+    // currently allow the phases that do pre-phase checks and
     // dumps via the phase object, and not via explicit calls from
     // the various methods in the phase.
     //
@@ -84,12 +84,12 @@ void Phase::PrePhase()
     //
     // Currently the list is just the set of phases that have custom
     // derivations from the Phase class.
-    static Phases s_whitelist[] = {PHASE_BUILD_SSA, PHASE_RATIONALIZE, PHASE_LOWERING, PHASE_STACK_LEVEL_SETTER};
+    static Phases s_allowlist[] = {PHASE_BUILD_SSA, PHASE_RATIONALIZE, PHASE_LOWERING, PHASE_STACK_LEVEL_SETTER};
     bool          doPrePhase    = false;
 
-    for (size_t i = 0; i < sizeof(s_whitelist) / sizeof(Phases); i++)
+    for (size_t i = 0; i < sizeof(s_allowlist) / sizeof(Phases); i++)
     {
-        if (m_phase == s_whitelist[i])
+        if (m_phase == s_allowlist[i])
         {
             doPrePhase = true;
             break;
@@ -145,7 +145,7 @@ void Phase::PostPhase(PhaseStatus status)
 
     // To help in the incremental conversion of jit activity to phases
     // without greatly increasing dump size or checked jit time, we
-    // currently whitelist the phases that do post-phase checks and
+    // currently allow the phases that do post-phase checks and
     // dumps via the phase object, and not via explicit calls from
     // the various methods in the phase.
     //
@@ -157,7 +157,7 @@ void Phase::PostPhase(PhaseStatus status)
     // well as the new-style phases that have been updated to return
     // PhaseStatus from their DoPhase methods.
     //
-    static Phases s_whitelist[] = {PHASE_IMPORTATION,
+    static Phases s_allowlist[] = {PHASE_IMPORTATION,
                                    PHASE_INDXCALL,
                                    PHASE_MORPH_INLINE,
                                    PHASE_ALLOCATE_OBJECTS,
@@ -174,9 +174,9 @@ void Phase::PostPhase(PhaseStatus status)
 
     if (madeChanges)
     {
-        for (size_t i = 0; i < sizeof(s_whitelist) / sizeof(Phases); i++)
+        for (size_t i = 0; i < sizeof(s_allowlist) / sizeof(Phases); i++)
         {
-            if (m_phase == s_whitelist[i])
+            if (m_phase == s_allowlist[i])
             {
                 doPostPhase = true;
                 break;
index 880e225..813b6bf 100644 (file)
@@ -77,10 +77,10 @@ namespace R2RTest
                 throw new ArgumentException($"Error: InputDirectory must point at a SERP build. Could not find {Path.Combine(SerpDir, "runserp.cmd")}");
             }
 
-            string whiteListFilePath = Path.Combine(SerpDir, "WhitelistDlls.txt");
-            if (!File.Exists(whiteListFilePath))
+            string allowListFilePath = Path.Combine(SerpDir, "WhitelistDlls.txt");
+            if (!File.Exists(allowListFilePath))
             {
-                throw new ArgumentException($"File {whiteListFilePath} was not found");
+                throw new ArgumentException($"File {allowListFilePath} was not found");
             }
 
             // Add all assemblies from the various SERP packages (filtered by ShouldInclude)
@@ -106,8 +106,8 @@ namespace R2RTest
             _coreCompileAssemblies = new List<string>();
             _coreReferenceAssemblies = new List<string>();
             {
-                // Add a whitelist of assemblies from bin
-                foreach (string item in new HashSet<string>(File.ReadAllLines(whiteListFilePath)))
+                // Add an allowlist of assemblies from bin
+                foreach (string item in new HashSet<string>(File.ReadAllLines(allowListFilePath)))
                 {
                     string binAssembly = Path.Combine(BinDir, item);
                     _coreCompileAssemblies.Add(binAssembly);
index b44daa6..f55e270 100644 (file)
@@ -44,21 +44,21 @@ namespace System.Net.Http
         private bool _persistAuthority;
 
         /// <summary>
-        /// When an Alt-Svc authority fails due to 421 Misdirected Request, it is placed in the blacklist to be ignored
-        /// for <see cref="AltSvcBlacklistTimeoutInMilliseconds"/> milliseconds. Initialized on first use.
+        /// When an Alt-Svc authority fails due to 421 Misdirected Request, it is placed in the blocklist to be ignored
+        /// for <see cref="AltSvcBlocklistTimeoutInMilliseconds"/> milliseconds. Initialized on first use.
         /// </summary>
-        private volatile HashSet<HttpAuthority>? _altSvcBlacklist;
-        private CancellationTokenSource? _altSvcBlacklistTimerCancellation;
+        private volatile HashSet<HttpAuthority>? _altSvcBlocklist;
+        private CancellationTokenSource? _altSvcBlocklistTimerCancellation;
         private volatile bool _altSvcEnabled = true;
 
         /// <summary>
-        /// If <see cref="_altSvcBlacklist"/> exceeds this size, Alt-Svc will be disabled entirely for <see cref="AltSvcBlacklistTimeoutInMilliseconds"/> milliseconds.
+        /// If <see cref="_altSvcBlocklist"/> exceeds this size, Alt-Svc will be disabled entirely for <see cref="AltSvcBlocklistTimeoutInMilliseconds"/> milliseconds.
         /// This is to prevent a failing server from bloating the dictionary beyond a reasonable value.
         /// </summary>
         private const int MaxAltSvcIgnoreListSize = 8;
 
-        /// <summary>The time, in milliseconds, that an authority should remain in <see cref="_altSvcBlacklist"/>.</summary>
-        private const int AltSvcBlacklistTimeoutInMilliseconds = 10 * 60 * 1000;
+        /// <summary>The time, in milliseconds, that an authority should remain in <see cref="_altSvcBlocklist"/>.</summary>
+        private const int AltSvcBlocklistTimeoutInMilliseconds = 10 * 60 * 1000;
 
         /// <summary>List of idle connections stored in the pool.</summary>
         private readonly List<CachedConnection> _idleConnections = new List<CachedConnection>();
@@ -712,7 +712,7 @@ namespace System.Net.Http
 #if false
                 if (quicConnection.NegotiatedApplicationProtocol != SslApplicationProtocol.Http3)
                 {
-                    BlacklistAuthority(authority);
+                    BlocklistAuthority(authority);
                     throw new HttpRequestException("QUIC connected but no HTTP/3 indicated via ALPN.", null, RequestRetryType.RetryOnSameOrNextProxy);
                 }
 #endif
@@ -803,11 +803,11 @@ namespace System.Net.Http
 
                 // If an Alt-Svc authority returns 421, it means it can't actually handle the request.
                 // An authority is supposed to be able to handle ALL requests to the origin, so this is a server bug.
-                // In this case, we blacklist the authority and retry the request at the origin.
+                // In this case, we blocklist the authority and retry the request at the origin.
                 if (response.StatusCode == HttpStatusCode.MisdirectedRequest && connection is Http3Connection h3Connection && h3Connection.Authority != _originAuthority)
                 {
                     response.Dispose();
-                    BlacklistAuthority(h3Connection.Authority);
+                    BlocklistAuthority(h3Connection.Authority);
                     continue;
                 }
 
@@ -846,13 +846,13 @@ namespace System.Net.Http
                     {
                         var authority = new HttpAuthority(value.Host!, value.Port);
 
-                        if (_altSvcBlacklist != null)
+                        if (_altSvcBlocklist != null)
                         {
-                            lock (_altSvcBlacklist)
+                            lock (_altSvcBlocklist)
                             {
-                                if (_altSvcBlacklist.Contains(authority))
+                                if (_altSvcBlocklist.Contains(authority))
                                 {
-                                    // Skip authorities in our blacklist.
+                                    // Skip authorities in our blocklist.
                                     continue;
                                 }
                             }
@@ -940,46 +940,46 @@ namespace System.Net.Http
         }
 
         /// <summary>
-        /// Blacklists an authority and resets the current authority back to origin.
-        /// If the number of blacklisted authorities exceeds <see cref="MaxAltSvcIgnoreListSize"/>,
+        /// Blocklists an authority and resets the current authority back to origin.
+        /// If the number of blocklisted authorities exceeds <see cref="MaxAltSvcIgnoreListSize"/>,
         /// Alt-Svc will be disabled entirely for a period of time.
         /// </summary>
         /// <remarks>
         /// This is called when we get a "421 Misdirected Request" from an alternate authority.
         /// A future strategy would be to retry the individual request on an older protocol, we'd want to have
-        /// some logic to blacklist after some number of failures to avoid doubling our request latency.
+        /// some logic to blocklist after some number of failures to avoid doubling our request latency.
         ///
         /// For now, the spec states alternate authorities should be able to handle ALL requests, so this
-        /// is treated as an exceptional error by immediately blacklisting the authority.
+        /// is treated as an exceptional error by immediately blocklisting the authority.
         /// </remarks>
-        internal void BlacklistAuthority(HttpAuthority badAuthority)
+        internal void BlocklistAuthority(HttpAuthority badAuthority)
         {
             Debug.Assert(badAuthority != null);
             Debug.Assert(badAuthority != _originAuthority);
 
-            HashSet<HttpAuthority>? altSvcBlacklist = _altSvcBlacklist;
+            HashSet<HttpAuthority>? altSvcBlocklist = _altSvcBlocklist;
 
-            if (altSvcBlacklist == null)
+            if (altSvcBlocklist == null)
             {
                 lock (SyncObj)
                 {
-                    altSvcBlacklist = _altSvcBlacklist;
-                    if (altSvcBlacklist == null)
+                    altSvcBlocklist = _altSvcBlocklist;
+                    if (altSvcBlocklist == null)
                     {
-                        altSvcBlacklist = new HashSet<HttpAuthority>();
-                        _altSvcBlacklistTimerCancellation = new CancellationTokenSource();
-                        _altSvcBlacklist = altSvcBlacklist;
+                        altSvcBlocklist = new HashSet<HttpAuthority>();
+                        _altSvcBlocklistTimerCancellation = new CancellationTokenSource();
+                        _altSvcBlocklist = altSvcBlocklist;
                     }
                 }
             }
 
             bool added, disabled = false;
 
-            lock (altSvcBlacklist)
+            lock (altSvcBlocklist)
             {
-                added = altSvcBlacklist.Add(badAuthority);
+                added = altSvcBlocklist.Add(badAuthority);
 
-                if (added && altSvcBlacklist.Count >= MaxAltSvcIgnoreListSize && _altSvcEnabled)
+                if (added && altSvcBlocklist.Count >= MaxAltSvcIgnoreListSize && _altSvcEnabled)
                 {
                     _altSvcEnabled = false;
                     disabled = true;
@@ -996,26 +996,26 @@ namespace System.Net.Http
                 }
             }
 
-            Debug.Assert(_altSvcBlacklistTimerCancellation != null);
+            Debug.Assert(_altSvcBlocklistTimerCancellation != null);
             if (added)
             {
-               _ = Task.Delay(AltSvcBlacklistTimeoutInMilliseconds)
+               _ = Task.Delay(AltSvcBlocklistTimeoutInMilliseconds)
                     .ContinueWith(t =>
                     {
-                        lock (altSvcBlacklist)
+                        lock (altSvcBlocklist)
                         {
-                            altSvcBlacklist.Remove(badAuthority);
+                            altSvcBlocklist.Remove(badAuthority);
                         }
-                    }, _altSvcBlacklistTimerCancellation.Token, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default);
+                    }, _altSvcBlocklistTimerCancellation.Token, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default);
             }
 
             if (disabled)
             {
-                _ = Task.Delay(AltSvcBlacklistTimeoutInMilliseconds)
+                _ = Task.Delay(AltSvcBlocklistTimeoutInMilliseconds)
                     .ContinueWith(t =>
                     {
                         _altSvcEnabled = true;
-                    }, _altSvcBlacklistTimerCancellation.Token, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default);
+                    }, _altSvcBlocklistTimerCancellation.Token, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default);
             }
         }
 
@@ -1401,11 +1401,11 @@ namespace System.Net.Http
                         _authorityExpireTimer = null;
                     }
 
-                    if (_altSvcBlacklistTimerCancellation != null)
+                    if (_altSvcBlocklistTimerCancellation != null)
                     {
-                        _altSvcBlacklistTimerCancellation.Cancel();
-                        _altSvcBlacklistTimerCancellation.Dispose();
-                        _altSvcBlacklistTimerCancellation = null;
+                        _altSvcBlocklistTimerCancellation.Cancel();
+                        _altSvcBlocklistTimerCancellation.Dispose();
+                        _altSvcBlocklistTimerCancellation = null;
                     }
                 }
                 Debug.Assert(list.Count == 0, $"Expected {nameof(list)}.{nameof(list.Count)} == 0");
index e059be2..703c4e8 100644 (file)
@@ -163,7 +163,7 @@ namespace System.Resources
     // resource files containing thousands of resources.
     //
 #if CORERT
-    public  // On CoreRT, this must be public because of need to whitelist past the ReflectionBlock.
+    public  // On CoreRT, this must be public to prevent it from getting reflection blocked.
 #else
     internal
 #endif
index 02eb5a1..b2d5712 100644 (file)
@@ -23,16 +23,16 @@ static char **pinvoke_search_directories;
 static MonoCoopMutex native_library_module_lock;
 static GHashTable *native_library_module_map;
 /*
- * This blacklist is used as a set for cache invalidation purposes with netcore pinvokes.
+ * This blocklist is used as a set for cache invalidation purposes with netcore pinvokes.
  * When pinvokes are resolved with anything other than the last-chance managed event,
  * the results of that lookup are added to an ALC-level cache. However, if a library is then
  * unloaded with NativeLibrary.Free(), this cache should be invalidated so that a newly called
- * pinvoke will not attempt to use it, hence the blacklist. This design means that if another
+ * pinvoke will not attempt to use it, hence the blocklist. This design means that if another
  * library is loaded at the same address, it will function with a perf hit, as the entry will
- * repeatedly be added and removed from the cache due to its presence in the blacklist.
+ * repeatedly be added and removed from the cache due to its presence in the blocklist.
  * This is a rare scenario and considered a worthwhile tradeoff.
  */
-static GHashTable *native_library_module_blacklist;
+static GHashTable *native_library_module_blocklist;
 #endif
 
 #ifndef DISABLE_DLLMAP
@@ -319,8 +319,8 @@ mono_global_loader_cache_init (void)
 #ifdef ENABLE_NETCORE
        if (!native_library_module_map)
                native_library_module_map = g_hash_table_new (g_direct_hash, g_direct_equal);
-       if (!native_library_module_blacklist)
-               native_library_module_blacklist = g_hash_table_new (g_direct_hash, g_direct_equal);
+       if (!native_library_module_blocklist)
+               native_library_module_blocklist = g_hash_table_new (g_direct_hash, g_direct_equal);
        mono_coop_mutex_init (&native_library_module_lock);
 #endif
 }
@@ -472,9 +472,9 @@ netcore_handle_lookup (gpointer handle)
 
 // LOCKING: expects you to hold native_library_module_lock
 static gboolean
-netcore_check_blacklist (MonoDl *module)
+netcore_check_blocklist (MonoDl *module)
 {
-       return g_hash_table_contains (native_library_module_blacklist, module);
+       return g_hash_table_contains (native_library_module_blocklist, module);
 }
 
 static MonoDl *
@@ -720,13 +720,13 @@ netcore_check_alc_cache (MonoAssemblyLoadContext *alc, const char *scope)
        result = (MonoDl *)g_hash_table_lookup (alc->pinvoke_scopes, scope);
 
        if (result) {
-               gboolean blacklisted;
+               gboolean blocklisted;
 
                native_library_lock ();
-               blacklisted = netcore_check_blacklist (result);
+               blocklisted = netcore_check_blocklist (result);
                native_library_unlock ();
 
-               if (blacklisted) {
+               if (blocklisted) {
                        g_hash_table_remove (alc->pinvoke_scopes, scope);
                        result = NULL;
                }
@@ -1420,7 +1420,7 @@ ves_icall_System_Runtime_InteropServices_NativeLibrary_FreeLib (gpointer lib, Mo
                goto leave;
 
        g_hash_table_remove (native_library_module_map, module->handle);
-       g_hash_table_add (native_library_module_blacklist, module);
+       g_hash_table_add (native_library_module_blocklist, module);
        mono_dl_close (module);
 
 leave:
index 126e070..ad2e654 100644 (file)
@@ -1350,20 +1350,15 @@ interp_handle_magic_type_intrinsics (TransformData *td, MonoMethod *target_metho
                /* emit call to managed conversion method */
                return FALSE;
        } else if (!strcmp (".cctor", tm)) {
-               /* white list */
                return FALSE;
        } else if (!strcmp ("Parse", tm)) {
-               /* white list */
                return FALSE;
        } else if (!strcmp ("ToString", tm)) {
-               /* white list */
                return FALSE;
        } else if (!strcmp ("GetHashCode", tm)) {
-               /* white list */
                return FALSE;
        } else if (!strcmp ("IsNaN", tm) || !strcmp ("IsInfinity", tm) || !strcmp ("IsNegativeInfinity", tm) || !strcmp ("IsPositiveInfinity", tm)) {
                g_assert (type_index == 2); // nfloat only
-               /* white list */
                return FALSE;
        }
 
index 0ddb5b0..e752679 100644 (file)
@@ -1446,9 +1446,9 @@ fill_frame_managed_info (MonoFrameSummary *frame, MonoMethod * method)
 typedef struct {
        char *suffix;
        char *exported_name;
-} MonoLibWhitelistEntry;
+} MonoLibAllowlistEntry;
 
-static GList *native_library_whitelist;
+static GList *native_library_allowlist;
 static gboolean allow_all_native_libraries = FALSE;
 
 static void
@@ -1457,10 +1457,10 @@ mono_crash_reporting_register_native_library (const char *module_path, const cha
        // Examples: libsystem_pthread.dylib -> "pthread"
        // Examples: libsystem_platform.dylib -> "platform"
        // Examples: mono-sgen -> "mono" from above line
-       MonoLibWhitelistEntry *entry = g_new0 (MonoLibWhitelistEntry, 1);
+       MonoLibAllowlistEntry*entry = g_new0 (MonoLibAllowlistEntry, 1);
        entry->suffix = g_strdup (module_path);
        entry->exported_name = g_strdup (module_name);
-       native_library_whitelist = g_list_append (native_library_whitelist, entry);
+       native_library_allowlist = g_list_append (native_library_allowlist, entry);
 }
 
 static void
@@ -1470,7 +1470,7 @@ mono_crash_reporting_allow_all_native_libraries ()
 }
 
 static gboolean
-check_whitelisted_module (const char *in_name, const char **out_module)
+check_allowlisted_module (const char *in_name, const char **out_module)
 {
 #ifndef MONO_PRIVATE_CRASHES
                return TRUE;
@@ -1498,8 +1498,8 @@ check_whitelisted_module (const char *in_name, const char **out_module)
                return TRUE;
        }
 
-       for (GList *cursor = native_library_whitelist; cursor; cursor = cursor->next) {
-               MonoLibWhitelistEntry *iter = (MonoLibWhitelistEntry *) cursor->data;
+       for (GList *cursor = native_library_allowlist; cursor; cursor = cursor->next) {
+               MonoLibAllowlistEntry*iter = (MonoLibAllowlistEntry*) cursor->data;
                if (!g_str_has_suffix (in_name, iter->suffix))
                        continue;
                if (out_module)
@@ -1538,7 +1538,7 @@ mono_get_portable_ip (intptr_t in_ip, intptr_t *out_ip, gint32 *out_offset, cons
        if (!success)
                return FALSE;
 
-       if (!check_whitelisted_module (fname, out_module))
+       if (!check_allowlisted_module (fname, out_module))
                return FALSE;
 
        *out_ip = mono_make_portable_ip ((intptr_t) saddr, (intptr_t) fbase);
index 37ef936..9d0adce 100644 (file)
@@ -133,7 +133,7 @@ gboolean mono_use_llvm = FALSE;
 
 gboolean mono_use_fast_math = FALSE;
 
-// Lists of whitelisted and blacklisted CPU features 
+// Lists of allowlisted and blocklisted CPU features 
 MonoCPUFeatures mono_cpu_features_enabled = (MonoCPUFeatures)0;
 
 #ifdef DISABLE_SIMD
index 9071837..d1330d0 100644 (file)
     happened.  This might make for a good first implementation to get
     some data on performance.
 
- *) Some sort of blacklist support?  Blacklists is a concept from the
+ *) Some sort of blocklist support?  Blocklists is a concept from the
     Boehm GC: if during a conservative scan we find pointers to an
     area which we might use as heap, we mark that area as unusable, so
     pointer retention by random pinning pointers is reduced.