Skip to content

Commit de3b850

Browse files
committed
Use more descriptive names for calling conventions.
Rename RuntimeCC into DefaultCC Rename RuntimeCC1 into RegisterPreservingCC Remove RuntimeCC0 because it was identical to DefaultCC.
1 parent 1d7cca9 commit de3b850

24 files changed

+321
-326
lines changed

Diff for: include/swift/Runtime/Config.h

+17-20
Original file line numberDiff line numberDiff line change
@@ -67,30 +67,26 @@
6767
// Annotation for specifying a calling convention of
6868
// a runtime function. It should be used with declarations
6969
// of runtime functions like this:
70-
// void runtime_function_name() CALLING_CONVENTION(RuntimeCC1)
70+
// void runtime_function_name() CALLING_CONVENTION(RegisterPreservingCC)
7171
#define CALLING_CONVENTION(CC) CALLING_CONVENTION_##CC
7272

7373
#define CALLING_CONVENTION_preserve_most __attribute__((preserve_most))
7474
#define CALLING_CONVENTION_preserve_all __attribute__((preserve_all))
7575
#define CALLING_CONVENTION_c
7676

77-
// Map a logical calling convention (e.g. RuntimeCC1) to LLVM calling
77+
// Map a logical calling convention (e.g. RegisterPreservingCC) to LLVM calling
7878
// convention.
7979
#define LLVM_CC(CC) LLVM_CC_##CC
8080

8181
// Currently, RuntimeFunction.def uses the following calling conventions:
82-
// RuntimeCC, RuntimeCC0, RuntimeCC1.
82+
// DefaultCC, RegisterPreservingCC.
8383
// If new runtime calling conventions are added later, they need to be mapped
8484
// here to something appropriate.
8585

86-
// RuntimeCC and RuntimeCC0 are the standard C calling convention.
87-
#define CALLING_CONVENTION_RuntimeCC CALLING_CONVENTION_c
88-
#define CALLING_CONVENTION_RuntimeCC_IMPL CALLING_CONVENTION_c
89-
#define LLVM_CC_RuntimeCC llvm::CallingConv::C
90-
91-
#define CALLING_CONVENTION_RuntimeCC0 CALLING_CONVENTION_c
92-
#define CALLING_CONVENTION_RuntimeCC0_IMPL CALLING_CONVENTION_c
93-
#define LLVM_CC_RuntimeCC0 llvm::CallingConv::C
86+
// DefaultCC is usually the standard C calling convention.
87+
#define CALLING_CONVENTION_DefaultCC CALLING_CONVENTION_c
88+
#define CALLING_CONVENTION_DefaultCC_IMPL CALLING_CONVENTION_c
89+
#define LLVM_CC_DefaultCC llvm::CallingConv::C
9490

9591
// If defined, it indicates that runtime function wrappers
9692
// should be used on all platforms, even they do not support
@@ -101,11 +97,11 @@
10197
// supported by the currnet target.
10298
// TODO: Define it once the runtime calling convention support has
10399
// been integrated into clang and llvm.
104-
//#define RT_USE_RuntimeCC1
100+
//#define RT_USE_RegisterPreservingCC
105101

106-
// RuntimeCC1 is a dedicated runtime calling convention to be used
102+
// RegisterPreservingCC is a dedicated runtime calling convention to be used
107103
// when calling the most popular runtime functions.
108-
#if defined(RT_USE_RuntimeCC1) && __has_attribute(preserve_most) && \
104+
#if defined(RT_USE_RegisterPreservingCC) && __has_attribute(preserve_most) && \
109105
(defined(__aarch64__) || defined(__x86_64__))
110106

111107
// Targets supporting the dedicated runtime convention should use it.
@@ -118,9 +114,10 @@
118114
// linker may clobber some of the callee-saved registers defined by
119115
// this new calling convention when it performs lazy binding of
120116
// runtime functions using this new calling convention.
121-
#define CALLING_CONVENTION_RuntimeCC1 CALLING_CONVENTION_preserve_most
122-
#define CALLING_CONVENTION_RuntimeCC1_IMPL CALLING_CONVENTION_preserve_most
123-
#define LLVM_CC_RuntimeCC1 llvm::CallingConv::PreserveMost
117+
#define CALLING_CONVENTION_RegisterPreservingCC CALLING_CONVENTION_preserve_most
118+
#define CALLING_CONVENTION_RegisterPreservingCC_IMPL \
119+
CALLING_CONVENTION_preserve_most
120+
#define LLVM_CC_RegisterPreservingCC llvm::CallingConv::PreserveMost
124121

125122
// Indicate that wrappers should be used, because it is required
126123
// for the calling convention to get around dynamic linking issues.
@@ -131,9 +128,9 @@
131128
// Targets not supporting the dedicated runtime calling convention
132129
// should use the standard calling convention instead.
133130
// No wrappers are required in this case by the calling convention.
134-
#define CALLING_CONVENTION_RuntimeCC1 CALLING_CONVENTION_c
135-
#define CALLING_CONVENTION_RuntimeCC1_IMPL CALLING_CONVENTION_c
136-
#define LLVM_CC_RuntimeCC1 llvm::CallingConv::C
131+
#define CALLING_CONVENTION_RegisterPreservingCC CALLING_CONVENTION_c
132+
#define CALLING_CONVENTION_RegisterPreservingCC_IMPL CALLING_CONVENTION_c
133+
#define LLVM_CC_RegisterPreservingCC llvm::CallingConv::C
137134

138135
#endif
139136

Diff for: include/swift/Runtime/Enum.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ RT_ENTRY_VISIBILITY
5454
extern "C" int swift_getEnumCaseSinglePayload(const OpaqueValue *value,
5555
const Metadata *payload,
5656
unsigned emptyCases)
57-
CALLING_CONVENTION(RuntimeCC1);
57+
CALLING_CONVENTION(RegisterPreservingCC);
5858

5959

6060

@@ -74,7 +74,7 @@ extern "C" void swift_storeEnumTagSinglePayload(OpaqueValue *value,
7474
const Metadata *payload,
7575
int whichCase,
7676
unsigned emptyCases)
77-
CALLING_CONVENTION(RuntimeCC1);
77+
CALLING_CONVENTION(RegisterPreservingCC);
7878

7979
/// \brief Initialize the value witness table for a generic, multi-payload
8080
/// enum instance.

Diff for: include/swift/Runtime/HeapObject.h

+42-42
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ extern "C"
5858
HeapObject *swift_allocObject(HeapMetadata const *metadata,
5959
size_t requiredSize,
6060
size_t requiredAlignmentMask)
61-
CALLING_CONVENTION(RuntimeCC1);
61+
CALLING_CONVENTION(RegisterPreservingCC);
6262

6363

6464
/// Initializes the object header of a stack allocated object.
@@ -159,15 +159,15 @@ extern "C" BoxPair::Return (*_swift_allocBox)(Metadata const *type);
159159
RT_ENTRY_VISIBILITY
160160
extern "C"
161161
void *swift_slowAlloc(size_t bytes, size_t alignMask)
162-
CALLING_CONVENTION(RuntimeCC1);
162+
CALLING_CONVENTION(RegisterPreservingCC);
163163

164164

165165
// If the caller cannot promise to zero the object during destruction,
166166
// then call these corresponding APIs:
167167
RT_ENTRY_VISIBILITY
168168
extern "C"
169169
void swift_slowDealloc(void *ptr, size_t bytes, size_t alignMask)
170-
CALLING_CONVENTION(RuntimeCC1);
170+
CALLING_CONVENTION(RegisterPreservingCC);
171171

172172
/// Atomically increments the retain count of an object.
173173
///
@@ -184,21 +184,21 @@ void swift_slowDealloc(void *ptr, size_t bytes, size_t alignMask)
184184
RT_ENTRY_VISIBILITY
185185
extern "C"
186186
void swift_retain(HeapObject *object)
187-
CALLING_CONVENTION(RuntimeCC1);
187+
CALLING_CONVENTION(RegisterPreservingCC);
188188

189189
SWIFT_RUNTIME_EXPORT
190190
extern "C"
191-
void (* CALLING_CONVENTION(RuntimeCC1) _swift_retain)(HeapObject *object);
191+
void (* CALLING_CONVENTION(RegisterPreservingCC) _swift_retain)(HeapObject *object);
192192

193193

194194
RT_ENTRY_VISIBILITY
195195
extern "C"
196196
void swift_retain_n(HeapObject *object, uint32_t n)
197-
CALLING_CONVENTION(RuntimeCC1);
197+
CALLING_CONVENTION(RegisterPreservingCC);
198198

199199
SWIFT_RUNTIME_EXPORT
200200
extern "C"
201-
void (*CALLING_CONVENTION(RuntimeCC1) _swift_retain_n)(HeapObject *object,
201+
void (*CALLING_CONVENTION(RegisterPreservingCC) _swift_retain_n)(HeapObject *object,
202202
uint32_t n);
203203

204204
static inline void _swift_retain_inlined(HeapObject *object) {
@@ -212,19 +212,19 @@ static inline void _swift_retain_inlined(HeapObject *object) {
212212
RT_ENTRY_VISIBILITY
213213
extern "C"
214214
HeapObject *swift_tryRetain(HeapObject *object)
215-
CALLING_CONVENTION(RuntimeCC1);
215+
CALLING_CONVENTION(RegisterPreservingCC);
216216

217217
SWIFT_RUNTIME_EXPORT
218218
extern "C"
219-
HeapObject * (* CALLING_CONVENTION(RuntimeCC1) _swift_tryRetain)(HeapObject *);
219+
HeapObject * (* CALLING_CONVENTION(RegisterPreservingCC) _swift_tryRetain)(HeapObject *);
220220

221221
/// Returns true if an object is in the process of being deallocated.
222222
SWIFT_RUNTIME_EXPORT
223223
extern "C" bool swift_isDeallocating(HeapObject *object);
224224

225225
SWIFT_RUNTIME_EXPORT
226226
extern "C"
227-
bool (* CALLING_CONVENTION(RuntimeCC1) _swift_isDeallocating)(HeapObject *);
227+
bool (* CALLING_CONVENTION(RegisterPreservingCC) _swift_isDeallocating)(HeapObject *);
228228

229229

230230
/// Attempts to atomically pin an object and increment its reference
@@ -236,15 +236,16 @@ bool (* CALLING_CONVENTION(RuntimeCC1) _swift_isDeallocating)(HeapObject *);
236236
/// The object reference may not be nil.
237237
RT_ENTRY_VISIBILITY
238238
extern "C" HeapObject *swift_tryPin(HeapObject *object)
239-
CALLING_CONVENTION(RuntimeCC1);
239+
CALLING_CONVENTION(RegisterPreservingCC);
240240

241241
/// Given that an object is pinned, atomically unpin it and decrement
242242
/// the reference count.
243243
///
244244
/// The object reference may be nil (to simplify the protocol).
245245
RT_ENTRY_VISIBILITY
246-
extern "C" void swift_unpin(HeapObject *object) CALLING_CONVENTION(RuntimeCC1);
247-
246+
extern "C" void swift_unpin(HeapObject *object)
247+
CALLING_CONVENTION(RegisterPreservingCC);
248+
248249
/// Atomically decrements the retain count of an object. If the
249250
/// retain count reaches zero, the object is destroyed as follows:
250251
///
@@ -263,23 +264,22 @@ extern "C" void swift_unpin(HeapObject *object) CALLING_CONVENTION(RuntimeCC1);
263264
RT_ENTRY_VISIBILITY
264265
extern "C"
265266
void swift_release(HeapObject *object)
266-
CALLING_CONVENTION(RuntimeCC1);
267+
CALLING_CONVENTION(RegisterPreservingCC);
267268

268269
SWIFT_RUNTIME_EXPORT
269-
extern "C"
270-
void (* CALLING_CONVENTION(RuntimeCC1) _swift_release)(HeapObject *object);
270+
extern "C" void (*CALLING_CONVENTION(RegisterPreservingCC)
271+
_swift_release)(HeapObject *object);
271272

272273
/// Atomically decrements the retain count of an object n times. If the retain
273274
/// count reaches zero, the object is destroyed
274275
RT_ENTRY_VISIBILITY
275276
extern "C"
276277
void swift_release_n(HeapObject *object, uint32_t n)
277-
CALLING_CONVENTION(RuntimeCC1);
278+
CALLING_CONVENTION(RegisterPreservingCC);
278279

279280
SWIFT_RUNTIME_EXPORT
280-
extern "C"
281-
void (*CALLING_CONVENTION(RuntimeCC1) _swift_release_n)(HeapObject *object,
282-
uint32_t n);
281+
extern "C" void (*CALLING_CONVENTION(RegisterPreservingCC)
282+
_swift_release_n)(HeapObject *object, uint32_t n);
283283

284284
// Refcounting observation hooks for memory tools. Don't use these.
285285
SWIFT_RUNTIME_EXPORT
@@ -323,19 +323,19 @@ extern "C" bool swift_isUniquelyReferenced_native(const struct HeapObject *);
323323
/// to an object?
324324
RT_ENTRY_VISIBILITY
325325
extern "C" bool swift_isUniquelyReferencedOrPinned_native(
326-
const struct HeapObject *) CALLING_CONVENTION(RuntimeCC1);
326+
const struct HeapObject *) CALLING_CONVENTION(RegisterPreservingCC);
327327

328328
/// Is this non-null native Swift pointer a unique reference to
329329
/// an object?
330330
RT_ENTRY_VISIBILITY
331331
extern "C" bool swift_isUniquelyReferenced_nonNull_native(
332-
const struct HeapObject *) CALLING_CONVENTION(RuntimeCC1);
332+
const struct HeapObject *) CALLING_CONVENTION(RegisterPreservingCC);
333333

334334
/// Does this non-null native Swift pointer refer to an object that
335335
/// is either uniquely referenced or pinned?
336336
RT_ENTRY_VISIBILITY
337337
extern "C" bool swift_isUniquelyReferencedOrPinned_nonNull_native(
338-
const struct HeapObject *) CALLING_CONVENTION(RuntimeCC1);
338+
const struct HeapObject *) CALLING_CONVENTION(RegisterPreservingCC);
339339

340340
/// Deallocate the given memory.
341341
///
@@ -355,7 +355,7 @@ extern "C" bool swift_isUniquelyReferencedOrPinned_nonNull_native(
355355
RT_ENTRY_VISIBILITY
356356
extern "C" void swift_deallocObject(HeapObject *object, size_t allocatedSize,
357357
size_t allocatedAlignMask)
358-
CALLING_CONVENTION(RuntimeCC1);
358+
CALLING_CONVENTION(RegisterPreservingCC);
359359

360360
/// Deallocate the given memory.
361361
///
@@ -465,35 +465,35 @@ struct UnownedReference {
465465
/// Increment the weak/unowned retain count.
466466
RT_ENTRY_VISIBILITY
467467
extern "C" void swift_unownedRetain(HeapObject *value)
468-
CALLING_CONVENTION(RuntimeCC1);
468+
CALLING_CONVENTION(RegisterPreservingCC);
469469

470470
/// Decrement the weak/unowned retain count.
471471
RT_ENTRY_VISIBILITY
472472
extern "C" void swift_unownedRelease(HeapObject *value)
473-
CALLING_CONVENTION(RuntimeCC1);
473+
CALLING_CONVENTION(RegisterPreservingCC);
474474

475475
/// Increment the weak/unowned retain count by n.
476476
RT_ENTRY_VISIBILITY
477477
extern "C" void swift_unownedRetain_n(HeapObject *value, int n)
478-
CALLING_CONVENTION(RuntimeCC1);
478+
CALLING_CONVENTION(RegisterPreservingCC);
479479

480480
/// Decrement the weak/unowned retain count by n.
481481
RT_ENTRY_VISIBILITY
482482
extern "C" void swift_unownedRelease_n(HeapObject *value, int n)
483-
CALLING_CONVENTION(RuntimeCC1);
483+
CALLING_CONVENTION(RegisterPreservingCC);
484484

485485
/// Increment the strong retain count of an object, aborting if it has
486486
/// been deallocated.
487487
RT_ENTRY_VISIBILITY
488488
extern "C" void swift_unownedRetainStrong(HeapObject *value)
489-
CALLING_CONVENTION(RuntimeCC1);
489+
CALLING_CONVENTION(RegisterPreservingCC);
490490

491491
/// Increment the strong retain count of an object which may have been
492492
/// deallocated, aborting if it has been deallocated, and decrement its
493493
/// weak/unowned reference count.
494494
RT_ENTRY_VISIBILITY
495495
extern "C" void swift_unownedRetainStrongAndRelease(HeapObject *value)
496-
CALLING_CONVENTION(RuntimeCC1);
496+
CALLING_CONVENTION(RegisterPreservingCC);
497497

498498
/// Aborts if the object has been deallocated.
499499
SWIFT_RUNTIME_EXPORT
@@ -640,11 +640,11 @@ extern "C" void swift_weakTakeAssign(WeakReference *dest, WeakReference *src);
640640

641641
SWIFT_RUNTIME_EXPORT
642642
extern "C" void *swift_bridgeObjectRetain(void *value)
643-
CALLING_CONVENTION(RuntimeCC0);
643+
CALLING_CONVENTION(DefaultCC);
644644
/// Increment the strong retain count of a bridged object by n.
645645
SWIFT_RUNTIME_EXPORT
646646
extern "C" void *swift_bridgeObjectRetain_n(void *value, int n)
647-
CALLING_CONVENTION(RuntimeCC0);
647+
CALLING_CONVENTION(DefaultCC);
648648

649649
/*****************************************************************************/
650650
/************************ UNKNOWN REFERENCE-COUNTING *************************/
@@ -656,57 +656,57 @@ SWIFT_RUNTIME_EXPORT
656656
/// Swift object.
657657
SWIFT_RUNTIME_EXPORT
658658
extern "C" void swift_unknownRetain(void *value)
659-
CALLING_CONVENTION(RuntimeCC0);
659+
CALLING_CONVENTION(DefaultCC);
660660
/// Increment the strong retain count of an object which might not be a native
661661
/// Swift object by n.
662662
SWIFT_RUNTIME_EXPORT
663663
extern "C" void swift_unknownRetain_n(void *value, int n)
664-
CALLING_CONVENTION(RuntimeCC0);
664+
CALLING_CONVENTION(DefaultCC);
665665

666666
#else
667667

668668
static inline void swift_unknownRetain(void *value)
669-
CALLING_CONVENTION(RuntimeCC0) {
669+
CALLING_CONVENTION(DefaultCC) {
670670
swift_retain(static_cast<HeapObject *>(value));
671671
}
672672

673673
static inline void swift_unknownRetain_n(void *value, int n)
674-
CALLING_CONVENTION(RuntimeCC0) {
674+
CALLING_CONVENTION(DefaultCC) {
675675
swift_retain_n(static_cast<HeapObject *>(value), n);
676676
}
677677

678678
#endif /* SWIFT_OBJC_INTEROP */
679679

680680
SWIFT_RUNTIME_EXPORT
681681
extern "C" void swift_bridgeObjectRelease(void *value)
682-
CALLING_CONVENTION(RuntimeCC0);
682+
CALLING_CONVENTION(DefaultCC);
683683
/// Decrement the strong retain count of a bridged object by n.
684684
SWIFT_RUNTIME_EXPORT
685685
extern "C" void swift_bridgeObjectRelease_n(void *value, int n)
686-
CALLING_CONVENTION(RuntimeCC0);
686+
CALLING_CONVENTION(DefaultCC);
687687

688688
#if SWIFT_OBJC_INTEROP
689689

690690
/// Decrement the strong retain count of an object which might not be a native
691691
/// Swift object.
692692
SWIFT_RUNTIME_EXPORT
693693
extern "C" void swift_unknownRelease(void *value)
694-
CALLING_CONVENTION(RuntimeCC0);
694+
CALLING_CONVENTION(DefaultCC);
695695
/// Decrement the strong retain count of an object which might not be a native
696696
/// Swift object by n.
697697
SWIFT_RUNTIME_EXPORT
698698
extern "C" void swift_unknownRelease_n(void *value, int n)
699-
CALLING_CONVENTION(RuntimeCC0);
699+
CALLING_CONVENTION(DefaultCC);
700700

701701
#else
702702

703703
static inline void swift_unknownRelease(void *value)
704-
CALLING_CONVENTION(RuntimeCC1) {
704+
CALLING_CONVENTION(RegisterPreservingCC) {
705705
swift_release(static_cast<HeapObject *>(value));
706706
}
707707

708708
static inline void swift_unknownRelease_n(void *value, int n)
709-
CALLING_CONVENTION(RuntimeCC1) {
709+
CALLING_CONVENTION(RegisterPreservingCC) {
710710
swift_release_n(static_cast<HeapObject *>(value), n);
711711
}
712712

0 commit comments

Comments
 (0)