Commit Graph

7762 Commits

Author SHA1 Message Date
Andrew Trick
c4f141a121 Reapply "Add test cases for isUnique sanity checks."
Handle linux.

Swift SVN r30357
2015-07-18 02:36:57 +00:00
Dmitri Hrybenko
4f6bedfc51 stdlib: mark some _HeapBuffer APIs public/@testable so that they can be used in tests
Should fix the broken buildbots.

Swift SVN r30354
2015-07-18 01:53:02 +00:00
Joe Groff
6608221a72 stdlib: Remove _UnitTestArray.
rdar://problem/20246497

Swift SVN r30348
2015-07-18 00:14:28 +00:00
Doug Gregor
89ff140503 Move the default implementation of ErrorType._domain into the standard library.
There is no reason for the compiler to be synthesizing a body of
_domain when it can be implemented in a protocol extension. As part of
this, fix a recent regression in the computed domain: it was using
string interpolation, which means that the recent changes not to print
qualified names affected the domain of the generated NSErrors. Oops.

Swift SVN r30343
2015-07-17 23:37:59 +00:00
Andrew Trick
6672ea0dbc Revert "Add test cases for isUnique sanity checks."
This reverts commit r30339.

Temporarilly remove these tests because I forgot to handle linux and
may end up reorganizing the tests.

Swift SVN r30340
2015-07-17 23:37:15 +00:00
Andrew Trick
59909cbd5a Add test cases for isUnique sanity checks.
Swift SVN r30339
2015-07-17 23:22:06 +00:00
Roman Levenstein
8624834b9e Clean-up of the stdlib file forcing pre-specializations.
- Remove public symbols.
- Only one top-level element called _Prespecialize.
- Simpler code.

Swift SVN r30333
2015-07-17 21:20:05 +00:00
Dmitri Hrybenko
4e1efd5e11 stdlib: move the implemnentation comment for AnyObject out of the doc comment
Swift SVN r30324
2015-07-17 20:25:31 +00:00
Argyrios Kyrtzidis
310d92ecc1 [stdlib] Add RawOptionSetType as unavailable with a 'renamed' fixit to OptionSetType.
rdar://21800523

Swift SVN r30313
2015-07-17 07:16:10 +00:00
Andrew Trick
e024f7fe41 Add sanity checks to the _isUnique_native API.
This is a low-level API that bypasses the usual type checks. To avoid
misuse, we add a dynamic type check that kicks in when stdlib asserts
are enabled.

Swift SVN r30311
2015-07-17 06:52:09 +00:00
Roman Levenstein
19a3821a56 Implementation of the pre-specialization for the most popular stdlib generic types.
This patch implements the pre-specialization for the most popular generic types from the standard library. If there are invocations of generic functions from the standard library in the user-code and the compiler can find the specialized, optimized versions of these functions, then calls of generic functions are simply replaced by the calls of the specialized functions.

This feature is supposed to be used with -Onone to produce much faster (e.g. 5x-10x faster) executables in debug builds without impacting the compile time. In fact, the compile-time is even improved, because IRGen has less work to do. The feature can be considered a light-weight version of the -Odebug, because pre-specialization is limited in scope, but does not have a potentially negative compile-time impact compared to -Odebug. It is planned to enable it by default in the future.

This feature is disabled by default for the time being. It can be enabled by using a hidden flag: -Xllvm -use-prespecialized.

The implementation consists of two logical steps:
- When the standard library is being built, we force a creation of specializations for the most popular generic types from the stdlib, e.g. Arrays of integer and floating point types, Range<Int>, etc. The list of specializations is not fixed and can be easily altered by editing the Prespecialized.swift file, which is responsible for forcing the specialization of generic types (this is simple solution for now, until we have a proper annotation to indicate which specializations of a given generic type or function we want to generate by means of the pre-specialization). These specializations are then optimized and preserved in the stdlib dylib and in the Swift SIL module. The size increase of the stdlib due to creation of pre-specializations is currently about 3%-7%.

- When a user-code is being compiled with -Onone, the compiler would run a generic specializer over the user-code. If there are calls of generic functions from the standard library, the specializer would check if there is an existing specialization matching these invocations. If such a specialization is found, the original call is replaced by the call of this more efficient specialized version.

Swift SVN r30309
2015-07-17 06:52:07 +00:00
Dmitri Hrybenko
85262ffeae stdlib: restore the doc comment on AnyObject
rdar://21496254

Swift SVN r30298
2015-07-17 03:11:09 +00:00
Dave Abrahams
6d3119e2a3 strip _prext_ from inside doc comments
Swift SVN r30279
2015-07-16 22:55:28 +00:00
David Farler
241de1a1c3 Add popFirst/popLast implementations for some collections
Add the following non-customizable implementations:

- popFirst/popLast for Collections whose SubSequence == Self.
- Array.popLast
- ContiguousArray.popLast
- Set.popFirst
- Dictionary.popFirst

Swift SVN r30278
2015-07-16 22:52:05 +00:00
Dave Abrahams
205ba195d5 [stdlib] Revamp doc comments for new LazySequence
Swift SVN r30277
2015-07-16 22:41:14 +00:00
Dmitri Hrybenko
e5e4335fad stdlib: Slice: trap on out-of-bounds indices
rdar://21822657

Swift SVN r30269
2015-07-16 18:22:40 +00:00
Arnold Schwaighofer
c772380f2c stdlib: Rename IsOrderedBefore to EscapingBinaryPredicate
Swift SVN r30267
2015-07-16 16:35:45 +00:00
Arnold Schwaighofer
4c2dd3ee97 Remove redundant typealias
Swift SVN r30263
2015-07-16 14:20:36 +00:00
David Farler
6099e156eb Add RangeReplaceableCollectionType.removeFirst
Add requirements and default implementations for removeFirst() and
removeFirst(n: Int).

rdar://problem/21844880

Swift SVN r30256
2015-07-16 07:47:06 +00:00
David Farler
f1c5e503a9 Doc review: tweak SequenceType.forEach's doc comment
No functional change.

Swift SVN r30250
2015-07-16 04:28:43 +00:00
David Farler
86f1a7088b Review: Rename SequenceType.forEach parameter to 'body'
No functional change.

Swift SVN r30249
2015-07-16 04:07:17 +00:00
Dave Abrahams
9963996fee [stdlib] Move lazy filter prototype into stdlib
(still underscored pending review).

Swift SVN r30248
2015-07-16 03:50:46 +00:00
David Farler
8f78e7ab16 Make ExtensibleCollectionType diagnostic use "renamed" for better fixit
rdar://problem/21710469

Swift SVN r30242
2015-07-16 00:01:02 +00:00
David Farler
91b89b8956 Add SequenceType.forEach requirement and default implementation
rdar://problem/21663830

Swift SVN r30236
2015-07-15 23:36:23 +00:00
Arnold Schwaighofer
27f792f308 Re-@noescape the isOrderedBefore closure argument to sort
The blocking optimization was added.

rdar://21024092

Swift SVN r30227
2015-07-15 21:44:45 +00:00
Dave Abrahams
198bf8072c [stdlib] Put "Lazy" in the names of new lazy things
Once you buy into the lazy system with a.lazy... you should see it in
the type.

Swift SVN r30216
2015-07-15 06:16:45 +00:00
Dave Abrahams
91f17ec375 [stdlib] ReverseCollection isn't implicitly lazy
You have to ask for it explicitly at some point in the chain.

Swift SVN r30213
2015-07-15 05:45:47 +00:00
Dmitri Hrybenko
e96251b0c4 stdlib: document complexity requirements for some CollectionType APIs
rdar://20167702

Swift SVN r30209
2015-07-15 01:59:47 +00:00
Andrew Trick
77ff5b7e57 Convert the new ArrayBuffer assert to _sanityCheck. We don't need it at -Onone.
Swift SVN r30185
2015-07-14 06:14:12 +00:00
Andrew Trick
6d03fe0a73 Add an assert to ArrayBuffer.getElementSlowPath.
The implementation is making a strong assumption about the array
element type (single-reference layout), but it is extremely
non-obvious that this helper is only called for those element types.

Swift SVN r30183
2015-07-14 05:09:46 +00:00
Joe Groff
db0fea590e stdlib: Use unqualified names in 'print'.
Leave the qualification off of enum cases and type names when 'print'-ing them, but keep them on 'debugPrint'. (At least, at the outermost level; since ad-hoc printing of structs and tuples uses debugPrint, we'll still get qualification at depth, which kind of sucks but needs more invasive state management in print to make possible.) Implements rdar://problem/21788604.

Swift SVN r30166
2015-07-13 21:42:11 +00:00
Joe Pamer
0e35bad9dc Revert "[stdlib] Remove workarounds for fixed bug"
This reverts commit r30148, since it regresses the following tests:

   Swift :: ClangModules/script.swift
   Swift :: Interpreter/currying_protocols.swift
   Swift :: Interpreter/if_expr.swift
   Swift :: Interpreter/protocol_extensions.swift
   Swift :: Interpreter/weak.swift
   Swift :: Interpreter/weak_objc.swift
   Swift :: PlaygroundTransform/array_did_set.swift
   Swift :: PlaygroundTransform/print.swift

Swift SVN r30159
2015-07-13 19:48:08 +00:00
Dave Abrahams
c0399e240f [stdlib] Remove workarounds for fixed bug
Also fixes rdar://21582758

Swift SVN r30148
2015-07-13 16:52:57 +00:00
Dave Abrahams
88aaed0a0c [stdlib] Move most of the lazy prototype into the stdlib
Swift SVN r30144
2015-07-13 15:36:17 +00:00
Dmitri Hrybenko
7ae303aeb3 Update Unicode data files to 8.0.0
rdar://19582621

Swift SVN r30141
2015-07-13 08:00:39 +00:00
Dmitri Hrybenko
b4ec45d625 stdlib: make Slice.init(base:bounds:) public
Swift SVN r30113
2015-07-11 05:58:06 +00:00
Dmitri Hrybenko
be5ef02bd0 Revert "stdlib: make Slice.init(base:bounds:) public"
This reverts commit 30111.  It broke the buildbots.

Swift SVN r30112
2015-07-11 05:34:05 +00:00
Dmitri Hrybenko
26ebe14178 stdlib: make Slice.init(base:bounds:) public
Swift SVN r30111
2015-07-11 05:20:41 +00:00
Dave Abrahams
9d07acd368 [stdlib] SequenceType's _initializeTo should return the end position
Otherwise, the length of the sequence is in principle lost.  If you know
you have a sequence of less than 100 elements, you still want to know
exactly how many elements you initialized from it.

Swift SVN r30104
2015-07-11 01:43:27 +00:00
Doug Gregor
29764dc34d Remove the ability to access the "0" member of a scalar.
This is a travesty that makes it hard to reason about tuple vs. scalar
types. It's only use in our own code involved dealing with the
difference in element types between Set and Dictionary in
gyb-generated code. Ewww. Fixes rdar://problem/17963034.

Swift SVN r30074
2015-07-10 17:28:53 +00:00
Jordan Rose
e1ffbbbcf5 Import MacTypes.Boolean as a dedicated DarwinBoolean type.
Like ObjCBool is a legitimate boolean type rather than a typealias for Int8,
DarwinBoolean is better than a typealias for UInt8. It's a BooleanType
(meaning you can use it directly in if/while/?:) and BooleanLiteralConvertible
(meaning you can use 'true' and 'false').

The next commit goes even further, so that you only have to deal with
DarwinBoolean when ABI is important. At all other times it should be
bridged with Bool, just like ObjCBool.

rdar://problem/19013551

Swift SVN r30050
2015-07-10 01:11:25 +00:00
Dmitri Hrybenko
a725d1e7e3 Fix a comment in a test
Swift SVN r30046
2015-07-09 23:24:59 +00:00
Dave Abrahams
ce8e51346c [stdlib] Remove a redundant and un-specific protocol extension
There's a better one in Sequence.swift; moving the comment there.

Swift SVN r30038
2015-07-09 20:27:19 +00:00
Dave Abrahams
913f09838a [stdlib] Add a default generate() for generators...
...that are also sequences, and rip out all redundant implementations of
generate() that match a default.

Swift SVN r30035
2015-07-09 19:49:24 +00:00
Mark Lacey
da983196a3 Add a specialization of extend for collections.
The specialization uses += operator for collections, which performs much
better than the += operator for sequences.

The extend benchmark from rdar://problem/21689050 improves by:
- 2500x with -O
- 15x with -O -whole-module-optimization

Unfortunately we still seem to be about 100x slower than the user's
memcpy version of the same benchmark with -O -whole-module-optimization.

Swift SVN r30033
2015-07-09 18:28:03 +00:00
Dave Abrahams
1870bb747e [stdlib] var => let suppresses a warning
Swift SVN r30027
2015-07-09 17:22:48 +00:00
Dave Abrahams
b023c10640 [stdlib] Concatenate.swift.gyb cleanups/optimizations
Swift SVN r30024
2015-07-09 17:10:33 +00:00
Joe Groff
0b54e21629 simd overlay: Use LLVM vector types.
This brings the David Owens benchmark from http://owensd.io/2015/06/27/performance-xcode7-beta-2.html from parity with simd.h-based C to 3x faster.

Before:

RenderGradient ([UInt32].withUnsafeMutablePointer (SIMD))                 │ 7.035851 │ 6.304739 │ 9.815832 │  1.212 │

After:

RenderGradient ([UInt32].withUnsafeMutablePointer (SIMD))                 │ 2.318357 │ 2.223325 │ 2.697981 │ 0.1490 │

This also addresses rdar://problem/21574425, since Builtin.add_VecNxIntM isn't overflow-checked, and overflow checks really aren't wanted when working with vector types directly.

Reapplying now that Nadav's fixed the ARM64 SelectionDAG issue this exposed before, and Arnold's fixed
yet another SelectionDAG issue exposed after that.

Swift SVN r30006
2015-07-09 01:20:01 +00:00
Joe Groff
ab1f459a40 Runtime/stdlib: Non-verbatim bridging of metatypes.
Metatypes can't directly conform to _ObjectiveCBridgeable, but we can pretend they do by making a struct with the same ABI conform and returning that conformance when we call findBridgeWitness on a metatype. Fixes rdar://problem/16238475.

Swift SVN r29999
2015-07-08 23:23:55 +00:00
Mark Lacey
9c713556d7 Remove a work-around from extend().
The test case in the radar appears to compile without issue now, and
moving this code back inline appears to work.

Swift SVN r29992
2015-07-08 20:56:08 +00:00