Commit Graph

1309 Commits

Author SHA1 Message Date
Erik Eckstein
384d936850 Use assumeNonNegative for the array body count.
This should help to optimize the range check in isValidSubscript to a single unsigned integer comparison.
But this is not done yet, because it also needs an optimization in llvm, which I'm currently working on.

Together with the llvm change there will be an performance improvement for array benchmarks, where the
range check cannot be hoisted out of a loop. E.g. ~ +30% on QuickSort.



Swift SVN r23583
2014-11-26 09:58:37 +00:00
Erik Eckstein
54e1071da0 Add a builtin assumeNonNegative.
It returns the argument and specifies that the value is not negative.
It has only an effect if the argument is a load or call.

The effect of this builtin is that for the load/call argument a positive range metadata is created in llvm ir.

I also added a public function _assumeNonNegative(x: Int) -> Int in the stdlib.
To be on the save side, I prefixed it with an underscore. But maybe it makes sense to make it available for all users.



Swift SVN r23582
2014-11-26 09:53:14 +00:00
Graham Batty
e537c75d0c Revert "Disable existential metatype casting on non-objc."
This reverts commit 3e918838b3708bf2287e7caab437ccf72fe9a3f6.

Swift SVN r23579
2014-11-24 17:42:19 +00:00
Graham Batty
7ed843aab9 Revert "Implement String Comparable and Hashable conformances for non-objc"
This reverts commit 6d086ae7fe6725c74924ff410c562949a286e7d1.

Swift SVN r23576
2014-11-24 17:42:05 +00:00
Graham Batty
277891d8b5 Disable existential metatype casting on non-objc.
Swift SVN r23575
2014-11-24 17:40:44 +00:00
Graham Batty
396eca75b4 Implement String Comparable and Hashable conformances for non-objc
This is just a basic implementation of each, with some questions
lingering about whether to do unicode normalization (and if so how),
but it gets things going.

Swift SVN r23572
2014-11-24 17:40:24 +00:00
Dave Abrahams
d9c750eefd [stdlib] Remove ArrayBuffer indirection
The case where Array stores class instances no longer requires an
intermediate indirect buffer object.

Also fixes <rdar://problem/17348939>

These are the speed changes < 0.95x and > 1.05x, as I measured them.
Although I don't have great confidence in these numbers, some are
consistent with Arnold's measurements, FWIW.

-O:
0.93 ArrayLiteral
1.56 Ary
1.39 Ary2
1.06 CaptureProp
1.93 ClassArrayGetter
1.08 DeltaBlue
1.08 DollarChain
1.13 InsertionSort
1.08 PrimeNum
1.11 RC4
0.93 Rectangles
1.08 SwiftStructuresBubbleSort

-Onone:
1.06 ArrayLiteral
1.10 ArraySubscript
1.12 Ary
1.12 Ary2
1.10 Ary3
1.20 ClassArrayGetter
1.19 DeltaBlue
1.08 DollarChain
1.09 Hash
1.07 Havlak
1.10 HeapSort
1.11 ImageProc
1.17 InsertionSort
1.18 Memset
1.11 NBody
1.07 PrimeNum
1.11 QuickSort
1.12 RC4
1.08 Rectangles
1.07 SelectionSort
1.06 StringBuilder
1.12 SwiftStructuresBubbleSort
1.10 Walsh
1.12 XorLoop

-Ounchecked:
0.91 ArrayLiteral
1.74 Ary
1.53 Ary2
2.08 ClassArrayGetter
1.19 DeltaBlue
1.06 DollarChain
1.07 Havlak
1.09 ImageProc
1.22 InsertionSort
0.89 PopFrontArrayGeneric
1.11 PrimeNum
0.85 QuickSort
1.10 RC4
1.12 Rectangles
1.06 StrToInt
1.11 SwiftStructuresBubbleSort

Swift SVN r23551
2014-11-22 08:19:57 +00:00
Joe Groff
b60a30c84b stdlib: Make isUniquelyReferenced shims properly return bool.
rdar://problem/18573806 is fixed.

Swift SVN r23547
2014-11-22 05:36:38 +00:00
Dave Abrahams
5798cf9014 [stdlib] Fix a dumb omission
This should fix the build

Swift SVN r23509
2014-11-21 04:27:15 +00:00
Dave Abrahams
15e195943e [stdlib] BridgeStorage: uniqueness check fast path
When we know we've got a native object and no spare bits set, we can use
a faster check for uniqueness.

Swift SVN r23506
2014-11-21 01:39:55 +00:00
Dave Abrahams
bf233c5b46 [stdlib] BridgeStorage: rename a property
This name is more consistent with the convention used throughout the
runtime: use underscores to separate the preconditions of partial
functions from the rest of their names.

Swift SVN r23505
2014-11-21 01:39:55 +00:00
Dave Abrahams
de8967e2cd [stdlib] Copious force-inling
Just trying to remove possible overheads in the new Array
implementation.  It doesn't seem to affect performance, though.

Swift SVN r23504
2014-11-21 01:39:54 +00:00
Dave Abrahams
0c1e5265c4 [stdlib] Degenericize some BridgeObject primitives
There's really no reason to make the compiler and optimizer work hard,
here.

Also, make some sanity checks more informative

Swift SVN r23503
2014-11-21 01:39:54 +00:00
Dave Abrahams
b9342e5c1b [stdlib] Array: one-element _typeCheck, for ARC
the ARC optimizer does not handle loops well, and so can get blocked by
the presence of a loop over the range. Therefore, add a single-element
check for the common case where we're not slicing.

Swift SVN r23502
2014-11-21 01:39:53 +00:00
Maxwell Swadling
530ae1777a Added ASCII fast paths for common string operations
- ==, <, lowercaseString and uppercaseString on String now have ASCII fast paths
- Fixes rdar://problem/17962640

Swift SVN r23494
2014-11-21 00:07:32 +00:00
Maxwell Swadling
55f3289054 Added additional tests and comments to String
Swift SVN r23490
2014-11-20 22:33:13 +00:00
Dave Abrahams
66da8500c7 [stdlib] Kill a stray backslash
Swift SVN r23467
2014-11-20 03:41:10 +00:00
Dave Abrahams
1ed31fa31a [stdlib] Fix BridgeStorage!
Fix the test so it actually runs, then fix all the bugs it finds, then
extend the test to cover the no-bits-fast-path functionality.

Swift SVN r23466
2014-11-20 03:41:10 +00:00
Dave Abrahams
44a18861b6 [stdlib] BridgeStorage: no-bits fast path
When there's static knowledge that no spare bits are to be set, it's
faster to use that knowledge.  We need a proper builtin to let us drop
the reinterpretCasts.

Swift SVN r23465
2014-11-20 03:41:09 +00:00
Mark Lacey
d344976d3d Remove @inline(__always) on a var decl.
@inline(__always) can only be used on functions and constructors.

Swift SVN r23462
2014-11-20 03:01:43 +00:00
Dave Abrahams
4785e7b2e9 [stdlib] Explicit keywords for BridgeStorage.init
This improves clarity of usage, especially when we add a fast
constructor for the "native with no spare bits set" case.

Swift SVN r23460
2014-11-20 01:05:39 +00:00
Dave Abrahams
e78ad13b7f [stdlib] Force-inline some bitmask constants
Swift SVN r23454
2014-11-19 22:57:44 +00:00
Dave Abrahams
e581216d28 [stdlib] Fix a comment
Swift SVN r23453
2014-11-19 22:57:44 +00:00
Dave Abrahams
2f29db9bfa [stdlib] Finish incomplete comment
Swift SVN r23432
2014-11-19 06:21:49 +00:00
Dave Abrahams
d4e06bd174 [stdlib] Clean up a sanity check
Swift SVN r23431
2014-11-19 06:21:01 +00:00
Dave Abrahams
68fbea2988 BridgeObject: native object with no spare bits set
Naturally, the fast path for things like Array<Int> has to be that no
masking is required to get at the buffer.  Therefore, the state with no
spare bits set needs to be reserved for native objects.  After the
change, an ObjC non-tagged pointer is stored with all spare bits set, and
native objects are stored with 0..<N bits set, where N is the number of
spare bits.  ObjC tagged pointers are still stored verbatim.

Swift SVN r23430
2014-11-19 06:07:19 +00:00
Dave Abrahams
726aba123a [stdlib] BridgeStorage optimizations
Stop trafficking in optionals and using checked arithmetic; the
optimizer doesn't like that.  Also drop a needless cast, fix up some
names, and accept a native 2nd argument.  Only classes imported from
ObjC actually have non-native refcounting, and we don't really care
about enforcing that for the 2nd argument.  It's just expected to be a
possibly-non-native class.

Swift SVN r23396
2014-11-18 02:46:09 +00:00
Dave Abrahams
9d6cccbf11 Revert "[stdlib] Workarounds for <rdar://18992875>"
This reverts commit r23361 now that Joe fixed the problem

Swift SVN r23388
2014-11-17 22:54:39 +00:00
Maxwell Swadling
5f75d2dca8 Removed _stdlib_dynamicCastToExistential1 hack
It is no longer required.

Swift SVN r23379
2014-11-17 20:56:41 +00:00
Dave Abrahams
d7689759f9 [stdlib] BridgeStorage: rename uniqueness check
The name should reflect the fact that the check only ever returns true
in the native case.

Swift SVN r23362
2014-11-17 02:15:27 +00:00
Dave Abrahams
f7ae19f7b9 [stdlib] Workarounds for <rdar://18992875>
Some brutal casting and type punning can get us past this bug, for now.

Swift SVN r23361
2014-11-17 02:15:26 +00:00
Dave Abrahams
d59e781b61 [stdlib] Kill some dead code
That this code is dead implies we are throwing away the knowledge that
we have a native buffer whenever we downcast an array.  That'll be fixed
when the array buffer simplification goes in.

Swift SVN r23350
2014-11-15 03:42:12 +00:00
Dave Abrahams
4111b94d1f [stdlib] _BridgeStorage: use Builtin.BridgeObject
Swift SVN r23348
2014-11-15 01:54:53 +00:00
Graham Batty
04f8efbdf5 Correctly calculate non-objc instance size and rename to reflect.
Renames swift_class_getInstanceSize to
swift_class_getInstancePositiveExtentSize to reflect that it is
the size of the object after the instance address point.

Swift SVN r23333
2014-11-14 22:09:20 +00:00
David Farler
2539ebdabf <rdar://problem/18979003> _Set([1,2,3]) crashes in Xcode playground: assertion in IDEPlaygroundQuickLookForStructure.m:405
Swift SVN r23319
2014-11-14 02:32:35 +00:00
Michael Gottesman
9a691a55b2 [playgrounds] Implement _swift_isClass(x: Any) -> Bool.
This is acting as a temporary work around until the more general
getTypeKind() is finalized from an API perspective.

The reason that removing this now instead of waiting makes sense is:

1. The previous way playgrounds was performing this check was using the runtime
c++ implementation of swift_isClassOrObjCExistential via @asmname. We
want to move away from the @asmname approach in general since it is
brittle since it leads to loose cupling of dependencies.

2. The @asmname version in playgrounds caused the deserializer to assert since
the c++ version of swift_isClassOrObjCExistential() does not match the signature
of the swift declaration of swift_isClassOrObjCExistential().

This allows us to avoid the aforementioned issues and make forward
progress on re-enabling the playground logger with optimization.

rdar://18841292

Swift SVN r23307
2014-11-13 19:35:59 +00:00
Dmitri Hrybenko
5f4a31aef4 Revert "stdlib: put back C_ARGC and C_ARGV for now to stage in the API change"
This reverts commit r23288.  All users have been updated.

Swift SVN r23300
2014-11-13 07:44:15 +00:00
Dmitri Hrybenko
2aef2c3c7d stdlib: put back C_ARGC and C_ARGV for now to stage in the API change
Swift SVN r23288
2014-11-12 22:59:20 +00:00
Dmitri Hrybenko
4cd60e6b4e stdlib/Set: add #if guards for non-ObjC platforms
Swift SVN r23266
2014-11-12 09:05:39 +00:00
David Farler
d0718c69fc Prefix Set<T> with underscore for API development
Swift SVN r23263
2014-11-12 07:07:01 +00:00
David Farler
c453eb4c48 Add Set type.
<rdar://problem/14661754> TLF: [data-structure] Set<T> data type + Bridging from NSSet

Swift SVN r23262
2014-11-12 07:07:00 +00:00
Dave Abrahams
b6c7d89ee7 [stdlib] Don't let gyb interfere with doc comments
The interposed line directive comment "// #line ..." prevents Swift from
associating the doc comment with the declaration.  Tested, this time,
and everything!

Swift SVN r23260
2014-11-12 02:58:40 +00:00
Maxwell Swadling
2bbf6b9293 [stdlib] changed C_ARG{C,V} @availability to provide fix-its
Swift SVN r23255
2014-11-12 00:09:52 +00:00
Joe Groff
08fe138808 Runtime: Generate a human-understandable name for Any.Type.
Expose this in the stdlib as _typeName(Any.Type) -> String, pending API review.

Swift SVN r23254
2014-11-11 23:38:24 +00:00
Arnold Schwaighofer
9ac0595334 Revert "[stdlib] Don't let gyb interfere with doc comments"
This reverts commit r23247.

It broke the incremental builder - I could reproduce this locally with a clean
rebuild.

Swift SVN r23250
2014-11-11 23:03:39 +00:00
Maxwell Swadling
963619cdc1 [stdlib] C_ARG{c,v} renamed to argc/unsafeArgv
Fixes rdar://problem/17229052
Make it clear C_ARGV var is unsafe.
Made it impossible to set the argc/unsafeArgv outside of the stdlib.
Refactored tests to not use C_ARG{C,V}.
Made C_ARG{C,V} unavailable.

Swift SVN r23249
2014-11-11 22:34:49 +00:00
Dave Abrahams
392a675b05 [stdlib] Don't let gyb interfere with doc comments
The interposed line directive comment "// #line ..." prevents Swift from
associating the doc comment with the declaration.

Swift SVN r23247
2014-11-11 22:16:31 +00:00
Arnold Schwaighofer
06a0a23562 Add a destructor memory effect analysis
This adds an analysis to the compiler that identifies types that are may store
to memory on destruction.

It adds a compiler known protocol _DestructorSafeContainer that allows the
standard library to identify containers whose destructor's memory effects
depends strictly on the type parameters of the container.

Array<T> : _DestructorSafeContainer {} may not store to memory during
destruction if the bound T is a type that does not store to memory on
destruction.

This is needed to deduce that for example Array<Array<Int>> is does not store to
memory on destruction (e.g during a call to release).

rdar://18940376

Swift SVN r23242
2014-11-11 19:27:41 +00:00
Maxwell Swadling
03021eccb3 [stdlib] simplified implementation of Process
Fixes rdar://problem/17257011

Swift SVN r23241
2014-11-11 19:20:48 +00:00
Graham Batty
dc6a776d10 stdlib: Use config directives to work without objective-c.
Swift SVN r23211
2014-11-10 20:06:25 +00:00