Commit Graph

4650 Commits

Author SHA1 Message Date
Dmitri Gribenko
a5a70dd14c StdlibUnittest: use ResettableValue more, removing error-prone boilerplate from tests 2016-01-29 13:24:59 -08:00
Slava Pestov
55644c1540 stdlib: Remove Self parameter from SequenceType._preprocessingPass
This code as written is not sound and should not type check
for non-final classes conforming to SequenceType (eg, NSArray).

Instead, capture the base of the call from the preprocess closure
passed in. The closure is @noescape, so it should be equivalent.
2016-01-29 12:18:39 -08:00
Dmitri Gribenko
fbbb42a5db Merge pull request #1130 from glessard/noobjc-testpredicate
Add cases .ObjCRuntime and .NativeRuntime to StdlibUnittest's TestPredicate
2016-01-29 10:36:28 -08:00
Xin Tong
d3c6d1f6d7 Revert "Address @gribozavr comments to 273b1495834bcc650642aec523dd0504f8623cfa"
This reverts commit 062d14b422.

Revert "Fix a swift argument initialization bug - swift argument should be initialized"

This reverts commit 273b149583.

This breaks DebugAssert as well as REPL builds. Revert to appease the bots while i
look further.
2016-01-29 08:00:16 -08:00
Slava Pestov
d887d823ef Re-apply "Protocol conformances can now reference resilient value types"
This comes with a fix for a null pointer dereference in _typeByName()
that would pop with foreign classes that do not have a
NominalTypeDescriptor.

Also, I decided to back out part of the change for now, where the
NominalTypeDescriptor references an accessor function instead of a
pattern, since this broke LLDB, which reaches into the pattern to
get the generic cache.

Soon we will split off the generic cache from the pattern, and at
that time we can change the NominalTypeDescriptor to point at the
cache. But for now, let's avoid needless churn in LLDB by keeping
that part of the setup unchanged.
2016-01-29 00:49:00 -08:00
Xin Tong
062d14b422 Address @gribozavr comments to 273b149583 2016-01-29 00:01:39 -08:00
Dmitri Gribenko
7368b08d86 Merge pull request #1133 from glessard/always-never-testpredicate
Add .Always and .Never cases to StdlibUnittest's TestPredicate
2016-01-28 23:19:55 -08:00
Xin Tong
273b149583 Fix a swift argument initialization bug - swift argument should be initialized
after argc and argv are initialized. rdar://24250684

I reordered the CHECK statements in some tests to make them pass.

I tested this on Darwin and Linux.
2016-01-28 22:36:14 -08:00
Guillaume Lessard
b7f19d6889 Add .Always and .Never cases to StdlibUnittest's TestPredicate 2016-01-28 23:03:00 -07:00
Dmitri Gribenko
a415ade5ae Merge pull request #854 from an0/master
Add O(1) `contains()` implementation for Range with Comparable Element
2016-01-28 21:41:31 -08:00
Guillaume Lessard
6879dbd553 Add runtime-related cases to StdlibUnittest's TestPredicate 2016-01-28 20:16:11 -07:00
Doug Gregor
2a42664129 Use #selector in StdlibUnitTest's Foundation extras 2016-01-28 11:23:14 -08:00
Ling Wang
1ae71d4915 Merge from upstream and resolve conflicts 2016-01-28 11:13:42 -06:00
Ling Wang
148c821d2c Fix test failure 2016-01-28 09:35:00 -06:00
Slava Pestov
4fd1387b3a Revert "Protocol conformances can now reference resilient value types"
This apparently broke Foundation and LLDB tests. I need to investigate further.

This reverts commit 65dd0e7b93.
2016-01-28 01:03:39 -08:00
Slava Pestov
65dd0e7b93 Protocol conformances can now reference resilient value types
Change conformance records to reference NominalTypeDescriptors instead of
metadata patterns for resilient or generic types.

For a resilient type, we don't know if the metadata is constant or not,
so we can't directly reference either constant metadata or the metadata
template.

Also, whereas previously NominalTypeDescriptors would point to the
metadata pattern, they now point to the metadata accessor function.
This allows the recently-added logic for instantiating concrete types
by name to continue working.

In turn, swift_initClassMetadata_UniversalStrategy() would reach into
the NominalTypeDescriptor to get the pattern out, so that its bump
allocator could be used to allocate ivar tables. Since the pattern is
no longer available this way, we have to pass it in as a parameter.

In the future, we will split off the read-write metadata cache entry
from the pattern; then swift_initClassMetadata_UniversalStrategy() can
just take a pointer to that, since it doesn't actually need anything
else from the pattern.

Since Clang doesn't guarantee alignment for function pointers, I had
to kill the cute trick that packed the NominalTypeKind into the low
bits of the relative pointer to the pattern; instead the kind is now
stored out of line. We could fix this by packing it with some other
field, or keep it this way in case we add new flags later.

Now that generic metadata is instantiated by calling accessor functions,
this change removes the last remaining place that metadata patterns were
referenced from outside the module they were defined in. Now, the layout
of the metadata pattern and the behavior of swift_getGenericMetadata()
is purely an implementation detail of generic metadata accessors.

This patch allows two previously-XFAIL'd tests to pass.
2016-01-28 00:33:10 -08:00
Austin Zheng
77918a86ac [SR-88] Reinstate Mirror migration changes, fix test issues
This reverts commit 182bb7f812.
2016-01-27 20:40:52 -08:00
Ling Wang
29bd8cc1b5 Merge from upstream and resolve conflicts 2016-01-27 16:08:15 -06:00
Max Moiseev
59303e239c [stdlib] improving RangeReplaceableCollection
Incorporates a commit from master, where an extra overload for `+` on
Collection was removed.
Also fixes a minor bug where capacity was calculated incorrectly as
`rhs.count + rhs.underestimatedCount`.
2016-01-27 11:19:42 -08:00
Andrew Trick
182bb7f812 Revert "Merge pull request #1058 from austinzheng/az-port-mirror"
This pull request broke the following tests on several build configurations
(eg --preset=buildbot,tools=RA,stdlib=DA)

    1_stdlib/Reflection.swift
    1_stdlib/ReflectionHashing.swift
    1_stdlib/UnsafePointer.swift.gyb

This reverts commit c223a3bf06, reversing
changes made to 5c2bb09b09.
2016-01-27 10:43:08 -08:00
Matt Rajca
0b678793dc Switched to computed variables and explicitly marked internal access 2016-01-27 11:13:52 -06:00
practicalswift
4d683be9e0 [gardening] Fix recently introduced incorrect headers 2016-01-27 11:56:10 +01:00
swift-ci
c223a3bf06 Merge pull request #1058 from austinzheng/az-port-mirror 2016-01-26 22:44:16 -08:00
Dmitri Gribenko
b2290992fa Allow StdlibCollectionUnittest to be built on Linux and FreeBSD 2016-01-26 22:02:17 -07:00
Austin Zheng
10d5b23c30 [SR-88] Reinstate mirror migration commit
Changes:
- Reverted commit reverting original SR-88 commit
- Removed mirror children helper collections and related code
- Rewrote some tests to keep them working properly
- Wrote two more tests for the three pointer APIs to ensure no crashes if created using a value > Int64.max

This reverts commit 8917eb0e5a.
2016-01-26 19:28:32 -08:00
Dmitri Gribenko
4c590585e0 Move Default* and Minimal* colections to StdlibCollectionUnittest
New StdlibUnittest build times:

* DebugAssert compiler and library: 50s
* ReleaseAssert compiler and library: 75s
2016-01-26 18:58:04 -08:00
Dmitri Gribenko
aeeb9c1325 Move collection testing code from StdlibUnittest to a new library
This brings down StdlibUnittest build time to 90 seconds with either
a DebugAssert or a ReleaseAssert compiler.

The new library, StdlibCollectionTests, is only built when running
validation tests.
2016-01-26 18:58:03 -08:00
Matt Rajca
ea3894d524 Cleaned up IOKit overlay
- Removed unnecessary #if guard
- Used IOReturn instead of Int32 return type
- Avoided private access control for overlays
- Added a test to ensure the type of the constants matches the return type of a IOKit function
2016-01-26 20:10:21 -06:00
Slava Pestov
19fe31fde9 IRGen: Emit and use accessors for generic type metadata
Instead of directly emitting calls to swift_getGenericMetadata*() and
referencing metadata templates, call a metadata accessor function
corresponding to the UnboundGenericType of the NominalTypeDecl.

The body of this accessor forwards arguments to a runtime metadata
instantiation function, together with the template.

Also, move some code around, so that metadata accesses which are
only done as part of the body of a metadata accessor function are
handled separately in emitTypeMetadataAccessFunction().

Apart from protocol conformances, this means metadata templates are
no longer referenced from outside the module where they were defined.
2016-01-26 16:00:54 -08:00
Maxim Moiseev
d2cccdeac0 Merge pull request #741 from nielsandriesse/collectiontype-overloads
[stdlib] Remove redundant +(_:_:) overload in RangeReplaceableCollectionType
2016-01-26 11:46:18 -08:00
Dmitri Gribenko
c497ea9da9 Revert "[SR-610][Stdlib] Use for-in to iterate over CollectionType elements" 2016-01-25 18:08:21 -08:00
Dmitri Gribenko
deac7566b0 CMake: remove stale comment 2016-01-25 17:19:58 -07:00
Dmitri Gribenko
544a8ef06a Merge pull request #1084 from lorentey/sr-610
[SR-610][Stdlib] Use for-in to iterate over CollectionType elements
2016-01-25 16:18:33 -08:00
Matt Rajca
7e5c9d34ec Added an an overlay for IOKit that adds the kIOReturnError* constants
All of the constants and comments have been taken from IOKit/IOReturn.h: http://www.opensource.apple.com/source/xnu/xnu-792.13.8/iokit/IOKit/IOReturn.h

The type of the kIOReturn* constants is Int32 to match the type of kIOReturnSuccess (which does get imported to Swift since it isn't defined in terms of a macro).

Fixes: https://bugs.swift.org/browse/SR-576
2016-01-25 16:58:31 -06:00
Károly Lőrentey
015004e3d5 [SR-610][stdlib] Use _initialize_to in _copyCollectionToNativeArrayBuffer
The Generator interface is specialized for iteration and is often faster than indexing.

Using _initialize_to results in a ~10% speedup for Dictionary. For collections with more complex iteration state (such as search trees with O(log(n)) indexing), this leads to a complexity class improvement.

This requires a small change to the testsuite, because the generate() method of Defaulted*RangeReplaceableSlice called Array(self), which now leads to infinite recursion.

https://bugs.swift.org/browse/SR-610
2016-01-25 19:47:43 +01:00
Arnold Schwaighofer
ce10cc7bd4 A dictionary must be native if *either* the key *or* the value is guaranteed not
to be a class/objc existential type.
2016-01-25 08:49:18 -08:00
Arnold Schwaighofer
b30f9fea03 Dictionary: More guaranteedNative fast paths
When we know that the backing of dictionary will be native only we can
circumvent the objective-c path.
2016-01-25 08:49:17 -08:00
practicalswift
71e00fefa1 [gardening] Fix typos: "word word" (two spaces) → "word word" (one space) 2016-01-24 21:27:16 +01:00
practicalswift
84a31184c7 PEP8: Fix all violations of type "missing whitespace after ','" (E231) 2016-01-24 09:40:32 +01:00
Dmitri Gribenko
fd8739105c Merge pull request #1057 from tanadeau/sr-538
[SR-538][Stdlib][3.0] Updated constraints and docs for popFirst/popLast. Added tests.
2016-01-23 21:20:06 -08:00
Ted Kremenek
5699bc67d4 Merge pull request #1003 from practicalswift/adhere-to-subset-of-pep8-iii
[gardening] Fix violations of non-controversial PEP8 rules
2016-01-23 16:38:43 -08:00
Trent Nadeau
160efd1023 Updated constraints and docs for popFirst/popLast. Added tests. 2016-01-23 18:01:06 +00:00
practicalswift
8efa5f587e [gardening] Remove "-*- C++ -*-" tag from .cpp files
Emacs assumes .h files are C files by default which is why the
tag "-*- C++ -*-" is needed.

.cpp files do not have this problem.
2016-01-23 12:09:32 +01:00
practicalswift
a3f857ca7b [gardening] Add "-*- C++ -*-" to header files currently missing it 2016-01-23 11:53:05 +01:00
practicalswift
ca9e488f30 [gardening] Add "-*- swift -*-" to *.swift.gyb. Remove from *.swift. 2016-01-23 10:27:03 +01:00
Dmitri Gribenko
fa5e4c74e5 stdlib comments: remove duplicated punctuation 2016-01-23 01:25:45 -08:00
practicalswift
1cd4d4e9c9 [gardening] Fix violations of non-controversial PEP8 rules
Fixes:
* multiple statements on one line (colon) (E701)
* missing whitespace around arithmetic operator (E226)
* missing whitespace around operator (E225)
* closing bracket does not match visual indentation (E124)
* blank line contains whitespace (W293)
* continuation line missing indentation or outdented (E122)
* continuation line over-indented for hanging indent (E126)
* missing expected blank line (E301)
* trailing whitespace (W291)
* unexpected spaces around keyword / parameter equals (E251)
* whitespace after '(', '[' or '{' (E201)
* whitespace before ')', ']' or '}' (E202)
* whitespace before ',' or ':' (E203)
2016-01-23 09:23:33 +01:00
Dmitri Gribenko
cd10e239cf Merge pull request #1054 from adrfer/master
Adjust space in property/subscript declarations
2016-01-22 20:40:14 -08:00
Adriano Ferreira
e6be43090e Adjust space in property/subscript declarations 2016-01-22 22:02:29 -05:00
Dmitri Gribenko
9bcd5a1056 Collection.length => .count 2016-01-22 18:41:19 -08:00