Commit Graph

136 Commits

Author SHA1 Message Date
Thomas Roughton
c5bf2ec553 [runtime] Remove TwoWordPair and use the Swift calling convention instead. (#13299) 2017-12-07 19:27:24 -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
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
Glenna Buford
a452f9002a [SR-5814] removes dead code around REFLECT_OBJC_IVARS 2017-09-09 17:09:32 +02:00
Saleem Abdulrasool
21a27b05e6 stdlib: tweak printf specifier to be more portable
This just adjusts the printf specifier to use the standard defined
printf conversion specifier rather than assuming that %zd will convert
properly.  NFC.
2017-07-19 10:14:03 -07:00
Anna Zaks
36a07e9a6b Update swift_demangle and tests to use new symbol mangling. 2017-07-12 13:41:07 -07:00
Arnold Schwaighofer
ca63326e1b Delete unused existential value witnesses from the old existential
implementation

And remove the SWIFT_RUNTIME_ENABLE_COW_EXISTENTIALS flag.
2017-06-02 14:34:41 -07:00
John McCall
2c40b39f26 Move runtime functions for casting into their own header. 2017-04-17 17:16:13 -04:00
Erik Eckstein
1625345b90 Remove the old mangler.
NFC
2017-03-17 16:10:36 -07:00
Arnold Schwaighofer
d5cbb0bd62 Runtime changes for the copy-on-write existential implementation
Adds the runtime implementation for copy-on-write existentials. This support is
enabled if SWIFT_RUNTIME_ENABLE_COW_EXISTENTIALS is defined. Focus is on
correctness -- not performance yet.

Don't use allocate/deallocate/projectBuffer witnesses for globals in cow
existential mode.

Use SWIFT_RUNTIME_ENABLE_COW_EXISTENTIALS configuration to set the default for
SILOptions.

This includes an IRGen fix to use the right projection in
emitMetatypeOfOpaqueExistential if SWIFT_RUNTIME_ENABLE_COW_EXISTENTIALS is set.

Use unknownRetain instead of native retain in dynamicCastToExistential.
2017-03-15 14:54:55 -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
Hugh Bellamy
4d45092c34 Cleanup uses of __asm__ in the runtime 2017-03-08 17:32:44 +07:00
Hugh Bellamy
8d40749f6a Misc fixes to the runtime for MSVC compatability with it's public headers 2017-03-02 19:47:24 +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
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
f001b7562b Use relatively new LLVM_FALLLTHROUGH instead of our own SWIFT_FALLTHROUGH 2017-02-12 10:47:03 +07: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
05a50fd978 Remove extern "C" from uses of SWIFT_RUNTIME_STDLIB_INTERFACE 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
30a88d38e6 [gardening] Fix recently introduced typos 2017-01-06 21:16:02 +01:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Saleem Abdulrasool
75533d9dac Merge pull request #6385 from hughbe/runtime
Fix building the runtime from Windows
2016-12-21 10:02:22 -08:00
Joe Groff
2e0cb9c0a2 Runtime: getDynamicType can't drill into existentials when producing a concrete metatype.
For a value of an opaque generic type `<T> x: T`, the language currently defines `type(of: x)` and `T.self` as both producing a type `T.Type`, and the result of substituting an existential type by `T == P` gives `P.Protocol`, so the `type(of:)` operation on `x` can only give the concrete protocol metatype when `x` is an existential in this case. The optimizer understood this rule, but the runtime did not, causing SR-3304.
2016-12-19 11:03:52 -08:00
Hugh Bellamy
7b66b579b1 Add various unreachable annotations to the runtime 2016-12-19 15:54:50 +00:00
swift-ci
55bdf5954c Merge pull request #6285 from eeckstein/more-mangling 2016-12-14 17:21:43 -08:00
Greg Parker
8734f21bd9 [runtime] Improve thread-safety of swift_conformsToProtocol(). (#5719) 2016-12-14 16:54:25 -08:00
Erik Eckstein
c34c0e4bbc Mangling: Don’t hardcode the mangling prefixes in symbols selected by SELECT_MANGLING 2016-12-14 16:39:00 -08:00
Erik Eckstein
9f8b68ae11 Mangling: use macros instead of hard-coded swift symbol names.
This makes it easier to switch between the old and new mangling scheme.
2016-12-02 15:55:30 -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
Slava Pestov
7c1adfe31d Runtime: Use metadata accessor functions in Reflection.mm and make sure they're public
Correct behavior with resilience requires calling accessors instead
of using the metadata symbols directly.

For some reason this file gets linked in with SwiftRuntimeTests too,
so make the types @_versioned in the stdlib.

Fixes <rdar://problem/29213794>.
2016-11-14 16:25:23 -08:00
practicalswift
f44686d825 [gardening] Fix trailing whitespace in *.cfg.in, *.html, *.mm and *.sil files 2016-10-29 14:06:43 +02:00
Doug Gregor
fcacd089d6 [Mirrors] Use tuple labels when forming a mirror for a tuple type.
Fixes rdar://problem/22191852.
2016-09-21 09:00:22 -07:00
practicalswift
b19481f887 [gardening] Fix 67 recently introduced typos 2016-09-16 11:16:07 +02:00
Dmitri Gribenko
dfb4f56e55 runtime: rename _TMps8Hashable to HashableProtocolDescriptor 2016-08-31 09:53:39 -07:00
David Farler
f0609a612b Make a temporary existential when reflecting weak properties
When getting a mirror child that is a class existential, there
may be witness tables for the protocol composition to copy. Don't
just take the address of a class instance pointer from the stack -
make a temporary existential-like before calling into the Mirror
constructor.

This now correctly covers reflecting weak optional class types, and weak
optional class existential types, along with fixing a stack buffer
overflow reported by the Address Sanitizer (thanks, ASan!).

Tests were also updated to check for the validity of the child's data.

rdar://problem/27348445
2016-08-19 15:30:35 -07:00
David Farler
47d618cb5b Don't leak boxes when releasing Mirror owners
Heap boxes don't have a "class" metadata kind, so make
sure to release them when creating a new owner for loading
weak references in the runtime mirrors.

rdar://problem/27348445
2016-08-17 12:42:26 -07:00
David Farler
10c44e1a3a Always, no, never... forget to check your references
for weak semantics, that is!

94a9c512b9 made some changes to loading
weak references by adding some information in the lower bits with
respect to locking. These bits need to be masked out when performing a
load, such as when we want to get the metadata pointer for a class
instance. This normally works fine when going through the normal weak
loading functions in the runtime.

When the runtime function swift_ClassMirror_subscript gets the offset of
one of its stored properties, it immediately packages it into the the
ad-hoc existential container, known as just `Mirror` in the runtime.
However, the weak reference isn't aligned! It has bit 1 set.  We weren't
loading the weak reference here as we would during normal SILGen, such
as with a weak_load instruction. Simulate that here and make the
reference strong before putting it into the Mirror container, which also
clears those lower bits.

rdar://problem/27475034

There are still a couple of other cases to handle, namely the
unowned(safe) and unowned(unsafe) reference kinds. There may be other
places where an unaligned pointer is problematic in the runtime, which
we should audit for correctness.

rdar://problem/27809991
2016-08-16 11:43:58 -07:00
Dmitri Gribenko
561ac46679 stdlib: move a function from runtime to stubs
This function is not needed in the runtime.
2016-07-28 01:19:31 -07:00
Joe
3938d5682a [SE-0095] [Runtime], [Demangler], & AST printer updated to new composition syntax
- All parts of the compiler now use ‘P1 & P2’ syntax
- The demangler and AST printer wrap the composition in parens if it is
in a metatype lookup
- IRGen mangles compositions differently
    - “protocol<>” is now “swift.Any”
    - “protocol<_TP1P,_TP1Q>” is now “_TP1P&_TP1Q”
- Tests cases are updated and added to test the new syntax and mangling
2016-07-19 12:01:37 -07:00
Doug Gregor
823c24b355 [SE-0112] Rename ErrorProtocol to Error.
This is bullet (5) of the proposed solution in SE-0112, and the last
major piece to be implemented.
2016-07-12 10:53:52 -07:00
Dmitri Gribenko
ef557a11ff runtime: rename 'getReflectableConformance()' to 'unwrapExistential()' 2016-07-05 14:13:54 -07:00
Dmitri Gribenko
a4fb03f1eb runtime: simplify getReflectableConformance() 2016-07-05 14:13:23 -07:00
Dmitri Gribenko
acac328eaa stdlib: remove _Reflectable 2016-07-05 14:13:23 -07:00
Dmitri Gribenko
2526da3455 Merge pull request #3037 from compnerd/buffer-lengths
Use `sizeof` for buffer lengths in snprintf
2016-06-17 00:23:02 -07:00
Saleem Abdulrasool
6a91919509 runtime: add missing include
The use of `std::make_tuple` requires the declaration of the function which is
provided by the C++ standard header `tuple`.  This would get implicitly included
by one of the other C++ headers on the currently tested libraries, but does not
occur with the Microsoft C++ library.  Add the missing include.
2016-06-16 07:51:11 -07:00
Saleem Abdulrasool
c553628964 Use sizeof for buffer lengths in snprintf
Rather than duplicating the constant value, use the `sizeof` operator to have
the value propogate from the static buffer allocation.  Any standards conforming
implementation of `snprintf` will null-terminate the output unless the buffer is
NULL (a zero-sized buffer is passed to the call).  On Windows, where this is not
the case, the function is named `_snprintf` which ensures that we do not
accidentally end up with the incorrect behaviour.
2016-06-15 17:41:16 -07:00
Dmitri Gribenko
8ac074687d runtime: remove unused includes 2016-05-30 19:36:26 -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
Slava Pestov
ee0e44ae71 Runtime: Fix memory management snafu in swift_EnumCaseName()
I don't have a good way to test for leaking a box. Once I come up
with one, I will write a test for this patch as well as the earlier
patch "Runtime: Tweak Mirrors for resilience".

Fixes <rdar://problem/25797038>.
2016-04-21 17:58:10 -07:00