Rename some macros based on the PR review comments.

- use  the SWIFT prefix for all macros
- make names of some macros shorter
This commit is contained in:
Roman Levenstein
2016-02-18 15:03:46 -08:00
parent de3b850ce8
commit 99fd8b6080
13 changed files with 246 additions and 237 deletions

View File

@@ -67,16 +67,16 @@
// Annotation for specifying a calling convention of
// a runtime function. It should be used with declarations
// of runtime functions like this:
// void runtime_function_name() CALLING_CONVENTION(RegisterPreservingCC)
#define CALLING_CONVENTION(CC) CALLING_CONVENTION_##CC
// void runtime_function_name() SWIFT_CC(RegisterPreservingCC)
#define SWIFT_CC(CC) SWIFT_CC_##CC
#define CALLING_CONVENTION_preserve_most __attribute__((preserve_most))
#define CALLING_CONVENTION_preserve_all __attribute__((preserve_all))
#define CALLING_CONVENTION_c
#define SWIFT_CC_preserve_most __attribute__((preserve_most))
#define SWIFT_CC_preserve_all __attribute__((preserve_all))
#define SWIFT_CC_c
// Map a logical calling convention (e.g. RegisterPreservingCC) to LLVM calling
// convention.
#define LLVM_CC(CC) LLVM_CC_##CC
#define SWIFT_LLVM_CC(CC) SWIFT_LLVM_CC_##CC
// Currently, RuntimeFunction.def uses the following calling conventions:
// DefaultCC, RegisterPreservingCC.
@@ -84,14 +84,14 @@
// here to something appropriate.
// DefaultCC is usually the standard C calling convention.
#define CALLING_CONVENTION_DefaultCC CALLING_CONVENTION_c
#define CALLING_CONVENTION_DefaultCC_IMPL CALLING_CONVENTION_c
#define LLVM_CC_DefaultCC llvm::CallingConv::C
#define SWIFT_CC_DefaultCC SWIFT_CC_c
#define SWIFT_CC_DefaultCC_IMPL SWIFT_CC_c
#define SWIFT_LLVM_CC_DefaultCC llvm::CallingConv::C
// If defined, it indicates that runtime function wrappers
// should be used on all platforms, even they do not support
// the new calling convention which requires this.
#define RT_USE_WRAPPERS_ALWAYS 1
#define SWIFT_RT_USE_WRAPPERS_ALWAYS 1
// If defined, it indicates that this calling convention is
// supported by the currnet target.
@@ -114,23 +114,24 @@
// linker may clobber some of the callee-saved registers defined by
// this new calling convention when it performs lazy binding of
// runtime functions using this new calling convention.
#define CALLING_CONVENTION_RegisterPreservingCC CALLING_CONVENTION_preserve_most
#define CALLING_CONVENTION_RegisterPreservingCC_IMPL \
CALLING_CONVENTION_preserve_most
#define LLVM_CC_RegisterPreservingCC llvm::CallingConv::PreserveMost
#define SWIFT_CC_RegisterPreservingCC \
SWIFT_CC_preserve_most
#define SWIFT_CC_RegisterPreservingCC_IMPL \
SWIFT_CC_preserve_most
#define SWIFT_LLVM_CC_RegisterPreservingCC llvm::CallingConv::PreserveMost
// Indicate that wrappers should be used, because it is required
// for the calling convention to get around dynamic linking issues.
#define RT_USE_WRAPPERS 1
#define SWIFT_RT_USE_WRAPPERS 1
#else
// Targets not supporting the dedicated runtime calling convention
// should use the standard calling convention instead.
// No wrappers are required in this case by the calling convention.
#define CALLING_CONVENTION_RegisterPreservingCC CALLING_CONVENTION_c
#define CALLING_CONVENTION_RegisterPreservingCC_IMPL CALLING_CONVENTION_c
#define LLVM_CC_RegisterPreservingCC llvm::CallingConv::C
#define SWIFT_CC_RegisterPreservingCC SWIFT_CC_c
#define SWIFT_CC_RegisterPreservingCC_IMPL SWIFT_CC_c
#define SWIFT_LLVM_CC_RegisterPreservingCC llvm::CallingConv::C
#endif
@@ -139,40 +140,40 @@
// Generates a name of the runtime enrty's implementation by
// adding an underscore as a prefix and a suffix.
#define RT_ENTRY_IMPL(Name) _##Name##_
#define SWIFT_RT_ENTRY_IMPL(Name) _##Name##_
// Library internal way to invoke the implementation of a runtime entry.
// E.g. a runtime function may be called internally via its public API
// or via the function pointer.
#define RT_ENTRY_CALL(Name) Name
#define SWIFT_RT_ENTRY_CALL(Name) Name
// Name of the symbol holding a reference to the
// implementation of a runtime entry.
#define RT_ENTRY_REF(Name) _##Name
#define SWIFT_RT_ENTRY_REF(Name) _##Name
// String representation of the symbol's name.
#define RT_ENTRY_REF_AS_STR(Name) "_" #Name
#define SWIFT_RT_ENTRY_REF_AS_STR(Name) "_" #Name
#if defined(RT_USE_WRAPPERS_ALWAYS)
#define RT_USE_WRAPPERS
#if defined(SWIFT_RT_USE_WRAPPERS_ALWAYS)
#define SWIFT_RT_USE_WRAPPERS
#endif
#if defined(RT_USE_WRAPPERS)
#if defined(SWIFT_RT_USE_WRAPPERS)
// Both the runtime functions and their implementation are hidden and
// can be directly referenced only inside the runtime library.
// User code can access these runtime entries only indirectly
// via a global function pointer.
#define RT_ENTRY_VISIBILITY LLVM_LIBRARY_VISIBILITY
#define RT_ENTRY_IMPL_VISIBILITY LLVM_LIBRARY_VISIBILITY
#define SWIFT_RT_ENTRY_VISIBILITY LLVM_LIBRARY_VISIBILITY
#define SWIFT_RT_ENTRY_IMPL_VISIBILITY LLVM_LIBRARY_VISIBILITY
#else
// Runtime functions are exported, because it should be possible
// to invoke them directly from the user code. But internal
// implementations of runtime functions do not need to be exported.
#define RT_ENTRY_VISIBILITY SWIFT_RUNTIME_EXPORT
#define RT_ENTRY_IMPL_VISIBILITY LLVM_LIBRARY_VISIBILITY
#define SWIFT_RT_ENTRY_VISIBILITY SWIFT_RUNTIME_EXPORT
#define SWIFT_RT_ENTRY_IMPL_VISIBILITY LLVM_LIBRARY_VISIBILITY
#endif

View File

@@ -50,11 +50,11 @@ extern "C" void swift_initEnumValueWitnessTableSinglePayload(
/// \returns -1 if the payload case is inhabited. If an empty case is inhabited,
/// returns a value greater than or equal to zero and less than
/// emptyCases.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" int swift_getEnumCaseSinglePayload(const OpaqueValue *value,
const Metadata *payload,
unsigned emptyCases)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
@@ -69,12 +69,12 @@ extern "C" int swift_getEnumCaseSinglePayload(const OpaqueValue *value,
/// case, or a value greater than or equal to zero and less
/// than emptyCases for an empty case.
/// \param emptyCases - the number of empty cases in the enum.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" void swift_storeEnumTagSinglePayload(OpaqueValue *value,
const Metadata *payload,
int whichCase,
unsigned emptyCases)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
/// \brief Initialize the value witness table for a generic, multi-payload
/// enum instance.

View File

@@ -53,12 +53,12 @@ struct OpaqueValue;
///
/// POSSIBILITIES: The argument order is fair game. It may be useful
/// to have a variant which guarantees zero-initialized memory.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C"
HeapObject *swift_allocObject(HeapMetadata const *metadata,
size_t requiredSize,
size_t requiredAlignmentMask)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
/// Initializes the object header of a stack allocated object.
@@ -156,18 +156,18 @@ extern "C" BoxPair::Return (*_swift_allocBox)(Metadata const *type);
//
// An "alignment mask" is just the alignment (a power of 2) minus 1.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C"
void *swift_slowAlloc(size_t bytes, size_t alignMask)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
// If the caller cannot promise to zero the object during destruction,
// then call these corresponding APIs:
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C"
void swift_slowDealloc(void *ptr, size_t bytes, size_t alignMask)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
/// Atomically increments the retain count of an object.
///
@@ -181,24 +181,23 @@ void swift_slowDealloc(void *ptr, size_t bytes, size_t alignMask)
/// - maybe a variant that can assume a non-null object
/// It may also prove worthwhile to have this use a custom CC
/// which preserves a larger set of registers.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C"
void swift_retain(HeapObject *object)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
SWIFT_RUNTIME_EXPORT
extern "C"
void (* CALLING_CONVENTION(RegisterPreservingCC) _swift_retain)(HeapObject *object);
void (*SWIFT_CC(RegisterPreservingCC) _swift_retain)(HeapObject *object);
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C"
void swift_retain_n(HeapObject *object, uint32_t n)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
SWIFT_RUNTIME_EXPORT
extern "C"
void (*CALLING_CONVENTION(RegisterPreservingCC) _swift_retain_n)(HeapObject *object,
void (*SWIFT_CC(RegisterPreservingCC) _swift_retain_n)(HeapObject *object,
uint32_t n);
static inline void _swift_retain_inlined(HeapObject *object) {
@@ -209,14 +208,14 @@ static inline void _swift_retain_inlined(HeapObject *object) {
/// Atomically increments the reference count of an object, unless it has
/// already been destroyed. Returns nil if the object is dead.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C"
HeapObject *swift_tryRetain(HeapObject *object)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
SWIFT_RUNTIME_EXPORT
extern "C"
HeapObject * (* CALLING_CONVENTION(RegisterPreservingCC) _swift_tryRetain)(HeapObject *);
HeapObject * (* SWIFT_CC(RegisterPreservingCC) _swift_tryRetain)(HeapObject *);
/// Returns true if an object is in the process of being deallocated.
SWIFT_RUNTIME_EXPORT
@@ -224,7 +223,7 @@ extern "C" bool swift_isDeallocating(HeapObject *object);
SWIFT_RUNTIME_EXPORT
extern "C"
bool (* CALLING_CONVENTION(RegisterPreservingCC) _swift_isDeallocating)(HeapObject *);
bool (* SWIFT_CC(RegisterPreservingCC) _swift_isDeallocating)(HeapObject *);
/// Attempts to atomically pin an object and increment its reference
@@ -234,17 +233,17 @@ bool (* CALLING_CONVENTION(RegisterPreservingCC) _swift_isDeallocating)(HeapObje
/// calling swift_unpin on the return value.
///
/// The object reference may not be nil.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" HeapObject *swift_tryPin(HeapObject *object)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
/// Given that an object is pinned, atomically unpin it and decrement
/// the reference count.
///
/// The object reference may be nil (to simplify the protocol).
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" void swift_unpin(HeapObject *object)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
/// Atomically decrements the retain count of an object. If the
/// retain count reaches zero, the object is destroyed as follows:
@@ -261,24 +260,24 @@ extern "C" void swift_unpin(HeapObject *object)
/// - a variant that can safely use non-atomic operations
/// - maybe a variant that can assume a non-null object
/// It's unlikely that a custom CC would be beneficial here.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C"
void swift_release(HeapObject *object)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
SWIFT_RUNTIME_EXPORT
extern "C" void (*CALLING_CONVENTION(RegisterPreservingCC)
extern "C" void (*SWIFT_CC(RegisterPreservingCC)
_swift_release)(HeapObject *object);
/// Atomically decrements the retain count of an object n times. If the retain
/// count reaches zero, the object is destroyed
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C"
void swift_release_n(HeapObject *object, uint32_t n)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
SWIFT_RUNTIME_EXPORT
extern "C" void (*CALLING_CONVENTION(RegisterPreservingCC)
extern "C" void (*SWIFT_CC(RegisterPreservingCC)
_swift_release_n)(HeapObject *object, uint32_t n);
// Refcounting observation hooks for memory tools. Don't use these.
@@ -321,21 +320,21 @@ extern "C" bool swift_isUniquelyReferenced_native(const struct HeapObject *);
/// Is this native Swift pointer a non-null unique or pinned reference
/// to an object?
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" bool swift_isUniquelyReferencedOrPinned_native(
const struct HeapObject *) CALLING_CONVENTION(RegisterPreservingCC);
const struct HeapObject *) SWIFT_CC(RegisterPreservingCC);
/// Is this non-null native Swift pointer a unique reference to
/// an object?
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" bool swift_isUniquelyReferenced_nonNull_native(
const struct HeapObject *) CALLING_CONVENTION(RegisterPreservingCC);
const struct HeapObject *) SWIFT_CC(RegisterPreservingCC);
/// Does this non-null native Swift pointer refer to an object that
/// is either uniquely referenced or pinned?
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" bool swift_isUniquelyReferencedOrPinned_nonNull_native(
const struct HeapObject *) CALLING_CONVENTION(RegisterPreservingCC);
const struct HeapObject *) SWIFT_CC(RegisterPreservingCC);
/// Deallocate the given memory.
///
@@ -352,10 +351,10 @@ extern "C" bool swift_isUniquelyReferencedOrPinned_nonNull_native(
/// POSSIBILITIES: It may be useful to have a variant which
/// requires the object to have been fully zeroed from offsets
/// sizeof(SwiftHeapObject) to allocatedSize.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" void swift_deallocObject(HeapObject *object, size_t allocatedSize,
size_t allocatedAlignMask)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
/// Deallocate the given memory.
///
@@ -463,37 +462,37 @@ struct UnownedReference {
};
/// Increment the weak/unowned retain count.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" void swift_unownedRetain(HeapObject *value)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
/// Decrement the weak/unowned retain count.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" void swift_unownedRelease(HeapObject *value)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
/// Increment the weak/unowned retain count by n.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" void swift_unownedRetain_n(HeapObject *value, int n)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
/// Decrement the weak/unowned retain count by n.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" void swift_unownedRelease_n(HeapObject *value, int n)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
/// Increment the strong retain count of an object, aborting if it has
/// been deallocated.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" void swift_unownedRetainStrong(HeapObject *value)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
/// Increment the strong retain count of an object which may have been
/// deallocated, aborting if it has been deallocated, and decrement its
/// weak/unowned reference count.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" void swift_unownedRetainStrongAndRelease(HeapObject *value)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
/// Aborts if the object has been deallocated.
SWIFT_RUNTIME_EXPORT
@@ -640,11 +639,11 @@ extern "C" void swift_weakTakeAssign(WeakReference *dest, WeakReference *src);
SWIFT_RUNTIME_EXPORT
extern "C" void *swift_bridgeObjectRetain(void *value)
CALLING_CONVENTION(DefaultCC);
SWIFT_CC(DefaultCC);
/// Increment the strong retain count of a bridged object by n.
SWIFT_RUNTIME_EXPORT
extern "C" void *swift_bridgeObjectRetain_n(void *value, int n)
CALLING_CONVENTION(DefaultCC);
SWIFT_CC(DefaultCC);
/*****************************************************************************/
/************************ UNKNOWN REFERENCE-COUNTING *************************/
@@ -656,22 +655,22 @@ SWIFT_RUNTIME_EXPORT
/// Swift object.
SWIFT_RUNTIME_EXPORT
extern "C" void swift_unknownRetain(void *value)
CALLING_CONVENTION(DefaultCC);
SWIFT_CC(DefaultCC);
/// Increment the strong retain count of an object which might not be a native
/// Swift object by n.
SWIFT_RUNTIME_EXPORT
extern "C" void swift_unknownRetain_n(void *value, int n)
CALLING_CONVENTION(DefaultCC);
SWIFT_CC(DefaultCC);
#else
static inline void swift_unknownRetain(void *value)
CALLING_CONVENTION(DefaultCC) {
SWIFT_CC(DefaultCC) {
swift_retain(static_cast<HeapObject *>(value));
}
static inline void swift_unknownRetain_n(void *value, int n)
CALLING_CONVENTION(DefaultCC) {
SWIFT_CC(DefaultCC) {
swift_retain_n(static_cast<HeapObject *>(value), n);
}
@@ -679,11 +678,11 @@ static inline void swift_unknownRetain_n(void *value, int n)
SWIFT_RUNTIME_EXPORT
extern "C" void swift_bridgeObjectRelease(void *value)
CALLING_CONVENTION(DefaultCC);
SWIFT_CC(DefaultCC);
/// Decrement the strong retain count of a bridged object by n.
SWIFT_RUNTIME_EXPORT
extern "C" void swift_bridgeObjectRelease_n(void *value, int n)
CALLING_CONVENTION(DefaultCC);
SWIFT_CC(DefaultCC);
#if SWIFT_OBJC_INTEROP
@@ -691,22 +690,22 @@ extern "C" void swift_bridgeObjectRelease_n(void *value, int n)
/// Swift object.
SWIFT_RUNTIME_EXPORT
extern "C" void swift_unknownRelease(void *value)
CALLING_CONVENTION(DefaultCC);
SWIFT_CC(DefaultCC);
/// Decrement the strong retain count of an object which might not be a native
/// Swift object by n.
SWIFT_RUNTIME_EXPORT
extern "C" void swift_unknownRelease_n(void *value, int n)
CALLING_CONVENTION(DefaultCC);
SWIFT_CC(DefaultCC);
#else
static inline void swift_unknownRelease(void *value)
CALLING_CONVENTION(RegisterPreservingCC) {
SWIFT_CC(RegisterPreservingCC) {
swift_release(static_cast<HeapObject *>(value));
}
static inline void swift_unknownRelease_n(void *value, int n)
CALLING_CONVENTION(RegisterPreservingCC) {
SWIFT_CC(RegisterPreservingCC) {
swift_release_n(static_cast<HeapObject *>(value), n);
}

View File

@@ -2493,11 +2493,11 @@ swift_getResilientMetadata(GenericMetadata *pattern);
/// metadata)
/// return metadata
/// }
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" const Metadata *
swift_getGenericMetadata(GenericMetadata *pattern,
const void *arguments)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
// Callback to allocate a generic class metadata object.
SWIFT_RUNTIME_EXPORT
@@ -2531,12 +2531,12 @@ swift_allocateGenericValueMetadata(GenericMetadata *pattern,
/// never form part of the uniquing key for the conformance, which
/// is ultimately a statement about the user model of overlapping
/// conformances.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" const WitnessTable *
swift_getGenericWitnessTable(GenericWitnessTable *genericTable,
const Metadata *type,
void * const *instantiationArgs)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
/// \brief Fetch a uniqued metadata for a function type.
SWIFT_RUNTIME_EXPORT
@@ -2738,11 +2738,11 @@ swift_getExistentialMetatypeMetadata(const Metadata *instanceType);
/// \brief Fetch a uniqued metadata for an existential type. The array
/// referenced by \c protocols will be sorted in-place.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" const ExistentialTypeMetadata *
swift_getExistentialTypeMetadata(size_t numProtocols,
const ProtocolDescriptor **protocols)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
/// \brief Perform a checked dynamic cast of a value to a target type.
///
@@ -2760,13 +2760,13 @@ swift_getExistentialTypeMetadata(size_t numProtocols,
///
/// \return true if the cast succeeded. Depending on the flags,
/// swift_dynamicCast may fail rather than return false.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" bool
swift_dynamicCast(OpaqueValue *dest, OpaqueValue *src,
const Metadata *srcType,
const Metadata *targetType,
DynamicCastFlags flags)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
/// \brief Checked dynamic cast to a Swift class type.
///
@@ -2775,10 +2775,10 @@ swift_dynamicCast(OpaqueValue *dest, OpaqueValue *src,
/// a Swift class type.
///
/// \returns the object if the cast succeeds, or null otherwise.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" const void *
swift_dynamicCastClass(const void *object, const ClassMetadata *targetType)
CALLING_CONVENTION(RegisterPreservingCC);
SWIFT_CC(RegisterPreservingCC);
/// \brief Unconditional, checked dynamic cast to a Swift class type.
///

View File

@@ -362,7 +362,7 @@ IRGenModule::IRGenModule(IRGenModuleDispatcher &dispatcher, SourceFile *SF,
C_CC = llvm::CallingConv::C;
// TODO: use "tinycc" on platforms that support it
DefaultCC = LLVM_CC(DefaultCC);
DefaultCC = SWIFT_LLVM_CC(DefaultCC);
// If it is an interpreter, don't use try to use any
// advanced calling conventions and use instead a
// more conservative C calling convention. This
@@ -376,7 +376,7 @@ IRGenModule::IRGenModule(IRGenModuleDispatcher &dispatcher, SourceFile *SF,
auto Arch = Triple.getArch();
if (Arch == llvm::Triple::ArchType::x86_64 ||
Arch == llvm::Triple::ArchType::aarch64)
RegisterPreservingCC = LLVM_CC(RegisterPreservingCC);
RegisterPreservingCC = SWIFT_LLVM_CC(RegisterPreservingCC);
else
RegisterPreservingCC = DefaultCC;
@@ -544,7 +544,7 @@ llvm::Constant *swift::getWrapperFn(llvm::Module &Module,
FUNCTION_IMPL(ID, NAME, CC, QUOTE(RETURNS), QUOTE(ARGS), QUOTE(ATTRS))
#define FOR_CONV_RegisterPreservingCC(ID, NAME, CC, RETURNS, ARGS, ATTRS) \
FUNCTION_WITH_GLOBAL_SYMBOL_IMPL(ID, NAME, RT_ENTRY_REF(NAME), CC, \
FUNCTION_WITH_GLOBAL_SYMBOL_IMPL(ID, NAME, SWIFT_RT_ENTRY_REF(NAME), CC, \
QUOTE(RETURNS), QUOTE(ARGS), QUOTE(ATTRS))
#define FUNCTION(ID, NAME, CC, RETURNS, ARGS, ATTRS) \

View File

@@ -86,8 +86,8 @@ class ARCEntryPointBuilder {
public:
ARCEntryPointBuilder(Function &F)
: B(&*F.begin()), Retain(), ObjectPtrTy(),
DefaultCC(LLVM_CC(DefaultCC)),
RegisterPreservingCC(LLVM_CC(RegisterPreservingCC)) {
DefaultCC(SWIFT_LLVM_CC(DefaultCC)),
RegisterPreservingCC(SWIFT_LLVM_CC(RegisterPreservingCC)) {
//TODO: If the target does not support the new calling convention,
//set RegisterPreservingCC to use a standard C calling convention.
}
@@ -209,7 +209,7 @@ private:
Retain = getWrapperFn(getModule(),
cache,
"swift_retain",
RT_ENTRY_REF_AS_STR(swift_retain),
SWIFT_RT_ENTRY_REF_AS_STR(swift_retain),
RegisterPreservingCC,
{VoidTy},
{ObjectPtrTy},
@@ -229,7 +229,7 @@ private:
Release = getWrapperFn(getModule(),
cache,
"swift_release",
RT_ENTRY_REF_AS_STR(swift_release),
SWIFT_RT_ENTRY_REF_AS_STR(swift_release),
RegisterPreservingCC,
{VoidTy},
{ObjectPtrTy},
@@ -265,7 +265,7 @@ private:
RetainN = getWrapperFn(getModule(),
cache,
"swift_retain_n",
RT_ENTRY_REF_AS_STR(swift_retain_n),
SWIFT_RT_ENTRY_REF_AS_STR(swift_retain_n),
RegisterPreservingCC,
{VoidTy},
{ObjectPtrTy, Int32Ty},
@@ -286,7 +286,7 @@ private:
ReleaseN = getWrapperFn(getModule(),
cache,
"swift_release_n",
RT_ENTRY_REF_AS_STR(swift_release_n),
SWIFT_RT_ENTRY_REF_AS_STR(swift_release_n),
RegisterPreservingCC,
{VoidTy},
{ObjectPtrTy, Int32Ty},

View File

@@ -498,11 +498,11 @@ _dynamicCastClassMetatype(const ClassMetadata *sourceType,
}
/// Dynamically cast a class instance to a Swift class type.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
const void *
swift::swift_dynamicCastClass(const void *object,
const ClassMetadata *targetType)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
#if SWIFT_OBJC_INTEROP
assert(!targetType->isPureObjC());
@@ -2046,13 +2046,13 @@ checkDynamicCastFromOptional(OpaqueValue *dest,
}
/// Perform a dynamic cast to an arbitrary type.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
bool swift::swift_dynamicCast(OpaqueValue *dest,
OpaqueValue *src,
const Metadata *srcType,
const Metadata *targetType,
DynamicCastFlags flags)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
auto unwrapResult = checkDynamicCastFromOptional(dest, src, srcType,
targetType, flags);
srcType = unwrapResult.payloadType;

View File

@@ -139,12 +139,12 @@ swift::swift_initEnumValueWitnessTableSinglePayload(ValueWitnessTable *vwtable,
}
}
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
int
swift::swift_getEnumCaseSinglePayload(const OpaqueValue *value,
const Metadata *payload,
unsigned emptyCases)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
auto *payloadWitnesses = payload->getValueWitnesses();
auto payloadSize = payloadWitnesses->getSize();
auto payloadNumExtraInhabitants = payloadWitnesses->getNumExtraInhabitants();
@@ -190,13 +190,13 @@ swift::swift_getEnumCaseSinglePayload(const OpaqueValue *value,
return -1;
}
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
void
swift::swift_storeEnumTagSinglePayload(OpaqueValue *value,
const Metadata *payload,
int whichCase,
unsigned emptyCases)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
auto *payloadWitnesses = payload->getValueWitnesses();
auto payloadSize = payloadWitnesses->getSize();
unsigned payloadNumExtraInhabitants

View File

@@ -22,17 +22,17 @@
using namespace swift;
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
void *swift::swift_slowAlloc(size_t size, size_t alignMask)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
// FIXME: use posix_memalign if alignMask is larger than the system guarantee.
void *p = malloc(size);
if (!p) swift::crash("Could not allocate memory.");
return p;
}
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
void swift::swift_slowDealloc(void *ptr, size_t bytes, size_t alignMask)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
free(ptr);
}

View File

@@ -41,15 +41,16 @@
using namespace swift;
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
HeapObject *
swift::swift_allocObject(HeapMetadata const *metadata,
size_t requiredSize,
size_t requiredAlignmentMask)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
assert(isAlignmentMask(requiredAlignmentMask));
auto object = reinterpret_cast<HeapObject *>(
RT_ENTRY_CALL(swift_slowAlloc)(requiredSize, requiredAlignmentMask));
SWIFT_RT_ENTRY_CALL(swift_slowAlloc)(requiredSize,
requiredAlignmentMask));
// FIXME: this should be a placement new but that adds a null check
object->metadata = metadata;
object->refCount.init();
@@ -90,7 +91,8 @@ SWIFT_RUNTIME_EXPORT
extern "C" HeapObject* swift_bufferAllocate(
HeapMetadata const* bufferType, size_t size, size_t alignMask)
{
return swift::RT_ENTRY_CALL(swift_allocObject)(bufferType, size, alignMask);
return swift::SWIFT_RT_ENTRY_CALL(swift_allocObject)(bufferType, size,
alignMask);
}
/// \brief Another entrypoint for swift_bufferAllocate.
@@ -101,7 +103,8 @@ extern "C" HeapObject* swift_bufferAllocate(
SWIFT_RUNTIME_EXPORT
extern "C" HeapObject* swift_bufferAllocateOnStack(
HeapMetadata const* bufferType, size_t size, size_t alignMask) {
return swift::RT_ENTRY_CALL(swift_allocObject)(bufferType, size, alignMask);
return swift::SWIFT_RT_ENTRY_CALL(swift_allocObject)(bufferType, size,
alignMask);
}
/// \brief Called at the end of the lifetime of an object returned by
@@ -177,7 +180,7 @@ static void destroyGenericBox(HeapObject *o) {
metadata->BoxedType->vw_destroy(value);
// Deallocate the box.
RT_ENTRY_CALL(swift_deallocObject) (o, metadata->getAllocSize(),
SWIFT_RT_ENTRY_CALL(swift_deallocObject) (o, metadata->getAllocSize(),
metadata->getAllocAlignMask());
}
@@ -215,12 +218,12 @@ static Lazy<MetadataCache<BoxCacheEntry>> Boxes;
SWIFT_RUNTIME_EXPORT
BoxPair::Return
swift::swift_allocBox(const Metadata *type) {
return RT_ENTRY_REF(swift_allocBox)(type);
return SWIFT_RT_ENTRY_REF(swift_allocBox)(type);
}
RT_ENTRY_IMPL_VISIBILITY
SWIFT_RT_ENTRY_IMPL_VISIBILITY
extern "C"
BoxPair::Return RT_ENTRY_IMPL(swift_allocBox)(const Metadata *type) {
BoxPair::Return SWIFT_RT_ENTRY_IMPL(swift_allocBox)(const Metadata *type) {
// Get the heap metadata for the box.
auto &B = Boxes.get();
const void *typeArg = type;
@@ -238,7 +241,7 @@ BoxPair::Return RT_ENTRY_IMPL(swift_allocBox)(const Metadata *type) {
auto metadata = entry->getData();
// Allocate and project the box.
auto allocation = RT_ENTRY_CALL(swift_allocObject)(
auto allocation = SWIFT_RT_ENTRY_CALL(swift_allocObject)(
metadata, metadata->getAllocSize(), metadata->getAllocAlignMask());
auto projection = metadata->project(allocation);
@@ -247,7 +250,7 @@ BoxPair::Return RT_ENTRY_IMPL(swift_allocBox)(const Metadata *type) {
void swift::swift_deallocBox(HeapObject *o) {
auto metadata = static_cast<const GenericBoxHeapMetadata *>(o->metadata);
RT_ENTRY_CALL(swift_deallocObject)(o, metadata->getAllocSize(),
SWIFT_RT_ENTRY_CALL(swift_deallocObject)(o, metadata->getAllocSize(),
metadata->getAllocAlignMask());
}
@@ -264,66 +267,66 @@ OpaqueValue *swift::swift_projectBox(HeapObject *o) {
// Forward-declare this, but define it after swift_release.
extern "C" LLVM_LIBRARY_VISIBILITY
void _swift_release_dealloc(HeapObject *object)
CALLING_CONVENTION(RegisterPreservingCC_IMPL)
SWIFT_CC(RegisterPreservingCC_IMPL)
__attribute__((noinline,used));
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C"
void swift::swift_retain(HeapObject *object)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
RT_ENTRY_REF(swift_retain)(object);
SWIFT_CC(RegisterPreservingCC_IMPL) {
SWIFT_RT_ENTRY_REF(swift_retain)(object);
}
RT_ENTRY_IMPL_VISIBILITY
SWIFT_RT_ENTRY_IMPL_VISIBILITY
extern "C"
void RT_ENTRY_IMPL(swift_retain)(HeapObject *object)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
void SWIFT_RT_ENTRY_IMPL(swift_retain)(HeapObject *object)
SWIFT_CC(RegisterPreservingCC_IMPL) {
_swift_retain_inlined(object);
}
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C"
void swift::swift_retain_n(HeapObject *object, uint32_t n)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
RT_ENTRY_REF(swift_retain_n)(object, n);
SWIFT_CC(RegisterPreservingCC_IMPL) {
SWIFT_RT_ENTRY_REF(swift_retain_n)(object, n);
}
RT_ENTRY_IMPL_VISIBILITY
SWIFT_RT_ENTRY_IMPL_VISIBILITY
extern "C"
void RT_ENTRY_IMPL(swift_retain_n)(HeapObject *object, uint32_t n)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
void SWIFT_RT_ENTRY_IMPL(swift_retain_n)(HeapObject *object, uint32_t n)
SWIFT_CC(RegisterPreservingCC_IMPL) {
if (object) {
object->refCount.increment(n);
}
}
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C"
void swift::swift_release(HeapObject *object)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
RT_ENTRY_REF(swift_release)(object);
SWIFT_CC(RegisterPreservingCC_IMPL) {
SWIFT_RT_ENTRY_REF(swift_release)(object);
}
RT_ENTRY_IMPL_VISIBILITY
SWIFT_RT_ENTRY_IMPL_VISIBILITY
extern "C"
void RT_ENTRY_IMPL(swift_release)(HeapObject *object)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
void SWIFT_RT_ENTRY_IMPL(swift_release)(HeapObject *object)
SWIFT_CC(RegisterPreservingCC_IMPL) {
if (object && object->refCount.decrementShouldDeallocate()) {
_swift_release_dealloc(object);
}
}
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
void swift::swift_release_n(HeapObject *object, uint32_t n)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
return RT_ENTRY_REF(swift_release_n)(object, n);
SWIFT_CC(RegisterPreservingCC_IMPL) {
return SWIFT_RT_ENTRY_REF(swift_release_n)(object, n);
}
RT_ENTRY_IMPL_VISIBILITY
SWIFT_RT_ENTRY_IMPL_VISIBILITY
extern "C"
void RT_ENTRY_IMPL(swift_release_n)(HeapObject *object, uint32_t n)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
void SWIFT_RT_ENTRY_IMPL(swift_release_n)(HeapObject *object, uint32_t n)
SWIFT_CC(RegisterPreservingCC_IMPL) {
if (object && object->refCount.decrementShouldDeallocateN(n)) {
_swift_release_dealloc(object);
}
@@ -337,18 +340,18 @@ size_t swift::swift_unownedRetainCount(HeapObject *object) {
return object->weakRefCount.getCount();
}
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
void swift::swift_unownedRetain(HeapObject *object)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
if (!object)
return;
object->weakRefCount.increment();
}
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
void swift::swift_unownedRelease(HeapObject *object)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
if (!object)
return;
@@ -358,25 +361,26 @@ void swift::swift_unownedRelease(HeapObject *object)
assert(metadata->isClassObject());
auto classMetadata = static_cast<const ClassMetadata*>(metadata);
assert(classMetadata->isTypeMetadata());
RT_ENTRY_CALL(swift_slowDealloc) (object, classMetadata->getInstanceSize(),
SWIFT_RT_ENTRY_CALL(swift_slowDealloc)
(object, classMetadata->getInstanceSize(),
classMetadata->getInstanceAlignMask());
}
}
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C"
void swift::swift_unownedRetain_n(HeapObject *object, int n)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
if (!object)
return;
object->weakRefCount.increment(n);
}
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C"
void swift::swift_unownedRelease_n(HeapObject *object, int n)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
if (!object)
return;
@@ -386,14 +390,15 @@ void swift::swift_unownedRelease_n(HeapObject *object, int n)
assert(metadata->isClassObject());
auto classMetadata = static_cast<const ClassMetadata*>(metadata);
assert(classMetadata->isTypeMetadata());
RT_ENTRY_CALL(swift_slowDealloc)(object, classMetadata->getInstanceSize(),
SWIFT_RT_ENTRY_CALL(swift_slowDealloc)
(object, classMetadata->getInstanceSize(),
classMetadata->getInstanceAlignMask());
}
}
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
HeapObject *swift::swift_tryPin(HeapObject *object)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
assert(object);
// Try to set the flag. If this succeeds, the caller will be
@@ -407,24 +412,24 @@ HeapObject *swift::swift_tryPin(HeapObject *object)
return nullptr;
}
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
void swift::swift_unpin(HeapObject *object)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
if (object && object->refCount.decrementAndUnpinShouldDeallocate()) {
_swift_release_dealloc(object);
}
}
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
HeapObject *swift::swift_tryRetain(HeapObject *object)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
return RT_ENTRY_REF(swift_tryRetain)(object);
SWIFT_CC(RegisterPreservingCC_IMPL) {
return SWIFT_RT_ENTRY_REF(swift_tryRetain)(object);
}
RT_ENTRY_IMPL_VISIBILITY
SWIFT_RT_ENTRY_IMPL_VISIBILITY
extern "C"
HeapObject *RT_ENTRY_IMPL(swift_tryRetain)(HeapObject *object)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
HeapObject *SWIFT_RT_ENTRY_IMPL(swift_tryRetain)(HeapObject *object)
SWIFT_CC(RegisterPreservingCC_IMPL) {
if (!object)
return nullptr;
@@ -435,19 +440,19 @@ HeapObject *RT_ENTRY_IMPL(swift_tryRetain)(HeapObject *object)
SWIFT_RUNTIME_EXPORT
extern "C"
bool swift_isDeallocating(HeapObject *object) {
return RT_ENTRY_REF(swift_isDeallocating)(object);
return SWIFT_RT_ENTRY_REF(swift_isDeallocating)(object);
}
RT_ENTRY_IMPL_VISIBILITY
SWIFT_RT_ENTRY_IMPL_VISIBILITY
extern "C"
bool RT_ENTRY_IMPL(swift_isDeallocating)(HeapObject *object) {
bool SWIFT_RT_ENTRY_IMPL(swift_isDeallocating)(HeapObject *object) {
if (!object) return false;
return object->refCount.isDeallocating();
}
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
void swift::swift_unownedRetainStrong(HeapObject *object)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
if (!object)
return;
assert(object->weakRefCount.getCount() &&
@@ -457,10 +462,10 @@ void swift::swift_unownedRetainStrong(HeapObject *object)
_swift_abortRetainUnowned(object);
}
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
void
swift::swift_unownedRetainStrongAndRelease(HeapObject *object)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
if (!object)
return;
assert(object->weakRefCount.getCount() &&
@@ -486,7 +491,7 @@ void swift::swift_unownedCheck(HeapObject *object) {
// Declared extern "C" LLVM_LIBRARY_VISIBILITY above.
void _swift_release_dealloc(HeapObject *object)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
asFullMetadata(object->metadata)->destroy(object);
}
@@ -510,7 +515,9 @@ void swift::swift_deallocClassInstance(HeapObject *object,
// references associated with this object.
objc_destructInstance((id)object);
#endif
RT_ENTRY_CALL(swift_deallocObject)(object, allocatedSize, allocatedAlignMask);
SWIFT_RT_ENTRY_CALL(swift_deallocObject)
(object, allocatedSize,
allocatedAlignMask);
}
/// Variant of the above used in constructor failure paths.
@@ -552,11 +559,11 @@ static inline void memset_pattern8(void *b, const void *pattern8, size_t len) {
}
#endif
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
void swift::swift_deallocObject(HeapObject *object,
size_t allocatedSize,
size_t allocatedAlignMask)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
assert(isAlignmentMask(allocatedAlignMask));
assert(object->refCount.isDeallocating());
#ifdef SWIFT_RUNTIME_CLOBBER_FREED_OBJECTS
@@ -634,29 +641,31 @@ void swift::swift_deallocObject(HeapObject *object,
// atomic decrement (and has the ability to reconstruct
// allocatedSize and allocatedAlignMask).
if (object->weakRefCount.getCount() == 1) {
RT_ENTRY_CALL(swift_slowDealloc)(object, allocatedSize, allocatedAlignMask);
SWIFT_RT_ENTRY_CALL(swift_slowDealloc)
(object, allocatedSize,
allocatedAlignMask);
} else {
RT_ENTRY_CALL(swift_unownedRelease)(object);
SWIFT_RT_ENTRY_CALL(swift_unownedRelease)(object);
}
}
void swift::swift_weakInit(WeakReference *ref, HeapObject *value) {
ref->Value = value;
RT_ENTRY_CALL(swift_unownedRetain)(value);
SWIFT_RT_ENTRY_CALL(swift_unownedRetain)(value);
}
void swift::swift_weakAssign(WeakReference *ref, HeapObject *newValue) {
RT_ENTRY_CALL(swift_unownedRetain)(newValue);
SWIFT_RT_ENTRY_CALL(swift_unownedRetain)(newValue);
auto oldValue = ref->Value;
ref->Value = newValue;
RT_ENTRY_CALL(swift_unownedRelease)(oldValue);
SWIFT_RT_ENTRY_CALL(swift_unownedRelease)(oldValue);
}
HeapObject *swift::swift_weakLoadStrong(WeakReference *ref) {
auto object = ref->Value;
if (object == nullptr) return nullptr;
if (object->refCount.isDeallocating()) {
RT_ENTRY_CALL(swift_unownedRelease)(object);
SWIFT_RT_ENTRY_CALL(swift_unownedRelease)(object);
ref->Value = nullptr;
return nullptr;
}
@@ -672,7 +681,7 @@ HeapObject *swift::swift_weakTakeStrong(WeakReference *ref) {
void swift::swift_weakDestroy(WeakReference *ref) {
auto tmp = ref->Value;
ref->Value = nullptr;
RT_ENTRY_CALL(swift_unownedRelease)(tmp);
SWIFT_RT_ENTRY_CALL(swift_unownedRelease)(tmp);
}
void swift::swift_weakCopyInit(WeakReference *dest, WeakReference *src) {
@@ -682,10 +691,10 @@ void swift::swift_weakCopyInit(WeakReference *dest, WeakReference *src) {
} else if (object->refCount.isDeallocating()) {
src->Value = nullptr;
dest->Value = nullptr;
RT_ENTRY_CALL(swift_unownedRelease)(object);
SWIFT_RT_ENTRY_CALL(swift_unownedRelease)(object);
} else {
dest->Value = object;
RT_ENTRY_CALL(swift_unownedRetain)(object);
SWIFT_RT_ENTRY_CALL(swift_unownedRetain)(object);
}
}
@@ -694,20 +703,20 @@ void swift::swift_weakTakeInit(WeakReference *dest, WeakReference *src) {
dest->Value = object;
if (object != nullptr && object->refCount.isDeallocating()) {
dest->Value = nullptr;
RT_ENTRY_CALL(swift_unownedRelease)(object);
SWIFT_RT_ENTRY_CALL(swift_unownedRelease)(object);
}
}
void swift::swift_weakCopyAssign(WeakReference *dest, WeakReference *src) {
if (auto object = dest->Value) {
RT_ENTRY_CALL(swift_unownedRelease)(object);
SWIFT_RT_ENTRY_CALL(swift_unownedRelease)(object);
}
swift_weakCopyInit(dest, src);
}
void swift::swift_weakTakeAssign(WeakReference *dest, WeakReference *src) {
if (auto object = dest->Value) {
RT_ENTRY_CALL(swift_unownedRelease)(object);
SWIFT_RT_ENTRY_CALL(swift_unownedRelease)(object);
}
swift_weakTakeInit(dest, src);
}

View File

@@ -266,11 +266,11 @@ swift::swift_getResilientMetadata(GenericMetadata *pattern) {
}
/// The primary entrypoint.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
const Metadata *
swift::swift_getGenericMetadata(GenericMetadata *pattern,
const void *arguments)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
auto genericArgs = (const void * const *) arguments;
size_t numGenericArgs = pattern->NumKeyArguments;
@@ -2217,11 +2217,11 @@ ExistentialTypeMetadata::getWitnessTable(const OpaqueValue *container,
/// \brief Fetch a uniqued metadata for an existential type. The array
/// referenced by \c protocols will be sorted in-place.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
const ExistentialTypeMetadata *
swift::swift_getExistentialTypeMetadata(size_t numProtocols,
const ProtocolDescriptor **protocols)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
// Sort the protocol set.
std::sort(protocols, protocols + numProtocols);
@@ -2619,12 +2619,12 @@ allocateWitnessTable(GenericWitnessTable *genericTable,
return entry;
}
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" const WitnessTable *
swift::swift_getGenericWitnessTable(GenericWitnessTable *genericTable,
const Metadata *type,
void * const *instantiationArgs)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
if (doesNotRequireInstantiation(genericTable)) {
return genericTable->Pattern;
}

View File

@@ -46,15 +46,15 @@ typedef void (*RuntimeEntry)();
// Define a global symbol referring to this implementation.
#define DEFINE_SYMBOL(SymbolName, Name, CC) \
RT_ENTRY_VISIBILITY extern "C" void Name() \
CALLING_CONVENTION(CC); \
SWIFT_RT_ENTRY_VISIBILITY extern "C" void Name() \
SWIFT_CC(CC); \
SWIFT_RUNTIME_EXPORT extern "C" RuntimeEntry SymbolName = \
reinterpret_cast<RuntimeEntry>(Name);
#define FUNCTION1(Id, Name, CC, ReturnTys, ArgTys, Attrs) \
DEFINE_SYMBOL(RT_ENTRY_REF(Name), Name, CC)
DEFINE_SYMBOL(SWIFT_RT_ENTRY_REF(Name), Name, CC)
#if defined(RT_USE_WRAPPERS)
#if defined(SWIFT_RT_USE_WRAPPERS)
// Automatically generate a global symbol name if it is required by the calling
// convention.
#define FUNCTION(Id, Name, CC, ReturnTys, ArgTys, Attrs) \

View File

@@ -477,7 +477,7 @@ static bool usesNativeSwiftReferenceCounting_allocated(const void *object) {
SWIFT_RUNTIME_EXPORT
void swift::swift_unknownRetain_n(void *object, int n)
CALLING_CONVENTION(DefaultCC_IMPL) {
SWIFT_CC(DefaultCC_IMPL) {
if (isObjCTaggedPointerOrNull(object)) return;
if (usesNativeSwiftReferenceCounting_allocated(object)) {
swift_retain_n(static_cast<HeapObject *>(object), n);
@@ -489,7 +489,7 @@ void swift::swift_unknownRetain_n(void *object, int n)
SWIFT_RUNTIME_EXPORT
void swift::swift_unknownRelease_n(void *object, int n)
CALLING_CONVENTION(DefaultCC_IMPL) {
SWIFT_CC(DefaultCC_IMPL) {
if (isObjCTaggedPointerOrNull(object)) return;
if (usesNativeSwiftReferenceCounting_allocated(object))
return swift_release_n(static_cast<HeapObject *>(object), n);
@@ -499,7 +499,7 @@ void swift::swift_unknownRelease_n(void *object, int n)
SWIFT_RUNTIME_EXPORT
void swift::swift_unknownRetain(void *object)
CALLING_CONVENTION(DefaultCC_IMPL) {
SWIFT_CC(DefaultCC_IMPL) {
if (isObjCTaggedPointerOrNull(object)) return;
if (usesNativeSwiftReferenceCounting_allocated(object)) {
swift_retain(static_cast<HeapObject *>(object));
@@ -510,10 +510,10 @@ void swift::swift_unknownRetain(void *object)
SWIFT_RUNTIME_EXPORT
void swift::swift_unknownRelease(void *object)
CALLING_CONVENTION(DefaultCC_IMPL) {
SWIFT_CC(DefaultCC_IMPL) {
if (isObjCTaggedPointerOrNull(object)) return;
if (usesNativeSwiftReferenceCounting_allocated(object))
return RT_ENTRY_CALL(swift_release)(static_cast<HeapObject *>(object));
return SWIFT_RT_ENTRY_CALL(swift_release)(static_cast<HeapObject *>(object));
return objc_release(static_cast<id>(object));
}
@@ -539,7 +539,7 @@ static void* toPlainObject_unTagged_bridgeObject(void *object) {
SWIFT_RUNTIME_EXPORT
void *swift::swift_bridgeObjectRetain(void *object)
CALLING_CONVENTION(DefaultCC_IMPL) {
SWIFT_CC(DefaultCC_IMPL) {
#if SWIFT_OBJC_INTEROP
if (isObjCTaggedPointer(object))
return object;
@@ -561,7 +561,7 @@ void *swift::swift_bridgeObjectRetain(void *object)
SWIFT_RUNTIME_EXPORT
void swift::swift_bridgeObjectRelease(void *object)
CALLING_CONVENTION(DefaultCC_IMPL) {
SWIFT_CC(DefaultCC_IMPL) {
#if SWIFT_OBJC_INTEROP
if (isObjCTaggedPointer(object))
return;
@@ -580,7 +580,7 @@ void swift::swift_bridgeObjectRelease(void *object)
SWIFT_RUNTIME_EXPORT
void *swift::swift_bridgeObjectRetain_n(void *object, int n)
CALLING_CONVENTION(DefaultCC_IMPL) {
SWIFT_CC(DefaultCC_IMPL) {
#if SWIFT_OBJC_INTEROP
if (isObjCTaggedPointer(object))
return object;
@@ -605,7 +605,7 @@ void *swift::swift_bridgeObjectRetain_n(void *object, int n)
SWIFT_RUNTIME_EXPORT
void swift::swift_bridgeObjectRelease_n(void *object, int n)
CALLING_CONVENTION(DefaultCC_IMPL) {
SWIFT_CC(DefaultCC_IMPL) {
#if SWIFT_OBJC_INTEROP
if (isObjCTaggedPointer(object))
return;
@@ -1186,9 +1186,9 @@ void swift::swift_instantiateObjCClass(const ClassMetadata *_c) {
(void)registered;
}
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
extern "C" Class swift_getInitializedObjCClass(Class c)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
// Used when we have class metadata and we want to ensure a class has been
// initialized by the Objective C runtime. We need to do this because the
// class "c" might be valid metadata, but it hasn't been initialized yet.
@@ -1244,10 +1244,10 @@ static bool usesNativeSwiftReferenceCounting_nonNull(
}
#endif
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
bool swift::swift_isUniquelyReferenced_nonNull_native(
const HeapObject* object
) CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
) SWIFT_CC(RegisterPreservingCC_IMPL) {
assert(object != nullptr);
assert(!object->refCount.isDeallocating());
return object->refCount.isUniquelyReferenced();
@@ -1255,7 +1255,7 @@ bool swift::swift_isUniquelyReferenced_nonNull_native(
bool swift::swift_isUniquelyReferenced_native(const HeapObject* object) {
return object != nullptr
&& swift::RT_ENTRY_CALL(swift_isUniquelyReferenced_nonNull_native)(object);
&& swift::SWIFT_RT_ENTRY_CALL(swift_isUniquelyReferenced_nonNull_native)(object);
}
bool swift::swift_isUniquelyReferencedNonObjC_nonNull(const void* object) {
@@ -1264,7 +1264,7 @@ bool swift::swift_isUniquelyReferencedNonObjC_nonNull(const void* object) {
#if SWIFT_OBJC_INTEROP
usesNativeSwiftReferenceCounting_nonNull(object) &&
#endif
RT_ENTRY_CALL(swift_isUniquelyReferenced_nonNull_native)((HeapObject*)object);
SWIFT_RT_ENTRY_CALL(swift_isUniquelyReferenced_nonNull_native)((HeapObject*)object);
}
// Given an object reference, return true iff it is non-nil and refers
@@ -1293,11 +1293,11 @@ bool swift::swift_isUniquelyReferencedNonObjC_nonNull_bridgeObject(
// object is going to be a negligible cost for a possible big win.
#if SWIFT_OBJC_INTEROP
return !isNonNative_unTagged_bridgeObject(bridgeObject)
? RT_ENTRY_CALL(swift_isUniquelyReferenced_nonNull_native)(
? SWIFT_RT_ENTRY_CALL(swift_isUniquelyReferenced_nonNull_native)(
(const HeapObject *)object)
: swift_isUniquelyReferencedNonObjC_nonNull(object);
#else
return RT_ENTRY_CALL(swift_isUniquelyReferenced_nonNull_native)(
return SWIFT_RT_ENTRY_CALL(swift_isUniquelyReferenced_nonNull_native)(
(const HeapObject *)object);
#endif
}
@@ -1343,10 +1343,10 @@ bool swift::swift_isUniquelyReferencedOrPinnedNonObjC_nonNull(
// Given a non-@objc object reference, return true iff the
// object is non-nil and either has a strong reference count of 1
// or is pinned.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
bool swift::swift_isUniquelyReferencedOrPinned_native(
const HeapObject* object)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
return object != nullptr
&& swift_isUniquelyReferencedOrPinned_nonNull_native(object);
}
@@ -1354,10 +1354,10 @@ bool swift::swift_isUniquelyReferencedOrPinned_native(
/// Given a non-nil native swift object reference, return true if
/// either the object has a strong reference count of 1 or its
/// pinned flag is set.
RT_ENTRY_VISIBILITY
SWIFT_RT_ENTRY_VISIBILITY
bool swift::swift_isUniquelyReferencedOrPinned_nonNull_native(
const HeapObject* object)
CALLING_CONVENTION(RegisterPreservingCC_IMPL) {
SWIFT_CC(RegisterPreservingCC_IMPL) {
assert(object != nullptr);
assert(!object->refCount.isDeallocating());
return object->refCount.isUniquelyReferencedOrPinned();