Commit Graph

1324 Commits

Author SHA1 Message Date
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
6e51e15a59 Add _sizeInBytes to fixed point types.
Swift SVN r32243
2015-09-25 22:05:15 +00:00
Arnold Schwaighofer
cc4e41cb3e Add a ispod builtin and _isPOD function to the stdlib
The builtin returns true if the argument type is a POD type: needs no special
handling for copy and destruct operations.

Swift SVN r32242
2015-09-25 22:05:14 +00:00
Dmitri Hrybenko
f57947a7e0 stdlib: fix capitalization issues in documentation comments
Patch by Nate Cook.

rdar://22054901

Swift SVN r32226
2015-09-25 17:13:54 +00:00
Dmitri Hrybenko
153d95efc6 SwiftShims: don't redeclare libc functions
Clang importer thinks that SwiftShims is the primary module where they
live, and this confuses code completion.

rdar://22488333

Swift SVN r32218
2015-09-25 03:33:50 +00:00
Dmitri Hrybenko
9da0b57178 stdlib: Add an initializer to RangeReplaceableCollectionType from SequenceType
rdar://19815116

Swift SVN r32213
2015-09-24 23:20:13 +00:00
Dmitri Hrybenko
1c0bb69a32 stdlib: add removeFirst() and removeLast() functions to slices
It is an oversight that we didn't add these when we were converting to
protocol extensions.

Swift SVN r32144
2015-09-22 02:50:33 +00:00
Dmitri Hrybenko
f7612273cf stdlib: simplify AnyGenerator API
Change the non-final class into a struct, and migrate global functions
into initializers.

rdar://21878289

Swift SVN r32137
2015-09-22 00:23:10 +00:00
Dmitri Hrybenko
384ec05ae4 stdlib: stop using Builtin types in UnicodeScalar
There is no reason for that now, and using Swift types simplifies code.

Swift SVN r32109
2015-09-21 01:33:10 +00:00
Dmitri Hrybenko
4375a463a7 stdlib: rename Int**.value and Float**.value to _value per naming convention
rdar://21357661

Swift SVN r32096
2015-09-20 00:01:13 +00:00
Dmitri Hrybenko
a2e1dc5fb7 stdlib: remove some workarounds for compiler bugs from ExistentialCollection
Swift SVN r32066
2015-09-18 03:37:03 +00:00
Dmitri Hrybenko
4f114006ab stdlib: fix the comment on removeFirst() to not refer to the 'n' parameter
Swift SVN r31954
2015-09-15 00:51:06 +00:00
Dmitri Hrybenko
cf19c6c532 stdlib: format a code snippet as a code block
rdar://22422749

Swift SVN r31922
2015-09-14 06:29:25 +00:00
Dmitri Hrybenko
2ff89aa40e stdlib: fix comment on ArraySlice.startIndex
ArraySlice.startIndex is not necessarily zero anymore.

rdar://22633052

Swift SVN r31921
2015-09-14 05:40:14 +00:00
Dmitri Hrybenko
67944589d6 stdlib: improve index invalidation guarantees for removeFirst()
Slice types that are RangeReplaceable (like ArraySlice) now slice
themselves in removeFirst().  Previously, these types were picking up
the wrong default implementation, and they were going through
replaceRange(), which caused all indices to be invalidated.  The new
implementation preserves all indices.

rdar://22536664

Swift SVN r31918
2015-09-12 04:35:51 +00:00
Dave Abrahams
07c47326cb [stdlib] Integer Prototype: get most signifcant bit
Swift SVN r31898
2015-09-11 18:40:47 +00:00
Argyrios Kyrtzidis
742f65c66b [stdlib] Fix comment of _ColorLiteralConvertible, NFC.
Swift SVN r31847
2015-09-10 02:03:16 +00:00
Enrico Granata
db4c6e4ab1 It is not necessary to return a quick look object for range - the summary takes good enough care of it
Swift SVN r31776
2015-09-08 21:03:31 +00:00
Nadav Rotem
da49bf2733 Revert "[stdlib] Move Low-Level Integers into stdlib"
This reverts commit r31707.

Swift SVN r31736
2015-09-07 04:57:07 +00:00
Dave Abrahams
e06ed15ece [stdlib] Move Low-Level Integers into stdlib
This should fix the build; the builtins for Int128 needed to be
generated in the stdlib.

Swift SVN r31707
2015-09-05 03:09:54 +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
Arnold Schwaighofer
aeece6bc1f stdlib: DRY and disable inlining of code to curb code growth
This halves the code size of array append inlined into user code.

Swift SVN r31603
2015-09-01 16:45:05 +00:00
Arnold Schwaighofer
314e5d9378 stdlib: Remove dead code
Swift SVN r31602
2015-09-01 16:45:04 +00:00
Arnold Schwaighofer
55e4795972 stdlib: Fix formatting.
Swift SVN r31601
2015-09-01 16:45:04 +00:00
Arnold Schwaighofer
de90e57428 stdlib: Reformulate to make ARC's job easier
The extra control-flow seems to inhibit ARC and we end up with an extra
retain-release regressing LevenshteinDistance by 40%.

rdar://22479186

Swift SVN r31588
2015-08-31 18:02:12 +00:00
Arnold Schwaighofer
eb3d5e4d4a Revert "stdlib: Move the darwin String implementation over to use the ICU library."
Revert "Add test cases to exercise the native String vs cocoa buffer String path."
Revert "stdlib: Add back a test I removed"
Revert "stdlib: Fix hasPrefix,hasSuffix tests"
Revert "stdlib: Add documentation for the cached ascii collation tables"

This reverts commit 31493, 31492, 31491, 31490, 31489.

There are linking errors in SwiftExternalProjects (we probably have to link
against libicucore somewhere).

Swift SVN r31543
2015-08-27 21:02:32 +00:00
Arnold Schwaighofer
9fd52b9123 stdlib: Instead of calling reserveCapacity in Array.init(_uninitializedCount)
directly construct a buffer of the right size

This safes a uniqueness check and unecessary code bloat when inlining
reserveCapacity.

rdar://22446738

Swift SVN r31540
2015-08-27 20:07:07 +00:00
Nadav Rotem
7a49d7e334 [codesize] Keep _print_unlocked in the swift dylib.
We keep most of our printing code in the swift dylib but we missed
this method in our last refactoring.

Swift SVN r31508
2015-08-26 22:14:19 +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
Nadav Rotem
b93256503a [codesize] Keep _assertionFailed in the swift dylib.
This commit annotates _assertionFailed with an attribute
that will keep in in the swift dylib. We don't care about
the performance of this function because it happens when
the program crashes. Keeping it in the swift dylib helps
in reducing the code size of the user app because it keeps
more of the printing and string.utf8 logic in the dylib.

Swift SVN r31506
2015-08-26 22:14:12 +00:00
Arnold Schwaighofer
502f1e3de1 stdlib: Move the darwin String implementation over to use the ICU library.
Reapply of 31474 with a fix in _compareCocoaBuffer to use the bufferSizeRhs
variable instead of bufferSizeLhs for the right hand side buffer.

We no longer create intermediate NSString copies to compare and hash swift
Strings. Instead we call directly into the ICU library.

I measured a 1.2 to 2x improvement on dictionary benchmarks as a result of this.
The SuperChars benchmark is also about 1.2x faster because of this.

Pure ASCII comparison has gotten a little bit slower (20% on a pure comparison
micro-benchmark) because we no longer do a memcmp. Doing a memcmp on ASCII is
not the same as the default unicode collation. Instead we have to a string scan.
The default unicode collation does not order like ASCII does and ignores
characters (for example the \0 character).

rdar://18992510

Swift SVN r31489
2015-08-26 15:14:18 +00:00
Arnold Schwaighofer
2d8f29e710 Revert "stdlib: Fix hasPrefix,hasSuffix tests"
Revert "stdlib: Add back a test I removed"
Revert "Add test cases to exercise the native String vs cocoa buffer String path."
Revert "stdlib: Move the darwin String implementation over to use the ICU library."

This reverts commit r31477, r31476, r31475, r31474.

Commit r31474 broke the ASAN build.

Swift SVN r31488
2015-08-26 13:09:03 +00:00
Chris Willmore
9c1f3e907a Revert "Transform EditorPlaceholderExpr into trap if executed in playground mode."
This reverts commit r31481, which apparently needed some parallel
changes to SourceKit and broke the build as a result.

Swift SVN r31483
2015-08-26 05:28:04 +00:00
Chris Willmore
0addd80bb3 Transform EditorPlaceholderExpr into trap if executed in playground mode.
Allow untyped placeholder to take arbitrary type, but default to Void.
Add _undefined<T>() function, which is like fatalError() but has
arbitrary return type. In playground mode, merely warn about outstanding
placeholders instead of erroring out, and transform placeholders into
calls to _undefined(). This way, code with outstanding placeholders will
only crash when it attempts to evaluate such placeholders.

<rdar://problem/21167372> transform EditorPlaceholderExpr into fatalError()

Swift SVN r31481
2015-08-26 04:50:55 +00:00
Arnold Schwaighofer
5a25a00d1f stdlib: Move the darwin String implementation over to use the ICU library.
We no longer create intermediate NSString copies to compare and hash swift
Strings. Instead we call directly into the ICU library.

I measured a 1.2 to 2x improvement on dictionary benchmarks as a result of this.
The SuperChars benchmark is also about 1.2x faster because of this.

Pure ASCII comparison has gotten a little bit slower (20% on a pure comparison
micro-benchmark) because we no longer do a memcmp. Doing a memcmp on ASCII is
not the same as the default unicode collation. Instead we have to a string scan.
The default unicode collation does not order like ASCII does and ignores
characters (for example the \0 character).

rdar://18992510

Swift SVN r31474
2015-08-26 03:36:59 +00:00
Arnold Schwaighofer
41119cb80b stdlib: Don't crash on strings that require a bigger buffer on normalization.
This is currently a linux only issue.

Swift SVN r31467
2015-08-26 02:00:19 +00:00
Dmitri Hrybenko
217ef5aa12 stdlib: fix legacy Mirror for ArraySlice
The mirror wasn't adjusted to account for non-zero-based indices of
ArraySlice.

rdar://problem/22373053

Swift SVN r31409
2015-08-22 08:04:58 +00:00
Dmitri Hrybenko
6360a590b5 Revert "Fix a problem where the legacy Mirror for ArraySlice would cause an out-of-bounds access if the slice is not zero-based"
This reverts commit r31398.  The commit does not have tests and
introduces code duplication.

Swift SVN r31408
2015-08-22 08:04:51 +00:00
Enrico Granata
fe27790126 Fix a problem where the legacy Mirror for ArraySlice would cause an out-of-bounds access if the slice is not zero-based
rdar://problem/22373053



Swift SVN r31398
2015-08-21 23:08:47 +00:00
Dmitri Hrybenko
bb3b00a0e0 stdlib: work around type checker not being able to deduce
RandomAccessIndexType.Distance

Fixes rdar://22373461, works around rdar://22381498

Swift SVN r31384
2015-08-21 18:18:23 +00:00
Dmitri Hrybenko
779444eec3 stdlib: rewrite the comment on CustomPlaygroundQuickLookable
It used to refer to Mirror and other related concepts, while it should
be refering to PlaygroundQuickLook.

rdar://21012615

Swift SVN r31374
2015-08-21 01:37:10 +00:00
Dmitri Hrybenko
951e65116d stdlib: document that unsafe pointers should be suitably aligned
rdar://21880864

Swift SVN r31373
2015-08-21 01:24:31 +00:00
Dmitri Hrybenko
f6e23d42cf stdlib: fix a bug in Character._SmallUTF8
8-byte UTF-8 sequences were throwing _SmallUTF8 into an infinite loop.

rdar://21005978

Swift SVN r31368
2015-08-20 21:49:36 +00:00
Dmitri Hrybenko
14466151eb stdlib: rename ImplicitlyUnwrappedOptional's parameter to Wrapped
We renamed the parameter of Optional, but missed
ImplicitlyUnwrappedOptional.

rdar://22332469

Swift SVN r31315
2015-08-18 22:33:10 +00:00
Dmitri Hrybenko
8311c05461 stdlib: add a default implementation for MutableCollection.subscript().set
rdar://20722366

Swift SVN r31241
2015-08-14 03:12:23 +00:00
David Farler
83a2b5cecd Provide renamed fixit for Optional.T -> Optional.Wrapped
rdar://problem/22281537

Swift SVN r31240
2015-08-14 02:18:31 +00:00