Commit Graph

102 Commits

Author SHA1 Message Date
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
Saleem Abdulrasool
81661fca61 stdlib: use the reserved attribute spellings
This is a purely mechanical change replacing the attributes with the reserved
spelling.  Compilers are to not error when they encounter a reserved spelling
for an attribute which they do not support.
2016-05-11 11:30:24 -07:00
rjmccall
9d2dfc0934 Merge pull request #1454 from glessard/weakref-threadsafety
[runtime] Thread safety for weak references
2016-05-04 11:03:46 -07: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
Guillaume Lessard
94a9c512b9 [runtime] thread safety for weak references
It has been fairly easy to cause the runtime to crash on multithreaded read-read access to weak references (e.g. https://bugs.swift.org/browse/SR-192). Although weak references are value types, they can get elevated to the heap in multiple ways, such as when captured by a closure or when used as a property in a class object instance. In such cases, race conditions involving weak references could cause the runtime to perform to multiple decrement operations of the unowned reference count for a single increment; this eventually causes early deallocation, leading to use-after-free, modify-after-free and double-free errors.

This commit changes the weak reference operations to use a spinlock rather than assuming thread-exclusive access, when appropriate.
With this change, the crasher discussed in SR-192 no longer encounters crashes due to modify-after-free or double-free errors.
2016-05-03 20:58:44 -06:00
practicalswift
fa40ad2f0c [gardening] "Objective C" → "Objective-C" 2016-04-09 12:22:18 +02:00
Greg Parker
41b12e7929 [runtime] Fix ObjC SwiftObject's header so it matches HeapObject.
rdar://25476641 and SR-1096.
2016-04-09 01:59:20 -07:00
Greg Parker
9a94aa5a82 [runtime] Remove a workaround in SwiftObject for an old clang bug.
Reverts the functionality of b50293b2, but leaves that commit's tests in place.
2016-04-09 01:51:58 -07:00
swiftix
fa0d270a69 Merge pull request #1909 from swiftix/wip-non-atomic-apis
Provide non-atomic versions of many reference counting operations.
2016-03-31 14:26:02 -07:00
Roman Levenstein
5d22a59e01 Provide non-atomic versions of many reference counting operations.
Provide the same guarantees regrading the barriers as the atomic versions.
2016-03-30 16:43:05 -07:00
Tom Birch
e2e3672786 [Runtime] Use OBJC_EXPORT for compatibility
objc uses OBJC_EXPORT when defining these symbols, the declarations should match
2016-03-30 13:30:32 -07:00
Shawn Erickson
3292124f87 [runtime] - switched most runtime code to use swift::Mutex and swift::Condition (see SR-946) 2016-03-20 22:56:48 -07:00
practicalswift
11dba6f361 [gardening] Fix recently introduced typo: "acccessing" → "accessing"
[gardening] Fix recently introduced typo: "definately" → "definitely"
2016-03-11 16:03:06 +01:00
Peter Cooper
7ec0e7348f Add more calls to the objc runtime for getting an object’s ISA.
Be more conservative in terms of masking ISAs.  This reduces tight coupling with the objc runtime.  This commit adds the required calls to IRGen and the runtime, and a test case to make sure IRGen is correct.
2016-03-10 15:07:20 -08:00
Max Moiseev
cf4bafe9e3 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-03 13:22:03 -08:00
Roman Levenstein
99fd8b6080 Rename some macros based on the PR review comments.
- use  the SWIFT prefix for all macros
- make names of some macros shorter
2016-02-25 05:31:00 -08:00
Roman Levenstein
de3b850ce8 Use more descriptive names for calling conventions.
Rename RuntimeCC into DefaultCC
Rename RuntimeCC1 into RegisterPreservingCC
Remove RuntimeCC0 because it was identical to DefaultCC.
2016-02-25 05:31:00 -08:00
Roman Levenstein
68b6181642 Annotate runtime functions using the newly introduced annotations from runtime/Config.h.
This makes sure that runtime functions use proper calling conventions, get the required visibility, etc.

We annotate the most popular runtime functions in terms of how often they are invoked from Swift code.
- Almost all variants of retain/release functions are annotated to use the new calling convention.
- Some popular non-reference counting functions like swift_getGenericMetadata or swift_dynamicCast are annotated as well.

The set of runtime functions annotated to use the new calling convention should exactly match the definitions in RuntimeFunctions.def!
2016-02-25 05:30:59 -08:00
Max Moiseev
78ba5d5f3f [stdlib] Requires in comments changed to Precondition 2016-02-19 18:57:26 -08:00
Joe Groff
ae0e855aaf Revert "Runtime: Remove retainCount entry points."
This reverts commit 51e0594e1c. The retainCount
entry points are used by Instruments.
2016-02-18 09:38:23 -08:00