Commit Graph

33 Commits

Author SHA1 Message Date
David Smith
f800fdf3d2 Adopt indirect tagged strings (#80425)
Fixes rdar://142991821
2025-04-01 12:53:29 -07:00
Mishal Shah
48d5aca28d Revert "Use associated objects to attach contiguous array buffers to lazy one…"
This reverts commit 7c011813f2.
2024-07-21 23:34:57 -07:00
David Smith
7c011813f2 Use associated objects to attach contiguous array buffers to lazy ones (#75148)
rdar://132124808
2024-07-19 23:21:41 -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
300f3fd12f Better memory order 2023-06-21 11:08:34 -07:00
David Smith
bb394a0561 Use proper atomics instead of trying to do it with explicit barriers 2023-06-21 10:58:56 -07:00
David Smith
53d308afcf Add an explicit barrier, mostly for clarity 2023-06-21 10:42:28 -07:00
David Smith
1d3ee23387 Use swift::once instead of swift_once to clean up the code a little, and make sure we unconditionally set the state from CF to make sure it's set even if we failed a lazy load earlier
(cherry picked from commit 1394a8e3ab529e855a5940ad983dacf402d09550)
2023-06-21 10:21:27 -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
Egor Zhdan
84a1ffcb33 [Shims] Include SwiftShims headers without ../
This replaces a number of `#include`-s like this:
```
#include "../../../stdlib/public/SwiftShims/Visibility.h"
```
with this:
```
#include "swift/shims/Visibility.h"
```

This is needed to allow SwiftCompilerSources to use C++ headers which include SwiftShims headers. Currently trying to do that results in errors:
```
swift/swift/include/swift/Demangling/../../../stdlib/public/SwiftShims/module.modulemap:1:8: error: redefinition of module 'SwiftShims'
module SwiftShims {
       ^
Builds.noindex/swift/swift/bootstrapping0/lib/swift/shims/module.modulemap:1:8: note: previously defined here
module SwiftShims {
       ^
```
This happens because the headers in both the source dir and the build dir refer to SwiftShims headers by relative path, and both the source root and the build root contain SwiftShims headers (which are equivalent, but since they are located in different dirs, Clang treats them as different modules).
2022-09-14 11:14:50 +01:00
Saleem Abdulrasool
ca39bb5b10 stubs: avoid reaching up-tree, prefer inclusion options
This removes the explicit tree structure reference in the stubs to
locate the shims.  Instead, it expects that the `SwiftShims` directory
will be added to the header search path.
2022-01-14 09:34:56 -08:00
Alastair Houghton
21ac407a21 <rdar://64939529> Convert unnecessary dlsym() calls into direct references.
Added SWIFT_RUNTIME_WEAK_IMPORT/CHECK/USE macros.

Everything supports fast dealloc except x86 iOS simulators, so we no longer need
to look up objc_has_weak_formation_callout.

Added direct references for

  objc_setHook_lazyClassNamer
	_objc_realizeClassFromSwift
	objc_setHook_getClass
	os_system_version_get_current_version
	_dyld_is_objc_constant
2021-06-18 10:16:30 +01:00
Zoe Carver
7eff49c1b6 [cxx-interop] [nfc] Remove swift namespace from SwiftShims in C++ mode. (#32715)
Most SwiftShims were put in the swift namespace in C++ mode which broke certain things when importing them in a swift file in C++ mode. This was OK when they were only imported as part of the swift runtime but, now they are used in C++ mode both in the swift runtime and when C++ interop is enabled.

This broke when C++ interop was enabled because the `Swift` module contains references to symbols in the SwiftShims headers which are built without C++ interop enabled (no "swift" namespace). But, when C++ interop is enabled, the SwiftShims headers would put everything in the swift namespace meaning the symbols couldn't be found in the global namespace. Then, the compiler would error when trying to deserialize the Swift module.
2020-07-08 08:43:26 -07:00
David Smith
220f0ccde8 Untag tagged constant NSString pointers before we wrap them, so BridgeObject doesn't stomp the high bits 2020-04-22 16:49:23 -07:00
David Smith
5ad4b15af6 Avoid attempting to create SmallStrings for constant tagged CFStrings 2020-04-15 12:30:20 -07:00
David Smith
1efa946caf Remove stdlib and runtime dependencies on Foundation and CF 2019-09-12 18:03:14 -07:00
David Smith
f559a94f1b Redo CFStringCreateWithBytes shim 2019-08-12 15:15:10 -07:00
David Smith
5a1f068415 Remove dead shim code 2019-08-07 16:50:47 -07:00
David Smith
c5fc715746 Reimplement the CF stub system using ObjC. The primary effect of this is to break the link-time dependency on the CF symbols, but it also improves performance a bit.
One additional tweak (setting the scalar-aligned bit on foreign indices) had to be made to avoid a performance regression for long non-ASCII foreign strings.
2019-08-01 19:56:45 -07:00
David Smith
584fbfc245 Avoid the overhead of looking up the current CFAllocator in String bridging 2019-04-15 15:28:00 -07:00
David Smith
8b57921905 Assorted bridging changes:
• Convert _AbstractStringStorage to a protocol, and the free functions used to deduplicate implementations to extensions on that protocol.
• Move 'start' into the abstract type and use that to simplify some code
• Move the ASCII fast path for length into UTF16View.
• Add a weirder but faster way to check which (if any) of our NSString subclasses a given object is, and adopt it
2018-11-28 16:04:34 -08:00
David Smith
8bb6b78e36 Use super trampolines to let us override several more NSString methods (-UTF8String, -cStringUsingEncoding:, and -getCString:maxLength:encoding:) for performance 2018-11-15 17:10:51 -08:00
David Smith
96691208e9 Bridged Strings should have some different/additional overrides for performance 2018-11-08 11:08:03 -08:00
Michael Ilseman
b572bfe2f4 [stubs] Add CFString*Bytes stubs, drop some dead ones.
NFC, just stubs and plumbing.
2018-03-13 15:32:20 -07: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
Brian Gesiak
eda6e839ac [stdlib] Use _Nonnull over __nonnull in Foundation
The `__nonnull` keyword is deprecated in favor of `_Nonnull`.
2016-08-26 16:19:46 -04: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
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
Andrew Trick
c1e45d899e Add a shim: swift_stdlib_objcDebugDescription, NFC.
This allows removal of the DebugDescription protocol which is invalid
because no classes actually conform to it. The problem is that we need
to send a debugDescription message to an NSObject without loading
Foundation. This is exactly what shims are for. A very simple shim
solves the problem.
2015-11-18 18:40:45 -08:00
Joe Groff
87325891a3 Move FoundationHelpers.mm to SwiftStubs. 2015-11-13 08:37:12 -08:00