Commit Graph

4750 Commits

Author SHA1 Message Date
Doug Gregor 1889ea2657 Remove the default implementation of _ObjectiveCBridgeable._unconditionallyBridgeFromObjectiveC.
SILGen can't handle it yet, so pull it out until SILGen is fixed.
2016-03-24 17:10:26 -07:00
John McCall 0ffb7278bc Only use metadata patterns for generic types; perform other
initialization in-place on demand.  Initialize parent metadata
references correctly on struct and enum metadata.

Also includes several minor improvements related to relative
pointers that I was using before deciding to simply switch the
parent reference to an absolute reference to get better access
patterns.

Includes a fix since the earlier commit to make enum metadata
writable if they have an unfilled payload size.  This didn't show
up on Darwin because "constant" is currently unenforced there in
global data containing relocations.

This patch requires an associated LLDB change which is being
submitted in parallel.
2016-03-24 15:10:31 -07:00
David Farler 790b7de5e4 Reenable building the SwiftReflectionTest library
This wasn't importing the Mach-O APIs from the right module.
2016-03-24 14:15:55 -07:00
Stephen Canon 7b1fddfbc1 Merge pull request #1835 from stephentyrone/simd-uint-vectors
Added uint[2,3,4] to simd, bridged to vector_uintN.
2016-03-24 17:08:26 -04:00
David Farler e65f685a23 Temporarily disable SwiftReflectionTest library builds
Some Mach APIs don't appear to resolve on iOS.
2016-03-24 12:40:59 -07:00
David Farler 0f62e6691c Add SwiftReflectionTest helper library
This is a small helper library to communicate information back to
swift-reflection-test from a test swift executable. Each swift test
file under test/Reflection should link this library to get the main
test hook to send responses back to the test tool.
2016-03-24 12:05:18 -07:00
Arnold Schwaighofer 7fb2cceec0 Add a method to _NSContiguousString to facilitate stack promotion
Use it for hashing and comparison.

During String's hashValue and comparison function we create a
_NSContiguousString instance to call Foundation's hash/compare function. This is
expensive because we have allocate and deallocate a short lived object on the
heap (and deallocation for Swift objects is expensive).  Instead help the
optimizer to allocate this object on the stack.

Introduces two functions on the internal _NSContiguousString:
_unsafeWithNotEscapedSelfPointer and _unsafeWithNotEscapedSelfPointerPair that
pass the _NSContiguousString instance as an opaque pointer to their closure
argument. Usage of these functions asserts that the closure will not escape
objects transitively reachable from the opaque pointer.

We then use those functions to call into the runtime to call foundation
functions on the passed strings. The optimizer can promote the strings to the
stack because of the assertion this API makes.

  let lhsStr = _NSContiguousString(self._core) // will be promoted to the stack.
  let rhsStr = _NSContiguousString(rhs._core) // will be promoted to the stack.
  let res = lhsStr._unsafeWithNotEscapedSelfPointerPair(rhsStr) {
    return _stdlib_compareNSStringDeterministicUnicodeCollationPointer($0, $1)
  }

Tested by existing String tests.

We should see some nice performance improvements for string comparison and
dictionary benchmarks.

Here is what I measured at -O on my machine

Name                          Speedup
Dictionary                      2.00x
Dictionary2                     1.45x
Dictionary2OfObjects            1.20x
Dictionary3                     1.50x
Dictionary3OfObjects            1.45x
DictionaryOfObjects             1.40x
SuperChars                      1.60x

rdar://22173647
2016-03-24 05:43:29 -07:00
Stephen Canon 8187dfb140 Added uint[2,3,4] to simd, bridged to vector_uintN. 2016-03-24 07:56:59 -04:00
Slava Pestov aa3700826e Runtime: Small cleanup to fix function order, NFC 2016-03-24 00:50:38 -07:00
John McCall abba7f0c8b Revert "Only use metadata patterns for generic types; perform other"
This reverts commit 41efb3d4d3.
LLDB has too many tendrils into our metadata.
2016-03-23 20:26:43 -07:00
John McCall 41efb3d4d3 Only use metadata patterns for generic types; perform other
initialization in-place on demand.  Initialize parent metadata
references correctly on struct and enum metadata.

Also includes several minor improvements related to relative
pointers that I was using before deciding to simply switch the
parent reference to an absolute reference to get better access
patterns.
2016-03-23 17:04:04 -07:00
Andrew Trick 043a85e128 Merge pull request #1799 from atrick/master
Fix for SR-912: Runtime exception casting an Any nil to an Optional.
2016-03-22 20:44:26 -07:00
Andrew Trick 1bd9dc97b4 SR-912: Runtime exception casting an Any nil to an Optional.
This is a simple runtime fix for the following case:

func cast<U>(t: Any) -> U {
  return t as! U
}
cast(nil as Int?) as Int?
2016-03-22 17:47:05 -07:00
Slava Pestov 34e41f2e81 built-script: Add --swift-stdlib-sil-serialize-all flag
We want to have the option of building the standard library without
-sil-serialize-all.

For now, the build crashes in the SIL verifier due to various issues;
upcoming patches will address these.

This is part of the larger goal of building the stdlib with
-enable-resilience.

Part of https://bugs.swift.org/browse/SR-267.
2016-03-22 17:13:34 -07:00
Jordan Rose cd9114423a Reapply "[StdlibUnittest] Install our own handler for uncaught ObjC exceptions."
This reapplies e6a519f and 86dcce1 by reverting e86d3bd, which reverted
more than it needed to.
2016-03-22 16:24:40 -07:00
Dmitri Gribenko 8c5d012ab4 Merge pull request #1774 from apple/use-truncatingBitPattern
stdlib: Use UInt8(truncatingBitPattern:) instead of an equivalent inline construct
2016-03-22 14:25:15 -07:00
Dmitri Gribenko 168e7e41a5 Merge pull request #1525 from PatrickPijnappel/utf8-rewrite
[stdlib] Rewrite UTF8 decoding
2016-03-22 14:24:11 -07:00
practicalswift ac87f428ea [gardening] Fix formatting of recently introduced headers. 2016-03-22 21:36:09 +01:00
Dmitri Gribenko 2c53727bf7 stdlib: Use UInt8(truncatingBitPattern:) instead of an equivalent inline construct 2016-03-22 11:14:46 -07:00
rintaro ishizaki 91108b4602 [stdlib] Implement tgmath in Glibc 2016-03-23 00:51:50 +09:00
rintaro ishizaki 9ce1387ee3 [stdlib] Merged Glibc code to Platform directory. 2016-03-23 00:51:37 +09:00
Patrick Pijnappel ffe864687a [stdlib] Clarify buffer comments in UTF8._decodeOne() 2016-03-22 22:33:13 +11:00
rintaro ishizaki eecfb6e41d [stdlib] Renamed cross-platform C helper functions in Darwin so that we can share them with Glibc. 2016-03-22 16:07:48 +09:00
rintaro ishizaki d875a56a75 [stdlib] Moved stdlib/public/SDK/Darwin to stdlib/public/Platform. NFC 2016-03-22 16:05:51 +09:00
Dmitri Gribenko 1e4f7109fa Merge pull request #1724 from compnerd/correct-linkage
stdlib: tweak import declarations
2016-03-21 23:32:46 -07:00
Erik Eckstein c8d61fce9f Add a build-script-impl option --build-sil-debugging-stdlib to compile the stdlib with SIL debug info (-gsil) 2016-03-21 12:57:05 -07:00
Doug Gregor 17c15932fa Foundation overlay: stringByAppendingFormat -> appendingFormat.
This API didn't get updated to match the Swift 3 name of this
method. Thanks to Nate Cook for finding the error!
2016-03-21 10:38:37 -07:00
Michael Ilseman e86d3bde6c Revert "[ReconstructType] Fix decl lookup when there are multiple constructors"
This reverts commit 65c86b713d.

I attempted to resolve the merge conflict, but Jordan will need to do
a second check.
2016-03-20 20:00:37 -07:00
marcusrossel e09b00e727 Added a missing period in a comment. 2016-03-20 18:01:02 -06:00
Xin Tong 92f2b3fb82 Merge pull request #1736 from trentxintong/PA
Fix thread-unsafety in Process.Argument initialization. 

rdar://problem/24250684 and SR-940
2016-03-19 21:18:55 -07:00
Xin Tong 9fdcf0f433 Remove some unused enum declaration 2016-03-19 18:46:16 -07:00
Xin Tong cb6a0328d2 Address more suggestions to Fix thread-unsafety in Process.Argument initialization 2016-03-19 18:15:39 -07:00
Xin Tong df41e6a53c Address more suggestions to Fix thread-unsafety in Process.Argument initialization 2016-03-19 14:06:35 -07:00
Dmitri Gribenko b7bc7c993b Merge pull request #1739 from leogiertz/master
[FreeBSD] Rename .memory to .pointee in Glibc
2016-03-18 20:45:58 -07:00
Doug Gregor 9c530f1d93 [Runtime] Add witness-table parameters to _ObjectiveCBridgeable witnesses.
The witness-table parameters got added to all witnesses as part of the
resilience work, but the hardcoded witness table in the runtime's
dynamic-casting infrastructure didn't get updated. Nothing seems to be
relying on these right now, so we cannot actually *test* it, but I've
verified that the types line up.
2016-03-18 16:30:53 -07:00
Xin Tong b36c343249 Address suggestions to Fix thread-unsafety in Process.Argument initialization 2016-03-18 16:23:51 -07:00
Doug Gregor 67dad6041c [Runtime] Use the _ObjectiveCBridgeable._ObjectiveCType type witness directly.
This lets us eliminate the _getObjectiveCType() value witness, which
was working around the lack of proper type witness metadata in witness
tables. Boilerplate -= 1.
2016-03-18 16:11:38 -07:00
Xin Tong 8a6fdebc38 Fix thread-unsafety in Process.Argument initialization
rdar://problem/24250684
2016-03-18 15:19:32 -07:00
Jordan Rose 86dcce1259 [StdlibUnittest] Don't catch ObjC exceptions on non-ObjC platforms.
My apologies!
2016-03-18 14:25:07 -07:00
Jordan Rose e6a519fbda [StdlibUnittest] Install our own handler for uncaught ObjC exceptions.
We don't want to be at the whims of the system on what to do with an
uncaught exception; we need to make sure its message gets printed to
stderr so that the parent process can check it.

(There's a bit of trickery here to see if the class looks like an
NSException; otherwise we lose the name of the exception and just get
the reason.)
2016-03-18 13:55:45 -07:00
Doug Gregor d92ae77076 Eliminate most remaining uses of _convertNSFooToFoo and _convertFooToNSFoo.
Generalized bridging has fully subsumed most of these. NSError is
still special, and _convertStringToNSString remains for the the
runtime's implementation of SwiftObject's -description method.
2016-03-18 11:42:00 -07:00
Dmitri Gribenko ceae4de018 Merge pull request #1723 from natecook1000/nc-sort-dedeprecate
[stdlib] Remove unavailable annotation for MutableCollection.sort()
2016-03-18 00:45:32 -07:00
Dmitri Gribenko afcf0e34e0 Merge pull request #1722 from harlanhaskins/stdlibunittest-formatting
[StdlibUnittest] Make output for expected crashes less fatalistic
2016-03-17 21:12:31 -07:00
Harlan Haskins 47541c92b4 [StdlibUnittest] Made output for expected crashes less fatalistic 2016-03-17 18:23:41 -06:00
Saleem Abdulrasool 42678c1e00 stdlib: tweak import declarations
Ensure that the functions which are declared with @_silgen_name for importing
from external libraries are described with the correct linkage.  If the declared
functions are marked with internal or no linkage, the declaration for the import
will be given internal linkage.  However, this is incorrect if the definition is
not part of the image.

The remaining uses were filtered on the assumption that the swift standard
library is statically linked and provides the definitions for those symbols and
thus will be part of the image.

This was noticed by manual inspection of the IR generated.  Thanks to Dmitri
Gribenko for the hint about the trampoline construction.
2016-03-17 17:22:50 -07:00
Joe Groff 36cf02597a Merge pull request #1720 from compnerd/underscore
runtime: improve portability and simplify aliases
2016-03-17 14:55:04 -07:00
Harlan Haskins 424eec9960 [StdlibUnitTest] Disable printing child stderr for expected crashes. 2016-03-17 15:14:05 -06:00
Nate Cook afac511c19 [stdlib] Remove unavailable annotation for MutableCollection.sort() 2016-03-17 16:12:37 -05:00
Max Moiseev 03cbb49982 [stdlib] _stdlibAssert => _debugPrecondition 2016-03-17 12:16:19 -07:00
Saleem Abdulrasool 13a2ef3b4b runtime: improve portability and simplify aliases
clang and gcc provide a preprocessor macro called `__USER_LABEL_PREFIX__` which
provides the user label prefix for the specific target that the translation unit
is being built for.  Rather than trying to reconstruct the logic in place via
various checks, fallback to the compiler to provide this information.  Although
this limits the compilers (MSVC does not provide this preprocessor macro
definition), the only supported compiler ATM is clang, and it has provided this
definition for some time now.

This addresses the FIXME that was associated with the user label prefix being
applied under specific cases.

NFC.
2016-03-17 10:05:07 -07:00