Commit Graph

3150 Commits

Author SHA1 Message Date
Joe Groff
3ec7fc169d Merge pull request #16698 from jckarter/metadata-forward-compatibility
Runtime: Tolerate unknown metadata kinds.
2018-05-18 09:50:13 -07:00
swift-ci
e64331ea3a Merge remote-tracking branch 'origin/master' into master-next 2018-05-18 06:29:34 -07:00
Joe Groff
681a96b45c Runtime: Tolerate unknown metadata kinds.
We want to be able to potentially introduce new metadata kinds in future Swift compilers, so a runtime ought to be able to degrade gracefully in the face of metadata kinds it doesn't know about. Remove attempts to exhaustively switch over metadata kinds and instead treat unknown metadata kinds as opaque.
2018-05-17 15:35:06 -07:00
swift-ci
336e42ee2c Merge remote-tracking branch 'origin/master' into master-next 2018-05-17 15:09:01 -07:00
Ben Langmuir
628b6a1fc7 Revert "Turn on ‘as’ bridging on Linux." 2018-05-17 14:54:35 -07:00
swift-ci
e0c8c31b0b Merge remote-tracking branch 'origin/master' into master-next 2018-05-17 14:29:05 -07:00
Mike Ash
177f34cd0e Merge branch 'master' into fix-static-stripped-error-bridging 2018-05-17 14:13:00 -04:00
Lily Vulcano
b9455930ee Turn on ‘as’ bridging on Darwin. 2018-05-17 09:59:39 -07:00
Mike Ash
3cc86eb836 [Runtime] Look up Error bridging symbols indirectly through special symbols that won't be stripped in static builds.
This fixes a problem where error bridging didn't work in stripped executables using the static versions of the Swift libraries. ErrorObject.mm looks up some symbols with dlsym, but stripping makes it so it can't find those. This change makes a separate set of symbols explicitly made for ErrorObject.mm to look up, and marks them as dynamically referenced so stripping won't remove them. Longer term, we'd like a better solution for looking up these symbols, but this will do for now.

rdar://problem/39810532
2018-05-17 11:43:15 -04:00
swift-ci
228d6d7674 Merge remote-tracking branch 'origin/master' into master-next 2018-05-17 07:49:03 -07:00
Arnold Schwaighofer
0be00c820e Merge pull request #16608 from aschwaighofer/unique_foreign_type_witnesses
Unique synthesized foreign type witnesses and make witness tables part of the metadata cache key
2018-05-17 07:35:10 -07:00
swift-ci
260bf93f5a Merge remote-tracking branch 'origin/master' into master-next 2018-05-16 11:09:52 -07:00
Mike Ash
0e952b45bc Merge pull request #16254 from mikeash/runtime-conformance-scanning-lockless-array
[Runtime] Change protocol conformance scanning to use a concurrent array rather than a locked vector.
2018-05-16 14:03:10 -04:00
swift-ci
3c1802a186 Merge remote-tracking branch 'origin/master' into master-next 2018-05-15 13:29:11 -07:00
Andrew Trick
495d5aecf6 [exclusivity] Add an access marker folding pass.
Use AccessedStorageAnalysis to find access markers with no nested conflicts.

This optimization analyzes the scope of each access to determine
whether it contains a potentially conflicting access. If not, then it
can be demoted to an instantaneous check, which still catches
conflicts on any enclosing outer scope.

This removes up to half of the runtime calls associated with
exclusivity checking.
2018-05-15 12:29:19 -07:00
Mike Ash
da4fa67d7e [Runtime] Move ConcurrentReadableArray's allocate/deallocate functions into Storage. Mark ConcurrentReadableArray as un-copyable, un-assignable, and un-movable. Use SWIFT_MEMORY_ORDER_CONSUME instead of std::memory_order_consume. Make read() pass a const pointer.
rdar://problem/37173156
2018-05-15 15:27:33 -04:00
Arnold Schwaighofer
1ba367ada8 Fix _swift_makeAnyHashableUpcastingToHashableBaseType to use the witness table of the just unboxed typed of a SwiftValue
This got exposed due to the change to use witness tables as part of the
metadata cache key.

The  Swift._ConcreteHashableBox<MinimalHashableValue> metadata created as
part of:

 AnyHashable(MinimalHashableValue(1))

and

 AnyHashable(_bridgeAnythingToObjectiveC(MinimalHashableValue(1)) as!  NSObject)

Would not be uniqued to the same metadata because the witness table of
NSObject that we queried before that change was not equal to the witness
table of MinimalHashableValue.

This is tested by the AnyHashable.swift.gyb test case.

rdar://24958043
2018-05-14 13:54:15 -07:00
Arnold Schwaighofer
b83941795a Unique synthesized foreign type conformances
- Add swift_getForeignWitnessTable to unique non-unique foreign type
   witness tables

 - IRGen: Call the foreign witness uniquing runtime function

rdar://24958043
2018-05-14 13:52:41 -07:00
swift-ci
03c738e9ec Merge remote-tracking branch 'origin/master' into master-next 2018-05-11 00:29:02 -07:00
Joe Groff
0d438c91c4 [Demangle to metadata] Support simple extension contexts.
Support demangling for types nested within some simple extension contexts.
Still does not support nested types within constrained extensions that
involve same-type constraints among generic parameters, nor
deeply-nested types in extensions. However, it fixes
rdar://problem/40071688.
2018-05-10 23:36:01 -07:00
swift-ci
8daaa4ea35 Merge remote-tracking branch 'origin/master' into master-next 2018-05-10 14:49:25 -07:00
Mike Ash
75450e5b3c Merge pull request #16472 from mikeash/silence-offsetof-warning
[Runtime] Silence warnings for offsetof usage on TupleCacheEntry.
2018-05-10 17:29:31 -04:00
swift-ci
8733e2bdaf Merge remote-tracking branch 'origin/master' into master-next 2018-05-10 09:49:16 -07:00
Saleem Abdulrasool
f4c24d6e2e Merge pull request #16403 from lanza/inspect-arch-sdk
Configure the swiftImageInspectionShared to generate arch & sdk speci…
2018-05-10 09:42:35 -07:00
Mike Ash
89bf915e99 Merge branch 'master' into runtime-conformance-scanning-lockless-array 2018-05-09 15:23:36 -04:00
Mike Ash
b821a2ef6d [Runtime] Silence warnings for offsetof usage on TupleCacheEntry.
rdar://problem/39739801
2018-05-09 13:51:59 -04:00
Nathan Lanza
9815368788 Configure the swiftImageInspectionShared to generate arch & sdk specific libraries
Previously, swiftImageInspectionShared generated one specific library at
`lib/libswiftImageInspectionShared.a` for only the main arch and sdk.
Generic cross compilation and various changes to the build system to get
cross compilation to work will require swiftImageInspectionShared to
generate libraries at the proper subdirectory. Change the outputs to
agree with paths such as `lib/swift/linux/x86_64`
2018-05-03 12:33:45 -07:00
swift-ci
49b2c7fe2a Merge remote-tracking branch 'origin/master' into master-next 2018-05-01 12:08:52 -07:00
Arnold Schwaighofer
1f65ee25f6 Distinguish between withoutActuallyEscaping and passing @noescape
Objective C closures when reporting that a closure has escaped

rdar://39682865
2018-05-01 07:24:19 -07:00
swift-ci
13ab622cba Merge remote-tracking branch 'origin/master' into master-next 2018-04-30 17:09:26 -07:00
Michael Gottesman
54137ed302 Merge pull request #16242 from davezarzycki/nfc_misc_warning_fixes
[Misc] NFC: Fix random build warnings
2018-04-30 17:04:29 -07:00
swift-ci
b80f58cbcf Merge remote-tracking branch 'origin/master' into master-next 2018-04-30 13:29:16 -07:00
Mike Ash
8459167b3e Merge pull request #16253 from mikeash/disable-mangled-name-verification
[Runtime] Disable mangled name verification unless specifically enabled with an environment variable.
2018-04-30 13:18:52 -07:00
Michael Gottesman
0d1f98a4ef Merge pull request #16259 from gottesmm/pr-aab473d24268b0934ac216bf2683f0a2c8e3be0f
[+0-all-args] Make _bridgeAnythingNonVerbatimToObjectiveC() take its …
2018-04-30 13:14:46 -07:00
swift-ci
9d81e603c3 Merge remote-tracking branch 'origin/master' into master-next 2018-04-30 12:29:27 -07:00
Michael Gottesman
c31033c525 [+0-all-args] Make _bridgeAnythingNonVerbatimToObjectiveC() take its parameter at +1.
This hoists out the retain into Swift code from the casting runtime and along a
few paths in the runtime allows us to eliminate a dynamic retain release.

rdar://38196046
rdar://38771331
2018-04-30 11:05:00 -07:00
Michael Gottesman
87681375e2 [+0-all-args] Change _swift_stdlib_bridgeErrorToNSError to take its parameter at +1.
This is truly a consuming operation. This can be seen since we always would need
to retain the argument here. This makes guaranteed -> owned less transformation
effective. Instead represent it taking a +1 argument so that the retain happens
outside the builtin instead of inside the builtin.

This also allows me to remove an extra copy from dynamicCastValueToNSError

rdar://38771331
2018-04-30 10:16:41 -07:00
David Zarzycki
95473a10d7 [Misc] NFC: Fix random build warnings
Unused variables/methods, language extensions, extra semicolons, intentional
self assignment, platform specific quirks, etc.
2018-04-30 12:52:43 -04:00
Mike Ash
8b59295a92 [Runtime] Change protocol conformance scanning to use a concurrent array rather than a locked vector.
rdar://problem/37173156
2018-04-30 12:24:47 -04:00
Mike Ash
09e1e355a4 [Runtime] Disable mangled name verification unless specifically enabled with an environment variable.
rdar://problem/39821779 rdar://problem/39821761 rdar://problem/39821758
2018-04-30 10:56:09 -04:00
swift-ci
3aa10bbefc Merge remote-tracking branch 'origin/master' into master-next 2018-04-27 20:29:05 -07:00
Mike Ash
5fc07b8709 Merge pull request #16188 from mikeash/assert-metadata-mangled-name-roundtrip
[Runtime] Assert that metadata mangled names successfully roundtrip.
2018-04-27 20:09:24 -07:00
swift-ci
1f1646b88b Merge remote-tracking branch 'origin/master' into master-next 2018-04-27 08:49:00 -07:00
Mike Ash
91619c4cd0 [Runtime] Make mangled name roundtrip verification a soft failure. Disable it entirely when running tests and when bootstrapping swiftpm, for now.
rdar://problem/37551850
2018-04-27 10:09:06 -04:00
Arnold Schwaighofer
dab3b0b184 Runtime: Fix swift_bridgeObjectRetain family of functions to return the input
object

Now we can use swift_bridgeObjectRetain's return value in BridgeObjectBox.
2018-04-27 06:14:32 -07:00
swift-ci
647867db68 Merge remote-tracking branch 'origin/master' into master-next 2018-04-26 16:29:08 -07:00
tbkka
924b8e55d5 Updates to Floating-point printing code (SwiftDtoa.cpp) (#16178)
This collects a number of changes I've been testing over the
last month.

* Bug fix: The single-precision float formatter did not always
  round the last digit even in cases where there were two
  possible outputs that were otherwise equally good.

* Algorithm simplification: The condition for determining
  whether to widen or narrow the interval was more complex than
  necessary. I now simply widen the interval for all even
  significands.

* Code simplification: The single-precision float formatter now uses fewer
  64-bit features.  This eliminated some 32-bit vs. 64-bit conditionals in
  exchange for a minor loss of performance (~2%).

* Minor performance tweaks: Steve Canon pointed out a few places
  where I could avoid some extraneous arithmetic.

I've also rewritten a lot of comments to try to make the exposition
clearer.

The earlier testing regime focused on testing from first
principles.  For example, I verified accuracy by feeding the
result back into the C library `strtof`, `strtod`, etc. and
checking round-trip exactness.  Unfortunately, this approach
requires many checks for each value, limiting test performance.
It's also difficult to validate last-digit rounding.

For this round of updates, I've instead compared the digit
decompositions to other popular algorithms:
* David M. Gay's gdtoa library is a robust and well-tested
  implementation based on Dragon4.  It supports all formats, but
  is slow. (netlib.org/fp)
* Grisu3 supports Float and Double.  It is fast but incomplete,
  failing on about 1% of all inputs.
  (github.com/google/double-conversion)
* Errol4 is fast and complete but only supports Double.  The
  repository includes an implementation of the enumeration
  algorithm described in the Errol paper.
  (github.com/marcandrysco/errol)

The exact tests varied by format:

* Float: SwiftDtoa now generates the exact same digits as gdtoa
  for every single-precision Float.

* Double: Testing against Grisu3 (with fallback to Errol4 when
  Grisu3 failed) greatly improved test performance.  This
  allowed me to test 100 trillion (10^14) randomly-selected
  doubles in a reasonable amount of time.  I also checked all
  values generated by the Errol enumeration algorithm.

* Float80: I compared the Float80 output to the gdtoa library
  because neither Grisu3 nor Errol4 yet supports 80-bit extended
  precision.  All values generated by the Errol enumeration
  algorithm have been checked, as well as several billion
  randomly-selected values.
2018-04-26 16:09:49 -07:00
Mike Ash
77e9b967f3 [Runtime] When asserts are enabled, verify that each newly created Metadata successfully roundtrips its mangled name through the demangler.
rdar://problem/37551850
2018-04-25 16:26:23 -04:00
swift-ci
4a97d36810 Merge remote-tracking branch 'origin/master' into master-next 2018-04-23 15:09:14 -07:00
Doug Gregor
d755b38ee5 [Runtime] Teach BridgeObjectBox::retain() not to drop the "not native" bit.
The "not native" bit in a BridgeObject is important, because it tells
us when we need to go through the Objective-C -retain method
vs. swift_retain. Losing the bit means that swift_retain() will stomp
on some memory within an Objective-C object, thinking its the inline
reference count.

Co-debugged with Arnold, who then found where this bit was getting dropped.
Fixes rdar://problem/39629937.
2018-04-23 14:04:22 -07:00