Commit Graph

93 Commits

Author SHA1 Message Date
Dmitri Hrybenko
397d2fb8c3 stdlib: coding style: when colon specifies is-a relationship, we put
spaces on both sides of it

Swift SVN r23935
2014-12-15 06:55:30 +00:00
Chris Lattner
cb8a65e831 Clean up the semantics of 'let' properties in a number of ways:
- We switch to a model where let properties may be "initialized", but never
  reassigned.  Specifically, immutable properties in structs/classes may have
  an init value specified in their declaration (but can then never be reset
  in any init implementation) or not (in which case they must be initialized 
  exactly once on all paths through every init.  This makes a lot more sense 
  for immutability, defines several problems away, and provides a path to
  supporting things like (rdar://16181314)

- We now *never* default initialize an immutable property.  Formerly
  we would default initialize optional let properties to nil, but this
  isn't actually useful, and allows an error of omission with let 
  properties.  

This resolves: <rdar://problem/19035287> let properties should only be initializable, not reassignable
and possibly other radars.





Swift SVN r23779
2014-12-08 20:59:53 +00:00
Dmitri Hrybenko
d56fd34d0c StdlibUnittest: remove redundant initializers for pthread_*_t types
The compiler can generate these automatically now.

Swift SVN r23735
2014-12-05 08:26:41 +00:00
Maxwell Swadling
55f3289054 Added additional tests and comments to String
Swift SVN r23490
2014-11-20 22:33:13 +00:00
David Farler
14159d942b Use string description in test sequence comparison
Using ObjectIdentifiers on the 32-bit simulator isn't a reliable
comparison method. For the purposes of these tests, it's better to
do a string comparison of the description instead.

rdar://problem/19013004

Swift SVN r23415
2014-11-18 21:55:32 +00:00
Maxwell Swadling
da227795a7 [stdlib-unittest] Added expectEqualsUnordered
Also added isSequenceType function.

Swift SVN r23215
2014-11-11 00:24:19 +00:00
Dmitri Hrybenko
c57bde235d CMake: add a (disabled) flag for serializing StdlibUnittest
It would speed up testing if it actually worked.

Swift SVN r23175
2014-11-08 04:41:08 +00:00
Greg Parker
69399885ce Test: Reconcile crashOutputMatches() with its own test, and test multiple uses.
Swift SVN r23157
2014-11-07 05:25:08 +00:00
Greg Parker
4c1f990ca8 Test: Allow multiple crashOutputMatches() on a single StdlibUnittest test.
Swift SVN r23140
2014-11-06 22:50:07 +00:00
Dave Abrahams
9857aaa1de [StdlibUnittest] Use _UnitTestArray now
This commit decouples StdlibUnittest from many details of
[Contiguous]Array, so tests can give useful feedback even in the
presence of a broken [Contiguous]Array implementation while we refactor.

Unfortunately, it wasn't practical to make _UnitTestArray use a
storage class other than _ContiguousArrayStorage[Base], so we still have
to watch out when making changes there.

Swift SVN r22875
2014-10-22 05:28:23 +00:00
Dave Abrahams
c799f3687c [StdlibUnittest] Try to use ContiguousArray
ContiguousArray is a simpler component, thus less prone to breakage.
Builting the unit testing framework atop broken components is a very bad
idea, so let's not.

This is a reinstatement of an earlier commit, plus changes to make the
validation tests work.

Swift SVN r22867
2014-10-21 22:17:06 +00:00
Dave Abrahams
215929b20e Revert "[StdlibUnittest] Try to use ContiguousArray"
This reverts commit r22769, which broke the validation tests

Swift SVN r22792
2014-10-16 03:46:35 +00:00
Dave Abrahams
cf8e450510 [StdlibUnittest] Try to use ContiguousArray
ContiguousArray is a simpler component, thus less prone to breakage.
Builting the unit testing framework atop broken components is a very bad
idea, so let's not.

Swift SVN r22769
2014-10-15 20:27:55 +00:00
Erik Eckstein
b51b3ed123 Mark public compiler intrinsics with // COMPILER_INTRINSIC
I followed Joe's example in Process.swift and used COMPILER_INTRINSIC (and not just INTRINSIC)



Swift SVN r22723
2014-10-14 07:32:03 +00:00
Erik Eckstein
60dcb9a435 Make compiler intrinsics public (part 2).
With the changed SILLinkage and dead function removal of internal functions this is necessary.



Swift SVN r22490
2014-10-03 13:58:50 +00:00
Dmitri Hrybenko
fcb7d40f99 StdlibUnittest: move expectType() predicate to the library
Swift SVN r22416
2014-10-01 01:12:11 +00:00
Dave Abrahams
156020de19 [stdlib] Rename 'countElements' => 'count'
The name was not only long and unwieldy, but inconsistent with our
conscious decision to avoid the use of "elements" in APIs as mostly
redundant.

Swift SVN r22408
2014-09-30 22:00:26 +00:00
Dave Abrahams
d8122fd010 [testing] Purge use of mixed-sign arithmetic
Swift SVN r22401
2014-09-30 20:21:00 +00:00
Dmitri Hrybenko
41a48f258a StdlibUnittest: add Printable and DebugPrintable testing predicates
Swift SVN r22355
2014-09-29 15:41:01 +00:00
Dmitri Hrybenko
a3724588cb Fix and expand the AtomicInt test
The previous version of this test was disallowing some thread
interleavings that I did not consider.  See comments in the test for
more details.

Swift SVN r22300
2014-09-26 10:29:56 +00:00
Dmitri Hrybenko
2ab8f0c50b StdlibUnittest: remove debug output from race tests
Swift SVN r22299
2014-09-26 10:29:52 +00:00
Dmitri Hrybenko
1410688b8f StdlibUnittest: add an autorelease pool to the master race thread to
stabilize memory consumption

Swift SVN r22282
2014-09-25 14:10:09 +00:00
Dmitri Hrybenko
83b06926c4 StdlibUnittest: simplify code
Swift SVN r22278
2014-09-25 09:55:58 +00:00
Dave Abrahams
c38e3201b2 [stdlib] Propagate ForwardIndexType docs to models
200 undocumented public APIs remain in core

Swift SVN r22222
2014-09-23 19:20:48 +00:00
Dmitri Hrybenko
fbd91f7ac3 Add missing 'public' modifiers in StdlibUnittest
Swift SVN r22216
2014-09-23 13:31:24 +00:00
Erik Eckstein
c16c510167 Set SILLinkage according to visibility.
Now the SILLinkage for functions and global variables is according to the swift visibility (private, internal or public).

In addition, the fact whether a function or global variable is considered as fragile, is kept in a separate flag at SIL level.
Previously the linkage was used for this (e.g. no inlining of less visible functions to more visible functions). But it had no effect,
because everything was public anyway.

For now this isFragile-flag is set for public transparent functions and for everything if a module is compiled with -sil-serialize-all,
i.e. for the stdlib.

For details see <rdar://problem/18201785> Set SILLinkage correctly and better handling of fragile functions.

The benefits of this change are:
*) Enable to eliminate unused private and internal functions
*) It should be possible now to use private in the stdlib
*) The symbol linkage is as one would expect (previously almost all symbols were public).

More details:

Specializations from fragile functions (e.g. from the stdlib) now get linkonce_odr,default
linkage instead of linkonce_odr,hidden, i.e. they have public visibility.
The reason is: if such a function is called from another fragile function (in the same module),
then it has to be visible from a third module, in case the fragile caller is inlined but not
the specialized function.

I had to update lots of test files, because many CHECK-LABEL lines include the linkage, which has changed.

The -sil-serialize-all option is now handled at SILGen and not at the Serializer.
This means that test files in sil format which are compiled with -sil-serialize-all
must have the [fragile] attribute set for all functions and globals.

The -disable-access-control option doesn't help anymore if the accessed module is not compiled
with -sil-serialize-all, because the linker will complain about unresolved symbols.

A final note: I tried to consider all the implications of this change, but it's not a low-risk change.
If you have any comments, please let me know.



Swift SVN r22215
2014-09-23 12:33:18 +00:00
Dmitri Hrybenko
ae8c52969b StdlibUnittest: make testing return-autoreleased optimization reliable
On some platforms (for example, x86_64), the first call to
`objc_autoreleaseReturnValue` will always autorelease because it would
fail to verify the instruction sequence in the caller.  On x86_64
certain PLT entries would be still pointing to the resolver function,
and sniffing the call sequence would fail.

This change adds a "warmup" return-autoreleased sequence to the test
harness.

rdar://18385128

Swift SVN r22127
2014-09-19 14:06:57 +00:00
Dave Abrahams
1e9e7734f0 Revert "[stdlib] any/all algorithms, keyword for contains"
This reverts r21810 and r21811 due to lack of design consensus

Swift SVN r21880
2014-09-11 17:42:32 +00:00
Dmitri Hrybenko
d3be963abf RaceTest: add radar references for bug workarounds
Swift SVN r21876
2014-09-11 16:07:42 +00:00
Dmitri Hrybenko
d68a5c4c98 stdlib: finish implementation of atomics for initializing an ARC
reference, add tests

Swift SVN r21873
2014-09-11 14:52:58 +00:00
Dmitri Hrybenko
756d129ec6 Rename StdlibUnittest.{getPtr -> getPointer}
Swift SVN r21839
2014-09-10 14:41:20 +00:00
Dmitri Hrybenko
b68d147ca1 stdlib/Unmanaged: trap when attempting to create an Unmanaged from a
null pointer

Swift SVN r21838
2014-09-10 14:15:06 +00:00
Dmitri Hrybenko
96d00d70b5 StdlibUnittest: add infrastructure for race tests (see examples)
This will be used to test rdar://18191358

Swift SVN r21836
2014-09-10 11:58:45 +00:00
Dave Abrahams
c467825bc2 [stdlib] any/all algorithms, keyword for contains
Expose any, all on Array and all the Lazy sequence adapters.  Make the
'contains' algorithm that takes a predecate unavailable in favor of
'any', which does the same thing.

Fixes <rdar://problem/18190149> [algorithm] `contains` syntax is ambiguous

Swift SVN r21810
2014-09-09 20:39:39 +00:00
Dmitri Hrybenko
8237d2a604 StdlibUnittest: remove compatibility typealias
rdar://18028805

Swift SVN r21627
2014-09-01 09:30:16 +00:00
Dave Abrahams
06414d842e [stdlib] Add LifetimeTracked to StdlibUnitTest
Swift SVN r21603
2014-08-30 01:54:31 +00:00
Dave Abrahams
6c07fb4ad1 [stdlib] Revert UnsafePointer casting change
The syntax being reverted added busywork and noise to the common case
where you want to say "I have the right address, but the wrong type,"
without adding any real safety.

Also it eliminated the ability to write UnsafePointer<T>(otherPointer),
without adding ".self" to T.  Overall, it was not a win.

This reverts commits r21324 and r21342

Swift SVN r21424
2014-08-22 21:53:12 +00:00
Dmitri Hrybenko
2124857300 Use withUnsafeMutableBufferPointer when mutating the buffer instead of
getting an immutable buffer and casting it

Swift SVN r21415
2014-08-22 17:57:58 +00:00
Greg Parker
121e65cdfc [test] No seriously, don't stop StdlibUnittest when the debugger interrupts select().
Swift SVN r21404
2014-08-22 04:56:18 +00:00
Greg Parker
afb85f012a [test] Don't stop StdlibUnittest when the debugger interrupts select().
Swift SVN r21401
2014-08-22 04:36:53 +00:00
Dmitri Hrybenko
f1c3d879ef StdlibUnittest: add setUp and tearDown functions, which are executed before and
after every test


Swift SVN r21362
2014-08-21 16:56:49 +00:00
Dave Abrahams
1fb0f889d7 [stdlib] Make UnsafePointer conversions explicit
Previously, it was possible to write Unsafe[Mutable]Pointer(x) and have
Swift deduce the pointee type based on context.  Since reinterpreting
memory is a fundamentally type-unsafe operation, it's better to be
explicit about conversions from Unsafe[Mutable]Pointer<T> to
Unsafe[Mutable]Pointer<U>.  This change is consistent with the move from
reinterpretCast(x) to unsafeBitCast(x, T.self).

Also, we've encoded the operations of explicitly adding or removing
mutability as properties, so that adding mutability can be separated
from wild reinterpretCast'ing, a much more severe form of unsafety.

Swift SVN r21324
2014-08-20 23:15:56 +00:00
Dmitri Hrybenko
61f9b11e5f StdlibUnittest: add expectEqualUnicodeScalars() assertion function for precise
String comparison


Swift SVN r21229
2014-08-15 10:11:31 +00:00
Dmitri Hrybenko
823291e735 StdlibUnittest: add a compatibility typealias to allow PlaygroundLogger to
transition to the new APIs


Swift SVN r21225
2014-08-15 08:11:36 +00:00
Dmitri Hrybenko
8cca039e62 StdlibUnittest: rename TestCase to TestSuite since it contains multiple tests
Thanks, Ben!


Swift SVN r21222
2014-08-15 00:09:58 +00:00
Dmitri Hrybenko
d812966d32 stdlib: remove Optional.hasValue property
rdar://17931456


Swift SVN r21172
2014-08-13 10:51:26 +00:00
Dmitri Hrybenko
3a04e0809f stdlib: add a function to squeeze a number in a given range from a hash value
This function mixes the bits in the hash value, which improves Dictionary
performance for keys with bad hashes.

PrecommitBenchmark changes with greater than 7% difference:

``````````Dictionary2`,```1456.00`,```1508.00`,```1502.00`,````624.00`,````607.00`,````592.00`,`864.00`,``145.9%
``````````Dictionary3`,```1379.00`,```1439.00`,```1408.00`,````585.00`,````567.00`,````552.00`,`827.00`,``149.8%
````````````Histogram`,````850.00`,````849.00`,````851.00`,```1053.00`,```1049.00`,```1048.00`,`199.00`,``-19.0%
````````````````Prims`,```1999.00`,```2005.00`,```2018.00`,```1734.00`,```1689.00`,```1701.00`,`310.00`,```18.4%
``````````StrSplitter`,```2365.00`,```2334.00`,```2316.00`,```1979.00`,```1997.00`,```2000.00`,`337.00`,```17.0%
```````````````TwoSum`,```1551.00`,```1568.00`,```1556.00`,```1771.00`,```1741.00`,```1716.00`,`165.00`,```-9.6%

Regressions are in benchmarks that use `Int` as dictionary key: we are just
doing more work than previously (hashing an `Int` was an identity function).

rdar://17962402


Swift SVN r21142
2014-08-12 12:02:26 +00:00
Dmitri Hrybenko
4b9c318c05 stdlib: correct trap messages for float to integer conversion
rdar://17943841


Swift SVN r21128
2014-08-09 18:02:28 +00:00
Jordan Rose
323c788c5b [CMake] Support simulator testing with the multiple-variants build.
New targets: check-swift-iphonesimulator-{i386,x86_64}. In theory this also
supports check-swift-iphoneos-{armv7,arm64}, but I didn't do any work to
support that (including even copying over what the separate-build tests do).

I'd suggest /not/ running both targets at the same time with Ninja; both
lit processes assume they can use all cores and end up contending for the
CPU and simulator.

Swift SVN r21111
2014-08-08 17:56:10 +00:00
Dmitri Hrybenko
f7499fa5d1 There is no Float80 outside x86, conditionalize the code
Swift SVN r21110
2014-08-08 16:14:50 +00:00