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 // Annotation for specifying a calling convention of
// a runtime function. It should be used with declarations // a runtime function. It should be used with declarations
// of runtime functions like this: // of runtime functions like this:
// void runtime_function_name() CALLING_CONVENTION(RegisterPreservingCC) // void runtime_function_name() SWIFT_CC(RegisterPreservingCC)
#define CALLING_CONVENTION(CC) CALLING_CONVENTION_##CC #define SWIFT_CC(CC) SWIFT_CC_##CC
#define CALLING_CONVENTION_preserve_most __attribute__((preserve_most)) #define SWIFT_CC_preserve_most __attribute__((preserve_most))
#define CALLING_CONVENTION_preserve_all __attribute__((preserve_all)) #define SWIFT_CC_preserve_all __attribute__((preserve_all))
#define CALLING_CONVENTION_c #define SWIFT_CC_c
// Map a logical calling convention (e.g. RegisterPreservingCC) to LLVM calling // Map a logical calling convention (e.g. RegisterPreservingCC) to LLVM calling
// convention. // 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: // Currently, RuntimeFunction.def uses the following calling conventions:
// DefaultCC, RegisterPreservingCC. // DefaultCC, RegisterPreservingCC.
@@ -84,14 +84,14 @@
// here to something appropriate. // here to something appropriate.
// DefaultCC is usually the standard C calling convention. // DefaultCC is usually the standard C calling convention.
#define CALLING_CONVENTION_DefaultCC CALLING_CONVENTION_c #define SWIFT_CC_DefaultCC SWIFT_CC_c
#define CALLING_CONVENTION_DefaultCC_IMPL CALLING_CONVENTION_c #define SWIFT_CC_DefaultCC_IMPL SWIFT_CC_c
#define LLVM_CC_DefaultCC llvm::CallingConv::C #define SWIFT_LLVM_CC_DefaultCC llvm::CallingConv::C
// If defined, it indicates that runtime function wrappers // If defined, it indicates that runtime function wrappers
// should be used on all platforms, even they do not support // should be used on all platforms, even they do not support
// the new calling convention which requires this. // 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 // If defined, it indicates that this calling convention is
// supported by the currnet target. // supported by the currnet target.
@@ -114,23 +114,24 @@
// linker may clobber some of the callee-saved registers defined by // linker may clobber some of the callee-saved registers defined by
// this new calling convention when it performs lazy binding of // this new calling convention when it performs lazy binding of
// runtime functions using this new calling convention. // runtime functions using this new calling convention.
#define CALLING_CONVENTION_RegisterPreservingCC CALLING_CONVENTION_preserve_most #define SWIFT_CC_RegisterPreservingCC \
#define CALLING_CONVENTION_RegisterPreservingCC_IMPL \ SWIFT_CC_preserve_most
CALLING_CONVENTION_preserve_most #define SWIFT_CC_RegisterPreservingCC_IMPL \
#define LLVM_CC_RegisterPreservingCC llvm::CallingConv::PreserveMost SWIFT_CC_preserve_most
#define SWIFT_LLVM_CC_RegisterPreservingCC llvm::CallingConv::PreserveMost
// Indicate that wrappers should be used, because it is required // Indicate that wrappers should be used, because it is required
// for the calling convention to get around dynamic linking issues. // for the calling convention to get around dynamic linking issues.
#define RT_USE_WRAPPERS 1 #define SWIFT_RT_USE_WRAPPERS 1
#else #else
// Targets not supporting the dedicated runtime calling convention // Targets not supporting the dedicated runtime calling convention
// should use the standard calling convention instead. // should use the standard calling convention instead.
// No wrappers are required in this case by the calling convention. // No wrappers are required in this case by the calling convention.
#define CALLING_CONVENTION_RegisterPreservingCC CALLING_CONVENTION_c #define SWIFT_CC_RegisterPreservingCC SWIFT_CC_c
#define CALLING_CONVENTION_RegisterPreservingCC_IMPL CALLING_CONVENTION_c #define SWIFT_CC_RegisterPreservingCC_IMPL SWIFT_CC_c
#define LLVM_CC_RegisterPreservingCC llvm::CallingConv::C #define SWIFT_LLVM_CC_RegisterPreservingCC llvm::CallingConv::C
#endif #endif
@@ -139,40 +140,40 @@
// Generates a name of the runtime enrty's implementation by // Generates a name of the runtime enrty's implementation by
// adding an underscore as a prefix and a suffix. // 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. // Library internal way to invoke the implementation of a runtime entry.
// E.g. a runtime function may be called internally via its public API // E.g. a runtime function may be called internally via its public API
// or via the function pointer. // 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 // Name of the symbol holding a reference to the
// implementation of a runtime entry. // 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. // 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) #if defined(SWIFT_RT_USE_WRAPPERS_ALWAYS)
#define RT_USE_WRAPPERS #define SWIFT_RT_USE_WRAPPERS
#endif #endif
#if defined(RT_USE_WRAPPERS) #if defined(SWIFT_RT_USE_WRAPPERS)
// Both the runtime functions and their implementation are hidden and // Both the runtime functions and their implementation are hidden and
// can be directly referenced only inside the runtime library. // can be directly referenced only inside the runtime library.
// User code can access these runtime entries only indirectly // User code can access these runtime entries only indirectly
// via a global function pointer. // via a global function pointer.
#define RT_ENTRY_VISIBILITY LLVM_LIBRARY_VISIBILITY #define SWIFT_RT_ENTRY_VISIBILITY LLVM_LIBRARY_VISIBILITY
#define RT_ENTRY_IMPL_VISIBILITY LLVM_LIBRARY_VISIBILITY #define SWIFT_RT_ENTRY_IMPL_VISIBILITY LLVM_LIBRARY_VISIBILITY
#else #else
// Runtime functions are exported, because it should be possible // Runtime functions are exported, because it should be possible
// to invoke them directly from the user code. But internal // to invoke them directly from the user code. But internal
// implementations of runtime functions do not need to be exported. // implementations of runtime functions do not need to be exported.
#define RT_ENTRY_VISIBILITY SWIFT_RUNTIME_EXPORT #define SWIFT_RT_ENTRY_VISIBILITY SWIFT_RUNTIME_EXPORT
#define RT_ENTRY_IMPL_VISIBILITY LLVM_LIBRARY_VISIBILITY #define SWIFT_RT_ENTRY_IMPL_VISIBILITY LLVM_LIBRARY_VISIBILITY
#endif #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 -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 /// returns a value greater than or equal to zero and less than
/// emptyCases. /// emptyCases.
RT_ENTRY_VISIBILITY SWIFT_RT_ENTRY_VISIBILITY
extern "C" int swift_getEnumCaseSinglePayload(const OpaqueValue *value, extern "C" int swift_getEnumCaseSinglePayload(const OpaqueValue *value,
const Metadata *payload, const Metadata *payload,
unsigned emptyCases) 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 /// case, or a value greater than or equal to zero and less
/// than emptyCases for an empty case. /// than emptyCases for an empty case.
/// \param emptyCases - the number of empty cases in the enum. /// \param emptyCases - the number of empty cases in the enum.
RT_ENTRY_VISIBILITY SWIFT_RT_ENTRY_VISIBILITY
extern "C" void swift_storeEnumTagSinglePayload(OpaqueValue *value, extern "C" void swift_storeEnumTagSinglePayload(OpaqueValue *value,
const Metadata *payload, const Metadata *payload,
int whichCase, int whichCase,
unsigned emptyCases) unsigned emptyCases)
CALLING_CONVENTION(RegisterPreservingCC); SWIFT_CC(RegisterPreservingCC);
/// \brief Initialize the value witness table for a generic, multi-payload /// \brief Initialize the value witness table for a generic, multi-payload
/// enum instance. /// enum instance.

View File

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

View File

@@ -2493,11 +2493,11 @@ swift_getResilientMetadata(GenericMetadata *pattern);
/// metadata) /// metadata)
/// return metadata /// return metadata
/// } /// }
RT_ENTRY_VISIBILITY SWIFT_RT_ENTRY_VISIBILITY
extern "C" const Metadata * extern "C" const Metadata *
swift_getGenericMetadata(GenericMetadata *pattern, swift_getGenericMetadata(GenericMetadata *pattern,
const void *arguments) const void *arguments)
CALLING_CONVENTION(RegisterPreservingCC); SWIFT_CC(RegisterPreservingCC);
// Callback to allocate a generic class metadata object. // Callback to allocate a generic class metadata object.
SWIFT_RUNTIME_EXPORT SWIFT_RUNTIME_EXPORT
@@ -2531,12 +2531,12 @@ swift_allocateGenericValueMetadata(GenericMetadata *pattern,
/// never form part of the uniquing key for the conformance, which /// never form part of the uniquing key for the conformance, which
/// is ultimately a statement about the user model of overlapping /// is ultimately a statement about the user model of overlapping
/// conformances. /// conformances.
RT_ENTRY_VISIBILITY SWIFT_RT_ENTRY_VISIBILITY
extern "C" const WitnessTable * extern "C" const WitnessTable *
swift_getGenericWitnessTable(GenericWitnessTable *genericTable, swift_getGenericWitnessTable(GenericWitnessTable *genericTable,
const Metadata *type, const Metadata *type,
void * const *instantiationArgs) void * const *instantiationArgs)
CALLING_CONVENTION(RegisterPreservingCC); SWIFT_CC(RegisterPreservingCC);
/// \brief Fetch a uniqued metadata for a function type. /// \brief Fetch a uniqued metadata for a function type.
SWIFT_RUNTIME_EXPORT SWIFT_RUNTIME_EXPORT
@@ -2738,11 +2738,11 @@ swift_getExistentialMetatypeMetadata(const Metadata *instanceType);
/// \brief Fetch a uniqued metadata for an existential type. The array /// \brief Fetch a uniqued metadata for an existential type. The array
/// referenced by \c protocols will be sorted in-place. /// referenced by \c protocols will be sorted in-place.
RT_ENTRY_VISIBILITY SWIFT_RT_ENTRY_VISIBILITY
extern "C" const ExistentialTypeMetadata * extern "C" const ExistentialTypeMetadata *
swift_getExistentialTypeMetadata(size_t numProtocols, swift_getExistentialTypeMetadata(size_t numProtocols,
const ProtocolDescriptor **protocols) const ProtocolDescriptor **protocols)
CALLING_CONVENTION(RegisterPreservingCC); SWIFT_CC(RegisterPreservingCC);
/// \brief Perform a checked dynamic cast of a value to a target type. /// \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, /// \return true if the cast succeeded. Depending on the flags,
/// swift_dynamicCast may fail rather than return false. /// swift_dynamicCast may fail rather than return false.
RT_ENTRY_VISIBILITY SWIFT_RT_ENTRY_VISIBILITY
extern "C" bool extern "C" bool
swift_dynamicCast(OpaqueValue *dest, OpaqueValue *src, swift_dynamicCast(OpaqueValue *dest, OpaqueValue *src,
const Metadata *srcType, const Metadata *srcType,
const Metadata *targetType, const Metadata *targetType,
DynamicCastFlags flags) DynamicCastFlags flags)
CALLING_CONVENTION(RegisterPreservingCC); SWIFT_CC(RegisterPreservingCC);
/// \brief Checked dynamic cast to a Swift class type. /// \brief Checked dynamic cast to a Swift class type.
/// ///
@@ -2775,10 +2775,10 @@ swift_dynamicCast(OpaqueValue *dest, OpaqueValue *src,
/// a Swift class type. /// a Swift class type.
/// ///
/// \returns the object if the cast succeeds, or null otherwise. /// \returns the object if the cast succeeds, or null otherwise.
RT_ENTRY_VISIBILITY SWIFT_RT_ENTRY_VISIBILITY
extern "C" const void * extern "C" const void *
swift_dynamicCastClass(const void *object, const ClassMetadata *targetType) swift_dynamicCastClass(const void *object, const ClassMetadata *targetType)
CALLING_CONVENTION(RegisterPreservingCC); SWIFT_CC(RegisterPreservingCC);
/// \brief Unconditional, checked dynamic cast to a Swift class type. /// \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; C_CC = llvm::CallingConv::C;
// TODO: use "tinycc" on platforms that support it // 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 // If it is an interpreter, don't use try to use any
// advanced calling conventions and use instead a // advanced calling conventions and use instead a
// more conservative C calling convention. This // more conservative C calling convention. This
@@ -376,7 +376,7 @@ IRGenModule::IRGenModule(IRGenModuleDispatcher &dispatcher, SourceFile *SF,
auto Arch = Triple.getArch(); auto Arch = Triple.getArch();
if (Arch == llvm::Triple::ArchType::x86_64 || if (Arch == llvm::Triple::ArchType::x86_64 ||
Arch == llvm::Triple::ArchType::aarch64) Arch == llvm::Triple::ArchType::aarch64)
RegisterPreservingCC = LLVM_CC(RegisterPreservingCC); RegisterPreservingCC = SWIFT_LLVM_CC(RegisterPreservingCC);
else else
RegisterPreservingCC = DefaultCC; RegisterPreservingCC = DefaultCC;
@@ -544,7 +544,7 @@ llvm::Constant *swift::getWrapperFn(llvm::Module &Module,
FUNCTION_IMPL(ID, NAME, CC, QUOTE(RETURNS), QUOTE(ARGS), QUOTE(ATTRS)) FUNCTION_IMPL(ID, NAME, CC, QUOTE(RETURNS), QUOTE(ARGS), QUOTE(ATTRS))
#define FOR_CONV_RegisterPreservingCC(ID, NAME, CC, RETURNS, ARGS, 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)) QUOTE(RETURNS), QUOTE(ARGS), QUOTE(ATTRS))
#define FUNCTION(ID, NAME, CC, RETURNS, ARGS, ATTRS) \ #define FUNCTION(ID, NAME, CC, RETURNS, ARGS, ATTRS) \

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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