mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The descriptor map is keyed by a simplified mangling that canonicalizes the differences that we accept in _contextDescriptorMatchesMangling, such as the ability to specify any kind of type with an OtherNominalType node. This simplified mangling is not necessarily unique, but we use _contextDescriptorMatchesMangling for the final equality checking when looking up entries in the map, so occasional collisions are acceptable and get resolved when probing the table. The table is meant to be comprehensive, so it includes all descriptors that can be looked up by name, and a negative result means the descriptor does not exist in the shared cache. We add a flag to the options that can mark it as non-definitive in case we ever need to degrade this, and fall back to a full search after a negative result. The map encompasses the entire shared cache but we need to reject lookups for types in images that aren't loaded. The map includes an image index which allows us to cheaply query whether a given descriptor is in a loaded image or not, so we can ignore ones which are not. TypeMetadataPrivateState now has a separate sections array for sections within the shared cache. _searchTypeMetadataRecords consults the map first. If no result is found in the map and the map is marked as comprehensive, then only the sections outside the shared cache need to be scanned. Replace the SWIFT_DEBUG_ENABLE_LIB_PRESPECIALIZED environment variable with one specifically for metadata and one for descriptor lookup so they can be controlled independently. Also add SWIFT_DEBUG_VALIDATE_LIB_PRESPECIALIZED_DESCRIPTOR_LOOKUP which consults the map and does the full scan, and ensures they produce the same result, for debugging purposes. Enhance the environment variable code to track whether a variable was set at all. This allows SWIFT_DEBUG_ENABLE_LIB_PRESPECIALIZED to override the default in either direction. Remove the disablePrespecializedMetadata global and instead modify the mapConfiguration to disable prespecialized metadata when an image is loaded that overrides one in the shared cache. rdar://113059233
69 lines
2.9 KiB
C++
69 lines
2.9 KiB
C++
//===--- EnvironmentVariables.h - Debug variables. --------------*- C++ -*-===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Debug behavior conditionally enabled using environment variables.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "swift/Threading/Once.h"
|
|
#include "swift/shims/Visibility.h"
|
|
|
|
namespace swift {
|
|
namespace runtime {
|
|
namespace environment {
|
|
|
|
void initialize(void *);
|
|
|
|
extern swift::once_t initializeToken;
|
|
|
|
// Define a typedef "string" in swift::runtime::environment to make string
|
|
// environment variables work
|
|
using string = const char *;
|
|
|
|
// Declare backing variables.
|
|
#define VARIABLE(name, type, defaultValue, help) \
|
|
extern type name##_variable; \
|
|
extern bool name##_isSet_variable;
|
|
#include "../../../stdlib/public/runtime/EnvironmentVariables.def"
|
|
|
|
// Define getter functions. This creates one function with the same name as the
|
|
// variable which returns the value set for that variable, and second function
|
|
// ending in _isSet which returns a boolean indicating whether the variable was
|
|
// set at all, to allow detecting when the variable was explicitly set to the
|
|
// same value as the default.
|
|
#define VARIABLE(name, type, defaultValue, help) \
|
|
inline type name() { \
|
|
swift::once(initializeToken, initialize, nullptr); \
|
|
return name##_variable; \
|
|
} \
|
|
inline bool name##_isSet() { \
|
|
swift::once(initializeToken, initialize, nullptr); \
|
|
return name##_isSet_variable; \
|
|
}
|
|
#include "../../../stdlib/public/runtime/EnvironmentVariables.def"
|
|
|
|
// Wrapper around SWIFT_DEBUG_CONCURRENCY_ENABLE_COOPERATIVE_QUEUES that the
|
|
// Concurrency library can call.
|
|
SWIFT_RUNTIME_STDLIB_SPI bool concurrencyEnableCooperativeQueues();
|
|
|
|
// Wrapper around SWIFT_DEBUG_VALIDATE_UNCHECKED_CONTINUATIONS that the
|
|
// Concurrency library can call.
|
|
SWIFT_RUNTIME_STDLIB_SPI bool concurrencyValidateUncheckedContinuations();
|
|
|
|
// Wrapper around SWIFT_IS_CURRENT_EXECUTOR_LEGACY_MODE_OVERRIDE that the
|
|
// Concurrency library can call.
|
|
SWIFT_RUNTIME_STDLIB_SPI const char *concurrencyIsCurrentExecutorLegacyModeOverride();
|
|
|
|
} // end namespace environment
|
|
} // end namespace runtime
|
|
} // end namespace swift
|