Commit Graph

311 Commits

Author SHA1 Message Date
Pavel Yaskevich
72bf180d0f Revert "[IRGen] Fix function metadata endpoints to use separate parameter/flags arguments"
This reverts commit 728d2a4c2f.
2017-11-07 00:24:22 -08:00
Pavel Yaskevich
4f354a7f09 Revert "[ABI/Runtime] NFC: Rename function metadata arguments to parameters"
This reverts commit 801b35e28c.
2017-11-07 00:24:20 -08:00
Pavel Yaskevich
e23a6f1359 Merge pull request #12500 from xedin/fn-metadata-changes
[IRGen] Improvements to function type metadata
2017-11-06 19:50:19 -08:00
Pavel Yaskevich
801b35e28c [ABI/Runtime] NFC: Rename function metadata arguments to parameters 2017-11-06 11:16:46 -08:00
Pavel Yaskevich
728d2a4c2f [IRGen] Fix function metadata endpoints to use separate parameter/flags arguments
Switch most general endpoint to be `flags, parameters, parameterFlags, result`,
instead of opaque `void **`, more specialized ones to use follow argument scheme:
`flags, param0, [flags0], ..., paramN, [flagsN], result` and store parameter/flags
information separately in `FunctionCacheEntry::{Key, Data}` as well.
2017-11-06 11:16:46 -08:00
Pavel Yaskevich
b33a6c7cdf [IRGen] Add parameter flags to function type metadata
Currently only single 'inout' flag has been encoded into function
metadata, these changes extend function metadata to support up to
32 flags per parameter.
2017-11-06 11:16:46 -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
Jacopo Andrea Giola
bcb9571079 Add fix in Casting.cpp for SR-6032 (#12298)
Private classes doesn't add extra stuff when passed to String(describing:)
2017-10-09 14:06:34 -07:00
Saleem Abdulrasool
086c12114d IRGen: switch to absolute pointers for nominal type descriptors
Alter the value metadata layout to use an absolute pointer for the
nominal type descriptor rather than a relative offset relative to the
complete type metadata.  Although this is slightly less efficient in
terms of load times, this is more portable across different
environments.  For example, PE/COFF does not provide a cross-section
relative offset relocation.  Other platform ports are unable to provide
a 64-bit relative offset encoding.

Given that the value witness table reference in the value metadata is
currently an absolute pointer, this page is most likely going to be
dirtied by the loader.
2017-10-03 14:45:45 -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
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
Slava Pestov
b5721e8d8e AST: Remove AnyObject protocol 2017-05-02 19:45:00 -07:00
Slava Pestov
1615915780 Runtime: Dynamic casts to subclass existentials 2017-04-27 20:46:36 -07:00
John McCall
7a4c761426 Merge pull request #8821 from rjmccall/dynamic-enforcement-vol-1
Basic dynamic enforcement of exclusivity
2017-04-18 13:57:54 -04:00
practicalswift
7eb7d5b109 [gardening] Fix 100 typos. 2017-04-18 17:01:42 +02:00
John McCall
2c40b39f26 Move runtime functions for casting into their own header. 2017-04-17 17:16:13 -04:00
Greg Parker
cfee4d9c5e [runtime] Fix some casts of _SwiftValue (#8457)
* [runtime] Fix some casts of _SwiftValue.

* Allow _SwiftValue to be cast to NSObject by yielding the box object itself.
* Failed casts from NSDictionary containing _SwiftValue should not crash.

SR-4306, rdar://31197066
2017-04-10 14:31:35 -07:00
Arnold Schwaighofer
709226258c Runtime: Allow taking out of inline opaque existentials
Only values stored in the outline boxed existential representation can be
shared.
2017-03-21 11:37:23 -07:00
Erik Eckstein
1625345b90 Remove the old mangler.
NFC
2017-03-17 16:10:36 -07:00
Arnold Schwaighofer
586527759d Change assert(false) to swift::fatalError 2017-03-15 16:01:02 -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
Hugh Bellamy
b3020d89d2 Merge pull request #7868 from hughbe/asm-uneeded
Remove unecessary empty asm statement
2017-03-14 00:13:03 +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
f7bac5dc6d Remove unecessary empty asm statement 2017-03-03 09:48:12 +07:00
Erik Eckstein
7d7dc5aaac Demangler: Use a bump-pointer allocator for node allocation.
This makes the demangler about 10 times faster.
It also changes the lifetimes of nodes. Previously nodes were reference-counted.
Now the returned demangle  node-tree is owned by the Demangler class and it’s lifetime ends with the lifetime of the Demangler.

Therefore the old (and already deprecated) global functions demangleSymbolAsNode and demangleTypeAsNode are no longer available.

Another change is that the demangling for reflection now only supports the new mangling (which should be no problem because
we are generating only new mangled names for reflection).
2017-02-24 19:04:13 -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
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
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
practicalswift
38be6125e5 [gardening] C++ gardening: Terminate namespaces, fix argument names, ...
Changes:
* Terminate all namespaces with the correct closing comment.
* Make sure argument names in comments match the corresponding parameter name.
* Remove redundant get() calls on smart pointers.
* Prefer using "override" or "final" instead of "virtual". Remove "virtual" where appropriate.
2016-12-17 00:32:42 +01: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
Saleem Abdulrasool
5217db0d73 runtime: clean up unused variable warning
classType is unused without ObjC interop.  Simplify the code a bit by increasing
the scope covered by the SWIFT_OBJC_INTEROP.  It also silences the warning.
2016-12-11 21:42:23 -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
4e4d281aa7 stdlib: Rework swift_typeName() to use _swift_buildDemanglingForMetadata()
Previously we had two separate mechanisms to turn a metatype
into a string. The swift_typeName() function was used to print
the metatype in a human-readable fashion, whereas the
_swift_buildDemanglingForMetadata() was used when naming
generated generic Objective-C classes.

Unify them, since what swift_typeName() does is redundant;
instead of going directly from the metatype to a human-readable
string, we can get the mangling, and print that using the
demangler.

This fixes some issues with unnecessary parenthesis when
printing function types, and also allows Objective-C classes
to be instantiated with nested generic types as parameters.
2016-11-18 00:39:14 -08:00
Joe Groff
2b4cba8499 Runtime: Call Set/Dictionary casting hooks in the stdlib with the correct calling convention.
We neglected to pass down the Hashable witness table parameters, leading to Heisenbugs because we would call into invalid witness pointers occasionally when loading the Hashable conformance from corrupted metadata. Fixes rdar://problem/28022201.
2016-10-12 12:16:40 -07:00
Doug Gregor
2942b850ad Merge pull request #4898 from DougGregor/tuple-casting
Runtime/standard library: fix tuple printing, reflection, and casting
2016-09-21 10:09:03 -07:00
Doug Gregor
c9ebcc592e [Runtime] Generalize dynamic casting between tuple types.
This allows dynamic casting to succeed between tuple types with
different element types, converting each element in turn. Fixes
rdar://problem/19892202.
2016-09-21 09:00:23 -07:00
swift-ci
81ee414f7a Merge pull request #4894 from DougGregor/tuple-casting 2016-09-20 21:04:34 -07:00
Doug Gregor
87908c8a1b [Runtime] Handle tuple/tuple dynamic casts that add/remove labels.
Introduce narrow support for tuple/tuple dynamic casts that merely add
or remove labels, but require the element types to match exactly. This
gets us back to allowing the same correct dynamic casts as in Swift
3.0, when labels were completely ignored.
2016-09-20 17:05:07 -07:00
Doug Gregor
1a8189814a [Runtime] Include tuple labels when printing the runtime name of a type.
When we started recording labels within the metadata for a tuple type,
we failed to print those labels when rendering the type name from
metadata.
2016-09-20 13:47:34 -07:00