Commit Graph

23 Commits

Author SHA1 Message Date
Dmitri Gribenko
3085c4937f stdlib: add argument labels to _didEnterMain 2016-02-22 18:16:38 -08:00
Max Moiseev
f51e708a8f Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-04 12:25:25 -08:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Max Moiseev
2f7b64e475 Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-21 12:02:13 -08:00
practicalswift
cd7d8dfaff Fix alignment as requested by @gribozavr in #692 2015-12-21 08:54:24 +01:00
practicalswift
176f487d76 Fix incorrect filenames in headers. 2015-12-20 23:59:05 +01:00
Dmitri Gribenko
feacbc4433 Rename ErrorType to ErrorProtocol 2015-12-09 17:12:19 -08:00
John McCall
312a9c1f6e Clean up correctly if a variadic argument throws.
rdar://20942603

Swift SVN r28622
2015-05-15 08:20:36 +00:00
Joe Groff
7612df1918 Runtime: Rename 'becomeNSError' to 'bridgeErrorTypeToNSError'.
We may want to use optimized ErrorType representations that don't naturally "become" NSErrors, such as tagged-pointer representations of small error enums, or a tagged function pointer to a deferred error type constructor. Rename the runtime function to something a bit more descriptive of its real purpose, not its implementation.

Swift SVN r27209
2015-04-10 17:37:40 +00:00
Roman Levenstein
d1698ba1cb Use a _bridgeable suffix for newly introduced fast bridging functions. NFC.
Dave explained that stdlib usually uses the suffix notation in such cases. This change follows his advice.

Swift SVN r27177
2015-04-09 20:59:42 +00:00
Roman Levenstein
3effd6fcf7 Introduce two new compiler-known library functions for performing bridging casts when conformances are known statically.
We define two new library functions _knownForceBridgeFromObjectiveC/_knownConditionallyBridgeFromObjectiveC, similar to _forceBridgeFromObjectiveC/_conditionallyBridgeFromObjectiveC. The main difference is that they require their arguments to conform to _BridgedToObjectiveC and _BridgedToObjectiveC. _ObjectiveCType accordingly. With this change, it is now possible to invoke the _BridgedToObjectiveC._forceBridgeFromObjectiveC witness directly, without going via the inefficient swift_bridgeNonVerbatimFromObjectiveC.

So now, for a cast O -> S, if it can be statically proven that an ObjC type O is bridgeable to a Swift type S implementing the _BridgedToObjectiveC protocol (i.e. O is the class (or its subclass) defined by the S._ObjectiveCType alias), we can generate a code to invoke the newly defined library function _knownForceBridgeFromObjectiveC/_knownConditionallyBridgeFromObjectiveC instead of _forceBridgeFromObjectiveC/_conditionallyBridgeFromObjectiveC.

After inlining, this will end-up invoking  S._forceBridgeFromObjectiveC directly instead of invoking a more general, but less effective swift_bridgeNonVerbatimFromObjectiveC, which always performs conformance checks at runtime, even if conformances are known statically. As a result, no conformance checks are performed at run-time if conformances are known statically.

The client code making use of these new APIs and the tests are coming in the subsequent commits.

The naming of the two new helper library functions was discussed with Dmitri.

This is part of the bridging casts optimization effort. And it is specifically useful for e.g. rdar://19081345.

Swift SVN r27100
2015-04-07 22:53:55 +00:00
Joe Groff
66ae68bcc3 Sema: Allow ErrorType-conforming types to be explicitly coerced 'as NSError'.
Swift SVN r26993
2015-04-04 22:38:04 +00:00
Chris Lattner
9c7417edc2 fix <rdar://problem/19782264> Immutable, optional class members can't have their subproperties read from during init()
The problem here was that the _preconditionImplicitlyUnwrappedOptionalHasValue
compiler intrinsic was taking the optional/IUO argument as inout as a performance
optimization, but DI would reject it (in narrow cases, in inits) because the inout
argument looks like a mutation.  

We could rework this to take it as an @in argument or something, but it is better
to just define this problem away: the precondition doesn't actually care about the
optional, it is just testing its presence, which SILGen does all the time.  Have
SILGen open code the switch_enum and just have the stdlib provide a simpler
_diagnoseUnexpectedNilOptional() to produce the error message.

This avoids the problem completely and produces slightly better -O0 codegen.



Swift SVN r25254
2015-02-12 22:35:51 +00:00
David Farler
c453eb4c48 Add Set type.
<rdar://problem/14661754> TLF: [data-structure] Set<T> data type + Bridging from NSSet

Swift SVN r23262
2014-11-12 07:07:00 +00:00
Joe Groff
cac5807ae2 SILGen: Emit "main" as a SIL function.
Eliminate the intermediate top_level_code function. Now that SIL is expressive enough to express a "main" function, there's no reason for it, and this eliminates a bunch of mystery code in IRGen to thunk from main to top_level_code by reaching for hardcoded symbol names. Demystify the special code for setting up C_ARGC and C_ARGV by having SILGen look for a transparent "_didEnterMain" hook in the stdlib and emit a call to it.

Swift SVN r22525
2014-10-05 04:13:24 +00:00
Joe Groff
9eb4f5b512 SILGen: Use Array._allocateUninitialized to form array literals.
This avoids a pointless copy every time an array literal is written, and will let us retire the horrible "alloc_array" instruction and globs of broken IRGen code. Implements rdar://problem/16386862, and probably fixes a bunch of bugs related to alloc_array brokenness.

Swift SVN r22289
2014-09-25 22:26:20 +00:00
Doug Gregor
811d0021ab Use library entry points rather than witnesses for bridging an object to a value type.
This is essentially NFC, but the protocols we were calling into are
changing in a way that makes it hard to use the witnesses directly
from the type checker.

Swift SVN r20933
2014-08-02 01:03:40 +00:00
Dave Abrahams
6e7f83fe98 Internalize old array casting entry-points
The core compiler now uses just two entry points for array casting

Swift SVN r20725
2014-07-29 23:56:51 +00:00
Joe Groff
8500acd7ff SILGen: Implement StringToPointerExpr.
Lower it to a call to the _convertConstStringToUTF8PointerArgument helper.

Swift SVN r19374
2014-06-30 22:00:50 +00:00
Joe Groff
954f746b92 SILGen: Implement pointer-to-pointer conversions.
Perform pointer-to-pointer argument conversions with the help of the _convertPointerToPointerArgument stdlib helper function.

Swift SVN r19105
2014-06-23 23:22:02 +00:00
Doug Gregor
4019d28ba8 Start using the forced collection downcast entry points.
This means that we'll get deferred checking of array and dictionary
downcasts when writing "arr as Derived[]", 
"(dict as? Dictionary<DerivedKey, DerivedValue>)!", etc, when the
collection can do so.

This is both a general optimization and also staging for
<rdar://problem/17319154>.


Swift SVN r18975
2014-06-18 05:22:41 +00:00
Doug Gregor
7eb090ab3a Macro-metaprogram array and dictionary up/downcast declaration accessors. NFC
Swift SVN r18962
2014-06-17 22:41:46 +00:00