File tree Expand file tree Collapse file tree 5 files changed +33
-2
lines changed Expand file tree Collapse file tree 5 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -26,8 +26,8 @@ class Slow {
26
26
}
27
27
}
28
28
29
- let inputArray_Int : [ Int ] = Array ( 0 ..< 1_000_000 )
30
- let inputArray_Class : [ Slow ] = ( 0 ..< 100_000 ) . map ( Slow . init ( num: ) )
29
+ let inputArray_Int : [ Int ] = Array ( 0 ..< 500_000 )
30
+ let inputArray_Class : [ Slow ] = ( 0 ..< 50_000 ) . map ( Slow . init ( num: ) )
31
31
32
32
@inline ( never)
33
33
func removeAll< T> ( _ arr: [ T ] ) -> [ T ] {
Original file line number Diff line number Diff line change 17
17
18
18
#if _runtime(_ObjC)
19
19
import SwiftShims
20
+ import Builtin
20
21
21
22
@usableFromInline
22
23
internal typealias _ArrayBridgeStorage
@@ -201,10 +202,12 @@ extension _ArrayBuffer {
201
202
if bufferIsUnique {
202
203
// As an optimization, if the original buffer is unique, we can just move
203
204
// the elements instead of copying.
205
+ if
204
206
let dest = newBuffer. firstElementAddress
205
207
dest. moveInitialize ( from: mutableFirstElementAddress,
206
208
count: c)
207
209
_native. mutableCount = 0
210
+ }
208
211
} else {
209
212
_copyContents (
210
213
subRange: 0 ..< c,
Original file line number Diff line number Diff line change @@ -709,6 +709,9 @@ internal func _isUnique<T>(_ object: inout T) -> Bool {
709
709
return Bool ( Builtin . isUnique ( & object) )
710
710
}
711
711
712
+ @_silgen_name ( " _swift_reallocObject " )
713
+ internal func _reallocObject( _ object: UnsafeMutableRawPointer , _ newSizeInBytes: Int ) -> UnsafeMutableRawPointer ?
714
+
712
715
/// Returns `true` if `object` is uniquely referenced.
713
716
/// This provides sanity checks on top of the Builtin.
714
717
@_transparent
Original file line number Diff line number Diff line change @@ -97,4 +97,11 @@ const HashableWitnessTable *getNSStringHashableConformance();
97
97
}
98
98
}
99
99
100
+ namespace swift {
101
+
102
+ SWIFT_CC (swift) SWIFT_RUNTIME_STDLIB_SPI
103
+ HeapObject *_swift_reallocObject (HeapObject *obj, size_t size);
104
+
105
+ }
106
+
100
107
#endif
Original file line number Diff line number Diff line change @@ -79,6 +79,24 @@ OBJC_EXPORT __attribute__((__weak_import__))
79
79
#endif
80
80
}
81
81
82
+ bool isObjCPinned (HeapObject *obj) {
83
+ #if SWIFT_OBJC_INTEROP
84
+ /* future: implement checking the relevant objc runtime bits */
85
+ return true ;
86
+ #else
87
+ return false ;
88
+ #endif
89
+ }
90
+
91
+ // returns non-null if realloc was successful
92
+ SWIFT_CC (swift) SWIFT_RUNTIME_STDLIB_SPI
93
+ HeapObject *swift::_swift_reallocObject(HeapObject *obj, size_t size) {
94
+ if (isObjCPinned (obj) || obj->refCounts .hasSideTable ()) {
95
+ return nullptr ;
96
+ }
97
+ return (HeapObject *)realloc (obj, size);
98
+ }
99
+
82
100
#if SWIFT_OBJC_INTEROP
83
101
// / Replacement for ObjC object_isClass(), which is unavailable on
84
102
// / deployment targets macOS 10.9 and iOS 7.
You can’t perform that action at this time.
0 commit comments