Commit Graph

43 Commits

Author SHA1 Message Date
Rose
7f2787e249 Use instancetype for the benchmark and SwiftNativeNSObject
This is more for consistency than anything else, really.
2024-09-04 13:07:04 -04:00
David Smith
b81aec5c1a rdar://127199021, fix compatibility with apps that accidentally do [[[aSwiftArray class] new] mutableCopy] to work (#73728) 2024-05-20 12:06:05 -07:00
David Smith
e20be0edc6 Revert [Runtime] Let CF provide us with state, avoiding runtime lookup. rdar://111104451 (#66606) 2023-06-22 10:24:51 -07:00
David Smith
7eb8283a49 [Runtime] Let CF provide us with state, avoiding runtime lookup. rdar://111104451 (#66606)
Provide a hook for CF to tell us about the state we need from it, rather than us having to look it up at runtime
2023-06-21 08:38:14 -07:00
David Smith
f36a4db856 Update fast dealloc to use new-style interposing and support objc weak refs 2020-01-22 13:55:27 -08:00
David Smith
1cce12f20c Add an Array-based NSMutableArray subclass 2019-09-24 18:15:33 -07:00
David Smith
1efa946caf Remove stdlib and runtime dependencies on Foundation and CF 2019-09-12 18:03:14 -07:00
Arnold Schwaighofer
fe69a86929 Revert "Remove stdlib and runtime dependencies on Foundation and CF"
It is causing bots to fail.

* Revert "The __has_include(<os/system_version.h>) branch here wasn't quite right, we'll just use the dlsym one for now"

This reverts commit f824922456.

* Revert "Remove stdlib and runtime dependencies on Foundation and CF"

This reverts commit 3fe46e3f16.

rdar://54709269
2019-08-26 13:00:08 -07:00
David Smith
3fe46e3f16 Remove stdlib and runtime dependencies on Foundation and CF 2019-08-23 14:10:23 -07:00
David Smith
48266a6f56 Remove unused Foundation subclasses 2019-07-26 14:47:43 -07:00
Mike Ash
3ad6e46930 [Stdlib] Fix warnings about designated initializers in SwiftNativeXXX classes. 2019-05-06 17:15:53 -04:00
Mike Ash
7506e9c4f8 [Stdlib] Make the SwiftNativeNSXXXBase classes gracefully handle being decoded with NSKeyedUnarchiver.
These would never be decoded in normal use, but it's possible to construct an archive that will attempt to decode them. Without this override, that throws an exception or worse.

rdar://problem/48429185
2019-05-01 10:04:14 -04:00
David Smith
ba2af14ffd Disable KVO auto-subclassing of internal Swift bridging types 2018-11-28 18:25:00 -08:00
David Smith
96691208e9 Bridged Strings should have some different/additional overrides for performance 2018-11-08 11:08:03 -08:00
Mike Ash
e18e03171f [Stdlib] Change SWIFT_RUNTIME_STDLIB_INTERNAL to not export the symbol.
The functions in LibcShims are used externally, some directly and some through @inlineable functions. These are changed to SWIFT_RUNTIME_STDLIB_SPI to better match their actual usage. Their names are also changed to add "_swift" to the front to match our naming conventions.

Three functions from SwiftObject.mm are changed to SPI and get a _swift prefix.

A few other support functions are also changed to SPI. They already had a prefix and look like they were meant to be SPI anyway. It was just hard to notice any mixup when they were #defined to the same thing.

rdar://problem/35863717
2018-10-03 09:55:33 -04:00
Mike Ash
317451c8ee [Runtime][Stdlib][Overlays] Add comments to all the renamed classes explaining the rename and noting that the old name cannot be used due to conflicts.
rdar://problem/35768222
2018-09-20 12:07:30 -04:00
Mike Ash
798edb9d0e [Runtime][Stdlib][Overlays] Rename various Objective-C classes and methods that would conflict when loading old Swift libraries into a process alongside ABI-stable libraries.
rdar://problem/35768222
2018-09-13 16:55:10 -04:00
Azoy
b8fc8b333c Remove _interface 2018-07-29 10:41:22 -04:00
Michael Gottesman
5648ef219d [+0-all-args] Clean up remains of +1 convention from the runtime. 2018-07-06 23:10:12 -07:00
Ben Cohen
f9b3e14137 [stdlib] Use Swift-native Character iteration for hasPrefix/Suffix (#14390)
* Use Swift-native Character iteration for hasPrefix/Suffix

* Remove old tests for removed C shims
2018-03-12 17:41:55 -07:00
Michael Gottesman
ce0c40e40b [+0-all] Update more runtime files for +0 normal arguments.
This is NFC when --enable-guaranteed-normal-arguments isn't passed into
build-script.

rdar://34222540
2018-01-29 12:13:45 -08:00
Michael Gottesman
18bcc1e143 [+0-args] Change SWIFT_CC(Swift) functions to use SWIFT_NS_RELEASES_ARGUMENT instead of NS_RELEASES_ARGUMENT.
rdar://34222540
2018-01-23 16:01:27 -08:00
Greg Parker
1e894cd80b [runtime] Clean up symbols in error machinery. (#12853)
* [runtime] Clean up symbols in error machinery.

* [runtime] Clean up symbols in Foundation overlay.

* [runtime] Clean up symbols in collections and hashing.

* [runtime] Remove symbol controls from the Linux definition of swift_allocError.

* [tests] Add more stub functions for tests that link directly to the runtime.
2017-11-15 22:20:11 -08:00
Greg Parker
0fa818ed6b [runtime] Make ivars in the runtime's ObjC classes private. 2017-10-23 18:30:28 -07:00
Arnold Schwaighofer
513303fd63 Also fix and test uppercased and lowercased 2017-10-06 13:04:03 -07:00
Arnold Schwaighofer
ec5f40f12f runtime: Move String implementation stubs that want need the auto-released return value optimization to an ARC compiled file
String's hashValue function is implemented in terms of Foundation's hash
function in a runtime function on darwin platforms. For non-ASCII strings we
will call str.decomposedStringWithCanonicalMapping inside this runtime function
which will allocate a new NSString and return the result in the current
autorelease pool. We implemented this function in a file compiled without ARC.
This meant that we would leak said NSString into the current active autorelease
pool.
This patch moves the implementation to a file compiled with ARC. ARC will insert
objc_retainAutoreleasedReturnValue call and on platforms that require it an
marker for the hand-off of the autoreleased return value optimization.

SR-4889
rdar://32199117
2017-10-06 11:12:22 -07:00
Karoy Lorentey
ed5b202c8f [stdlib] Implement -retainCount in _SwiftNativeNS*Base
Fixes rdar://problem/28002554.
2017-09-26 14:32:20 -07:00
Ben Cohen
d8be7ae29e Use CF for Hashing (#9203) 2017-05-03 05:42:40 -07:00
Philippe Hausler
6c26b80e6e [Foundation] Rework the backing storage for CharacterSet to be more performant and bridge correctly to objective-c and CF
Some cases of using isSuperset can cause crashes, this was caused by improper subclassing callouts; this pr resolves those failures (and provides unit tests for that case)
The cases where the bridge was traversed too much now only causes a single bridge out call (without needing to reallocate or thrash retain/release)
String.components(separatedBy: CharacterSet) should be considerably faster now not only for more apporpriate bridging calls but also no longer needing to bridge arrays back and forth.

Resolves the following issues:
rdar://problem/17281998
rdar://problem/26611771
rdar://problem/29738989
2017-03-31 11:06:38 -07:00
Hugh Bellamy
05a50fd978 Remove extern "C" from uses of SWIFT_RUNTIME_STDLIB_INTERFACE 2017-01-22 18:32:17 +00:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Saleem Abdulrasool
c67a33fbc7 build: remove TARGET_SDKS from the runtime
The runtime and stubs are built for ALL targets, not specific ones.  This allows
us to configure when cross-compiling to Windows again.  Collapse the dual
addition of the swiftRuntime into a single build.  This unifies the runtime
build for the apple and non-Apple SDKs.  The difference here was the ObjC
interop sources.  In order to deal with that unification add a CPP macro to
indicate whether the interop sources should be included or not.
2016-12-03 17:02:44 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Greg Parker
1c58cc20ba [stdlib] Remove workaround for an old clang bug (rdar://18950072). 2016-08-24 20:14:03 -07:00
Mishal Shah
87b7bcfd3e Update master to build with Xcode 8 beta 1, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs. 2016-06-14 14:53:55 -07:00
John McCall
50d58b2732 Add a lot of calling-convention annotations to the standard library / runtime.
The general rule here is that something needs to be SWIFT_CC(swift)
if it's just declared in Swift code using _silgen_name, as opposed to
importing something via a header.

Of course, SWIFT_CC(swift) expands to nothing by default for now, and
I haven't made an effort yet to add the indirect-result / context
parameter ABI attributes.  This is just a best-effort first pass.

I also took the opportunity to shift a few files to just implement
their shims header and to demote a few things to be private stdlib
interfaces.
2016-05-04 10:31:23 -07:00
Arnold Schwaighofer
e67acdb70d Improve the performance of String.hasPrefix/hasSuffix by using a stack allocated _NSContiguousString
rdar://25797140
2016-04-19 09:04:58 -07:00
Arnold Schwaighofer
7fb2cceec0 Add a method to _NSContiguousString to facilitate stack promotion
Use it for hashing and comparison.

During String's hashValue and comparison function we create a
_NSContiguousString instance to call Foundation's hash/compare function. This is
expensive because we have allocate and deallocate a short lived object on the
heap (and deallocation for Swift objects is expensive).  Instead help the
optimizer to allocate this object on the stack.

Introduces two functions on the internal _NSContiguousString:
_unsafeWithNotEscapedSelfPointer and _unsafeWithNotEscapedSelfPointerPair that
pass the _NSContiguousString instance as an opaque pointer to their closure
argument. Usage of these functions asserts that the closure will not escape
objects transitively reachable from the opaque pointer.

We then use those functions to call into the runtime to call foundation
functions on the passed strings. The optimizer can promote the strings to the
stack because of the assertion this API makes.

  let lhsStr = _NSContiguousString(self._core) // will be promoted to the stack.
  let rhsStr = _NSContiguousString(rhs._core) // will be promoted to the stack.
  let res = lhsStr._unsafeWithNotEscapedSelfPointerPair(rhsStr) {
    return _stdlib_compareNSStringDeterministicUnicodeCollationPointer($0, $1)
  }

Tested by existing String tests.

We should see some nice performance improvements for string comparison and
dictionary benchmarks.

Here is what I measured at -O on my machine

Name                          Speedup
Dictionary                      2.00x
Dictionary2                     1.45x
Dictionary2OfObjects            1.20x
Dictionary3                     1.50x
Dictionary3OfObjects            1.45x
DictionaryOfObjects             1.40x
SuperChars                      1.60x

rdar://22173647
2016-03-24 05:43:29 -07:00
Arnold Schwaighofer
0b181a1861 Don't throw away the top bits of our hashed value for strings on 64bit platforms
SR-877
rdar://24918173
2016-03-04 14:29:02 -08:00
Joe Groff
f7291b21ec Runtime: Build with -fvisibility=hidden.
...and explicitly mark symbols we export, either for use by executables or for runtime-stdlib interaction. Until the stdlib supports resilience we have to allow programs to link to these SPI symbols.
2016-02-08 08:06:02 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Joe Groff
37b827c8c5 stdlib: Override ObjC weak support in SwiftNativeNSXXXBase to use Swift refcounting.
Noticed by inspection.
2015-12-22 11:52:34 -08:00
Joe Groff
c6b6d346bd Move the SwiftNativeNSXXXBase classes and stubs to SwiftStubs.
Move the ObjC internal declarations to a public runtime header so they can be shared, and rename _swift_deallocClassInstance to the more descriptive name swift_rootObjCDealloc (and make it only available with ObjC interop).
2015-11-13 08:37:12 -08:00