Commit Graph

9268 Commits

Author SHA1 Message Date
Max Moiseev
885b564bf5 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-09 17:16:37 -08:00
Xi Ge
9a91075509 Serialization: Add an error when group information for a specific source file is not found. 2016-03-09 17:09:34 -08:00
Max Moiseev
02006f20bc Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-09 16:05:03 -08:00
Joe Groff
77dd9b2992 Split exact-subclass and bindable-to-subclass queries.
In many places, we're interested in whether a type with archetypes *might be* a superclass of another type with the right bindings, particularly in the optimizer. Provide a separate Type::isBindableToSuperclassOf method that performs this check. Use it in the devirtualizer to fix rdar://problem/24993618. Using it might unblock other places where the optimizer is conservative, but we can fix those separately.
2016-03-09 11:14:45 -08:00
Argyrios Kyrtzidis
345d05e2e9 Introduce an internal attribute '@_show_in_interface' to be used in stdlib for underscored protocols that
should be shown in the interface.

Also switch the option and hide all underscored protocols by default, unless they are marked with the new attribute.
2016-03-08 23:30:58 -08:00
Xin Tong
8eedb43c4c Implement partially dead argument elimination.
This change includes an option on how IsLive is defined/computed. the ProjectionTree
can now choose to ignore epilogue releases and mark a node as dead if its only non-debug
user is epilogue release.

It can also mark a node as alive even its only user is epilogue release as before.

Imagine a case where one passes in an array and not access its owner
besides to release it. In such a case, we *do* want to be able to eliminate
that argument even though there is a release in the function epilogue.

This will help to get rid of the retain and release pair at the callsite. i.e.
the guaranteed paramter is elimininated.

rdar://21114206
2016-03-08 23:12:38 -05:00
Arnold Schwaighofer
3676671b7f Merge pull request #1587 from aschwaighofer/stack_promote_with_unsafe_mutable_buffer_pointer
Mark Array.withUnsafeMutableBuffer as not escaping the array storage.
2016-03-08 19:39:28 -08:00
Arnold Schwaighofer
b5f018a4b1 Mark Array.withUnsafeMutableBuffer as not escaping the array storage.
This is safe because the closure is not allowed to capture the array according
to the documentation of 'withUnsafeMutableBuffer' and the current implementation
makes sure that any such capture would observe an empty array by swapping self
with an empty array.

Users will get "almost guaranteed" stack promotion for small arrays by writing
something like:

  func testStackAllocation(p: Proto) {
    var a = [p, p, p]
    a.withUnsafeMutableBufferPointer {
      let array = $0
      work(array)
    }
  }

It is "almost guaranteed" because we need to statically be able to tell the size
required for the array (no unspecialized generics) and the total buffer size
must not exceed 1K.
2016-03-08 19:37:47 -08:00
Xi Ge
ce12c6dc95 ModulePrinting: Add an option to synthesize unconditional extensions; true by default. 2016-03-08 18:34:38 -08:00
Ben Langmuir
bac7521af7 [SourceKit] Fix crash with cursor info on generic typealias
For now, just skip mangling the name since we know the decl context will
crash the mangler.
2016-03-08 18:03:42 -08:00
Doug Gregor
3fb06d7442 [Swift runtime] Deallocation of partial class instances for Objective-C-derived classes.
Teach swift_deallocPartialClassInstance how to deal with classes that
have pure Objective-C classes in their hierarchy. In such cases, we
need to make sure a few things happen:

1) We deallocate via objc_release rather than
swift_deallocClassInstance.
2) We only attempt to find an execute ivar destroyers for
Swift-defined classes in the hierarchy
3) When we hit the most-derived pure Objective-C class, make sure that we
only execute the dealloc of that class and not any of the subclasses
(which would end up trying to destroy ivars again).

Fixes rdar://problem/25023544.
2016-03-08 16:47:57 -08:00
Michael Gottesman
ef6ff01fd8 Use perfect forwarding on the Predicate passed into none_of/count_if.
This ensures that if one wishes to pass an std::moved, std::function into the
functions, one can do that.
2016-03-08 15:07:27 -08:00
Michael Gottesman
bb15808554 Convert some trivial std::count_if invocations on ranges to use the provided range adaptor. 2016-03-08 14:58:13 -08:00
Michael Gottesman
5f72810ad3 Add a range adaptor for std::count and update various trivial usages in the compiler to use this API instead. 2016-03-08 14:58:13 -08:00
Michael Gottesman
0612d886e9 Add a "hasEmptyIntersection" method to ImmutablePointerSet.
We do this by doing a traversal of our sorted lists in a similar manner as one
would when one is merging two such sets, i.e. one has two iterators and always
advances the iterator that has a value that is less than the other. If we ever
hit a situation where the two iterators equal, we must have a non-empty
intersection.

A unittest that exercises very basic functionality is provided as well.
2016-03-08 14:05:10 -08:00
Michael Gottesman
6f64082bc5 Clean up count_if/none in STLExtras.
Specifically this change:

1. Changed the input collection to be a const T & instead of T.
2. The return type of count_if is now properly the difference_type of the input range's iterators.
2016-03-08 14:00:24 -08:00
Max Moiseev
1fae0d1325 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-08 12:48:48 -08:00
Xi Ge
c84f667676 [Serialization] Serialize the source order of Decls appearing in their original source file.
We used to think the source order is preserved after de-serialization; however, this seems to be
not the case.
2016-03-08 12:18:10 -08:00
Xi Ge
7a3276738b Re-apply "ModulePrinter: Print decls from the same source file near each other."
This reverts commit 1db83907e3.
2016-03-08 12:18:10 -08:00
practicalswift
7bc51357be [gardening] Fix recently introduced typo: "metadat" → "metadata" 2016-03-08 18:59:53 +01:00
practicalswift
bf8347457a Merge pull request #1572 from practicalswift/remove-unused-diagnostic-typealias_generic_list_where
[gardening] Remove unused diagnostic: typealias_generic_list_where
2016-03-08 11:26:03 +01:00
practicalswift
37bf58399a [gardening] Fix formatting of two recently introduced file headers 2016-03-08 11:23:45 +01:00
practicalswift
daa03f1fd2 [gardening] Remove unused diagnostic: typealias_generic_list_where 2016-03-08 11:20:15 +01:00
Xi Ge
1db83907e3 Revert "ModulePrinter: Print decls from the same source file near each other."
This reverts commit a5c9072344 for mysterious bot test failure.
2016-03-07 23:33:23 -08:00
Xi Ge
a5c9072344 ModulePrinter: Print decls from the same source file near each other. 2016-03-07 22:51:50 -08:00
Chris Lattner
fe9fe47b7e Implement support for generic typealiases. 2016-03-07 22:20:16 -08:00
Xin Tong
2fe08d9cda Move LSBase.cpp to lib/SILOptimzer/Utils/ 2016-03-07 22:04:15 -05:00
Xin Tong
cf7614eeb6 Remove a small whitespace. NFC
I do not know how it got into there.

Thanks @gottesmm  for catching this.
2016-03-07 21:59:54 -05:00
Ben Langmuir
3866e74604 [IDE] Fix some 80-column violations in Utils.h NFC 2016-03-07 18:56:25 -08:00
David Farler
80d3e7e189 [TypeRef] Look up generic substitutions with index and depth
A little bit of trivial future-proofing looking forward to nested
generics.
2016-03-07 18:53:19 -08:00
David Farler
6d32c02c74 [ReflectionContext] Remove some now dead code re: dependent members
This is done as a part of TypeRefSubstitution now.
2016-03-07 18:53:19 -08:00
Xin Tong
56a09b67da Update some comments and delete abit dead code. NFC 2016-03-07 21:26:57 -05:00
Xin Tong
ba0249c924 Rename SILValueProjection.x to LSBase.x. NFC 2016-03-07 21:26:56 -05:00
Xin Tong
c37cb78780 Rename SILValueProjection to LSBase. NFC. 2016-03-07 21:26:56 -05:00
Xin Tong
55377e727a Move createExtract to ProjectionPath::createExtract. NFC. 2016-03-07 21:26:56 -05:00
Xin Tong
bfc258f628 Simplify LSValue::reduce for redundant load elimination
LSValue::reduce reduces a set of LSValues (mapped to a set of LSLocations) to
a single LSValue.

It can then be used as the forwarding value for the location.

Previously, we expand into intermediate nodes and leaf nodes and then go bottom
up, trying to create a single LSValue out of the given LSValues.

Instead, we now use a recursion to go top down. This simplifies the code. And this
is fine as we do not expect to run into type tree that are too deep.

Existing test cases ensure correctness.
2016-03-07 21:26:56 -05:00
David Farler
834b03b6cd [Reflection] Substitute generics and resolve dependent members
Once an unsubstituted typeref for a field is built, we substitute
`GenericTypeParameterTypeRef`s with concrete ones built from the generic
arguments of concrete bound generic metadata.

During that process, if we run into a `DependentMemberTypeRef` (e.g.
something of type T.Index), we substitute the base (T) using the current
list of substitutions, and then resolve what `Index` is for the base
using the associated type metadata in the 'assocty' data section.
2016-03-07 17:43:13 -08:00
David Farler
7fd8c79ec5 [ReflectionContext] Cache results of reading metadata and nominal type descriptors
These are the two main round-trips to the external target.
2016-03-07 17:43:13 -08:00
David Farler
759cd23a86 Use int32_t for external relative direct pointers 2016-03-07 17:43:13 -08:00
David Farler
db1a715ef1 Fix off-by-one allocation for reading remote strings 2016-03-07 17:43:12 -08:00
David Farler
96386b03be Don't use interface type as field descriptor key
Nominal type descriptors use declared types for their mangled names,
so we need to use them when scanning the fieldmd section for a
matching record. This is fine because the descriptor can tell us
about the type's generics. Individual field records continue to use
the interface type.
2016-03-07 17:43:12 -08:00
David Farler
0aba14430c Move PrintTypeRef and TypeRefSubstitution into the cpp - NFC 2016-03-07 17:43:12 -08:00
David Farler
6f0a399e5c Use offsetof to calculate offset to Descriptor offset 2016-03-07 17:43:12 -08:00
David Farler
ff75058188 Gardening: indentation 2016-03-07 17:43:12 -08:00
David Farler
a9404f910b Directly pass 'free' as custom deleter for SharedTargetNominalTypeDescriptorRef 2016-03-07 17:43:11 -08:00
David Farler
ea352103f8 Check result of getting function result typeref
Bail if it can't be constructed.
2016-03-07 17:43:11 -08:00
Slava Pestov
7d55d5a0be SILGen: Factor out TypeConverter::getMaterializeForSetCallbackType(), NFC
I'm planning on changing materializeForSet to return the callback
as a RawPointer, and casting it to the correct polymorphic SILFunctionType
type at the call site.

This will allow us to call it with the right generic signature, which
is currently not possible since it is returned as an optional of an
AST function type, and optionals of SIL function types are not permitted.
2016-03-07 17:05:44 -08:00
Ben Langmuir
e752de0d20 [SourceKit] Print and annotate the raw value expression of enum elements
For now, only do this in SourceKit (printQuickHelpDeclaration), but
there are probably other printing modes that should do this.

rdar://problem/24292226
2016-03-07 12:36:47 -08:00
Max Moiseev
7fe6916bf6 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-07 12:10:47 -08:00
Ben Langmuir
3d424b5e96 [SourceKit] Annotate tuple types and nested function types
Move the type callbacks into the respective type/typerepr printers so
taht we get these callbacks even when we print the type directly, or in
a nested fashion.  Also make the returntype more explicit than just
"inside a function type", since visiting the function type currently
visits the input argument tuple (which is different than e.g. the
function *decl* printing, which walks the parameter list explicitly).

rdar://problem/24292226
2016-03-07 10:13:01 -08:00