Commit Graph

1397 Commits

Author SHA1 Message Date
Dmitri Hrybenko
d68a5c4c98 stdlib: finish implementation of atomics for initializing an ARC
reference, add tests

Swift SVN r21873
2014-09-11 14:52:58 +00:00
Dmitri Hrybenko
a61e4c205a stdlib: document that sort() is not a stable sort
Swift SVN r21870
2014-09-11 10:59:50 +00:00
Dmitri Hrybenko
5000a983a6 stdlib/Unmanaged: change the precondition for non-null pointer to a
debug precondition

Swift SVN r21869
2014-09-11 08:52:55 +00:00
Dave Abrahams
904e0c4203 [stdlib] Fix sorted()
Remove the overload for MutableCollectionType and make it return a
regular Array, as the comment said.  Together with r21829 this fixes
<rdar://problem/18286522>

Swift SVN r21844
2014-09-10 19:05:12 +00:00
Dmitri Hrybenko
b68d147ca1 stdlib/Unmanaged: trap when attempting to create an Unmanaged from a
null pointer

Swift SVN r21838
2014-09-10 14:15:06 +00:00
Dmitri Hrybenko
4b19606551 stdlib: fix definition of atomics for 32-bit platforms
Swift SVN r21837
2014-09-10 13:05:14 +00:00
Dmitri Hrybenko
96d00d70b5 StdlibUnittest: add infrastructure for race tests (see examples)
This will be used to test rdar://18191358

Swift SVN r21836
2014-09-10 11:58:45 +00:00
Dmitri Hrybenko
1bac1e6855 stdlib/Dictionary: convert some 'var's to 'let's
Swift SVN r21835
2014-09-10 11:38:44 +00:00
Dmitri Hrybenko
57983579ac stdlib: move declarations of runtime entry points for atomics to
Runtime.swift.gyb

Swift SVN r21832
2014-09-10 08:07:45 +00:00
Dave Abrahams
09793716cb [stdlib] try to measure sequences before array-izing
When creating an array from a SequenceType not statically known to be a
CollectionType, don't neglect to pre-allocate based on its
underestimated count.

Swift SVN r21829
2014-09-10 03:21:14 +00:00
Dave Abrahams
c467825bc2 [stdlib] any/all algorithms, keyword for contains
Expose any, all on Array and all the Lazy sequence adapters.  Make the
'contains' algorithm that takes a predecate unavailable in favor of
'any', which does the same thing.

Fixes <rdar://problem/18190149> [algorithm] `contains` syntax is ambiguous

Swift SVN r21810
2014-09-09 20:39:39 +00:00
Dave Abrahams
69075bc61d [stdlib] Kill unintended argument label
Fixes <rdar://problem/18232095> Remove mandatory keyword from generic String init

Swift SVN r21801
2014-09-09 03:50:40 +00:00
Dmitri Hrybenko
6a85dc4c0f stdlib: fix strange indentation
Swift SVN r21769
2014-09-08 08:33:37 +00:00
Joe Groff
419ba5cbea Change RawRepresentable to use failable initializers and property requirements.
Redefine the RawRepresentable protocol to use an 'init?' method instead of 'fromRaw(Raw)', and a 'raw' get-only property instead of 'toRaw()'. Update the compiler to support deriving conformances for enums and option sets with the new protocol. rdar://problem/18216832

Swift SVN r21762
2014-09-06 18:40:14 +00:00
Dmitri Hrybenko
7d51b2b7fe stdlib: improve comment for sorted() overload with predicate and reduce
comment duplication with gyb code

Swift SVN r21742
2014-09-05 15:27:25 +00:00
Michael Gottesman
e8df864581 [stdlib] Change _fixLifetime<T> to use Builtin.fixLifetime now that we lower fix_lifetime to swift_keepAlive in IRGen.
Also remove the old swift_keepAlive and rename swift_keepAlive2 => swift_fixLifetime.

rdar://16464507

Swift SVN r21723
2014-09-04 22:58:37 +00:00
Dmitri Hrybenko
149d3aaa8f stdlib: docs: sort() is not a stable sort
rdar://17570356


Swift SVN r21703
2014-09-04 11:27:53 +00:00
Dave Abrahams
c16987cc8b [stdlib] Add/use unsafeDowncast
now that <rdar://problem/18184883> is fixed, this factoring can be done

Swift SVN r21647
2014-09-02 17:26:03 +00:00
Dave Abrahams
27809a507a [stdlib] Don't @asmname POSIX APIs
For reasons not entirely clear yet, this can cause problems in the
compiler when some modules bring in the same names via the Darwin
module (see <rdar://problem/18184795>).  Use SwiftShims instead.

Swift SVN r21646
2014-09-02 17:26:03 +00:00
Dmitri Hrybenko
4139fe129e stdlib: underscore-prefix private type Character.SmallUTF16
Swift SVN r21640
2014-09-02 14:26:51 +00:00
Dmitri Hrybenko
51a8becf1c stdlib/String: strength-reduce some String methods: prefer StringCore.append
over String.extend

Performance testsuite changes over 2% are as follows.  A lot of tests unrelated
to String have been affected because of measurement noise and because strings
are used in result verification.

                 Ary3     4.8%
          CaptureProp    10.3%
           Dictionary    -4.0%
         EditDistance     2.8%
               Forest    -4.0%
                 Hash     8.6%
        InsertionSort     6.7%
                 Life    -2.3%
               MatMul     2.6%
           NestedLoop     3.9%
        PopFrontArray     2.9%
             PrimeNum     3.6%
                Prims     2.2%
              SmallPT    -2.1%
               TwoSum     4.1%

Swift SVN r21629
2014-09-01 14:30:41 +00:00
Erik Eckstein
962a50160a stdlib: Optimize convertion from array literal for Array
Replaced the general implementation (which works for all array types) to the obvious and trivial implementation for Array.
This speeds up array literal initialization by about 2x.



Swift SVN r21626
2014-09-01 08:21:13 +00:00
Dave Abrahams
42a2f263fd [stdlib] Add/use unsafeAddressOf
Turning a class into an UnsafePointer should be available to users, and
both safer and more optimizable than using unsafeBitCast.

Swift SVN r21593
2014-08-29 22:33:13 +00:00
Dmitri Hrybenko
60cf5d3d1b SwiftIntTypes.py: remove transitional '_new' suffix from a function name
Swift SVN r21579
2014-08-29 15:38:22 +00:00
Dmitri Hrybenko
cf1d5722a9 stdlib/FixedPoint: precondition for shifts: use a SIL-compile-time
constant instead of an expression that will be folded only by LLVM

Swift SVN r21576
2014-08-29 15:10:05 +00:00
Dmitri Hrybenko
4ecfc2b244 stdlib/FixedPoint: fix strange indentation
Swift SVN r21574
2014-08-29 15:09:59 +00:00
Dmitri Hrybenko
cb9e5c2c86 stdlib: use simpler interface to iterate over integer types
Swift SVN r21573
2014-08-29 14:32:46 +00:00
Dmitri Hrybenko
c5181c2d65 stdlib/FixedPoint: fix hash computation for [U]Int64 on 32-bit platforms
It used to trap if the value of [U]Int64 was outside the Int32 range.

rdar://18113807

Swift SVN r21572
2014-08-29 13:48:32 +00:00
Dmitri Hrybenko
14899abdf5 stdlib/FixedPoint: define the same set of 'truncatingBitPattern'
initializers on all platforms

rdar://18167806

Swift SVN r21570
2014-08-29 10:32:33 +00:00
Dmitri Hrybenko
985def47c9 stdlib: improve performance of string appending
CaptureProp ,  -21.8%
             HeapSort ,   12.7%
            ImageProc ,  -25.6%
               StrCat ,   92.6%
       StrComplexWalk ,   11.1%
             StrToInt ,   16.6%
  StringInterpolation ,   21.6%

Regression in CaptureProp is due to some interference of the harness.  When the
code is extracted into a separate file, there is no difference.

Regression in ImageProc is caused by unconditional construction of a string for
CheckResults()

rdar://18119872

Swift SVN r21535
2014-08-28 16:48:39 +00:00
Dmitri Hrybenko
4acc8a3e4b stdlib: remove redundant parens
Swift SVN r21529
2014-08-28 14:10:07 +00:00
Roman Levenstein
97014172b7 [sil-combine] String literal concatenation optimization. Constant-fold concatenation of string literals known at compile-time.
Addresses rdar://17033696.

Swift SVN r21526
2014-08-28 11:33:21 +00:00
Dmitri Hrybenko
8e4c76f4f6 stdlib/StringBuffer: update doc comment
Swift SVN r21523
2014-08-28 10:03:02 +00:00
Dave Abrahams
a45cb59747 [stdlib] Eliminate some gratuitous @objc labels
Swift SVN r21511
2014-08-28 02:03:31 +00:00
Dave Abrahams
18dac28aea [stdlib] Eliminate HeapBufferStorageBase
It's just needless complexity

Swift SVN r21508
2014-08-28 01:41:43 +00:00
Dave Abrahams
082c396cfe [stdlib] String.replaceRange: fix value semantics
Fixes <rdar://problem/18114265> Swift Compiler Optimizations for Strings causing incorrect behaviour

Swift SVN r21487
2014-08-27 19:24:55 +00:00
Dmitri Hrybenko
61ef07732f stdlib/FixedPoint: add IntXX(truncatingBitPattern:) initializers
rdar://18101336


Swift SVN r21481
2014-08-27 10:04:33 +00:00
Dave Abrahams
349e730c07 [stdlib] Add a missing mode string in a .gyb file
Swift SVN r21462
2014-08-26 19:59:04 +00:00
Dmitri Hrybenko
001c00fb44 stdlib/Dictionary: add a doc comment for _DictionaryBuilder
Swift SVN r21456
2014-08-26 11:33:06 +00:00
Dave Abrahams
ea73121217 [stdlib] Make a method final
Swift SVN r21441
2014-08-25 16:50:29 +00:00
Dmitri Hrybenko
203cbaa5df stdlib: remove unused GYB code
Swift SVN r21437
2014-08-25 14:46:14 +00:00
Dmitri Hrybenko
7c943d5377 stdlib: remove migration aids for IntXX.asSigned(), IntXX.asUnsigned()
Swift SVN r21436
2014-08-25 14:02:36 +00:00
Dmitri Hrybenko
44bf1a81a6 stdlib/Printing: print floating point numbers with appropriate precesion for
the type

Printing Float32 with %0.15g not only wastes screen space, but also causes
confusion for users, and pretends that a Float32 has more precision than it
actually does.

rdar://18043123


Swift SVN r21435
2014-08-25 13:56:38 +00:00
Dmitri Hrybenko
ea48185358 stdlib: don't silently truncate Float80 literals
We used to first truncate them to Float64, and then construct a Float80.

Swift SVN r21433
2014-08-25 13:21:54 +00:00
Dmitri Hrybenko
3e5154b23a stdlib: fix typo in private API name
Swift SVN r21431
2014-08-23 18:21:36 +00:00
Andrew Trick
125846a213 Consider capacity >= mincapacity the _fastPath in requestUniqueMutableBackingBuffer.
This should allow us to better optimize repeated push/pop benchmarks.

I didn't notice a performance change at the time I did this. I'm just
putting it in as a hopefully obvious drive-by fix.

Swift SVN r21429
2014-08-23 01:31:07 +00:00
Dave Abrahams
6c07fb4ad1 [stdlib] Revert UnsafePointer casting change
The syntax being reverted added busywork and noise to the common case
where you want to say "I have the right address, but the wrong type,"
without adding any real safety.

Also it eliminated the ability to write UnsafePointer<T>(otherPointer),
without adding ".self" to T.  Overall, it was not a win.

This reverts commits r21324 and r21342

Swift SVN r21424
2014-08-22 21:53:12 +00:00
Arnold Schwaighofer
9a7b869faf Revert "Add @effects(readnone) to _swift_isClassOrObjCExistential"
We have not defined whether readnone would potentially allow it to be
speculatively executed which is not desired semantics for
_swift_isClassOrObjCExistential because the metadata might not have been loaded
at the speculative point. Since we don't need the readnone property on this
function after the Builtin.canBeClass change for performance remove it for now.

This reverts commit r21330.

Swift SVN r21422
2014-08-22 21:34:33 +00:00
Dave Abrahams
f3ac09497d Store ASCII string literals as UTF8
Fixes <rdar://problem/16740011> ASCII string literals produce UTF16
Strings

Swift SVN r21419
2014-08-22 19:05:15 +00:00
Nadav Rotem
9a495b56e5 Inline _arrayReplace into replaceRange.
The buffer argument of _arrayReplace was a protocol and it forced
all of the calls to that member to be virtually dispatched and generic.

This boosts DeltaBlue by 2X.

Swift SVN r21405
2014-08-22 06:56:22 +00:00