Commit Graph

4650 Commits

Author SHA1 Message Date
Arnold Schwaighofer
e1131ce3ee stdlib: Add back a test I removed
Reapply of 31476.

Swift SVN r31491
2015-08-26 15:14:20 +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
2588f44d83 stdlib: Add back a test I removed
Swift SVN r31476
2015-08-26 03:57:24 +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
811b779438 stdlib: Cache the unicode collation values for the ASCII range and use this
cache instead.

Create two tables. One that caches the ASCII ordering as returned by the root
collator. This table is static and we can use this for comparison and ordering.
The second table is cached the first time it is queried. This table caches the
actual collation values. We use this table for hashing. Collation values might
change between versions of the ICU dylib and so we can't store this in a static
table.

Use the second table to create a unicode hash for ascii strings.

The first table will be used in a follow-up commit.

Swift SVN r31472
2015-08-26 02:55:45 +00:00
Arnold Schwaighofer
3ec9325c58 stdlib: Don't hash in the length of the string
Some characters are not considered when comparing strings. Hashing in the length
would cause a difference of hash values in equal strings.

Swift SVN r31468
2015-08-26 02:00:20 +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
Dmitri Hrybenko
6402fda0c5 stdlib: remove a bunch of dynamic initializers from the library and overlays
Swift SVN r31403
2015-08-22 04:51:39 +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
36620d8229 stdlib: add an overlay for sem_open(), which is variadic in C
Patch by Mish Awadah.

Swift SVN r31397
2015-08-21 22:25:32 +00:00
Roman Levenstein
18057b65a9 Get rid of static. NFC.
Swift SVN r31392
2015-08-21 21:21:08 +00:00
Dmitri Hrybenko
c93bf3bbf0 stdlib: remove 58 global initializers from the Darwin overlay
This change removes the global initializers, but the constants are
still not inlineable.  Filed rdar://22384493 for that.

Swift SVN r31390
2015-08-21 21:05:38 +00:00
Roman Levenstein
19155fcd69 Change #if __APPLE__ to #if defined(__APPLE__). NFC.
This is required, because  __APPLE__ can be either defined to 1 or not defined at all.

Swift SVN r31389
2015-08-21 20:43:21 +00:00
Roman Levenstein
b7e023c2a7 [swift-runtime] Use vm_page_mask if we are compiling for an Apple OS.
Thanks to this, we can get rid of these two dirty symbols:
19f0f24e0 __ZZN17MetadataAllocator5allocEmE12pagesizeMask 8
19f0f24e8 __ZGVZN17MetadataAllocator5allocEmE12pagesizeMask 8

This is part of the effort to put the stdlib into a shared cache.

rdar://22375554

Swift SVN r31388
2015-08-21 19:57:03 +00:00
Dmitri Hrybenko
f7c0c57214 stdlib: remove emacs commands left over from this file being a gyb file
Swift SVN r31386
2015-08-21 18:44:26 +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
Jordan Rose
5a82ddfd08 [ClangImporter] If a name contains "unsigned", import NSUInteger as UInt.
This takes care of things like NSNumber's 'init(unsignedInteger:)' and
'unsignedIntegerValue'.

rdar://problem/19134055

Swift SVN r31354
2015-08-19 22:10:48 +00:00
Jordan Rose
53b1cf2b09 [CMake] Fix dependencies for CloudKit.
...which unfortunately meant splitting tvOS out from iOS.

Swift SVN r31343
2015-08-19 20:57:02 +00:00
Dmitri Hrybenko
3f7d64c532 Diagnose invalid arguments for '#if _runtime()'
rdar://problem/20117677

Swift SVN r31336
2015-08-19 16:55:39 +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
Roman Levenstein
0b5157b104 Reduce the amount of memory required for caching protocol conformances.
The reason for this patch:
- Currently, when we invoke swift_conformsToProtocol for the first time, we load ALL protocol conformances into conformances cache (to avoid rescanning the conformances section next time), which consumes about 50-70KB of memory even per minimal Swift application (e.g. hello-world app). While it may seem not so much, if you think about apps running on watchOS or writing daemons in Swift (and we have about 120 of those running on iOS), it is a lot of memory.
- In reality, only a couple of those conformances are used by applications, which means that most of the loaded conformances are useless and just consume the memory.

The implemented solution:
- Load only the conformances which were queried by calling swift_conformsToProtocol. Don’t try to load any other conformances, when not asked to do so.
- Use std::vector instead of std::deqeue for SectionsToScan. This shaves off another 4KB of memory, because std::deque reserves at least 4KB by default.

This patch does not seem to produce any detectable performance hit on our benchmark suite.

With these changes, the minimal "hello world" application consumes only 9.8KB, whereas before it used to consume 60KB.

rdar://22331482

Swift SVN r31310
2015-08-18 21:35:37 +00:00
David Farler
9e4d52c9cb Reinstate watchOS and other SDK overlays to build against the public SDKs.
Un-revert the below commits with the following addition:
add declarations for posix_spawn related APIs to SwiftPrivateDarwinExtras.
posix_spawn-related APIs aren't available in the public SDKs, so force past
the availability by creating our own stubs in the internal DarwinExtras
library.

r31244, r31245

CMake: build all platforms except watchOS using the public SDK

Covers rdar://problem/21145996.
A step towards rdar://problem/21099318.

Switch SDK overlays to use the public SDK

I had to cut the dependency on CrashReporterClient.h and reimplement
some of that code inline in the Swift runtime.  This shoud be OK (even
though not very clean), since the layout of CrashReporter sections is
ABI.

rdar://21099318

Swift SVN r31252
2015-08-14 22:09:49 +00:00
Dmitri Hrybenko
c75fc00cec Revert "CMake: build all platforms except watchOS using the public SDK"
This reverts commit r31244.  It broke the buildbot.

Swift SVN r31247
2015-08-14 18:56:15 +00:00
Dmitri Hrybenko
f2fce4388f Revert "Switch SDK overlays to use the public SDK"
This reverts commit r31245, it broke buildbots.

Swift SVN r31246
2015-08-14 18:56:13 +00:00
Dmitri Hrybenko
b9ef88247d Switch SDK overlays to use the public SDK
I had to cut the dependency on CrashReporterClient.h and reimplement
some of that code inline in the Swift runtime.  This shoud be OK (even
though not very clean), since the layout of CrashReporter sections is
ABI.

rdar://21099318

Swift SVN r31245
2015-08-14 17:26:06 +00:00
Dmitri Hrybenko
dd38372fb7 CMake: build all platforms except watchOS using the public SDK
Covers rdar://problem/21145996.
A step towards rdar://problem/21099318.

Swift SVN r31244
2015-08-14 17:26:04 +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
Chris Willmore
51f08e0285 Add FileReference object literals and _FileReferenceLiteralConvertible protocol.
<rdar://problem/21781451> Add file literal to Swift

Swift SVN r31232
2015-08-13 22:38:55 +00:00
Chris Willmore
e4ff8fdc05 Make image literals non-optional by routing delegation of non-failable
literal initializer to underlying failable initializer through
implicitly-failable initializer (proper solution is covered in
22276505).

<rdar://problem/20788137> Image literals should not be optional

Swift SVN r31229
2015-08-13 22:11:47 +00:00
Jordan Rose
cb2c6a6d08 Demangle 'So' as '__ObjC' rather than 'ObjectiveC'.
And similarly 'SC' as '__C' rather than 'C'.

There's a real module named 'ObjectiveC', and imported decls are not
all in it.

Swift SVN r31225
2015-08-13 21:22:02 +00:00
Dave Abrahams
146d2daa9d [stdlib] Add missing nullability to reflected NSString API
getBytes still lacks the ability to take an optional buffer, but Ali
agrees that we can leave that off for this release in light of the fact
that we have lengthOfBytesUsingEncoding.

Swift SVN r31223
2015-08-13 20:11:40 +00:00
Dmitri Hrybenko
33631ca9c4 stdlib: Fix a bug in split()
split() used to drop the tail of the sequence under certain
circumstances.

rdar://22200821

Swift SVN r31207
2015-08-13 05:31:07 +00:00
Dmitri Hrybenko
4efa7f4372 stdlib: fix the docs to refer to the actual parameter name
Swift SVN r31205
2015-08-13 04:59:16 +00:00
Dmitri Hrybenko
8a435da63b Un-XFAIL tests for partition()
The underlying bug is fixed now.

rdar://21780567

Swift SVN r31196
2015-08-13 01:21:25 +00:00
Dmitri Hrybenko
a067fb004c stdlib: re-add the part of the comment that was dropped during a refactoring
Swift SVN r31194
2015-08-12 23:41:58 +00:00
Dave Abrahams
06bb06452b [stdlib] String.init(data: NSData, encoding: UInt)
Fixes <rdar://19872780>

Swift SVN r31191
2015-08-12 21:44:13 +00:00
Dave Abrahams
a8d56c3f54 [stdlib] Shuffle methods to keep comments in sync
Swift SVN r31190
2015-08-12 21:44:09 +00:00
Dmitri Hrybenko
ee20926b20 stdlib: rename join() to joinWithSeparator()
rdar://22022419, rdar://21474222

Swift SVN r31188
2015-08-12 21:16:38 +00:00
Dmitri Hrybenko
22b15bda60 stdlib: loosen the type signature of join()
rdar://17696054

Swift SVN r31187
2015-08-12 21:16:35 +00:00
Dmitri Hrybenko
d6f04ade75 stdlib: convert join() into a protocol extension
Part of rdar://22022419

Swift SVN r31186
2015-08-12 21:16:25 +00:00
Dave Abrahams
713ae47caf [stdlib] Explicitly document how to print without trailing newline.
Swift SVN r31181
2015-08-12 18:46:43 +00:00