Commit Graph

1324 Commits

Author SHA1 Message Date
Max Moiseev
61c837209b Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-04 16:13:39 -08:00
Chris Lattner
0619e57a61 Switch the stdlib to use #file instead of __FILE__, and deprecate the __FILE__ identifiers.
This also updates the tests that would otherwise fail.
2016-02-04 15:08:31 -08:00
Dmitri Gribenko
b2ca7712f6 Merge pull request #929 from kballard/remove-reundant-locking-from-print
[Stdlib] Remove all redundant stdout locking when printing
2016-02-04 09:15:24 -08:00
Xin Tong
19869d4fb5 Minor code refactoring and changing an enum of 2 fields to an Optional 2016-02-03 15:01:46 -08:00
Xin Tong
d2a1cb90f5 Fix a swift argument initialization bug - swift argument should be initialized
after argc and argv are initialized.

The problem before is that the argument function is a global_init which can be moved
by the GlobalOpt optimization and thus broke the data dependence on argc and argv.

rdar://24250684
2016-02-03 14:02:31 -08:00
Arnold Schwaighofer
ebfb504415 Don't use generators in array equality comparisons
This is easier to read and faster if we don't specialize away the generator
code.
2016-02-02 14:58:23 -08:00
Kevin Ballard
ac1996000e [Stdlib] Remove all redundant stdout locking when printing
* Switch to calling `putchar_unlocked()` instead of `putchar()` for
  actual printing. We're already locking stdout with `flockfile()`, so
  there's no need for the redundant lock that `putchar()` uses.
* Add an explicit lock to the output stream in `dump()`. This means the
  entire dump is printed with the lock held, which will prevent the
  output of `dump()` from mixing with prints on other threads.
* Use `_debugPrint_unlocked()` instead of `debugPrint()` in
  `_adHocPrint()`. The output stream is already locked while this
  function is executing. Rename the function to `_adHocPrint_unlocked()`
  to make this explicit.
* Use `targetStream.write()` and `_print_unlocked()` instead of
  `print()` in `_dumpObject()`. This removes the redundant locking, and
  also eliminates the creation of intermediate strings. Rename the
  function to `_dumpObject_unlocked()` to make this explicit.
* Use `targetStream.write()`, `_print_unlocked()`, and
  `_debugPrint_unlocked()` in `_dumpSuperclass()`. This removes the
  redundant locking, and also eliminates the creation of intermediate
  strings. Rename the function to `_dumpSuperclass_unlocked()` to make
  this explicit.
* Use `_debugPrint_unlocked()` instead of `debugPrint()` in
  `String.init(reflecting:)`. This shouldn't really make much of a
  difference but it matches the usage of `_print_unlocked()` in
  `String.init(_:)`.

The net result is that all printing is still covered under locks like
before, but stdout is never recursively locked. This should result in
slightly faster printing. In addition, `dump()` is now covered under a
single lock so it can't mix its output with prints from other threads.
2016-02-02 13:40:55 -08:00
Dmitri Gribenko
34b00e25b1 stdlib: fix coding guideline violations 2016-01-31 23:42:05 -08:00
Dmitri Gribenko
81ce88847c stdlib: remove dead code 2016-01-31 21:57:06 -08:00
David Farler
d45aa36e85 Clean up some things that sneaked into var reverts
- Remove an overload that came back in after rebase
- Minor formatting issues
2016-01-30 10:03:53 -08:00
Dmitri Gribenko
dc11ccded4 Merge pull request #1122 from harlanhaskins/fatalError-stack-trace
Add backtrace reporting on fatalError
2016-01-30 04:07:07 -08:00
Dmitri Gribenko
a385779e41 stdlib: define a custom mirror for DictionaryGenerator and SetGenerator
The default mirror tries to access implementation details of the
generator, accessing the 'description' property of the storage, which is
an NSDictionary subclass.  The default implementation of -[NSDictionary
description] tries to print the dictionary contents.  But if the
Swift.Dictionary can't be bridged to NSDictionary, that causes a runtime
trap.

rdar://problem/24238609
2016-01-30 02:09:45 -08:00
David Farler
3f635d04c7 Reinstante var bindings in refutable patterns, except function parameters.
This reverts commits: b96e06da44,
                      8f2fbdc93a,
                      93b6962478,
                      64024118f4,
                      a759ca9141,
                      3434f9642b,
                      9f33429891,
                      47c043e8a6.

This commit leaves 'var' on function parameters as a warning to be
merged into Swift 2.2. For Swift 3, this will be an error, to be
converted in a follow-up.
2016-01-29 15:27:08 -08:00
Harlan Haskins
b55d8d9c3c [Runtime] Add backtrace reporting on fatalError in debug builds 2016-01-29 13:42:06 -08:00
Dmitri Gribenko
cf7e3f6df4 stdlib: Range.contains: fix coding style and make the function public
... so that it actually has a chance to get referenced in the witness
table.

But since the function is in a constrained extension, it can't be.
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
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
Xin Tong
062d14b422 Address @gribozavr comments to 273b149583 2016-01-29 00:01:39 -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
Ling Wang
1ae71d4915 Merge from upstream and resolve conflicts 2016-01-28 11:13:42 -06: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
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
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
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
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
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
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
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
Adriano Ferreira
e6cbebe6ea Revert "Adjust space in property/subscript declarations"
This reverts commit 47ab2e0e28.
2016-01-22 19:53:01 -05:00
Max Moiseev
29b26cf3b8 [stdlib] making Set conform to SetAlgebra
Since the API is not quite the same, needed to introduce several
overloads that accept Set<> and not any S : Sequence.
Some dynamic casts were removed from methods, since Set.init already
handles situations where sequence being passed is in fact a Set.
Verified there is no significant change in performance after vs before
the change.
2016-01-22 15:00:57 -08:00
Adriano Ferreira
47ab2e0e28 Adjust space in property/subscript declarations 2016-01-22 17:03:15 -05:00
Dmitri Gribenko
ed790c8d54 Swift 3 migration: add annotations for MirrorPathType 2016-01-22 09:16:11 -08:00
Mark Lacey
8917eb0e5a Revert "[Runtime][StdLib] Migrate mirrors to use CustomReflectable API, rewrite dump()"
This reverts commit 9798dfd4aa because it
broke the stdlib build.
2016-01-22 08:41:07 -08:00
Dmitri Gribenko
3b4248ea78 stdlib: add migration aids for lazy filter collections 2016-01-21 18:00:30 -08:00
Dmitri Gribenko
f5153572d7 stdlib: rename count labels in underscored protocols
lengthInBytes => utf8CodeUnitCount

numberOfCodeUnits => utf16CodeUnitCount
2016-01-21 17:18:15 -08:00
Dmitri Gribenko
574052f1be stdlib: standardize fatalError() messages for unavailable APIs 2016-01-21 16:34:54 -08:00
Dmitri Gribenko
b371422dd9 stdlib: standardize fatalError() messages for unavailable APIs 2016-01-21 15:27:03 -08:00
Dmitri Gribenko
c5d694c4af Swift 3 migration: add migration aids for EnumeratedIterator and EnumeratedSequence 2016-01-21 15:25:21 -08:00