Skip to content

Commit 026c3c9

Browse files
authored
Merge pull request #28918 from lorentey/foundation-no-inlinable-shim-calls
2 parents aa0bf50 + 0344f08 commit 026c3c9

18 files changed

+189
-186
lines changed

stdlib/public/Darwin/Foundation/Calendar.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
@_exported import Foundation // Clang module
14-
import _SwiftFoundationOverlayShims
14+
@_implementationOnly import _SwiftFoundationOverlayShims
1515

1616
/**
1717
`Calendar` encapsulates information about systems of reckoning time in which the beginning, length, and divisions of a year are defined. It provides information about the calendar and support for calendrical computations such as determining the range of a given calendrical unit and adding units to a given absolute time.

stdlib/public/Darwin/Foundation/CharacterSet.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
@_exported import Foundation // Clang module
1414
import CoreFoundation
15-
import _SwiftCoreFoundationOverlayShims
16-
import _SwiftFoundationOverlayShims
15+
@_implementationOnly import _SwiftCoreFoundationOverlayShims
16+
@_implementationOnly import _SwiftFoundationOverlayShims
1717

1818
private func _utfRangeToCFRange(_ inRange : Range<Unicode.Scalar>) -> CFRange {
1919
return CFRange(

stdlib/public/Darwin/Foundation/Data.swift

Lines changed: 172 additions & 131 deletions
Large diffs are not rendered by default.

stdlib/public/Darwin/Foundation/Date.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
@_exported import Foundation // Clang module
1414
import CoreFoundation
15-
import _SwiftCoreFoundationOverlayShims
15+
@_implementationOnly import _SwiftCoreFoundationOverlayShims
1616

1717
/**
1818
`Date` represents a single point in time.

stdlib/public/Darwin/Foundation/DateInterval.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
@_exported import Foundation // Clang module
14-
import _SwiftCoreFoundationOverlayShims
14+
@_implementationOnly import _SwiftCoreFoundationOverlayShims
1515

1616
/// DateInterval represents a closed date interval in the form of [startDate, endDate]. It is possible for the start and end dates to be the same with a duration of 0. DateInterval does not support reverse intervals i.e. intervals where the duration is less than 0 and the end date occurs earlier in time than the start date.
1717
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)

stdlib/public/Darwin/Foundation/Decimal.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
@_exported import Foundation // Clang module
14-
import _SwiftCoreFoundationOverlayShims
14+
@_implementationOnly import _SwiftCoreFoundationOverlayShims
1515

1616
extension Decimal {
1717
public typealias RoundingMode = NSDecimalNumber.RoundingMode

stdlib/public/Darwin/Foundation/FileManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
@_exported import Foundation // Clang module
14-
import _SwiftFoundationOverlayShims
14+
@_implementationOnly import _SwiftFoundationOverlayShims
1515

1616
extension FileManager {
1717
/*

stdlib/public/Darwin/Foundation/IndexPath.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
@_exported import Foundation // Clang module
14-
import _SwiftFoundationOverlayShims
14+
@_implementationOnly import _SwiftFoundationOverlayShims
1515

1616
/**
1717
`IndexPath` represents the path to a specific node in a tree of nested array collections.

stdlib/public/Darwin/Foundation/IndexSet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
@_exported import Foundation // Clang module
14-
import _SwiftFoundationOverlayShims
14+
@_implementationOnly import _SwiftFoundationOverlayShims
1515

1616
extension IndexSet.Index {
1717
public static func ==(lhs: IndexSet.Index, rhs: IndexSet.Index) -> Bool {

stdlib/public/Darwin/Foundation/Locale.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
@_exported import Foundation // Clang module
14-
import _SwiftFoundationOverlayShims
14+
@_implementationOnly import _SwiftFoundationOverlayShims
1515

1616
/**
1717
`Locale` encapsulates information about linguistic, cultural, and technological conventions and standards. Examples of information encapsulated by a locale include the symbol used for the decimal separator in numbers and the way dates are formatted.

stdlib/public/Darwin/Foundation/Measurement.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import CoreFoundation
1515
#else
1616
@_exported import Foundation // Clang module
17-
import _SwiftCoreFoundationOverlayShims
17+
@_implementationOnly import _SwiftCoreFoundationOverlayShims
1818
#endif
1919

2020
/// A `Measurement` is a model type that holds a `Double` value associated with a `Unit`.

stdlib/public/Darwin/Foundation/NSCoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
@_exported import Foundation // Clang module
14-
import _SwiftFoundationOverlayShims
14+
@_implementationOnly import _SwiftFoundationOverlayShims
1515

1616
//===----------------------------------------------------------------------===//
1717
// NSCoder

stdlib/public/Darwin/Foundation/NSDictionary.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
@_exported import Foundation // Clang module
14-
import _SwiftFoundationOverlayShims
14+
@_implementationOnly import _SwiftFoundationOverlayShims
1515

1616
// We don't check for NSCopying here for performance reasons. We would
1717
// just crash anyway, and NSMutableDictionary will still do that when

stdlib/public/Darwin/Foundation/NSError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
@_exported import Foundation // Clang module
1414
import CoreFoundation
1515
import Darwin
16-
import _SwiftFoundationOverlayShims
16+
@_implementationOnly import _SwiftFoundationOverlayShims
1717

1818
//===----------------------------------------------------------------------===//
1919
// NSError (as an out parameter).

stdlib/public/Darwin/Foundation/NSUndoManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
@_exported import Foundation // Clang module
14-
import _SwiftFoundationOverlayShims
14+
@_implementationOnly import _SwiftFoundationOverlayShims
1515

1616
extension UndoManager {
1717
@available(*, unavailable, renamed: "registerUndo(withTarget:handler:)")

stdlib/public/Darwin/Foundation/TimeZone.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
@_exported import Foundation // Clang module
14-
import _SwiftFoundationOverlayShims
14+
@_implementationOnly import _SwiftFoundationOverlayShims
1515

1616
/**
1717
`TimeZone` defines the behavior of a time zone. Time zone values represent geopolitical regions. Consequently, these values have names for these regions. Time zone values also represent a temporal offset, either plus or minus, from Greenwich Mean Time (GMT) and an abbreviation (such as PST for Pacific Standard Time).

stdlib/public/Darwin/Foundation/UUID.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
@_exported import Foundation // Clang module
1414
import Darwin.uuid
15-
import _SwiftCoreFoundationOverlayShims
15+
@_implementationOnly import _SwiftCoreFoundationOverlayShims
1616

1717
/// Represents UUID strings, which can be used to uniquely identify types, interfaces, and other items.
1818
@available(macOS 10.8, iOS 6.0, *)

stdlib/public/SwiftShims/FoundationOverlayShims.h

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -34,44 +34,6 @@
3434
#import "NSTimeZoneShims.h"
3535
#import "NSUndoManagerShims.h"
3636

37-
typedef struct {
38-
void *_Nonnull memory;
39-
size_t capacity;
40-
_Bool onStack;
41-
} _ConditionalAllocationBuffer;
42-
43-
static inline _Bool _resizeConditionalAllocationBuffer(_ConditionalAllocationBuffer *_Nonnull buffer, size_t amt) {
44-
size_t amount = malloc_good_size(amt);
45-
if (amount <= buffer->capacity) { return true; }
46-
void *newMemory;
47-
if (buffer->onStack) {
48-
newMemory = malloc(amount);
49-
if (newMemory == NULL) { return false; }
50-
memcpy(newMemory, buffer->memory, buffer->capacity);
51-
buffer->onStack = false;
52-
} else {
53-
newMemory = realloc(buffer->memory, amount);
54-
if (newMemory == NULL) { return false; }
55-
}
56-
if (newMemory == NULL) { return false; }
57-
buffer->memory = newMemory;
58-
buffer->capacity = amount;
59-
return true;
60-
}
61-
62-
static inline _Bool _withStackOrHeapBuffer(size_t amount, void (__attribute__((noescape)) ^ _Nonnull applier)(_ConditionalAllocationBuffer *_Nonnull)) {
63-
_ConditionalAllocationBuffer buffer;
64-
buffer.capacity = malloc_good_size(amount);
65-
buffer.onStack = (pthread_main_np() != 0 ? buffer.capacity < 2048 : buffer.capacity < 512);
66-
buffer.memory = buffer.onStack ? alloca(buffer.capacity) : malloc(buffer.capacity);
67-
if (buffer.memory == NULL) { return false; }
68-
applier(&buffer);
69-
if (!buffer.onStack) {
70-
free(buffer.memory);
71-
}
72-
return true;
73-
}
74-
7537
@protocol _NSKVOCompatibilityShim <NSObject>
7638
+ (void)_noteProcessHasUsedKVOSwiftOverlay;
7739
@end

0 commit comments

Comments
 (0)