Commit Graph

119 Commits

Author SHA1 Message Date
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
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
Austin Zheng
9798dfd4aa [Runtime][StdLib] Migrate mirrors to use CustomReflectable API, rewrite dump()
Jira: SR-88
Changes:
- Removed stdlib type conformances to _Reflectable
- Conformed stdlib types to CustomReflectable, CustomPlaygroundQuickLookable
- Rewrote dump() function to not use _reflect()
- CGRect, CGPoint, CGSize now conform to CustomDebugStringConvertible
- Rewrote unit tests for compatibility with new API
2016-01-21 09:44:15 -08:00
gregomni
e2dee6b9dd [stdlib] Switch keywords from 'typealias' to 'associatedtype' in stdlib
Fixes deprecation warnings arising from addition of new
‘associatedtype’ keyword in sr-511.
2016-01-14 09:39:15 -08:00
Maxim Moiseev
f82389a70f Merge pull request #923 from johnlui/master
[stdlib] Change C-style for loop to Swift-style for-in loop
2016-01-12 09:29:50 -08:00
JohnLui
451ce376e3 [stdlib] Change C-style for loop to Swift-style for-in loop 2016-01-09 12:57:55 +08:00
practicalswift
4689a22f1b Replace left/right quotation marks with apostrophes in non-quote contexts
* LEFT SINGLE QUOTATION MARK (U+2018) → APOSTROPHE (U+0027)
* RIGHT SINGLE QUOTATION MARK (U+2019) → APOSTROPHE (U+0027)
2016-01-06 12:29:40 +01:00
practicalswift
50baf2e53b Use consistent formatting in top of file headers. 2016-01-04 02:17:48 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
ken0nek
fcd8fcee91 Convert [Cc]an not -> [Cc]annot 2015-12-23 00:55:48 +09:00
Chris Lattner
66f7ef1295 Move stdlib off ++ and -- 2015-12-21 18:07:36 -08:00
Dmitri Gribenko
2ed81bd19a Revert "[stdlib][performance] skip copying old values during removeAll(keepCapacity: true)" 2015-12-20 22:46:56 -08:00
Dmitri Gribenko
2e0efaee69 Revert "[Performance] iterate the smaller set during Set.intersect()" 2015-12-20 22:45:30 -08:00
Dmitri Gribenko
6f8bee17aa Merge pull request #576 from dduan/set_intersect_optimization
[Performance] iterate the smaller set during Set.intersect()
2015-12-19 17:26:42 -08:00
Daniel Duan
d919f4cb5c [stdlib] iterate the smaller set in Set.intersect()
This introduces a small constant in speed, but it's a big win for
worst case scenario.
2015-12-19 04:26:44 -08:00
Dmitri Gribenko
f436764742 Merge pull request #616 from dduan/removeAll_speedup
[stdlib][performance] skip copying old values during removeAll(keepCapacity: true)
2015-12-17 22:43:22 -08:00
Chris Lattner
99fcb2dfe1 Change all uses of x = x.successor() to use x._successorInPlace()
...because it is apparently more efficient in some cases.  Technically
we don't do this in ALL places, because it would be unfortunate if
the implementation of _successorInPlace() were self recursive :-)
2015-12-16 22:38:37 -08:00
Daniel Duan
b177c69d6b skip copying old values during removeAll()
As noted in FIXME(performance), calling `.removeAll(keepCapacity: true)` on a
containter of type Dictionay or Set causes a copy of its storage being made.
Only then, it would proceed to delete each element.

This patch makes these hashed collections skip the wasteful copying step.
2015-12-16 22:28:38 -08:00
Chris Lattner
e9a2e1e128 Eliminate all of the uses of ++/-- from stdlib/public/core.
At DaveA's suggestion, I took a mostly mechanical approach to this:
pointers and numeric types start using += 1, and indexes use
i = i.successor().  The index model is likely to be revised in
Swift 3 anyway, so micro-optimizing this code syntactically isn't
super important.

There is some performance concern of this patch, since some
in-place succesor operations are more efficient than
i = i.successor().  The one that seems particularly at issue is the
instance in the implementation of partition(), which I changed to
use i._successorInPlace().  If other instances lead to a perf issue,
they can be changed to use that as well.
2015-12-15 23:21:55 -08:00
Patrick Pijnappel
bbe0e514a2 [stdlib] Fix capitalization 2015-12-13 21:37:44 +11:00
Patrick Pijnappel
668e7101eb [stdlib] Replace .None by nil in doc comments 2015-12-13 12:10:43 +11:00
Patrick Pijnappel
95622c435b [stdlib] Replace .Some(x) and .None by x and nil, respectively 2015-12-13 12:10:43 +11:00
Dmitri Gribenko
4c093cf4a0 stdlib: fix indentation 2015-12-10 14:24:28 -07:00
Daniel Duan
9c28ff0207 compare Set and Dictionary by address for equality
as noted in the comment, the native storage version of Set and Dictionary can
be considered equal if their Owner object have the same address. This should
speed up == by quite a bit in those cases.

use === for equality of HashedCollection owner
2015-12-10 12:45:12 -08:00
Monica Soni
9d98066d7d Fix typo contigous => contiguous 2015-12-08 18:03:00 +05:30
Florian Reinhart
2134e55c25 Fix typo in comment 2015-12-07 14:24:11 +01:00
Patrick
14fdf744b0 Make documented complexity consistent
Since most of the documentation in the code use O(`self.count`) instead of O(`count`), change the inconsistent code documentation to O(`self.count`).
2015-12-04 17:15:55 -08:00
Joe Groff
fbd2e4d872 Rename @asmname to @_silgen_name.
This reflects the fact that the attribute's only for compiler-internal use, and isn't really equivalent to C's asm attribute, since it doesn't change the calling convention to be C-compatible.
2015-11-17 14:13:48 -08:00
Jordan Rose
cf8baedee2 Re-apply "Rename @transparent to @_transparent for now."
This re-applies 90fcbfe9a6. I'll be committing
the corresponding change to Foundation momentarily.
2015-11-16 10:53:56 -08:00
Xin Tong
16843684b2 Revert "Rename @transparent to @_transparent for now."
This reverts commit 90fcbfe9a6.

Seems there are still some tests that are left not modified.
2015-11-14 07:04:31 -08:00
Jordan Rose
90fcbfe9a6 Rename @transparent to @_transparent for now.
This feature has not been fully designed, let alone properly implemented.
For more information, see docs/TransparentAttr.rst.
2015-11-13 16:25:34 -08:00
Maxwell Swadling
5d52666132 Improved the performance of _dictionaryBridgeFromObjectiveCConditional by specifying the minimumCapacity up front. NFC 2015-11-05 12:01:30 -08:00
Maxwell Swadling
933c973551 Revert "Improved the performance of _dictionaryBridgeFromObjectiveCConditional by only allocating a _NativeDictionaryStorage once all the items are bridged. NFC"
This reverts commit e001efc741.

A faster approach is to reserve the memory with minimumCapacity.
2015-11-05 12:01:30 -08:00
Maxwell Swadling
e001efc741 Improved the performance of _dictionaryBridgeFromObjectiveCConditional by only allocating a _NativeDictionaryStorage once all the items are bridged. NFC 2015-11-04 14:30:31 -08:00
Arnold Schwaighofer
7fa673c6bc Revert "stdlib: Replace unsafeBitCast calls with unsafeCastReference."
Revert "For unsafeReferenceCast rely on static verifier checks."

This reverts commit r32796.
This reverts commit r32795.

They very likely broke a buildbot.

Swift SVN r32813
2015-10-21 22:06:01 +00:00
Andrew Trick
b1b07ef0fa stdlib: Replace unsafeBitCast calls with unsafeCastReference.
unsafeBitCast should only be used when we actually need to lie to the type system (as opposed to just having an unchecked downcast).

Theses are the places where unsafeReferenceCast makes sense:
(In general it makes sense whenever the source & dest are class or class existential types)

- ArrayBuffer.getElement.

  The deferred downcast case cannot be benchmarked. It is never on the critical path.

  The ObjC array case cannot conceivably matter either, however, it is touched by
  DollarChain, JSONHelperDeserialize, and StrSplitter.
  These benchmarks do not regress at -O.

- arrayForceCast

  No regressions at -O based on microbenchmarks.

None of these remaining cases affect PerfTestSuite at -O:

- General ObjC bridging

- Set/Dictionary bridging

- String bridging

- AutoreleasingUnsafeMutablePointer

These are confirmed speedups but I did not investigate the cause:

|.Chars...................|.32.1%.|
|.Sim2DArray..............|.15.4%.|
|.Calculator..............|.13.0%.|
|.RecursiveOwnedParameter.|..7.9%.|

Swift SVN r32796
2015-10-21 19:41:57 +00:00
Arnold Schwaighofer
66275a3ad8 Replace handrolled max by max.
Swift SVN r32250
2015-09-25 23:37:29 +00:00
Arnold Schwaighofer
9ec0c2391d Nuke the CollectionType implementation from _BitMap.
It is dead code.

Swift SVN r32249
2015-09-25 23:37:23 +00:00
Arnold Schwaighofer
fd00a80029 HashedCollections: Fix code only executed if compiled with internal checks enabled
Swift SVN r32247
2015-09-25 22:47:33 +00:00
Arnold Schwaighofer
6c88b414cd Fix _BitMap's endIndex function
Swift SVN r32246
2015-09-25 22:19:14 +00:00
Arnold Schwaighofer
a5e75311af stdlib: Implement Dictionary using a structs of arrays strategy
Instead of Optional entries use a third bitmap array to mark whether an entry is
valid. This representation saves space (because individual entries don't have a
alignment padding slack) and simplifies ARC's job leading to better performance.

Speedup measured (before/after) at -O:

DictionaryHashableClass`````````3.1
DollarFilter````````````````````1.3
DollarMap```````````````````````1.3
DollarReduce````````````````````1.4
JSONHelperDeserialize```````````1.4
NSDictionaryImplicitConversion``1.4
NSXMLParser`````````````````````1.3

Speedup measured (before/after) at -Onone:

DictOfArraysToArrayOfDicts``````1.3
Dictionary``````````````````````3.5
Dictionary2`````````````````````3.2
Dictionary3`````````````````````3.2
DictionaryHashableClass`````````1.9
DictionaryHashableStruct````````2.4
DictionaryRemove````````````````3.3
DictionarySwap``````````````````2.5
DollarFilter````````````````````1.2
DollarMap```````````````````````1.2
DollarReduce````````````````````1.3
Forest``````````````````````````1.8
Histogram```````````````````````1.6
JSONHelperDeserialize```````````1.6
NSDictionaryImplicitConversion``1.3
Prims```````````````````````````2.9
RGBHistogram````````````````````1.4

rdar://22173734

Swift SVN r32244
2015-09-25 22:05:15 +00:00
Arnold Schwaighofer
1b8cd94410 stdlib: Half the size of dictionary get/set operations inlined into user code
Reapply of 31644 with fix for building on linux.

Mark one method on the cocoa path noinline and outline the cocoa path for
maybeGet.

Swift SVN r31648
2015-09-03 01:07:06 +00:00
Xi Ge
df3dd4564b Revert "stdlib: Half the size of dictionary get/set operations inlined into user code"
To unblock Swift master Incremental RA.

Swift SVN r31645
2015-09-03 00:19:29 +00:00
Arnold Schwaighofer
932bb37a4f stdlib: Half the size of dictionary get/set operations inlined into user code
Mark one method on the cocoa path noinline and outline the cocoa path for
maybeGet.

Swift SVN r31644
2015-09-02 23:35:37 +00:00
Nadav Rotem
c96a127f6c [codesize] Force _dictionaryBridgeToObjectiveC to stay in the swift dylib.
Keeping this method in the swift dylib saves a few kilobytes for each
specialization of dictionary. This function is not on the critical
performance path and we don't gain much from pulling it and specializing
it in user code.

Swift SVN r31507
2015-08-26 22:14:18 +00:00
David Farler
9f10b691e6 Reviewed: Containers should use debug description of their elements in both description and debugDescription
- Don't need CollectionOfOne.description
- Don't use private functions for shared internal functions for
  constructing descriptions

Swift SVN r31071
2015-08-07 08:52:35 +00:00
David Farler
9aa7663ad3 Always debugPrint containers' elements
rdar://problem/19312992

Swift SVN r31067
2015-08-07 06:14:19 +00:00
Dmitri Hrybenko
dd3194a18c stdlib: adopt @warn_unused_result
rdar://20957486

Swift SVN r31048
2015-08-06 14:53:18 +00:00
Joe Pamer
828eb68e72 Commit DaveA's API changes to 'print', along with the compiler changes necessary to support them.
There's still work left to do. In terms of next steps, there's still rdar://problem/22126141, which covers removing the 'workaround' overloads for print (that prevent bogus overload resolution failures), as well as providing a decent diagnostic when users invoke print with 'appendNewline'.

Swift SVN r30976
2015-08-04 01:57:11 +00:00