Commit Graph

34 Commits

Author SHA1 Message Date
Erik Little
863f3a19ff Rename @effects to @_effects
@effects is too low a level, and not meant for general usage outside
the standard library. Therefore it deserves to be underscored like
other such attributes.
2018-06-06 12:53:03 -04:00
Michael Ilseman
1fe5fb717d [string] Skip allocation in reserveCapacity if smol
If the requested capacity is small enough to fit in our small string
representation, don't allocate a UTF-16 buffer, instead just return
early.
2018-05-18 21:26:59 -07:00
Michael Ilseman
b2ad5b6f8a [string] Kill _StringGuts.Iterator
_StringGuts is not meant to be an abstraction across all the forms a
String may take. It's meant to abstract the book-keeping and the
visitor is a parameterization over operations.
2018-05-14 07:01:44 -07:00
Michael Ilseman
00e214ec50 [string] Clean up String.UTF8View
Extract slow paths into non-inlinable functions so that fast-paths can
be faster and we don't pay the large code bloat for the Unicode
parsers.

Some tests proactively extended to highlight UTF8View of multiple
kinds of Strings.
2018-05-14 07:01:38 -07:00
Michael Ilseman
4a368ab46c [string] Drop many @inlinable from big API.
Drop append-related @inlinable annotations for String, StringGuts,
StringStorage, and the Views. Drop several for larger operations, such
as case conversion. Drop as many as we can from StringGuts for now.
2018-05-13 07:38:55 -07:00
Michael Ilseman
459833725e [String] Streamline more String creation logic.
Streamline and de-genericize non-inlinable internal functions to
create a String from UTF-8 efficiently.
2018-05-13 07:38:55 -07:00
Erik Eckstein
9a961208ec stdlib: remove some @inlineables from String API functions.
Beside the general goal to remove inlinable functions, this reduces code size and also improves performance for several benchmarks.
The performance problem was that by inlining top-level String API functions into client code (like String.count) it ended up calling non-inlinable internal String functions eventually.
This is much slower than to make a single call at the top-level API boundary into the library. Inside the library all the internal String functions can be specialized and inlined.

rdar://problem/39921548
2018-05-03 14:37:11 -07:00
Michael Ilseman
c00a460ea3 [string] Drop StringStorage.create inlinability annotation.
StringStorage.create is the primary means of allocating storage for a
string, so drop inlinability to allow for future evolution.

StringStorage also exposes some .appendInPlace methods, which we
currently need to keep inlinable for benchmark performance. We'd
really like to drop inlinability for these for evolution purposes
(e.g. imagine a future version that adjusts nul-termination or changes
in coordination with create). These are flagged with:

` // TODO(inlinability): @usableFromInline - P3`

Where "P3" reflects urgency on a scale from 1 (stop the presses) to 5
(whatevs).
2018-04-28 15:36:12 -07:00
Michael Ilseman
715003c206 [gardening] Internalize many non-API String interfaces 2018-04-28 15:36:05 -07:00
Slava Pestov
2e5aef9c8d stdlib: Remove redundant @usableFromInline attributes 2018-04-06 00:02:30 -07:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
Michael Ilseman
8b6d0f6402 [string] Aggressively form small strings.
Whenever possible, prefer the small string format. Updates creation
logic. Adds assertion on large strings that they're not intended to be
small.
2018-03-27 14:00:59 -07:00
Michael Ilseman
93d6130066 [string] Integrate small strings.
Switch StringObject and StringGuts from opaquely storing tagged cocoa
strings into storing small strings. Plumb small string support
throughout the standard library's routines.
2018-03-27 14:00:59 -07:00
Michael Ilseman
cdfeb88cfe [string] Simplify creation logic, especially for C strings.
Streamline internal String creation. Previously, everything funneled
into a single generic function, however, every single call of the
generic funnel had relevant specific information that could be used
for a more efficient algorithm.

In preparation for efficiently forming small strings, refactor this
logic into a handful of more specialized subroutines to preserve more
specific information from the callers.
2018-03-27 10:49:02 -07:00
Michael Ilseman
020d94ade0 [string] Add less bad SPI for Foundation 2018-03-22 20:48:51 -07:00
Michael Ilseman
189bc4dd91 [string] Un-break Linux due to duplicate def 2018-03-13 15:32:20 -07:00
Michael Ilseman
63ed19122b [string] Finally, un-version _asOpaque 2018-03-13 15:32:20 -07:00
Michael Ilseman
e7c418b0fa [comments] Annotate places we don't use _StringGuts visitor. NFC
Adds some comments for sections of code that doesn't adopt the
visitation pattern, or have inefficiencies discovered as part of this
work. Additionally, mutating methods generally do not use the visitor
scheme.
2018-03-13 15:32:19 -07:00
Michael Ilseman
12fe85fad1 [string] Establish opaque branching pattern.
Stop inlining _asOpaque into user code. Inlining it bloats user code
as there's a bit-test-and-branch to a block containing the _asOpaque
call, followed up some operations to e.g. manipulate the range or
re-align the calling convention, etc., followed by a final branch to
opaque stdlib code.

Instead, branch directly into opaque stdlib code. In theory, this
means that supporting all opaque patterns can be done with minimal
bloat. On ARM, this is a single tbnz instruction.
2018-03-13 15:32:19 -07:00
Michael Ilseman
884356fc0a [string] Bifurcate StringGuts inits for large strings.
In preparation for small strings optimizations, bifurcate StringGuts's
inits to denote when the caller is choosing to skip any checks for is
small. In the majority of cases, the caller has more local information
to guide the decision.

Adds todos and comments as well:

  * TODO(SSO) denotes any task that should be done simultaneously with
    the introduction of small strings.

  * TODO(TODO: JIRA) denotes tasks that should eventually happen
    later (and will have corresponding JIRAs filed for).

  * TODO(Comparison) denotes tasks when the new string comparison
    lands.
2018-03-13 15:32:19 -07:00
Michael Ilseman
a6e79efbbe [string] Minor simplifications 2018-03-13 15:32:19 -07:00
Michael Ilseman
b1f1e98a63 [string] Clean up StringObject; Clarify its tagged BridgeObjects. (#14425)
[string] Clean up StringObject; Clarify its tagged BridgeObjects.

Bifurcate StringObjects raw bit-pattern initializers to expose whether
the caller is passing a value rather than a reference. This way,
StringObject can call the approprite BridgeObject helper and
participate in upcoming peephole optimizations like retains of
known-values. This is all meant to be a NOP.

Additionally, do some cleanup while we're at it.
2018-02-06 17:36:32 -08:00
Michael Ilseman
ccdba811f1 Merge pull request #14117 from milseman/sanitime_runty
[string] sanity check for runtime size
2018-01-23 23:06:31 -08:00
Michael Ilseman
5b716bd4bc [string] sanity check for runtime size 2018-01-23 20:24:42 -08:00
Michael Ilseman
ef926c9031 [string] Hack around more ARC.
Utilize pre-existing CFStringGetLength hack. Gives about 20%
performance improvement bridging in contiguous NSStrings from
ObjectiveC.
2018-01-22 21:29:39 -08:00
Michael Ilseman
9a87d24bc7 [string] Workaround fail emptySingleton check.
This is a temporary workaround for some situations where the empty
singleton is not being formed correctly (and this seems to be highly
configuration dependent). Work around that for now for also checking
for empty non-storage-backed Strings.

This is probably too expensive a check for us to do long-term, but it
works for now.
2018-01-22 11:07:52 -08:00
Michael Ilseman
d14b8abc8b [string] Force specialization for small Character 2018-01-22 01:06:09 -08:00
Michael Ilseman
b61b53330f [Builtin] Add _isValidAddress pointer-value check.
And adopt it for StringGuts, as it is more robust on 32-bit systems.
2018-01-21 12:40:35 -08:00
Michael Ilseman
6d1866f846 [StringGuts] Clean-up in preparation for merge.
Clean up a lot of the scattered utility functions, FIXMEs, etc in
preparation for the merge to master.
2018-01-21 12:38:49 -08:00
Karoy Lorentey
90e894729a [StringGuts] Linux support
Add support for compiling StringGuts without the Objective-C runtime.
2018-01-21 12:37:36 -08:00
Karoy Lorentey
f2a96496a0 [StringGuts] Support for 32-bit platforms
Add 32-bit support to the new StringGuts.
2018-01-21 12:36:09 -08:00
Karoy Lorentey
5cf9fd7414 Remove _StringBuffer 🎉🎉🎉 2018-01-21 12:35:15 -08:00
Karoy Lorentey
b360bd6d69 Remove _LegacyStringCore 🎉🎉🎉 2018-01-21 12:35:15 -08:00
Michael Ilseman
3be2faf5d3 [String] Initial implementation of 64-bit StringGuts.
Include the initial implementation of _StringGuts, a 2-word
replacement for _LegacyStringCore. 64-bit Darwin supported, 32-bit and
Linux support in subsequent commits.
2018-01-21 12:32:26 -08:00