Commit Graph

1397 Commits

Author SHA1 Message Date
Dave Abrahams
32303b985d [stdlib] Allow String construction from its views
Swift SVN r24638
2015-01-22 17:34:18 +00:00
Maxwell Swadling
aec2f955e7 [stdlib] fixed bug in bounds of pointer copy/move operations
Fixes rdar://problem/19392115

Swift SVN r24614
2015-01-21 22:41:10 +00:00
Dave Abrahams
84c3daa909 [stdlib] Clean up/strengthen an invariant check
Swift SVN r24611
2015-01-21 21:32:10 +00:00
Arnold Schwaighofer
0142bbcdeb array.make_mutable_shared -> array.make_mutable
There is no difference in high level semantics.

Swift SVN r24601
2015-01-21 13:43:53 +00:00
John McCall
3be27ad22b Adopt safe addressors in Swift's Array family of types.
rdar://190323998

Swift SVN r24599
2015-01-21 09:12:49 +00:00
Maxwell Swadling
037d9532a8 [stdlib] Added radar fixme to String Index
Swift SVN r24574
2015-01-20 23:31:12 +00:00
Erik Eckstein
9c1e42c82d stdlib: Explicitly disable inlining of _forceCreateUniqueMutableBuffer.
This function is on the slow path (unfortunately I could not use the _fastPath intrinsic, which would be a better alternative to @inline(never)).
The effect is that it keeps the calling functions (Array.append) small and lets the inliner inline the calling functions.

This change fixes the performance degradation of Ary/Ary2:
Ary: +53 @ -O, +40% @ -Ounchecked
Ary2: +32% @ -O, +20% @ -Ounchecked

Other improvements/degradations:
QuickSort: +21% @ -Ounchecked
Chars: +9% @ -O
CaptureProp: -13% @ -O
InsertionSort: -12% @ -Ounchecked
SwiftStructuresBubbleSort: -11% @ -Ounchecked



Swift SVN r24554
2015-01-20 14:41:58 +00:00
Dave Abrahams
f16a6b0897 [stdlib] Kill some dead code
Swift SVN r24543
2015-01-20 00:53:17 +00:00
Maxwell Swadling
b0770dcb90 [stdlib] added zip function
Fixes rdar://problem/17292393

Swift SVN r24537
2015-01-19 23:18:07 +00:00
Dave Abrahams
2cbdffb09f [stdlib] Document String index conversions
Also rename some parameters to make the documentation read well.

Fixes rdar://18018911

Swift SVN r24512
2015-01-19 18:36:29 +00:00
Maxwell Swadling
374df28991 Revert "[stdlib] Set automaticallyNotifiesObserversForKey to false"
Adding this complexity does not offer any significant improvements.

This reverts commit r24467.
Git commit: c17e2294e4e100bfc44efe792523c314a38cec47.

Swift SVN r24481
2015-01-16 22:47:44 +00:00
Andrew Trick
e2760a7036 Add a return statement to Variant[Set|Dictionary]Storage.removeAtIndex.
This fast path is only taken when the code is specialized.
Fixes <rdar://problem/19331717> Optimizer breaks Set<T> and Dictionary<K, V>

Swift SVN r24479
2015-01-16 21:10:48 +00:00
Graham Batty
057c27f009 Disable existential metatype casting on non-objc.
Also fixes getting the size of an instance of a class to
work without it when objective-c interop is turned off.

Swift SVN r24477
2015-01-16 20:27:54 +00:00
Maxwell Swadling
92e55287aa [stdlib] Set automaticallyNotifiesObserversForKey to false
automaticallyNotifiesObserversForKey is now false for Array, Dictionary
and Set (since they can not be mutated).

Fixes rdar://problem/19404025

Swift SVN r24467
2015-01-16 01:25:51 +00:00
Doug Gregor
5916fc23d5 Use Swift.splice in Array.splice.
r24460 fixed rdar://problem/17866066 as well, so address the FIXME in the
standard library.

Swift SVN r24463
2015-01-16 00:55:00 +00:00
Maxwell Swadling
a698891817 [stdlib] fixed converting integers to floats at bounds
We found converting ints to floats at bounds caused it to overflow
without trapping. This was due to the construction of floats using
rounding (on x86 using an instruction dependent on the status register).

To fix this we check the bounds of the float with constants that are
known to be the last valid floating point numbers valid for conversion.

Fixes rdar://problem/18406402

Swift SVN r24459
2015-01-15 23:01:19 +00:00
Nadav Rotem
86a4f9923a Allow the cloning of the print functions that use a stream because they are used in string interpolation.
Swift SVN r24450
2015-01-15 19:05:24 +00:00
Nadav Rotem
789623daa8 Rename stdlib.noimport to stdlib_binary_only.
The name was proposed by Dave and Dmitry in an off-line conversation.

Swift SVN r24449
2015-01-15 19:05:23 +00:00
Dmitri Hrybenko
83f5a45f24 stdlib/runtime: re-enable CrashReporter
Fold the contents of CrashReporterClient.a into the Swift runtime.

rdar://19482263

Swift SVN r24443
2015-01-15 10:13:02 +00:00
Dmitri Hrybenko
a6db175ecc stdlib: fix spelling of 'Objective-C'
Swift SVN r24438
2015-01-15 02:48:37 +00:00
Dmitri Hrybenko
730025e939 stdlib: fix spelling of 'Objective-C'
Swift SVN r24437
2015-01-15 02:41:09 +00:00
Nadav Rotem
1f889608db Mark _fatalErrorMessage as noimport - rdar://19413726
Swift SVN r24406
2015-01-13 23:55:37 +00:00
Nadav Rotem
b51a4d0bb5 Do not link (import from stdlib) the 'print' family of functions.
We don't need the "print to stdout" family of functions to be fast
and prefer to reduce the binary size by not linking the printing code
(and all of its dependencies).

This reduces the SIL of the code of a file that contains 'println()' from
~4000** lines of SIL down to ~200.

**(depending on the assert configuration)

Swift SVN r24404
2015-01-13 23:24:57 +00:00
John McCall
dc4431ebff Split addressors into unsafe, owning, and pinning variants.
Change all the existing addressors to the unsafe variant.

Update the addressor mangling to include the variant.

The addressor and mutable-addressor may be any of the
variants, independent of the choice for the other.

SILGen and code synthesis for the new variants is still
untested.

Swift SVN r24387
2015-01-13 03:09:16 +00:00
Enrico Granata
729b90e087 Split the floating-point QuickLook object in two: Float and Double for respectively single and double precision values
This allows reflection clients a more detailed perspective on what precision values they are inspecting, and is largely meant to support improvements to the way Xcode represents floating point numbers in the playgrounds UI (rdar://19124310)



Swift SVN r24372
2015-01-12 19:54:58 +00:00
David Farler
280d212c78 Set: print different forms for description and debugDescription
Set.description now prints its array literal form, and
Set.debugDescription prints its initializer form. Both print
the debugDescription of the members.

Set([1,2,3]).description = "[2, 3, 1]"
Set([1,2,3]).debugDescription = "Set([2, 3, 1])"

rdar://problem/19312961

Swift SVN r24306
2015-01-09 10:09:40 +00:00
Dmitri Hrybenko
9efbdb8278 stdlib/HashedCollections: mark some APIs @testable
The mandatory inlining of generic functions simplifies code and the
compiler omits these symbols now, so they could not be used in tests.

Swift SVN r24296
2015-01-09 03:53:34 +00:00
Maxwell Swadling
21fd60fd92 [stdlib] added fast getObjects:andKeys:
Improved performance of some bridged dictionary operations
Fixes rdar://problem/18873563

Swift SVN r24293
2015-01-09 02:09:53 +00:00
Roman Levenstein
d96bdab1c0 Reduce code-bloat in the user functions which happens due to inlining of print-related stdlib functions.
This patch marks almost all print-related functions as @inline(never), so that they are not inlined into user functions. This significantly reduces the size of produced SIL and has positive impact on the size of executables. More over, it speeds up compilation as less SIL code needs to be processed and optimized.

Only inlining of those functions is disabled. Specialization is still performed, so that e.g. println(myIntValue) is using the optimized specialised version.

The patch is reviewed by Dmitri.

Swift SVN r24285
2015-01-08 22:52:42 +00:00
Dmitri Hrybenko
df8f53e9b4 stdlib: fix coding style
Swift SVN r24284
2015-01-08 22:36:46 +00:00
Mark Lacey
a8944f4540 Enable mandatory inlining of generic functions with unbound generic types.
This allows us to inline @transparent functions in cases like this:

  @transparent
  func partial<T, U>(x: T, f: (T) -> U) -> U {
    return f(x)
  }

  func applyPartial<U>(x: Int32, f: (Int32) -> U) -> U {
    return partial(x, f)
  }

I had planned on enabling this same behavior in the performance inliner
first in order to be able to test the underlying functionality more
thoroughly, but I hit a blocking issue pretty quickly in type
lowering (rdar://problem/19387372).

Given that @transparent is not currently user-facing, it seems
reasonable to go ahead and enable this now and fix any new issues it
exposes since it should be easy to work around those issues by not using
@transparent.

There were lots of performance differences as a result of this change,
mostly positive. Below I list the 10 largest improvements for each of
-Onone, -O, and -Ounchecked, along with all regressions greater than
10%. I will be opening radars for these.

-Onone
---------------------------------------
ArrayOfPOD                     104.200%
ArrayOfGenericPOD               40.700%
TwoSum                          37.800%
EditDistance                    35.600%
GenericStack                    33.500%
SwiftStructuresStack            29.700%
SwiftStructuresInsertionSort    29.300%
Havlak                          27.200%
NestedLoop                      26.800%
Life                            26.400%

SwiftStructuresTrie            -15.500%

-O
---------------------------------------
TwoSum                          46.200%
GenericStack                    37.900%
SwiftStructuresStack            37.100%
Dictionary                      30.200%
Forest                          27.800%
NSDictionaryImplicitConversion  24.400%
Prims                           23.500%
Dictionary2                     19.600%
DollarFilter                    17.00%
SwiftStructuresQueue            16.600%

NSStringConversion             -22.600%
SwiftStructuresTrie            -25.900%
PopFrontArray                  -44.100%

-Ounchecked
---------------------------------------
SwiftStructuresStack            38.900%
GenericStack                    37.400%
NSDictionaryImplicitConversion  21.200%
TwoSum                          20.500%
Histogram                       16.600%
DollarFilter                    15.900%
DollarFunction                  13.600%
ArrayLiteral                    12.900%
Forest                          12.300%
Prims                           10.300%

ImageProc                      -10.900%
InsertionSort                  -11.200%
StrToInt                       -11.800%
NBody                          -14.900%
SwiftStructuresTrie            -29.900%

Swift SVN r24263
2015-01-08 03:36:08 +00:00
David Farler
87c3d7421f Refine static func and var syntax
rdar://problem/17198298

- Allow 'static' in protocol property and func requirements, but not 'class'.
- Allow 'static' methods in classes - they are 'class final'.
- Only allow 'class' methods in classes (or extensions of classes)
- Remove now unneeded diagnostics related to finding 'static' in previously banned places.
- Update relevant diagnostics to make the new rules clear.

Swift SVN r24260
2015-01-08 03:03:29 +00:00
Chris Willmore
03a6190a1f <rdar://problem/19031957> Change failable casts from "as" to "as!"
Previously the "as" keyword could either represent coercion or or forced
downcasting. This change separates the two notions. "as" now only means
type conversion, while the new "as!" operator is used to perform forced
downcasting. If a program uses "as" where "as!" is called for, we emit a
diagnostic and fixit.

Internally, this change removes the UnresolvedCheckedCastExpr class, in
favor of directly instantiating CoerceExpr when parsing the "as"
operator, and ForcedCheckedCastExpr when parsing the "as!" operator.

Swift SVN r24253
2015-01-08 00:33:59 +00:00
Maxwell Swadling
7fc1ad679a [stdlib] fixed incorrect deinitialization in Dictionary
Dictionary could be double freed after bridging to ObjC due to a call to
takeRetainedValue(), causing a segfault. This was fixed by removing the
free call, as it was unnecessary.

Fixes rdar://problem/18544533

Swift SVN r24208
2015-01-06 03:36:54 +00:00
Dmitri Hrybenko
ce9f5887b7 Revert "adopt @__noescape in various places in the stdlib, making sure to cover all of the "
This reverts commit r24141, it broke tests:

Failing Tests (2):
    Swift :: parser/parse_stdlib.sil
    Swift :: stdlib/AssertDiagnostics.swift

Swift SVN r24147
2014-12-24 05:51:51 +00:00
Chris Lattner
a86c7902ae adopt @__noescape in various places in the stdlib, making sure to cover all of the
@transparent functions that take a closure.  NFC since these always get inlined
at the moment anyway.



Swift SVN r24141
2014-12-24 01:30:00 +00:00
Maxwell Swadling
42207c0a21 [stdlib] fixes bug in Bit overflow
rdar://problem/18282108

Swift SVN r24137
2014-12-24 00:40:56 +00:00
Dmitri Hrybenko
6670bb76ec Rewrite the CMake build system
Swift SVN r24124
2014-12-23 22:15:30 +00:00
Maxwell Swadling
b3253f7651 [stdlib] Changed uintValue to a var
Fixes rdar://problem/18469215

Swift SVN r24118
2014-12-23 20:11:51 +00:00
Maxwell Swadling
02808373d8 [stdlib] Fixed bugs with string views
Fixes rdar://problem/18435682
Fixes rdar://problem/19238102

Swift SVN r24117
2014-12-23 20:02:38 +00:00
Dave Abrahams
7d50db0cec [stdlib] String index mapping: finish tests
Doc comments are next.

Swift SVN r24070
2014-12-22 15:30:57 +00:00
Dave Abrahams
f78b6b125a [stdlib] Conversions to String.Index
Also, hide an initializer on String.Index that was unintentionally
public/visible by giving it an underscored keyword argument.

Testing comes next.

Swift SVN r24069
2014-12-22 15:30:56 +00:00
Dave Abrahams
d6bdfc1cfe [stdlib] Finish tests for current String index conversions
Also clean unused detritus and anacrhonisms from testing code.

Tests for the currently-implemented conversions were incomplete, but are
now done.

Swift SVN r24068
2014-12-22 05:40:57 +00:00
Dave Abrahams
a9d7577b5f [stdlib] conversions to String.UnicodeScalarIndex
Also expanded testing to include checking translation of end indices
between views.

Swift SVN r24067
2014-12-22 01:13:46 +00:00
Dmitri Hrybenko
4f819a9cf7 Remove an NSSet.copyObjectPointers() API that was unintentionally added
Swift SVN r24054
2014-12-20 03:01:34 +00:00
Chris Lattner
b8596ffccb move the stdlib to the new syntax for @autoclosure attribute.
Swift SVN r24048
2014-12-20 00:16:36 +00:00
Dave Abrahams
2cd5290005 [stdlib] Add some missing doc comments
Swift SVN r24038
2014-12-19 19:48:37 +00:00
Maxwell Swadling
b6cd6ebda8 [stdlib] Removed bidirectional iterator from Dictionary and Set
Swift SVN r24023
2014-12-19 00:22:15 +00:00
David Farler
1766dd71ed Use Set([...]) as Set's description, debugPrint elements
Don't use {. . .} as Set's description - use:

Set([1, 2, 3]) and debugPrint the elements.

rdar://problem/19299943

Swift SVN r24021
2014-12-19 00:01:38 +00:00
Dave Abrahams
43ea3db04e [stdlib] conversions to UTF16View.Index
Swift SVN r24013
2014-12-18 20:47:38 +00:00