Commit Graph

35 Commits

Author SHA1 Message Date
Jonathan Grynspan
099fdc2e41 Fix an issue on COFF/ELF targets where the runtime would register each loaded image twice (at least early on.) 2022-01-01 11:39:25 -05:00
Arnold Schwaighofer
cf3951394a Revert "Fix an issue on COFF/ELF targets where the runtime would register each loaded image twice (at least early on.)" 2021-12-21 07:15:08 -08:00
Jonathan Grynspan
7fe5ea7398 Fix an issue on COFF/ELF targets where the runtime would register each loaded image twice (at least early on.) 2021-12-20 15:15:02 -05:00
Pavel Yaskevich
3f4c06eb1b [Distributed] Runtime: Add skeleton support for accessible function sections 2021-12-17 10:52:56 -08:00
Kuba (Brecka) Mracek
c2a92722c6 Split the NO_DYLD CMake flag into separate HAS_DLADDR and STATIC_IMAGE_INSPECTION flags (#39339) 2021-09-29 19:57:05 -07:00
Mike Ash
70354af2b5 [Runtime] Avoid operator new/delete in ConcurrentReadableArray.
The callbacks made in ImageInspectionMachO.cpp are called in a dangerous context, with the dyld and ObjC runtime locks held. C++ allows programs to overload the global operator new/delete, and there's no guarantee that those overloads behave. Ideally, we'd avoid them entirely, but that's a bigger job. For now, avoid the worst trouble by avoiding STL and new/delete in these callbacks. That use came from ConcurrentReadableArray's free list, so we switch that from a std::vector to a linked list.

rdar://75036800
2021-04-09 09:29:20 -04:00
Mike Ash
6aab257c33 [Concurrency] Add compatibility overrides to Concurrency library.
Take the existing CompatibilityOverride mechanism and generalize it so it can be used in both the runtime and Concurrency libraries. The mechanism is preprocessor-heavy, so this requires some tricks. Use the SWIFT_TARGET_LIBRARY_NAME define to distinguish the libraries, and use a different .def file and mach-o section name accordingly.

We want the global/main executor functions to be a little more flexible. Instead of using the override mechanism, we expose function pointers that can be set by the compatibility library, or by any other code that wants to use a custom implementation.

rdar://73726764
2021-03-22 11:09:06 -04:00
Mike Ash
17e31d89d2 [Runtime] Restore objc_addLoadImageFunc in ImageInspectionMacho.cpp.
The conditional use of objc_addLoadImageFunc was accidentally removed in b5759c9fd9. Put it back.

rdar://problem/70452221
2020-10-19 15:53:52 -04:00
Doug Gregor
b5759c9fd9 [Concurrency] Allow overload 'async' with non-async and disambiguate uses.
Allow an 'async' function to overload a non-'async' one, e.g.,

    func performOperation(_: String) throws -> String { ... }
    func performOperation(_: String) async throws -> String { ... }

Extend the scoring system in the type checker to penalize cases where
code in an asynchronous context (e.g., an `async` function or closure)
references an asychronous declaration or vice-versa, so that
asynchronous code prefers the 'async' functions and synchronous code
prefers the non-'async' functions. This allows the above overloading
to be a legitimate approach to introducing asynchronous functionality
to existing (blocking) APIs and letting code migrate over.
2020-09-08 16:51:10 -07:00
Kuba (Brecka) Mracek
db18deaf91 Add a SWIFT_RUNTIME_MACHO_NO_DYLD stdlib mode that doesn't dynamically look up sections in modules, and only assumes a single static module (#33441) 2020-08-18 11:46:42 -07:00
Kuba (Brecka) Mracek
aa924196ff Add a flag to build the stdlib without COMPATIBILITY_OVERRIDE (#33438) 2020-08-14 17:06:38 -07:00
Kuba (Brecka) Mracek
e2e69578a6 For the 'minimal' stdlib, disable Objective-C interop (#33427) 2020-08-13 15:26:04 -07:00
pschuh
37c6414e77 Fix usage of uninitialized memory in swift_addNewDSOImage. (#26275)
This should address https://bugs.swift.org/browse/SR-6848.

Couldn't transform the unsafeGet to get because it would produce an
infinite loop.
2019-08-13 13:23:33 -07:00
Mike Ash
2ac0ab069a [Runtime] Use objc_addLoadImageFunc when available to find out about newly loaded images.
rdar://problem/49742015
2019-06-14 17:09:28 -04:00
Arnold Schwaighofer
5c3a4d329b Fix dynamic replacement of some type when used with associated types
rdar://50638228
2019-05-18 10:34:52 -07:00
Saleem Abdulrasool
618d525b91 runtime: enable stack traces on Windows
We would not previously symbolicate the stack trace and as a result
would not display the stack trace.  Add symbolication support to the
runtime to actually make use of the captured stack trace.  This allows
us to get a stack trace when the standard library or swift code reports
a fatal error.
2019-03-04 10:39:10 -08:00
Arnold Schwaighofer
152e8db8bb IRGen and runtime implementation for dynamic replacements 2018-11-06 09:58:36 -08:00
Joe Groff
2a8b7f76bf Runtime: Don't register fieldmd sections.
They're no longer necessary to track separately from types.
2018-08-15 16:20:53 -07:00
Arnold Schwaighofer
cc7f207cec Rename swift sections from swift4 to swift5
rdar://38465220
2018-05-23 12:18:08 -07:00
Mike Ash
9e8d4da76f [Runtime] Add a hooking mechanism to allow future apps to extend dynamic casting and type lookup. Make swift_dynamicCast and swift_getTypeByMangledName use these hooks.
rdar://problem/36997475
2018-03-20 16:33:37 -07:00
Arnold Schwaighofer
0c11e1a0a3 Mark swift sections as swift4 for Swift 4.2
rdar://36363251
2018-03-14 10:27:28 -07:00
Pavel Yaskevich
50785df558 [Runtime] NFC: Update names of the field section to swift5_fieldmd 2018-02-20 18:20:09 -08:00
Pavel Yaskevich
0da5e48a0e [Runtime/Reflection] Add swift_getFieldAt runtime accessor
Use information from reflection section of the binary to lookup
type field info such as name and it's type and return it using
new `swift_getFieldAt` method based on nominal type and field index.
2018-02-20 18:20:09 -08:00
Pavel Yaskevich
bc1c170a45 [Runtime] Register type field metadata section 2018-02-20 18:18:48 -08:00
Doug Gregor
a7fef62a44 [Runtime] Search through protocols to resolve protocol declarations.
Search through the new section containing Swift protocol descriptor
references to resolve protocols by mangled name. Use this
functionality to support protocol composition types within
_typeForMangledName.
2018-01-09 20:17:44 -08:00
Doug Gregor
310bd6be48 [Runtime] Mangle the reference kind in the lower two bits of type references.
The separate section of type references uses the same type reference format
as in protocol conformance records. As with protocol conformance records,
mangle the type reference kind into the lower two bits. Then, eliminate the
separate "flags" field from the type metadata record. Finally, rename
the section because the Swift 5 stable format for this section is
different from prior formats, and the two runtimes need to be able to
coexist.
2018-01-03 10:49:21 -08:00
Doug Gregor
8c668ba524 [Runtime] Rename the segment for protocol conformance records.
The format of protocol conformance records will be changing in Swift 5, so
rename the segment (from, e.g., __swift2_proto to __swift5_proto) to allow
Swift < 5 and Swift 5+ runtimes to coexist.
2018-01-02 11:01:51 -08:00
Saleem Abdulrasool
635bb00d61 runtime: make LLP64 clean
This is a blanket pass replacing use of `__LP64__` with
`__POINTER_WIDTH__ == 64`.  The latter is more expressive and also LLP64
clean.  This change is needed to enable support for Windows x86_64 which
is a LLP64 environment.
2017-09-17 18:41:10 -07:00
Kuba (Brecka) Mracek
fc7dbefcf8 Revert backtrace ban and start printing backtraces from the runtime again (#9528)
* Revert "[strip -ST] Disable runtime stack trace dumping on Darwin when asserts are disabled."
This reverts commit 6bc28ff1c9.
* Bring back important fixes from the revert of 6bc28ff1c9.
* Change swift::swift_reportError to only print the backtrace in assert builds (swift::warning prints backtrace always).
2017-05-12 15:46:35 -07:00
Michael Gottesman
6bc28ff1c9 [strip -ST] Disable runtime stack trace dumping on Darwin when asserts are disabled.
This commit disables runtime stack trace dumping via dladdr on Darwin when
asserts are disabled.

This stack trace dumping was added as a way to improve the ability to debug the
compiler for compiler developers. This is all well and good but having such a
feature always enabled prevents us from reducing the size of the swift standard
library by eliminating the swift nlist.

rdar://31372220
2017-05-04 16:46:26 -06:00
Michael Gottesman
43c5acbb19 [gardening] Fix doxygen headers in ImageInspection files. 2017-05-02 13:53:11 -07:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Simon Evans
c17ca759aa [runtime] Add platform independent version of dladdr() / Dl_info
- Win32 does not support dlfcn.h, Dl_info or dladdr() so add
  lookupSymbol() as a wrapper for ELF/MachO/Win32

- Win32 version needs an implementation, currently it just returns
  an error for `cannot lookup address'
2016-11-29 00:05:11 +00: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
Joe Groff
87b27c6451 Runtime: Refactor platform-dependent image inspection code.
The code we use to interface with the platform dynamic linker is turning into a rat's nest of conditionals that's hard to maintain and extend. Since ELF, Mach-O, and PE platforms have pretty fundamentally different dynamic linker interfaces and capabilities, it makes sense to factor that code into a separate file per-platform, instead of trying to conditionalize the logic in-line. This patch factors out a much simpler portable interface for lazily kicking off the protocol conformance and type metadata lookup caches, and factors the guts out into separate MachO, ELF, and Win32 backends. This should also be a much cleaner interface to interface static binary behavior into, assisting #5349.
2016-11-17 16:50:04 -08:00