Commit Graph

7762 Commits

Author SHA1 Message Date
Karoy Lorentey
fce428e715 [stdlib] String.UTF16View: Tweak ASCII paths 2022-12-29 16:32:40 -08:00
Karoy Lorentey
7d89d62dce [stdlib] Remove @_specialize attributes obsoleted by explicit type checks 2022-12-29 13:18:10 -08:00
Karoy Lorentey
d00f8ed44b [stdlib] Optimize StringProtocol._toUTF16Indices/_toUTF16Offsets
Speed up conversion between UTF-16 offset ranges
and string index ranges, by carefully switching
between absolute and relative index calculations,
depending on the distance we need to go.

It is a surprisingly tricky puzzle to do this
correctly while avoiding redundant calculations.
Offset ranges within substrings add the additional
complication of having to bias offset values with
the absolute offset of the substring’s start index.
2022-12-28 20:08:05 -08:00
Karoy Lorentey
ec35728b8d [stdlib] String.UTF16View: Rework thresholds for relative indexing
We commonly start from the `startIndex`, in which case
`_nativeGetOffset` is essentially free. Consider this
case when calculating the threshold for using breadcrumbs.
2022-12-28 20:07:53 -08:00
Karoy Lorentey
6fee1b372b [stdlib] Breadcrumbs are spaced in UTF-16 code units, not UTF-8 2022-12-27 20:22:38 -08:00
Karoy Lorentey
2423b8ba3c [stdlib] StringProtocol._toUTF16Indices: Speed up conversion of short ranges
Instead of calling `_toUTF16Index` twice, call it once and then use
`index(_:offsetBy:)` to potentially avoid another breadcrumbs lookup.
2022-12-27 20:22:38 -08:00
Karoy Lorentey
f3a930592f [stdlib] Simplify breadcrumbs avoidance paths in String.UTF16View 2022-12-27 20:22:37 -08:00
Karoy Lorentey
483087a47d [stdlib] Speed up short UTF-16 distance calculations
Previously we insisted on using breadcrumbs even if we only needed to
travel a very short way. This could be as much as ten times slower
than the naive algorithm of simply visiting all the Unicode scalars
in between the start and the end.

(Using breadcrumbs generally means that we need to walk to both
endpoints from their nearest breadcrumb, which on average requires
walking half the distance between breadcrumbs — and this can mean
visiting vastly more Unicode scalars than the ones that are simply
lying in between the endpoints themselves.)
2022-12-27 20:22:34 -08:00
Evan Wilde
f8a54181a9 Zipper all the things!
This patch goes through and adds zippering and the swift module
dependencies to a bunch of pieces of the swift runtimes. Here's to
hoping I hit everything that needed to be hit. :D

With this patch, I'm seeing the appropriate modules under
lib/swift/maccatalyst, so things seem to be working right.
2022-12-22 13:41:59 -08:00
Mike Ash
47d02db6ff Merge pull request #62528 from mikeash/self-keypath-debug-description
[Runtime] Fix debugDescription of .self keypaths.
2022-12-13 16:24:57 -05:00
Jonathan Grynspan
26fc627ad0 Fix a use-after-free bug on Win32 when calling lookupSymbol() (#62484) 2022-12-13 09:04:34 -05:00
Ben Rimmington
620ba334fb [SE-0368] StaticBigInt: support older compilers (#62541) 2022-12-13 11:15:48 +00:00
Mike Ash
f440432891 [Runtime] Fix debugDescription of .self keypaths.
AnyKeyPath's debugDescription assumes there's always at least one component, but `\Type.self` produces an empty keypath. Special-case the empty case to display a `.self` component.

rdar://103237845
2022-12-12 14:34:22 -05:00
Ben Rimmington
0b29450a3d [SE-0368] StaticBigInt (#40722) 2022-12-06 21:59:42 +00:00
Alex Martini
7e58b81092 Call out time complexity of String.count.
This discussion borrows wording from the docs for the default
implementation of Collection.count[1], which are inherited by many other
symbols, but with a rewrite here because String doesn't guarantee
random-access performance (doesn't conform to RandomAccessCollection),
so accessing the count is never an O(1) operation.

1: https://developer.apple.com/documentation/swift/collection/count-4l4qk
2022-12-01 16:06:55 -08:00
Erik Eckstein
126f3e14c1 stdlib: create optimal code for initializing a Set with an empty array literal
Always inline the empty-array-check of `Set.init(arrayLiteral:)`, because for array literal this check can always be constant folded.

rdar://53509655
2022-12-01 07:02:22 +01:00
Karoy Lorentey
7b45c8bb60 Merge pull request #62158 from karwa/patch-16
[stdlib] Do not allocate when creating a Set from a generic Sequence which happens to be another Set
2022-11-30 17:55:48 -08:00
Bradley Mackey
a16329f848 Improve Never documentation 2022-11-29 20:11:11 +00:00
Karl
d16f4679e5 [stdlib] Do not allocate when creating a Set from a generic Sequence which happens to be another Set 2022-11-17 13:47:20 +01:00
Valeriy Van
95d25d3ba5 Minor comment typo fix 2022-11-15 10:40:43 +02:00
Saleem Abdulrasool
04dd83983b Merge pull request #61756 from mhjacobson/freebsd-define-CLongDouble-typealias
stdlib: define typealias CLongDouble for FreeBSD
2022-11-02 10:02:26 -07:00
Saleem Abdulrasool
0a2b10b777 Merge pull request #61815 from MillerTechnologyPeru/trunk/riscv64
[stdlib] Add RISCV64 support
2022-11-02 09:53:34 -07:00
Alsey Coleman Miller
62b7be4e9c [stdlib] Add RISCV64 support 2022-11-01 23:59:42 -07:00
Joe Groff
121adf6eb2 Merge pull request #60758 from fibrechannelscsi/faster-keypaths
KeyPath performance improvement: Omit projection across trivially-typed memory.
2022-11-01 11:59:44 -07:00
Martin Cwikla
bc4b38d747 Removed an unnecessary disabling of isPureStruct.
This would have prevented explicitly specified KeyPaths through pure structs, e.g., \A.b.c, from taking the optimized path.
2022-10-31 14:43:44 -06:00
Matt Jacobson
802d877460 stdlib: define typealias CLongDouble for FreeBSD on i386, x86_64
This fixes a failure compiling the stdlib where the importer cannot find (i.e.,
refuses to import) functions _stdlib_remainderl and _stdlib_squareRootl.
2022-10-31 15:52:26 -04:00
Martin Cwikla
92d7cf5725 Revised _tryToAppendKeyPaths(). Removed two instances of isPureStruct.append() that weren't needed. 2022-10-26 11:05:02 -06:00
Martin Cwikla
21f175ae3c Added missing instances of pureStruct information propagation.
This means we no longer need to check for empty KeyPath Walker results.
2022-10-24 17:43:00 -06:00
유재호
c0c84f4a95 [stdlib] Fix typo in Hashable.swift 2022-10-22 10:31:19 +09:00
Martin Cwikla
a6a2f509b3 Use Int(bitPattern) rather than distance(to) to compute the offset. 2022-10-20 14:26:35 -06:00
Martin Cwikla
4fb2f9e15e Modified storage of valid offsets in assignOffsetToStorage() and getOffsetFromStorage().
Got rid of isTuple(). Moved determination of pure struct KeyPaths into _instantiateKeyPathBuffer.
2022-10-20 14:26:35 -06:00
Martin Cwikla
d2912dca75 Fixed .unresolvedFieldOffset should count as an optimized offset. Restored optimization for KeyPath writes. 2022-10-20 14:25:40 -06:00
Martin Cwikla
2d5086c085 Fixed the failing unit tests in capture_propagate_keypath.swift.
Revisited formatting. Pulled in changes from the past four weeks.
2022-10-20 14:25:39 -06:00
Martin Cwikla
afebae5694 Moved computation of offset for pureStructKeyPaths into KeyPathPatternVisitors.
Next expected commit: Move information stored in _pureStructValueOffset to _kvcKeyPathStringPtr (or similar).
2022-10-20 14:25:39 -06:00
Martin Cwikla
353eb9ffd5 KeyPath offset tests were breaking on Ubuntu 20.04. It's possible _storedInlineOffset wasn't factored out correctly. 2022-10-20 14:25:39 -06:00
Martin Cwikla
5efc87c67e ABI stability fix: isPureStructKeyPath should be internal. 2022-10-20 14:25:39 -06:00
Martin Cwikla
9fb8f598eb Clarified a comment in isTuple(). 2022-10-20 14:25:38 -06:00
Martin Cwikla
ebdd00c071 Proposed design for skipping of KeyPath projections across trivially-typed memory. 2022-10-20 14:25:38 -06:00
Karoy Lorentey
2f2c5b6f6b Merge pull request #61379 from lorentey/add-docs-for-customContainsEquatableElement
[stdlib] Add docs for Sequence._customContainsEquatableElement
2022-10-15 16:21:31 -07:00
Karoy Lorentey
b799866b8f Update stdlib/public/core/Sequence.swift 2022-10-14 09:11:55 -07:00
Karoy Lorentey
e1429dd36e Update stdlib/public/core/Sequence.swift
Co-authored-by: Guillaume Lessard <glessard@users.noreply.github.com>
2022-10-12 12:54:27 -07:00
Karoy Lorentey
704b565d40 [stdlib] String.Index: Add _description & _debugDescription
While we’re vacillating on how best to add CustomStringConvertible
and CustomDebugStringConvertible conformances to String.Index, add
the prospective implementations as underscored-but-public members,
to make life a little more bearable for people who need to debug
string index operations.
2022-10-11 14:37:20 -07:00
Jake
5c3459f2a8 Added Builtin.unreachable() calls (#61422)
Previously unavailable due to #57622 (fixed)
2022-10-04 09:01:59 -07:00
Guillaume Lessard
1ccc36cbd2 Merge pull request #61082 from glessard/source-equals-destination 2022-10-03 14:50:25 -07:00
Karoy Lorentey
9fc062e106 [stdlib] Add docs for Sequence._customContainsEquatableElement 2022-09-29 18:34:54 -07:00
Anthony Latsis
c731089068 Gardening: Migrate stdlib sources to GH issues 2022-09-26 06:30:49 +03:00
David Smith
3292f4e97e Separate out ASCII and UTF8 in NSString accessors, and use the ASCII one where we really need ASCII (#61086)
Separate out ASCII and UTF8 in NSString accessors, and use the ASCII one where we really need ASCII
2022-09-23 12:31:45 -07:00
Tony Allevato
2415288450 Merge pull request #60936 from natecook1000/stable_sort
[stdlib] Document stable sort guarantee
2022-09-21 07:32:45 -07:00
Guillaume Lessard
df0adc815d Merge pull request #61122 from glessard/rdar99890632-use-copyContents
[stdlib] use `_copyContents` after all
2022-09-15 10:30:44 -06:00
Guillaume Lessard
03d37a9538 [stdlib] use _copyContents after all
- originally had avoided `_copyContents` because all the standard library fast paths were already covered.
- however Swift Collections piecewise-contiguous collections still rely on `_copyContents` to accelerate copies.
2022-09-14 16:23:21 -06:00