Commit Graph

34 Commits

Author SHA1 Message Date
Saleem Abdulrasool
15a25a2126 Merge pull request #15568 from lanza/normalizeunicodeto59
change icu version check in UnicodeNormalization to 59
2018-03-29 12:01:10 -04:00
Lance Parker
cbf157f924 [stdlib]Unify String hashing implementation (#14921)
* Add partial range subscripts to _UnmanagedOpaqueString

* Use SipHash13+_NormalizedCodeUnitIterator for String hashes on all platforms

* Remove unecessary collation algorithm shims

* Pass the buffer to the SipHasher for ASCII

* Hash the ascii parts of UTF16 strings the same way we hash pure ascii strings

* De-dupe some code that can be shared between _UnmanagedOpaqueString and _UnmanagedString<UInt16>

* ASCII strings now hash consistently for in hashASCII() and hashUTF16()

* Fix zalgo comparison regression

* Use hasher

* Fix crash when appending to an empty _FixedArray

* Compact ASCII characters into a single UInt64 for hashing

* String: Switch to _hash(into:)-based hashing

This should speed up String hashing quite a bit, as doing it through hashValue involves two rounds of SipHash nested in each other.

* Remove obsolete workaround for ARC traffic

* Ditch _FixedArray<UInt8> in favor of _UIntBuffer<UInt64, UInt8>

* Bad rebase remnants

* Fix failing benchmarks

* michael's feedback

* clarify the comment about nul-terminated string hashes
2018-03-17 22:13:37 -07:00
Nathan Lanza
d00223e687 change icu version check in UnicodeNormalization to 59 2018-02-26 14:38:16 -08:00
Saleem Abdulrasool
73c04d1dd9 stubs: match ICU signature for unorm2_normalize (NFC)
Adjust the signature to match the ICU declaration for
`unorm2_normalize`.  This was adjusted to allow building against ICU
59.1.  The shim type definition for the UChar ensures that the signature
is correct on all the targets.  NFC.
2018-02-25 22:48:27 -08:00
Lance Parker
0661de22a2 [stdlib]Un-revert string comparison (#14694)
Restore (un-revert) sting comparison, with fixes

More exhaustive testing of opaque strings, which consistently reproduces prior sporadic failure. Shims fixups. Some test tweaking.
2018-02-18 10:50:33 -08:00
Saleem Abdulrasool
cd58f5c1c9 Shims: adjust the ICU interface
The default ICU build will change the underlying type of the UChar type,
with C++ using the builtin `char16_t` rather than `unsigned short`.
This adjusts the interface to account for that.  I've verified across
Apple's implementation that they always use the `unsigned short` as the
type for `UChar`.  Since we cannot guarantee that the ICU interfaces are
built the same way on all targets, especially when using the underlying
system's ICU.

Adjust the stubs implementation declaration to match the ICU header's
declaration.
2018-02-15 21:11:06 -08:00
Lance Parker
abe6a6d177 Revert string comparison (#14657) 2018-02-15 14:37:43 -08:00
Lance Parker
db2de58dd6 Remove unecessary unicode collation algorithm shims 2018-02-14 15:44:11 -08:00
Lance Parker
32d21c489f Add unicode normalization shims 2018-02-14 15:44:11 -08:00
Saleem Abdulrasool
05edabff5e stubs: fix Windows link
There is no icucore.lib in the official ICU distribution for Windows.
Remove the autolink directive for now.
2017-09-26 16:13:47 -07:00
Saleem Abdulrasool
e1f98943ba stubs: simplify the Unicode stubs
Force the autolinking on Windows and Darwin as both have mechanisms to
support this.  ELFish targets are unfortunately not supported yet as
there is no portable mechanism to do this.

Remove the unnecessary handling of specific targets.  Always perform the
cast as it adds no overhead and will always be correct (worst case is
that the type is cast to itself).  This simplifies the logic.

Move the forward declarations to avoid inclusion to the same location as
the inclusion.
2017-09-15 15:59:27 -07:00
Saleem Abdulrasool
21d407529f stdlib: clean up some whitespace issues
Clean up incorrect whitespace.  NFC.
2017-09-15 15:58:38 -07:00
Adrian Popescu
b61c51b7b6 Fixed clang 4.0 compilation under Arch Linux with icu59.1-1 (#10361)
ICU headers prefer use of `char16_t` instead of `uint16_t` for `UChar` in C++, where it is treated as a distinct type. This fixes associated warnings and errors.
2017-08-17 13:26:22 -07:00
Michael Ilseman
8e0362e2c1 [stubs] Autolink against icucore on Darwin.
Programs using a statically linked build of the standard library need
to explicitly link against icucore. There are various potential
hacks^Wsolutions to this problem, and this is an attempt at a lesser
of evils approach.

Emit a linker directive to perform autolinking against icucore on
Darwin systems. This allows us to avoid hacking the compiler driver
and propagating that hack onto any build systems that don't go through
the driver.
2017-05-19 10:39:24 -07:00
Michael Ilseman
d1b2cbef39 [stdlib] Add prototypes to avoid dependency
Avoid a dependency on ICU headers on Apple platforms, rather than rely
on corelibs-foundation being checked out. This simplifies the
dependencies and unblocks build bots.
2017-05-16 20:30:03 -07:00
Michael Ilseman
5eb5e34897 [stdlib] Shims for UBreakIterator and thread local storage.
Introduce shims for using UBreakIterators from ICU. Also introduce
shims for using thread local storage via pthreads.

We will be relying on ICU and UBreakIterators for grapheme
breaking. But, UBreakIterators are very expensive to create,
especially for the way we do grapheme breaking, which is relatively
stateless. Thus, we will stash one or more into thread local storage
and reset it as needed.

Note: Currently, pthread_key_t is hard coded for a single platform
(Darwin), but I have a static_assert alongside directions on how to
adapt it to any future platforms who differ in key type.
2017-05-16 20:28:31 -07:00
Michael Ilseman
f0abff5539 Revert "Merge pull request #9265 from milseman/tls_ftw"
This reverts commit 26f7659efe, reversing
changes made to 7b927e55e8.
2017-05-11 10:39:58 -07:00
Michael Ilseman
4a17449d02 [stdlib] Shims for UBreakIterator and thread local storage.
Introduce shims for using UBreakIterators from ICU. Also introduce
shims for using thread local storage via pthreads.

We will be relying on ICU and UBreakIterators for grapheme
breaking. But, UBreakIterators are very expensive to create,
especially for the way we do grapheme breaking, which is relatively
stateless. Thus, we will stash one or more into thread local storage
and reset it as needed.

Note: Currently, pthread_key_t is hard coded for a single platform
(Darwin), but I have a static_assert alongside directions on how to
adapt it to any future platforms who differ in key type.
2017-05-10 15:21:07 -07:00
Slava Pestov
e0fa2e0872 Merge pull request #6238 from hughbe/stubs-clang-cl
Fix documentation warnings building runtime with clang-cl
2017-01-09 12:26:41 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Hugh Bellamy
3f802bb2ab Fix documentation warnings building runtime with clang-cl 2016-12-27 14:55:35 +00:00
Saleem Abdulrasool
c67a33fbc7 build: remove TARGET_SDKS from the runtime
The runtime and stubs are built for ALL targets, not specific ones.  This allows
us to configure when cross-compiling to Windows again.  Collapse the dual
addition of the swiftRuntime into a single build.  This unifies the runtime
build for the apple and non-Apple SDKs.  The difference here was the ObjC
interop sources.  In order to deal with that unification add a CPP macro to
indicate whether the interop sources should be included or not.
2016-12-03 17:02:44 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Dmitri Gribenko
e8e8b35610 stdlib: use SipHash-1-3 for string hashing on non-ObjC platforms
Part of rdar://problem/24109692
2016-09-06 20:41:03 -07:00
Dmitri Gribenko
e765091217 stdlib: remove an unused Unicode data table 2016-09-02 19:42:37 -07:00
Andrew Trick
ed3813a876 Linux build fixes. 2016-07-28 21:06:40 -07:00
Andrew Trick
0b75ee975e Remove "illegal" UnsafePointer casts from the stdlib.
Update for SE-0107: UnsafeRawPointer

This adds a "mutating" initialize to UnsafePointer to make
Immutable -> Mutable conversions explicit.

These are quick fixes to stdlib, overlays, and test cases that are necessary
in order to remove arbitrary UnsafePointer conversions.

Many cases can be expressed better up by reworking the surrounding
code, but we first need a working starting point.
2016-07-28 20:42:23 -07:00
Joe Groff
ba11a1c121 StdlibStubs: Favor swift::Lazy over static local initialization.
To minimize code size and VM live set, we try to funnel all one-time initialization through swift_once instead of mixing it with the C++ runtime's support for lazy static initialization.
2016-07-07 10:33:59 -07:00
Han Sangjin
be815aabbb [stdlib/msvc] Runtime with MSVC library
This patch is for libswiftCore.lib, linking with the library set of Visual Studio 2015. Clang with the option -fms-extension is used to build this port.
This is the approved subpatch of a large patch.
2016-06-02 08:10:40 +09:00
John McCall
50d58b2732 Add a lot of calling-convention annotations to the standard library / runtime.
The general rule here is that something needs to be SWIFT_CC(swift)
if it's just declared in Swift code using _silgen_name, as opposed to
importing something via a header.

Of course, SWIFT_CC(swift) expands to nothing by default for now, and
I haven't made an effort yet to add the indirect-result / context
parameter ABI attributes.  This is just a best-effort first pass.

I also took the opportunity to shift a few files to just implement
their shims header and to demote a few things to be private stdlib
interfaces.
2016-05-04 10:31:23 -07:00
Han Sangjin
e06c7136cb Porting to Cygwin. rebased and squashed 2016-02-22 13:20:21 +09:00
Joe Groff
f7291b21ec Runtime: Build with -fvisibility=hidden.
...and explicitly mark symbols we export, either for use by executables or for runtime-stdlib interaction. Until the stdlib supports resilience we have to allow programs to link to these SPI symbols.
2016-02-08 08:06:02 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Joe Groff
46cd14efbd Runtime: Move Unicode utilities to stdlib.
These are used by String; they aren't part of the core runtime.
2015-12-23 09:17:08 -08:00