Commit Graph

13406 Commits

Author SHA1 Message Date
zhuowei
b9c1deff5f [stdlib] fix return type of getNumRuntimeFunctionCounters (#24182)
The return type of getNumRuntimeFunctionCounters is defined as uint64_t in RuntimeInvocationsTracking.cpp, but it has return type Int in RuntimeFunctionCounters.swift.

Found when compiling the stdlib for WebAssembly, as WebAssembly validates return types. uint64_t corresponds to i64, but Int is i32, so the program fails validation.
2019-11-22 13:44:56 -05:00
Mike Ash
3912e7c8ac [Runtime] Enhance Metadata::dump to dump the number of generic args and the pointer of each. 2019-11-22 13:17:54 -05:00
Stephen Canon
671df74418 Use the truncatingIfNeeded init on the result of these runtime funcs. (#28426)
The swift_floatNToString, swift_int64ToString, and swift_uint64ToString functions all return a uint64_t from c++. This is a historical accident, but these are SWIFT_RUNTIME_STDLIB_API, which means that we can't trivially change the return type. The result should naturally be size_t or int (it's always small enough to fit into *any* c integer type). However, we can elide the check in the caller at the point that the result is converted to Int, because we know that the check will always pass. This makes it so that the only overhead the wrong type introduces on 32b platforms is zeroing a register, which is free or nearly-free.
2019-11-21 20:45:04 -05:00
zhuowei
8b3a15babf [stdlib] Fix return type of swift_{uint64,int64,float*}ToString (#24181)
The return type of these functions are uint64_t in Stubs.cpp but UInt in the Swift code; this changes the Swift code to match the C++ return type.

Found when compiling the stdlib for WebAssembly, which requires that all return types match: UInt maps to i32 while uint64_t maps to i64, so functions calling these functions fail the validation.
2019-11-21 17:21:22 -05:00
Robert Widmann
b9fe66e0e8 Add documentation to _DependenceToken 2019-11-21 10:48:18 -08:00
Arnold Schwaighofer
75c0bf076f Merge pull request #28337 from aschwaighofer/get_type_by_mangled_name_abstract_runtime
Add swift_getTypeByMangledNameInContextInMetadataState such that we can
2019-11-21 07:37:25 -08:00
Mao ZiJun
d5e2533cef improved OptionSet.remove's code style 2019-11-21 14:55:39 +09:00
swift-ci
2fa65ae23a Merge pull request #28393 from DougGregor/error-bridge-to-nsobject-redux 2019-11-20 19:08:46 -08:00
Saleem Abdulrasool
ac1685e5f1 Merge pull request #28348 from compnerd/ballantyne-syndrome
build: split out swiftReflection builds
2019-11-20 18:45:29 -08:00
Mao ZiJun
a8fd973876 fixed OptionSet's remove method 2019-11-21 11:25:41 +09:00
Doug Gregor
859fb0dc45 [Runtime] Handle dynamic casting to NSObject via error bridging.
The dynamic casting machinery failed to account for NSError bridging when
casting to NSObject; check for it explicitly.
2019-11-20 15:56:24 -08:00
Brent Royal-Gordon
bc5d59ecb7 Revert "[Runtime] Handle dynamic casting to NSObject via error bridging." 2019-11-20 10:38:44 -08:00
swift-ci
6d46eb182a Merge pull request #28353 from DougGregor/error-bridge-to-nsobject 2019-11-19 10:24:30 -08:00
Arnold Schwaighofer
cf20dd4cf3 Add swift_getTypeByMangledNameInEnvironmentInMetadataState runtime function 2019-11-19 09:18:04 -08:00
Doug Gregor
ab062fcd14 [Runtime] Handle dynamic casting to NSObject via error bridging.
The dynamic casting machinery failed to account for NSError bridging when
casting to NSObject; check for it explicitly.
2019-11-18 23:00:57 -08:00
Saleem Abdulrasool
cb3365f03d build: split out swiftReflection builds
We would build two copies of swiftReflection, one for the host and one
for the target.  However, the compiler configuration cannot be swapped
out in the middle as we were attempting to do.  This would result in a
failure to build sometimes due to the missing dependency on the wanted
compiler.  More importantly, it would also use the wrong compiler when
building the library.  Although this duplicates the source paths,
correctness is preserved.
2019-11-18 17:17:35 -08:00
swift-ci
598042b521 Merge pull request #21550 from valeriyvan/patch-1 2019-11-18 15:27:40 -08:00
Arnold Schwaighofer
0d324d223f Add swift_getTypeByMangledNameInContextInMetadataState such that we can
use getTypeByMangledName when abstract metadata state is requested

This can significantly reduce the code size of apps constructing deeply
nested types with conditional conformances.

Requires a new runtime.

rdar://57157619
2019-11-18 14:41:35 -08:00
swift-ci
9905c44509 Merge pull request #28327 from CodaFi/do-it-for-the-datagrams 2019-11-18 13:38:21 -08:00
Philippe Hausler
498a240a98 [Foundation] Reorder _DataStorage to save 14 bytes of overhead 2019-11-18 10:52:35 -08:00
Robert Pieta
cda5676525 IndexSet.union performance improvement 2019-11-18 09:50:05 -08:00
Sergo Beruashvili
62a75d762d Use precondition instead of fatalError in DateInterval initializer 2019-11-17 15:15:55 -08:00
Slava Pestov
50872964dd Merge pull request #28289 from slavapestov/generic-parameters-are-unreliable-witnesses
Revert "Sema: Look for generic parameters first when inferring an associated type"
2019-11-16 01:56:16 -05:00
Nate Cook
8bfe519413 [stdlib] Use RRC.filter in removeAll(where: _) (#18825) 2019-11-15 16:24:27 -06:00
Mike Ash
8499a7f4fb Merge pull request #28183 from mikeash/zero-size-builtin-type-descriptors-remote-mirror
[Reflection] Ignore BuiltinTypeDescriptors with zero size, alignment, or stride.
2019-11-15 13:15:38 -08:00
Slava Pestov
55e3797471 Revert "Sema: Look for generic parameters first when inferring an associated type"
This breaks source compatibility a little bit more than we'd like, so
reverting it for now.

Fixes <rdar://problem/57213598>.

This reverts commit 04fbcc0149.
2019-11-15 14:32:13 -05:00
Nate Cook
7c0ed24867 [stdlib] Document Windows implementation of SystemRandomNumberGenerator (#28268) 2019-11-15 10:38:44 -06:00
Mike Ash
ee8447e7ab [Reflection] Reject BuiltinTypeDescriptors with non-power-of-two alignments.
rdar://problem/56784375
2019-11-15 10:50:51 -05:00
Mike Ash
e7163006ee [Reflection] Accept BuiltinTypeDescriptors with zero size.
rdar://problem/56784375
2019-11-14 16:43:51 -05:00
Mike Ash
1b8a723038 [Reflection] Ignore BuiltinTypeDescriptors with zero size, alignment, or stride.
rdar://problem/56784375
2019-11-14 16:14:48 -05:00
Luca Torella
e6992d35cd Fix reference to range(of:) in the contains doc
Signed-off-by: Luca Torella <luca@scandit.com>
2019-11-14 10:44:05 -08:00
Slava Pestov
04fbcc0149 Sema: Look for generic parameters first when inferring an associated type
Previously we did this as a last resort if inference fails. The new
behavior is technically source-breaking, but I suspect nobody
relied on the old behavior.

This can help avoid cycles by eliminating some unnecessary validation work.

Fixes <https://bugs.swift.org/browse/SR-11407>, <rdar://problem/54979757>.
2019-11-13 23:42:08 -05:00
Ravi Kandhadai
b0de132aad [stdlib-private][oslog] Remove OSLogArguments.serializeAt method
and instead directly access the array stored in OSLogArguments.
This will make constant folding of the array possible when its
contents are inferred at compile time by the OSLogOptimization pass.
2019-11-07 17:11:07 -08:00
Michael Ilseman
1d63710a06 Merge pull request #28016 from milseman/swept_under_the_bridge
[stdlib] [gardening] Refactor bridging from StringStorage.swift
2019-11-06 13:43:32 -08:00
Dan Zheng
53e61a9587 [AutoDiff upstream] Add the _Differentiation module. (#27511)
The `_Differentiation` module is the experimental support library for
differentiable programming. It is built when the build-script flag
`--enable-experimental-differentiable-programming` is enabled.

The `Differentiable` protocol generalizes all types that work with
differentiation. It is a core piece of the differentiable programming
project. Other parts depending on the `Differentiable` protocol will
be upstreamed piece by piece.

The `Differentiable` protocol is compiler-known and will be used during
type-checking, SILGen, and the SIL differentiation transform.
2019-11-06 11:31:12 -08:00
Karoy Lorentey
4008261ab8 Merge pull request #27939 from compnerd/gnu-no-more
stdlib: remove usage of GNU extensions in the Darwin os module
2019-11-05 12:01:41 -08:00
Hamish Knight
40231991ae [Sema] Diagnose unsound pointer conversions (#27695)
[Sema] Diagnose unsound pointer conversions
2019-11-04 17:18:57 -08:00
Saleem Abdulrasool
5d683d9670 StdlibUnittest: port to android x86, x86_64
Account for the x86 and x86_64 architectures when defining
`RTLD_DEFAULT`.
2019-11-03 20:52:11 -08:00
Hamish Knight
1bc56dcc11 [stdlib] Mark some parameters @_nonEphemeral
These include the pointer-to-pointer and pointer-to-buffer-pointer
initialiser parameters amongst a couple of others, such as
`Unmanaged.fromOpaque`, and the source for the `move[...]` family of
methods.
2019-11-03 08:42:26 -08:00
Michael Ilseman
8463e53df3 [stdlib] [gardening] Refactor bridging from StringStorage.swift
Add StringStorageBridge.swift to separate out ObjC interop
functionality.

NFC
2019-11-01 17:25:08 -07:00
Mike Ash
da71f6bedc [Reflection] Fix length calculation in readTypeRef.
The code was skipping 4/8 bytes to jump overn embedded reference, but it actually needs to skip 5/9 bytes in order to skip over the leading control character as well.

Also change the abort() calls to return nullptr so that we can fail more gracefully if this code is ever presented with bad data, since we want inspection tools to be robust in the face of garbage.

rdar://problem/56460096
2019-10-31 14:12:41 -04:00
David Smith
406d03bdef Merge pull request #27974 from Catfish-Man/erroneous-errors
Don't try to speculatively bridge tagged pointers to Errors
2019-10-30 18:31:16 -07:00
David Smith
acb5b570f5 Don't try to speculatively bridge tagged pointers to Errors 2019-10-30 15:16:10 -07:00
swift-ci
2d73686903 Merge pull request #27962 from mikeash/isbackdeploying-fix 2019-10-30 12:36:12 -07:00
Mike Ash
ce1112126c [Runtime] Fix guards around _swift_isBackDeploying call in SwiftObject.mm.
This could fail to build due to BackDeployment.h not always being included in Config.h. Check an additional condition to ensure that this code is only active when BackDeployment.h is included.

rdar://problem/56735154
2019-10-30 13:48:30 -04:00
Saleem Abdulrasool
7e050d14e6 stdlib: remove usage of GNU extensions in the Darwin os module
Remove the gratuitous use of the GNU extensions to implement the OS logging
module.  This allows us to enable `-Werror=gnu` globally, even on macOS builds.
2019-10-30 08:38:46 -07:00
Mike Ash
7b650c5da5 [Runtime] Extend Metadata::dump for existential type metadata.
Dump whether it's class bounded, the protocols it contains, and the superclass constraint if there is one.
2019-10-30 09:36:14 -04:00
Ravi Kandhadai
861c0aaca9 [OSLogOptimization][stdlib/private] Make string interpolation methods
of OSLogMessage constant evaluable and remove @_transparent annotation
from the methods. Also, improve diagnostics in the OSLogOptimization
pass as now it rely on seeing the appendInterpolation/Literal calls.
2019-10-29 19:35:37 -07:00
Mike Ash
55f9d2afca Merge pull request #27863 from mikeash/will-throw-callback
[Runtime] Add a function pointer for intercepting swift_willThrow calls.
2019-10-29 16:50:36 -04:00
Saleem Abdulrasool
a41b4a8f14 SwiftReflectionTest: enable builds on non-Apple targets
Ensure that the swift-reflection-test binary is built for Windows by
default.  This is preventing tests from executing on Windows.  There are
dependencies which were already specified for Linux even, the tool just
was disabled due to an invalid check.
2019-10-29 08:37:49 -07:00