Commit Graph

33 Commits

Author SHA1 Message Date
Davide Italiano
cb8d946cba [Runtime] Remove the dependency on LLVM's Compiler.h
<rdar://problem/35860874>
2018-07-03 13:52:40 -07:00
Joe Groff
681a96b45c Runtime: Tolerate unknown metadata kinds.
We want to be able to potentially introduce new metadata kinds in future Swift compilers, so a runtime ought to be able to degrade gracefully in the face of metadata kinds it doesn't know about. Remove attempts to exhaustively switch over metadata kinds and instead treat unknown metadata kinds as opaque.
2018-05-17 15:35:06 -07:00
Mike Ash
ba506a90fc [Runtime] Add the inline attribute to CRGet/SetCrashLogMessage functions to silence warnings about unused functions.
rdar://problem/39579513
2018-04-20 15:55:24 -04:00
John McCall
f22d02a67a Detect unbreakable metadata dependency cycles and abort with a diagnostic. 2018-04-01 19:23:57 -04:00
Arnold Schwaighofer
e106161d8f Speculative fix for linux bot linker failure 2018-03-09 17:55:39 -08:00
Arnold Schwaighofer
b9602754cd Untangle the dependency on swiftStdlibStubs from swiftRuntime that I introduced
rdar://35525730
2018-03-07 11:17:19 -08:00
Mike Ash
406ebaddfc [Runtime] Implement overflow check for weak refcounts (#14023)
* Check for overflow in incrementWeak().

This mirrors what is currently done for unowned reference counts, where overflowing the side table field produces a fatal error. Without this, the count silently wrapped from 2^31-1 to 0, which then caused breakage when the balancing releases happened (possibly including use-after-free bugs).

* Fix the implementation of RefCounts::getWeakCount().

The previous implementation was only appropriate for heap objects, but not side tables. This resulted in the weak count always returning 0 or 1. This change specializes the implementation for the two different cases and returns the correct count for side tables.

* Test large weak retain counts.

This tests the largest allowed weak retain count, as well as the overflow check when that count is exceeded.
2018-01-19 19:13:47 -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
Arnold Schwaighofer
d8abd2fed9 runtime: Fix overflow of swift_unownedRetain reference counts
On 32bit platforms there are 7 bits reserved for the unowned retain count. This
makes overflow a likely scenario. Implement overflow into the side table.

rdar://33495003
2017-08-02 07:12:47 -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
Kuba (Brecka) Mracek
4b88da2a2c Use the debugger hook, reportToDebugger, for all calls to _swift_stdlib_reportFatalError[InFile]. Only do this when a hidden frontend flag, -report-errors-to-debugger, is used. (#10617) 2017-06-29 09:12:26 -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
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
Doug Gregor
cd811edb14 [Runtime] Add a “swift::warning” entrypoint for runtime warnings.
Like swift::fatalError(), but without the abort or crash logging.
2017-03-31 21:22:16 -07:00
Greg Parker
ae1c984920 New refcount representation (#5282)
New refcount representation and weak variable implementation. See SwiftShims/RefCount.h for details.
2017-02-24 14:19:11 -08:00
Hugh Bellamy
818099ecbe Rename swift_unreachable to swift_runtime_unreachable 2017-01-26 15:31:34 +00:00
Hugh Bellamy
5a59971b95 Move Unreachable.h from include/Basic to include/Runtime 2017-01-26 15:31:33 +00:00
Hugh Bellamy
63cf2d561e Remove extern "C" from uses of SWIFT_RUNTIME_EXPORT 2017-01-22 18:32:17 +00:00
Slava Pestov
230b50263e Merge pull request #6940 from hughbe/crash-client-hidden
Remove CRASH_REPORTER_CLIENT_HIDDEN in favour of equivilent LLVM macro
2017-01-20 20:28:44 -08:00
Hugh Bellamy
4e55214c18 Remove CRASH_REPORTER_CLIENT_HIDDEN in favour of equivilent LLVM macro 2017-01-20 13:48:56 +00:00
Hugh Bellamy
9b06a72f44 Use LLVM_BUILTIN_TRAP in swift::crash instead of our own solution 2017-01-20 13:26:53 +00:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01: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
Dmitri Gribenko
53c424409d stdlib: add AnyHashable
Implements SE-0131 "Add AnyHashable to the standard library".
2016-07-26 03:10:52 -07:00
David Farler
cd65a8e0b0 Template metadata structures
- Add RuntimeTarget template This will allow for converting between
  metadata structures for native host and remote target architectures.

- Create InProcess and External templates for stored pointers

Add a few more types to abstract pointer access in the runtime
structures but keep native in-process pointer access the same as that
with a plain old pointer type.

There is now a notion of a "stored pointer", which is just the raw value
of the pointer, and the actual pointer type, which is used for loads.
Decoupling these allows us to fork the behavior when looking at metadata
in an external process, but keep things the same for the in-process
case.

There are two basic "runtime targets" that you can use to work with
metadata:

InProcess: Defines the pointer to be trivially a T* and stored as a
uintptr_t. A Metadata * is exactly as it was before, but defined via
AbstractMetadata<InProcess>.

External: A template that requires a target to specify its pointer size.

ExternalPointer: An opaque pointer in another address space that can't
(and shouldn't) be indirected with operator* or operator->.  The memory
reader will fetch the data explicitly.
2016-03-02 21:25:04 -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
Harlan Haskins
b55d8d9c3c [Runtime] Add backtrace reporting on fatalError in debug builds 2016-01-29 13:42:06 -08:00
practicalswift
a3f857ca7b [gardening] Add "-*- C++ -*-" to header files currently missing it 2016-01-23 11:53:05 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Joe Groff
d3cba67344 Runtime: Move assert implementation details to stdlib.
Many of the report* entry points are specific to the stdlib assert implementation, so belong in the stdlib. Keep a single `reportError` entry point in the runtime to handle the CrashReporter/ASL interface, and call down to it from the assert implementation functions.
2015-12-22 15:54:42 -08:00
Joe Groff
69a206229d Runtime: Start splitting out stubs only needed by the standard library.
Set up a separate libSwiftStubs.a archive for C++ stub functionality that's needed by the standard library but not part of the core runtime interface. Seed it with the Stubs.cpp and LibcShims.cpp files, which consist only of stubs, though a few stubs are still strewn across the runtime code base.
2015-11-11 17:28:57 -08:00