Skip to content

Commit ac6e0bd

Browse files
author
Greg Parker
committed
[runtime] Remove function pointer hooks from Error implementation.
1 parent 36e6c29 commit ac6e0bd

File tree

1 file changed

+20
-72
lines changed

1 file changed

+20
-72
lines changed

stdlib/public/runtime/ErrorObject.mm

Lines changed: 20 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ static Class getSwiftNativeNSErrorClass() {
161161
}
162162

163163
/// Allocate a catchable error object.
164-
static BoxPair::Return
165-
_swift_allocError_(const Metadata *type,
166-
const WitnessTable *errorConformance,
167-
OpaqueValue *initialValue,
168-
bool isTake) {
164+
BoxPair::Return
165+
swift::swift_allocError(const Metadata *type,
166+
const WitnessTable *errorConformance,
167+
OpaqueValue *initialValue,
168+
bool isTake) {
169169
auto TheSwiftNativeNSError = getSwiftNativeNSErrorClass();
170170
assert(class_getInstanceSize(TheSwiftNativeNSError) == sizeof(SwiftErrorHeader)
171171
&& "NSError layout changed!");
@@ -213,30 +213,11 @@ static Class getSwiftNativeNSErrorClass() {
213213
return BoxPair{reinterpret_cast<HeapObject*>(instance), valuePtr};
214214
}
215215

216-
SWIFT_RUNTIME_EXPORT
217-
auto *_swift_allocError = _swift_allocError_;
218-
219-
BoxPair::Return
220-
swift::swift_allocError(const Metadata *type,
221-
const WitnessTable *errorConformance,
222-
OpaqueValue *value, bool isTake) {
223-
return _swift_allocError(type, errorConformance, value, isTake);
224-
}
225-
226216
/// Deallocate an error object whose contained object has already been
227217
/// destroyed.
228-
static void
229-
_swift_deallocError_(SwiftError *error,
230-
const Metadata *type) {
231-
object_dispose((id)error);
232-
}
233-
234-
SWIFT_RUNTIME_EXPORT
235-
auto *_swift_deallocError = _swift_deallocError_;
236-
237218
void
238219
swift::swift_deallocError(SwiftError *error, const Metadata *type) {
239-
return _swift_deallocError(error, type);
220+
object_dispose((id)error);
240221
}
241222

242223
static const WitnessTable *getNSErrorConformanceToError() {
@@ -335,10 +316,10 @@ static Class getSwiftNativeNSErrorClass() {
335316
/// temporary buffer. The implementation may write a reference to itself to
336317
/// that buffer if the error object is a toll-free-bridged NSError instead of
337318
/// a native Swift error, in which case the object itself is the "boxed" value.
338-
static void
339-
_swift_getErrorValue_(const SwiftError *errorObject,
340-
void **scratch,
341-
ErrorValueResult *out) {
319+
void
320+
swift::swift_getErrorValue(const SwiftError *errorObject,
321+
void **scratch,
322+
ErrorValueResult *out) {
342323
// TODO: Would be great if Clang had a return-three convention so we didn't
343324
// need the out parameter here.
344325

@@ -356,16 +337,6 @@ static Class getSwiftNativeNSErrorClass() {
356337
}
357338
}
358339

359-
SWIFT_RUNTIME_EXPORT
360-
auto *_swift_getErrorValue = _swift_getErrorValue_;
361-
362-
void
363-
swift::swift_getErrorValue(const SwiftError *errorObject,
364-
void **scratch,
365-
ErrorValueResult *out) {
366-
return _swift_getErrorValue(errorObject, scratch, out);
367-
}
368-
369340
// @_silgen_name("swift_stdlib_getErrorDomainNSString")
370341
// public func _stdlib_getErrorDomainNSString<T : Error>
371342
// (x: UnsafePointer<T>) -> AnyObject
@@ -414,7 +385,8 @@ typedef SWIFT_CC(swift)
414385

415386
/// Take an Error box and turn it into a valid NSError instance.
416387
SWIFT_CC(swift)
417-
static id _swift_bridgeErrorToNSError_(SwiftError *errorObject) {
388+
id
389+
swift::swift_bridgeErrorToNSError(SwiftError *errorObject) {
418390
auto ns = reinterpret_cast<NSError *>(errorObject);
419391

420392
// If we already have a domain set, then we've already initialized.
@@ -475,16 +447,6 @@ static id _swift_bridgeErrorToNSError_(SwiftError *errorObject) {
475447
return ns;
476448
}
477449

478-
SWIFT_CC(swift)
479-
SWIFT_RUNTIME_EXPORT
480-
id (*_swift_bridgeErrorToNSError)(SwiftError*) = _swift_bridgeErrorToNSError_;
481-
482-
SWIFT_CC(swift)
483-
id
484-
swift::swift_bridgeErrorToNSError(SwiftError *errorObject) {
485-
return _swift_bridgeErrorToNSError(errorObject);
486-
}
487-
488450
bool
489451
swift::tryDynamicCastNSErrorToValue(OpaqueValue *dest,
490452
OpaqueValue *src,
@@ -562,37 +524,23 @@ bool BridgeFn(NSError *, OpaqueValue*, const Metadata *,
562524
return false;
563525
}
564526

565-
static SwiftError *_swift_errorRetain_(SwiftError *error) {
527+
SwiftError *
528+
swift::swift_errorRetain(SwiftError *error) {
566529
// For now, SwiftError is always objc-refcounted.
567530
return (SwiftError*)objc_retain((id)error);
568531
}
569532

570-
SWIFT_RUNTIME_EXPORT
571-
auto *_swift_errorRetain = _swift_errorRetain_;
572-
573-
SwiftError *swift::swift_errorRetain(SwiftError *error) {
574-
return _swift_errorRetain(error);
575-
}
576-
577-
static void _swift_errorRelease_(SwiftError *error) {
533+
void
534+
swift::swift_errorRelease(SwiftError *error) {
578535
// For now, SwiftError is always objc-refcounted.
579536
return objc_release((id)error);
580537
}
581538

582-
SWIFT_RUNTIME_EXPORT
583-
auto *_swift_errorRelease = _swift_errorRelease_;
584-
585-
void swift::swift_errorRelease(SwiftError *error) {
586-
return _swift_errorRelease(error);
539+
/// Breakpoint hook for debuggers.
540+
void
541+
swift::swift_willThrow(SwiftError *error) {
542+
// empty
587543
}
588544

589-
static void _swift_willThrow_(SwiftError *error) { }
590-
591-
SWIFT_RUNTIME_EXPORT
592-
auto *_swift_willThrow = _swift_willThrow_;
593-
594-
void swift::swift_willThrow(SwiftError *error) {
595-
return _swift_willThrow(error);
596-
}
597545
#endif
598546

0 commit comments

Comments
 (0)