Commit Graph

1743 Commits

Author SHA1 Message Date
Mike Ash
fb200e6159 [Test] Fix generic_casts and generic_casts_objc for back-deployment testing.
When we're testing against a runtime that doesn't have the fix, just fake the correct results.

rdar://problem/56375164
2019-10-21 16:36:06 -04:00
Mike Ash
68e93a171c [Test] Make sure generic_casts_objc.swift tests an unoptimized build of the test even when --test-optimized is passed.
rdar://problem/56339727
2019-10-16 15:48:36 -04:00
Mike Ash
8dc43e6cea Merge pull request #27572 from mikeash/protocol-existential-crisis
[Runtime] Handle existential target types in swift_dynamicCastMetatypeImpl
2019-10-16 09:14:41 -04:00
Mike Ash
b05e0099f8 [Test] Make sure generic_casts.swift tests an unoptimized build of the test even when --test-optimized is passed.
rdar://problem/56044443
2019-10-15 15:49:03 -04:00
Mike Ash
0aab6d2368 [Test] Remove --dump-input fail from generic_casts.swift.
rdar://problem/56044443
2019-10-11 17:25:46 -04:00
Mike Ash
6a3eecb79c [Test] Split out the @objc bits of the new generic_casts.swift code.
rdar://problem/56044443
2019-10-11 13:15:57 -04:00
Arnold Schwaighofer
e4e162d25f IRGen: Fix cast of existential type with anyobject to super class constraint existential
rdar://55987397
SR-11565
2019-10-11 10:00:14 -07:00
Mike Ash
3ff277d31d [Runtime] Use _conformsToProtocols instead of manually checking protocol conformance.
This is cleaner and it fixes a bunch of cases the old code didn't handle: @objc protocols, class bounds, and superclass constraints.

rdar://problem/56044443
2019-10-10 14:14:41 -04:00
Mike Ash
d56173eb14 [Runtime] Handle existential target types in swift_dynamicCastMetatypeImpl.
This fixes cases like `type is T.Type` when T is generic specialized to a protocol type.

Note: the compiler can still optimize these checks away and will optimize this check down to `false` in some cases. We'll want to fix that as well.

rdar://problem/56044443
2019-10-08 11:37:39 -04:00
Michael Gottesman
c3be255008 [polymorphic-builtin] Disable experimental builtin test when optimization is enabled for now.
I am going to loop back around later and I want to unblock the package bots.
2019-09-23 17:54:16 -07:00
Michael Gottesman
b9046c6d03 [polymorphic-builtin] Rather than asserting in IRGen if we see a builtin that was not specialized, turn the builtin into a trap.
I forgot about this part of the design when I was working on this. To ensure
that the whole design works as expected, I included a small end-to-end test
using an experimental design for simd that uses polymorphic builtins that test
this functionally.

NOTE: The experimental design is only intended to exercise the code functionally.

rdar://48248417
2019-09-23 13:51:01 -07:00
David Smith
1efa946caf Remove stdlib and runtime dependencies on Foundation and CF 2019-09-12 18:03:14 -07:00
Joe Groff
427ed9c79d Compatibility50: Fix for high-bit characters. 2019-09-06 18:19:19 -04:00
Joe Groff
0ae86c9c9d IRGen: Backward-deploy fix using open-coded accessors.
If we mangled an opaque associated type while targeting an older OS, we can use a \9
accessor reference string to instantiate the associated type.
2019-09-04 10:22:17 -07:00
Joe Groff
6817c53031 Mangle associated types of opaque types like dependent member types.
The archetype mangling does not have enough information to accurately recover the associated type
at runtime. This fixes rdar://problem/54084733.

Although this changes the mangling in both runtime and symbols, this should not affect ABI, because
there is no way for associated types of opaque types to be surfaced in the types of public
declarations today.
2019-09-04 10:20:10 -07:00
Erik Eckstein
5f01b0d1b3 tests: make two tests more resilient to destroy hoisting 2019-08-29 10:49:54 +02:00
Joe Groff
a49e0d5a2e Runtime: Hook the ObjC runtime with an untrusted demangler.
We don't want objc_getClass and NSClassFromString to be able to feed arbitrary symbolic reference
pointers into the Swift runtime. Fixes rdar://problem/54724618.
2019-08-28 11:56:45 -07:00
Arnold Schwaighofer
51193f4c82 These tests require __swift_debug_verifyTypeLayoutAttribute which is not ABI or available on OS stdlibs
Interpreter/multi_payload_extra_inhabitant.swift
  Interpreter/struct_extra_inhabitants.swift

Mark the test as unsupported when running the tests with the OS' stdlib.

rdar://54749176
2019-08-27 09:06:12 -07:00
Michael Gottesman
5294e51ef1 [mandatory-inlining] Fix lifetime extension error.
This bug is caused by a quirk in the API of the linear lifetime
checker. Specifically, even though valueHasLinearLifetime is passed a SILValue
(the value whose lifetime one is checking), really it doesnt care about that
value (except for error diagnostics). Really it just cares about the parent
block of the value since it assumes that the value is guaranteed to dominate all
uses.

This creates a footgun when if one is writing code using "generic ossa/non-ossa"
routines on SILBuilder (the emit*Operation methods), if one in non-ossa code
calls that function, it returns the input value of the strong_retain. This
causes the linear lifetime error, to use the parent block of the argument of the
retain, instead of the parent block of the retain itself. This then causes it to
find the wrong leaking blocks and thus insert destroys in the wrong places.

I fix this problem in this commit by noting that the partial apply is our
original insertion point for the copy, so of course it is going to be in the
same block. So I changed the linear lifetime checker to check for leaks with
respect to the partial applies result.

In a subsequent commit, I am going to add a new API on top of this that is based
around the use of the value by the partial apply (maybe
extendLifetimeFromUseToInsertionPoint?). By using the use, it will express in
code more clearly what is happening here and will insert the copy for you.

rdar://54234011
2019-08-22 09:37:29 -07:00
Mike Ash
93128d8fea [Runtime] Add missing FakeUnavailableSwiftDylib.swift file. 2019-08-14 15:01:58 -04:00
Mike Ash
6473b9d7cd [Runtime] Fix swift_conformsToProtocol crashing on conformances to unavailable classes.
An extension on a class creates a conformance record that's always visible even when that class is not present at runtime. In that case, the type pointer in the conformance record is NULL. The runtime did not like this, and crashed. This fixes it to ignore such records instead.

rdar://problem/54054895
2019-08-13 14:39:20 -04:00
Joe Groff
44af3a9398 Merge pull request #26561 from jckarter/opaque-assoc-type-demangle-workaround
IRGen: Work around runtime bug demangling associated types of opaque types.
2019-08-08 13:06:40 -07:00
Joe Groff
e6bc3e7adf IRGen: Work around runtime bug demangling associated types of opaque types.
The Swift 5.1 runtime (and master, for the time being) do not successfully demangle this mangling,
so for the time being, fall back to open-coded metadata access in this case. Workaround for
rdar://problem/54084733.
2019-08-08 10:31:48 -07:00
Pavel Yaskevich
9bd06af328 [Tests] NFC: Disable GLKit_parse tests due to unexpected warnings on tvOS 2019-08-07 10:51:33 -07:00
Joe Groff
f9e5de9371 IRGen: Reenable caching opaque type metadata accessors.
Dynamic replacement can only really get away with replacing opaque return types if a function's
opaque type has never been instantiated in the first place. Meanwhile, repeatedly instantiating
the metadata is too slow for many clients to tolerate. Fixes rdar://problem/53213600.
2019-07-17 20:15:09 -07:00
Arnold Schwaighofer
b233ca78c6 Int64 in more places 2019-07-12 18:05:53 -07:00
Arnold Schwaighofer
4300a589dc Fix test/Interpreter/dynamic_replacement_opaque_result.swift
rdar://53029978
2019-07-12 17:20:57 -07:00
Stephen Canon
ca1e808bde Replace all 9999 availability in non-stdlib tests. (#26109)
Replace all 9999 availability in non-stdlib tests with the appropriate platform availability.
2019-07-12 14:48:37 -04:00
Slava Pestov
cea8a6d6dc Split up test/IRGen/jit_metadata_strategy.swift and fix the REQUIRES: line 2019-07-08 15:08:47 -04:00
Arnold Schwaighofer
d4a7e5e582 Fix test dynamic_replacement_multifile on back-deployment bots
rdar://52357954
2019-07-01 07:57:22 -07:00
Doug Gregor
bc2e605b31 [Property wrappers] Improve enclosing-self subscript handling.
Extend handling of enclosing-self subscripts by differentiating
between the original wrapped property (which now goes through
`subscript(_enclosingInstance:wrapped:storage:)`) and the projected
property (which goes through
`subscript(_enclosingInstance:projected:storage:)`). The new middle
argument provides a key path to the property that was accessed,
allowing one to distinguish the property being updated.
2019-06-29 23:22:01 -07:00
Doug Gregor
8c54db727b [Property wrappers] Prototype support for enclosing self-based access
Allow property wrapper types to support a second access pattern for
instance properties of classes. When supported, the property wrapper's
static subscript(_enclosingInstance:storage:) is provided with the
enclosing "self" and a reference-writable key path referring to the
backing storage property.

Implements rdar://problem/52222560.
2019-06-29 00:08:49 -07:00
John Holdsworth
b158163d71 Update tests 2019-06-26 01:10:11 -04:00
John Holdsworth
c1c1801448 CovariantReturnConversionExpr required. 2019-06-26 01:10:11 -04:00
Arnold Schwaighofer
fea9d87a3c Mark test dynamic_replacement_multifile as UNSUPPORTED in optimize mode
rdar://52073880
2019-06-25 08:38:30 -07:00
Xi Ge
e4fe41d76c test: xfail Interpreter/dynamic_replacement_multifile while investigating CI failures 2019-06-24 15:25:30 -07:00
Slava Pestov
e1e0984cc7 Revert "Frontend: Remove -enable-resilience flag"
This reverts commit 566e9dfea0.
2019-06-24 14:33:45 -04:00
Slava Pestov
566e9dfea0 Frontend: Remove -enable-resilience flag 2019-06-22 21:37:04 -04:00
Slava Pestov
e2d660f148 SILGen: Fix generated vtable thunk when a final override is more visible than the base
Don't re-dispatch to the override's vtable slot if the override
is final; there's no vtable slot and this will result in an
infinite loop.

Fixes <rdar://problem/52006394>.
2019-06-21 22:56:48 -04:00
Arnold Schwaighofer
d662c5cc62 Fail dynamic_replacement_multifile in optimize mode
rdar://51944415
2019-06-20 08:31:03 -07:00
Arnold Schwaighofer
fb08153de0 Fix dynamic replacement runtime when generating replacements from multiple object files
The sections with the replacements get merged and we need to consider all replacements.

SR-10947
rdar://51913012
2019-06-19 15:11:33 -07:00
Arnold Schwaighofer
15ecf924f0 Merge pull request #25281 from aschwaighofer/class_constrained_stored_property_keypath
IRGen: Allow stored_property keypaths on class constraint archetypes
2019-06-10 12:37:43 -07:00
Arnold Schwaighofer
bd6fa67f39 Fix generic class constraint keypath 2019-06-10 09:02:46 -07:00
Arnold Schwaighofer
bc9eac9f1f IRGen: Allow stored_property keypaths on class constraint archetypes
rdar://50271944
2019-06-06 07:59:52 -07:00
mishal_shah
1e38fc3030 Update master to build with Xcode 11 beta, macOS 10.15, iOS 13, tvOS 13, and watchOS 6 SDKs 2019-06-03 22:50:02 -07:00
Slava Pestov
a31248997c SILGen: Correctly emit vtables when an override is more visible than the base
If an override B.f() is more visible than a base method A.f(), it is
possible that an override C.f() of B.f() cannot see the original method
A.f().

In this case, we would encounter linker errors if we referenced the
method descriptor or method dispatch thunk for A.f().

Make this work by treating B.f() as the least derived method in this
case, and ensuring that the vtable thunk for B.f() dispatches through
the vtable again.

Fixes <rdar://problem/48330571>, <https://bugs.swift.org/browse/SR-10648>.
2019-06-01 00:08:05 -04:00
Arnold Schwaighofer
b31b7a9d8e Remove some UNSUPPORTED swift_test_mode_optimize_none_with_implicit_dynamic
rdar://51228899
2019-05-31 08:45:37 -07:00
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00
Daniel Rodríguez Troitiño
24d23a0293 Merge pull request #25128 from drodriguez/android-sr-10600-executable-test
[test] Mark SR-10600.swift as executable.
2019-05-29 17:59:03 -07:00
Slava Pestov
4e80b9ce95 Merge pull request #25119 from slavapestov/re-enable-subclass-existentials-test
Re-enable test/Interpreter/subclass_existentials on optimized builds
2019-05-29 20:22:27 -04:00