Commit Graph

221 Commits

Author SHA1 Message Date
Greg Parker
415b36dddc [runtime] Clean up symbol exports in casting and class introspection. (#13005) 2017-12-01 17:48:48 -08:00
Greg Parker
78501448b1 [runtime] Remove _swift_getSuperclass(). (#12988)
There are too many superclass-lookup functions.
This one does not pull its own weight.
2017-11-17 02:57:58 -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
Joe Groff
95d251051b Runtime: Put ObjC class wrapper unwrapping behind a runtime call.
This is a small code size win, and also gives us some abstraction so that future cooperative ObjC compilers/runtimes might be able to interoperate ObjC class objects with Swift type metadata efficiently than they currently are in the fragile Swift runtime.

While I'm here, I also noticed that swift_getObjCClassMetadata was unnecessarily getting exposed in non-ObjC-interop runtime builds, so I fixed that as well.
2017-11-03 10:18:38 -07:00
Arnold Schwaighofer
3ae6d7cb4d runtime/IRGen: return the argument from swift_retain family of functions
On architectures where the calling convention uses the same argument register as
return register this allows the argument register to be live through the calls.

We use LLVM's 'returned' attribute on the parameter to facilitate this.

We used to perform this optimization via an optimization pass. This was ripped
out some time ago around commit 955e4ed652.
By using LLVM's 'returned' attribute on swift_*retain, we get the same
optimization from the LLVM backend.
2017-09-19 07:16:37 -07:00
Arnold Schwaighofer
90f51f2599 runtime: Also return the destination argument of the unknownWeak- and unknownUnownedInit/Assign functions
rdar://18172130
2017-09-15 11:28:27 -07:00
Greg Parker
0bae31c1f0 [runtime] Add some missing -isNSWhatever__ methods to SwiftObject. (#11891)
SR-5636, rdar://33764085
2017-09-13 03:01:37 -07:00
Greg Parker
dd38ace506 [runtime] Fix more const cast warnings. (#11725)
* [runtime] Fix more const cast warnings.
2017-09-05 13:13:01 -07:00
Greg Parker
f3bd55eb52 [runtime] Implement SwiftObject -methodForSelector: and +instanceMethodForSelector:.
Fixes SR-5577 and rdar://33606034.
2017-08-23 17:11:47 -07:00
Greg Parker
d5d5d8aa98 [stdlib] Don't call object_isClass(). (#11467)
object_isClass() is unavailable on Swift's oldest deployment targets.

rdar://33872748
2017-08-15 15:34:02 -07:00
Jordan Rose
1e38b4b624 Merge pull request #10893 from jrose-apple/are-you-having-issues
[stdlib] Surface NSKeyedArchiver issues in Xcode.
2017-07-13 12:53:01 -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
Greg Parker
79e33808f1 Fix swift_getObjectType() of class objects. 2017-07-12 20:37:20 -07:00
Greg Parker
fb1b8c9d75 Simply no-ObjC-interop case. 2017-07-12 20:37:20 -07:00
Greg Parker
05de18dc0a [runtime] swift_getObjectType() must ignore KVO's artificial subclasses.
Fixes SR-4363.
2017-07-12 20:37:20 -07:00
giginet
74eca0dd2f Fix warning on Xcode 9 beta2 2017-07-10 14:28:21 -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
Greg Parker
318f6c1ac5 [runtime] Add swift_unownedIsEqual and swift_unknownUnownedIsEqual.
It is safe to test pointer equality of an unowned variable, even if
the unowned variable refers to a dead object. Allowing this operation
without an unnecessary unowned abort enables some kinds of caching
schemes more cheaply than can be done with weak variables.

rdar://32142240
2017-06-01 13:53:19 -07:00
Michael Ilseman
90a86334dc Merge pull request #9734 from jckarter/implicit-objc-log-newline
Runtime: Add newline to implicit ObjC entrypoint log message.
2017-05-18 10:16:47 -07:00
Joe Groff
56a52ae9eb Runtime: Add newline to implicit ObjC entrypoint log message.
See if this clears up buffering issues in CI. rdar://problem/32272992
2017-05-18 10:08:49 -07:00
Joe Groff
80c6671c39 Runtime: Only complain about a deprecated ObjC entry point once.
We only need to alert the user once. rdar://problem/32229417
2017-05-17 12:05:53 -07:00
Joe Groff
c8a7a442ae Runtime: Include source location information in log messages about deprecated implicit Objective-C entry points.
Make it easier for migration by pinpointing exactly where to insert @objc to keep the entry points in Swift 4 mode. rdar://problem/32230003
2017-05-16 19:02:47 -07:00
Doug Gregor
571853dbbb [SE-0160] Emit runtime warnings by default.
Fixes rdar://problem/32229395.
2017-05-16 14:14:44 -07:00
John McCall
2c40b39f26 Move runtime functions for casting into their own header. 2017-04-17 17:16:13 -04:00
practicalswift
e0c7e7cfb4 [gardening] Fix indentation. 2017-04-03 09:07:20 +02:00
practicalswift
ca72b12287 [gardening] Remove accidental \t:s 2017-04-02 16:03:54 +02:00
Doug Gregor
5b3fe49cd0 [SE-0160] Log uses of @objc thunks emitted due to deprecated @objc inference.
Introduce a new runtime entry point,
`swift_objc_swift3ImplicitObjCEntrypoint`, which is called from any
Objective-C method that was generated due to `@objc` inference rules
that were removed by SE-0160. Aside from being a central place where
users can set a breakpoint to catch when this occurs, this operation
provides logging capabilities that can be enabled by setting the
environment variable SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT:

  SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT=0 (default): do not log
  SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT=1: log failed messages
  SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT=2: log failed messages with
  backtrace
  SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT=3: log failed messages with
  backtrace and abort the process.

The log messages look something like:

    ***Swift runtime: entrypoint -[t.MyClass foo] generated by
       implicit @objc inference is deprecated and will be removed in
       Swift 4
2017-03-31 21:22:16 -07:00
Erik Eckstein
5e80555c9b demangler: put the demangler into a separate library
Previously it was part of swiftBasic.

The demangler library does not depend on llvm (except some header-only utilities like StringRef). Putting it into its own library makes sure that no llvm stuff will be linked into clients which use the demangler library.

This change also contains other refactoring, like moving demangler code into different files. This makes it easier to remove the old demangler from the runtime library when we switch to the new symbol mangling.

Also in this commit: remove some unused API functions from the demangler Context.

fixes rdar://problem/30503344
2017-03-09 13:42:43 -08: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
Arnold Schwaighofer
39fa2f0228 Use the swift calling convention for swift functions
Use the generic type lowering algorithm described in
"docs/CallingConvention.rst#physical-lowering" to map from IRGen's explosion
type to the type expected by the ABI.

Change IRGen to use the swift calling convention (swiftcc) for native swift
functions.

Use the 'swiftself' attribute on self parameters and for closures contexts.

Use the 'swifterror' parameter for swift error parameters.

Change functions in the runtime that are called as native swift functions to use
the swift calling convention.

rdar://19978563
2017-02-14 12:17:57 -08:00
Hugh Bellamy
1d2aa8dcbd Cleanup uses of SWIFT_RUNTIME_EXPORT in implementation files (#7127) 2017-01-31 19:38:53 -08:00
Hugh Bellamy
d030ae4c94 Cleanup uses of SWIFT_RT_ENTRY_VISIBILITY (#7103) 2017-01-31 15:53:14 -08:00
Hugh Bellamy
a5a4880075 Remove extern "C" uses of SWIFT_RT_ENTRY_VISIBILITY 2017-01-22 18:32:17 +00:00
Hugh Bellamy
63cf2d561e Remove extern "C" from uses of SWIFT_RUNTIME_EXPORT 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
practicalswift
f44686d825 [gardening] Fix trailing whitespace in *.cfg.in, *.html, *.mm and *.sil files 2016-10-29 14:06:43 +02:00
John McCall
e958dd0663 Type metadata for a class isn't necessarily ClassMetadata; it could
be an ObjC class wrapper.

Fixes a longstanding bug that was exposed by my metadata cache improvements;
previously it was hidden due to a chain of coincidences around the
allocation of ObjCClassWrapper metadata.
2016-08-31 18:53:54 -07:00
Greg Parker
b3566eace5 Fix shadow warnings of a local variable versus an instance variable. 2016-08-29 17:01:28 -07:00
Roman Levenstein
880be3be4f Remove unsafeAddress(of:)
rdar://problem/18589289
2016-07-26 19:57:26 -07:00
Luke Larson
74e0498015 Revert "Update master to build with Xcode 8 beta 3, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs."
This reverts commit 62d1fa760c.
2016-07-19 15:18:17 -07:00
Mishal Shah
62d1fa760c Update master to build with Xcode 8 beta 3, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs. 2016-07-19 22:31:34 +02:00
Joe Groff
9cba38537e Runtime: Forward SwiftValue -description and -debugDescription to the boxed value.
Following the example of SwiftObject, use swift_getSummary to get the description string for a Swift value as the description of a boxed SwiftValue.
2016-07-18 12:21:54 -07:00
Joe Groff
bc8433f186 Runtime: Implement an opaque 'SwiftValue' ObjC class to hold bridged values.
If there's no better mapping for a Swift value into an Objective-C object for bridging purposes, we can fall back to boxing the value in a class. This class doesn't have any public interface beyond being `NSObject`-conforming in Objective-C, but is recognized by the Swift runtime so that it can be dynamically cast back to the boxed type.
2016-07-15 15:56:25 -07:00
Han Sangjin
e6ecc9a3ec Modified for some reviews 2016-06-10 06:26:47 +09:00
Han Sangjin
198441bee9 stdlib/msvc: Runtime with MSVC library
This patch is for libswiftCore.lib, linking with the library set of Visual Studio 2015. Clang with the option -fms-extension is used to build.
2016-06-04 05:16:41 +09:00
Bryan Chan
85fde8b1fb Add support for Linux s390x. LLVM's Swift calling convention support is used to ensure correct operations of C++ code in the runtime. This patch also includes some (incomplete) changes to enum handling to make enums work in most common cases. 2016-05-24 20:03:28 -04:00