Commit Graph

24 Commits

Author SHA1 Message Date
Erik Eckstein
7a5de47aa1 runtime: change the naming of TLS related stuff to make it more general and not specific to exclusivity checking.
Just a refactoring, NFC
2019-05-30 15:28:16 -07:00
Erik Eckstein
2ea531c3b3 IRGen/runtime: change the code generation for dynamically replaceable functions
Instead of a thunk insert the dispatch into the original function.
If the original function should be executed the prolog just jumps to the "real" code in the function. Otherwise the replacement function is called.
There is one little complication here: when the replacement function calls the original function, the original function should not dispatch to the replacement again.
To pass this information, we use a flag in thread local storage.
The setting and reading of the flag is done in two new runtime functions.

rdar://problem/51043781
2019-05-30 15:28:16 -07:00
Andrew Trick
823137b2f4 Remove runtime support for exclusivity warnings. 2018-10-13 10:06:35 -07:00
Andrew Trick
2ecb48a89d Remove exclusivity support for Swift 3 mode.
Remove the compiler support for exclusivity warnings.

Leave runtime support for exclusivity warnings in non-release builds
only for unit testing convenience.

Remove a test case that checked the warning log output.

Modify test cases that relied on successful compilation in the
presence of exclusivity violations.

Fixes: <rdar://problem/45146046> Remaining -swift-version 3 tests for exclusivity
2018-10-12 09:08:42 -07:00
Mike Ash
29ff3de4ab [Runtime][Stdlib] Use dedicated thread-local storage keys when possible.
rdar://problem/32275323 rdar://problem/44104305
2018-09-13 14:36:57 -04:00
Mike Ash
9638cb8f6e [Runtime] Fix format string warnings in Errors.cpp and Exclusivity.cpp when built for 32-bit.
rdar://problem/40345076
2018-05-25 16:16:02 -04:00
Andrew Trick
495d5aecf6 [exclusivity] Add an access marker folding pass.
Use AccessedStorageAnalysis to find access markers with no nested conflicts.

This optimization analyzes the scope of each access to determine
whether it contains a potentially conflicting access. If not, then it
can be demoted to an instantaneous check, which still catches
conflicts on any enclosing outer scope.

This removes up to half of the runtime calls associated with
exclusivity checking.
2018-05-15 12:29:19 -07:00
Michael Gottesman
636b5f67f0 [runtime] Add support for an asserts only debugging routine called swift_dumpTrackedAccesses().
This makes it easy to perform printf debugging in the debugger. I have found it
to be useful in understanding programs around exclusivity quickly.
2018-04-19 21:37:12 -07:00
Andrew Trick
89d96bff4e Runtime support for nontracking begin_access.
There are multiple reasons to do this. Primarily this is
useful as an optimization. Whenever analysis can determine that no
potentially conflicting access occurs within the scope, the access can
be demoted to "nontracking". It is also useful as an escape hatch for
future code deploying to older runtimes. For example, if a future access
scope may cross threads, and the older runtime doesn't know how to
migrate threads.

See <rdar://problem/37507434> add a flag to swift_beginAccess to inform
the runtime that an access might migrate between threads
2018-03-27 12:04:32 -07:00
Greg Parker
1a0e3e7c31 [runtime] Don't use C++ thread_local on two old Apple simulators.
32-bit iOS 9 simulator and 32-bit watchOS 2 simulator do not support
C++ thread_local, even though clang's has_feature(cxx_thread_local)
thinks they do.

rdar://35063043
2017-10-19 16:55:19 -07:00
Saleem Abdulrasool
ef70671f77 runtime: clean up some warnings
This is a smorgasbord of warning cleanups in the runtime.  This just
adjusts the casts for the various types.  There were a number of casts
which lost const qualifiers on the type.
2017-09-17 16:20:16 -07:00
Jordan Rose
9c10398514 [runtime] Expose reportToDebugger as swift_reportToDebugger.
...so that the overlays can use it. See next commit.
2017-07-13 11:18:41 -07:00
Andrew Trick
91405a7f91 Remove the hash function from the runtime's exclusive access checks.
I expect this to improve the following Onone benchmarks:
- 1.09x accessGlobal
- 1.08x accessInMatSet
- 1.06x accessIndependent

And the preexisting benchmarks:

| TEST                    | DELTA | SPEEDUP   |
|                         |       |           |
| Random                  | -7.9% | **1.09x** |
| MatMul                  | -7.6% | **1.08x** |
| XorShift                | -7.2% | **1.08x** |
| PolymorphicCalls        | -6.2% | **1.07x** |
| NopDeinit               | -6.1% | **1.06x** |
| Ary                     | -6.0% | **1.06x** |
| Integrate               | -5.8% | **1.06x** |
| StringWalk              | -5.5% | **1.06x** |
| ArrayInClass            | -5.2% | **1.06x** |
| MultiFileTogether       | -5.2% | **1.06x** |
| DictionaryHashableClass | -5.2% | **1.05x** |
| MultiFileSeparate       | -4.9% | **1.05x** |
2017-06-29 16:32:35 -07:00
Kuba (Brecka) Mracek
8cb95b8fcd Improve reporting of @objc inference issues from the Swift runtime (#10406)
* Extend Swift runtime issue reporting for @objc inference to include details about the declaration of the method (that is missing the @objc annotation) and a suggested fix-it. This changes the ABI of RuntimeErrorDetails, so we're also bumping the version.

* Update SwiftObject.mm
2017-06-22 21:35:48 -07:00
Kuba (Brecka) Mracek
d29557bd24 Change the signature of reportToDebugger and _swift_runtime_on_report to avoid using 'bool'. It's much easier to work with native-width integers only in LLDB. (#10523) 2017-06-22 21:22:27 -07:00
John McCall
4399bd37fa Fix some embarrassing list-management bugs with the exclusivity runtime
which can arise when accesses are not strictly nested.
2017-06-21 19:04:46 -04:00
Kuba (Brecka) Mracek
fec8d72ea3 Debugger hook/breakpoint for issue reporting from the Swift runtime (#10293)
* Implements a debugger hook (breakpoint) API and data structure. This structure is passed to the debugger and describes extra information about a fatal error or a non-fatal warning, which should be logged as a runtime issue.

This debugger hook is then used from two places, which currently only log to stderr:
- Runtime exclusivity violations.
- Swift 3 implicit Obj-C entrypoints.

A subsequent LLDB support will be able to catch these callbacks and show the runtime issues in a better way than just logging them to stderr.  When the debugger is not attached, this shouldn't have any effect.
2017-06-19 14:28:19 -07:00
Kuba (Brecka) Mracek
a5a59f5aed [runtime] Enhance output from dynamic exclusivity violations. Print current stacktrace and the symbolicated frame of the previous conflicting access. (#9501) 2017-05-12 20:28:28 -07:00
practicalswift
8a26719344 [gardening] Fix duplicate include. 2017-05-11 16:04:48 +02:00
John McCall
ab250848b4 Downgrade dynamic exclusivity failures to a warning in Swift 3 compatibility mode. 2017-05-10 14:44:59 -04:00
John McCall
e01c31a17c Remember a PC in the exclusivity-tracking set and report it during failures. 2017-05-10 14:44:56 -04:00
John McCall
2525710017 Make the exclusivity-set tracking a singly-linked list.
We'll use this space for something else in a follow-up.
2017-05-10 01:35:34 -04:00
Devin Coughlin
73aabd73f7 [Exclusivity] Fix insertion/remove in AccessSet in runtime.
And add some basic tests for trapping on accesses to globals.
2017-04-27 15:38:07 -07:00
John McCall
6c16cfaa14 Implement a basic dynamic-enforcement runtime and teach IRGen to use it. 2017-04-18 11:23:43 -04:00