Commit Graph

115 Commits

Author SHA1 Message Date
Dario Rexin
999b93bfdb Merge pull request #30815 from ktoso/wip-mangledTypeName
Improve usability of _mangledTypeName with Any.Type arguments
2020-04-06 20:49:13 -07:00
Nate Chandler
ab2d3e84ad Disabled tests failing from missing objc symbol.
Two tests are currently failing with

dyld: lazy symbol binding failed: Symbol not found: _objc_opt_self
  Expected in: /usr/lib/libobjc.A.dylib

dyld: Symbol not found: _objc_opt_self
  Expected in: /usr/lib/libobjc.A.dylib

Here, they are disabled for now.

rdar://problem/61345988
2020-04-06 11:12:11 -07:00
Xi Ge
aa39afa32a test: disable Runtime/superclass_constraint_metadata_resilient_superclass_future.swift
rdar://61345988
2020-04-06 09:48:49 -07:00
Konrad `ktoso` Malawski
5faf82c553 Improve usability of _mangledTypeName with Any.Type arguments 2020-04-05 12:27:50 +09:00
Nate Chandler
2863f1964d [Runtime] Handle incomplete class metadata in _checkGenericRequirements.
When constructing the metadata for a type Gen<T : Super>
where Super is a superclass constraint, the generic argument K at which
the metadata for Gen is being instantiated is verified to be a subclass
of Super via _checkGenericRequirements.

Previously, that check was done using swift_dynamicCastMetatype.  That
worked for the most part but provided an incorrect answer if the
metadata for K was not yet complete.  These classes are incomplete more
often thanks to __swift_instantiateConcreteTypeFromMangledNameAbstract.

That issue occurred concretely in the following case:

  Framework with Library Evolution enabled:

    open class Super { ... }
    public struct Gen<T : Super> {
    }

  Target in a different resilience domain from that framework:

    class Sub : Super {
      var gen: Gen<Sub>?
    }

Here, the mechanism for checking whether the generic argument K at which
the metadata for Gen is being instantiated handles the case where K's
metadata is incomplete.  At worst, every superclass name from super(K)
up to Super are demangled to instantiate metadata.  A number of faster
paths are included as well.

rdar://problem/60790020
2020-04-03 13:28:54 -07:00
Konrad `ktoso` Malawski
33444489e5 Add _mangledTypeName to allow round trips T->mangledName->T 2020-03-10 12:20:08 +09:00
fischertony
f14604e225 Demangle: Test demangling of nested types with contextual where clauses 2020-03-05 07:29:28 +03:00
Jonas Devlieghere
21327e79d9 [test] Fix LLDB Python Path and re-enable linux-fatal-backtrace.swift 2020-02-10 16:17:04 -08:00
Mishal Shah
7952f051a3 Disable linux-fatal-backtrace.swift (59328972) 2020-02-10 15:44:31 -08:00
Xi Ge
624c2fc4a7 test: move demangle metadata for moved symbols to a separate file 2019-12-17 12:22:22 -08:00
Xi Ge
12d148b40b test: add a test for demangle moved type names during runtime 2019-12-17 11:13:44 -08:00
Lei Zhang
f04de1d4d3 Disable 4 tests on s390x 2019-09-20 19:48:33 +00: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
Brent Royal-Gordon
29bff80d49 Unskip most of associated_type_demangle_private (#25657)
There’s only one specific case that isn’t working correctly right now; re-enable the rest of the test. rdar://problem/51959305
2019-06-20 21:34:38 -07:00
Xi Ge
179a0ac99e test: disable Runtime/associated_type_demangle_private.swift
Related: rdar://51959305
2019-06-20 15:19:20 -07:00
Brent Royal-Gordon
4149c8f97d [Runtime] Fix private generic type witness demangling failure (#25611)
This one’s screwily specific--if you have:

* a private generic type,
* with a nested generic type in it,
* and the nested type conforms to a protocol with an associated type,
* and that associated type’s witness is a generic type,
* and some of the witness type’s generic parameters are generic parameters of the nested type,

demangling would fail. The problem is that the substitution machinery in the runtime would consider there to be three, not two, generic context depths involved. Depth 1, which should correspond to the nested type, would instead have no generic parameters. The fix is to skip over depths with zero generic parameters.

Fixes <rdar://problem/47773183>.
2019-06-20 12:02:01 -07:00
Julian Lettner
105e4ad592 [TSan] Add positive test for TSan + Dispatch on Linux
1) Enable tests that use `import Dispatch` on Linux. Add substitution
   `%import-libdispatch` that needs to be used for all cross-platform
   tests (i.e., tests that are intended to be run on other platforms
   than Darwin) that do `import Dispatch` or enable thread sanitizer.

2) Make sure as many existing Dispatch and TSan tests as possible run on
   Linux. Mark tests that would require substantial work with
   `UNSUPPORTED: OS=linux-gnu`.

3) Add integration-style Swift test that shows that TSan finds a simple
   race when using `Dispatch.async` incorrectly. A more complete test
   suite for TSan's libdispatch support lives on the LLVM/compiler-rt
   side.

rdar://problem/49177535
2019-06-10 14:24:53 -07:00
Mike Ash
20b24c54b5 [Test] Use --allow-empty in crash_without_backtrace[_optimized].swift. 2019-05-23 14:50:08 -04:00
Michael Gottesman
195672a201 Disable crash_without_backtrace.swift.
rdar://51076215
2019-05-23 11:39:55 -07:00
Mike Ash
95e90fa8bf [Test] Fix crash_without_backtrace_optimized.swift.
Insert a fputs before the crash to keep FileCheck happy.
2019-05-23 11:35:55 -04:00
Mike Ash
7f4f5734d2 [Test] Upgrade the all backtrace tests to use not.py and %target-run.
rdar://problem/50863395
2019-05-20 13:10:26 -04:00
Mike Ash
c93c8e44a1 [Test] Fix backtrace.swift to use %target-run.
rdar://problem/50863395
2019-05-17 15:13:16 -04:00
Doug Gregor
54d3930ae8 [Runtime] Adjust to conforming type when instantiating witness table.
When we find a protocol conformance descriptor for a given type, make sure
we adjust to the conforming type of that descriptor (following the superclass
chain as needed) before instantiating the witness table.

Fixes rdar://problem/49741838.
2019-05-13 20:53:02 -07:00
sarveshtamba
44575a3ac5 Update linux-fatal-backtrace.swift 2019-03-28 11:17:52 +05:30
Mike Ash
fbe990481b [Runtime] Dynamically select the is-Swift bit at runtime on Apple platforms.
Recent Swift uses 2 as the is-Swift bit when running on newer versions, and 1 on older versions. Since it's difficult or impossible to know what we'll be running on at build time, make the selection at runtime.
2019-03-07 10:12:27 -05:00
Doug Gregor
b5f45f8f72 [IRGen] Mangle Swift @objc(renamed) protocols as Objective-C in metadata.
When emitting metadata for a Swift-defined @objc protocol that has
provided a specific Objective-C name (e.g., via @objc(renamed)),
mangle such protocols using their Objective-C names so they can be
found at runtime.

Only do this for metadata, because doing it anywhere else would cause
an ABI break. Fixes rdar://problem/47877748.
2019-02-25 17:31:08 -08:00
swift-ci
e9c05b0292 Merge pull request #22410 from DougGregor/irgen-cyclic-metadata-sr-5958 2019-02-06 06:50:42 -08:00
Doug Gregor
229ddf570f [IRGen] Metadata for the conforming type in a witness table access need not be complete.
When calling a witness table accessor, IRGen was forcing the
conforming type to have complete metadata, even though only abstract
metadata is required for that query. This could cause cyclic metadata
dependencies when checking conditional conformances.

Fixes SR-5958.
2019-02-05 22:02:49 -08:00
Saleem Abdulrasool
b1deb97344 test: explicitly indicate interpreter for utils
This fixes the last couple of instances of the interpreter not being
passed to the python the scripts which makes them fail on OSes where
shebangs are not honoured (i.e. Windows)
2019-02-05 10:25:36 -08:00
sarveshtamba
c1612c73c3 Merge branch 'master' of https://github.com/apple/swift 2019-01-17 06:57:21 +00:00
sarveshtamba
7cb42b740c Changes for #SR-9413:Swift 5.0 test failures on PowerPC #21541 2019-01-16 11:05:02 +00:00
Doug Gregor
c999ad0947 [Runtime] Correctly match demangle tree for generic Objective-C classes.
When we encounter the demangle tree for a bound generic class type, look
through the "Type" node of the child tree before checking whether we
have an Objective-C class name. If we do have an Objective-C class name,
there is no way to preserve the generic arguments, so we ignore them and
return the (non-generic) class type.

Fixes rdar://problem/47028102.
2019-01-03 11:12:13 -08:00
sarveshtamba
56318f3e1f Changes for #SR-9413:Swift 5.0 test failures on PowerPC 2018-12-24 11:37:38 +00:00
Doug Gregor
f223d0b886 [Runtime] Eliminate a use-after-free when comparing @objc type names.
We were creating a local Demangler instance, demangling a type name
using it, and then returning one of the resulting nodes to the caller.

Fixes rdar://problem/46817009.
2018-12-20 20:28:23 -08:00
Doug Gregor
4cdfa7e07e [IRGen/Runtime] Anonymous context descriptors can (should be) generic.
Anonymous context descriptors were being treated as non-generic by
IRGen, which lead to problems for (file)private types within generic
types. Emit generic parameters and requirements for anonymous contexts
as well.

The runtime was mostly prepared for this, and the ABI already
accounted for it, so the runtime change is minor---it only affected
building a demangle tree from metadata.

Fixes rdar://problem/46853806.
2018-12-19 23:25:59 -08:00
Doug Gregor
b7df342bd1 [Test] Add a test for rdar://problem/46685973 2018-12-13 13:56:21 -08:00
Doug Gregor
32f577abf2 [Runtime] Perform “deep” comparisons of witness tables when uniquing metadata.
Metadata uniquing might encounter witness tables that were distinctly
generated but come from identical descriptors. Handle this case in metadata
uniquing be looking into the protocol conformance descriptors themselves.
2018-11-20 22:07:55 -08:00
Doug Gregor
17699d4e33 [Metadata] Emit complete context descriptors for parents of anonymous contexts
When a (file)private entity occurs inside a generic context, we still need
information about the genericity of the enclosing context to demangle
to metadata. Emit complete context descriptors for parents of anonymous
contexts.

Fixes rdar://problem/46109026.
2018-11-16 21:34:32 -08:00
Doug Gregor
a53b2e285c [Standard library] Drop _typeByMangledName().
This underscored function was only intended for testing; drop it from the
ABI. We’re keeping _typeByName because it’s used by Foundation.
2018-11-15 11:06:52 -08:00
Doug Gregor
9dd6a5f033 [Runtime] Use the old remangler to compute the @objc protocol name.
The “old” mangling that is used for runtime names of @objc protocols
uses a simpler substitution scheme, so you can’t simply take a mangled
name from the new mangling and fix up the ends.

Fixes rdar://problem/45685649.
2018-11-06 15:16:33 -08:00
Doug Gregor
8552af0884 Merge pull request #20217 from DougGregor/runtime-objc-existential-conforms-to-protocol
[Runtime] Check for @objc existentials conforming to @objc protocols.
2018-11-01 09:33:26 -07:00
Doug Gregor
452e1b12e1 [Runtime] Check for @objc existentials conforming to @objc protocols.
When checking conformance requirements against an @objc protocol, also
check for an @objc existential using protocol_conformsToProtocol().
Fixes rdar://problem/45685649.
2018-11-01 06:37:39 -07:00
Doug Gregor
c3b806b230 Merge pull request #20097 from DougGregor/protocol-symbolic-reference
[Mangling] Mangle protocol symbolic references in any-generic-type production.
2018-10-27 00:52:43 -07:00
Doug Gregor
dafaabecd6 [Mangling] Mangle protocol symbolic references in any-generic-type production.
We were strangely excluding protocols from being symbolically referenced
in the any-generic-type production, which meant that we could not resolve
(e.g.) associated type references to private protocols at runtime. Allow
protocol symbolic references in this position, and cope with it in the
demangler.

Fixes the rest of rdar://problem/44977236.
2018-10-26 18:10:07 -07:00
Doug Gregor
e87dea480c [IRGen] Make (most) builtin type metadata round-trippable.
Rather than mapping all of the builtin floating-point and vector
types down to the type metadata symbols for power-of-two integers,
map down to the type metadata symbols provided by the runtime.
This allows us to round-trip type metadata <-> mangled name for all of
the builtin types that have such symbols. When we don’t have a runtime
symbol, we will fail to link if that builtin type gets referenced.
2018-10-26 16:09:21 -07:00
Doug Gregor
65d5d15fc1 [Runtime] Extend known builtin metadata for floating point and vector types.
Expose symbols for metadata for the various builtin floating point types
and vector types. This is used by the demangler to handle builtin names.

This is a narrow fix for rdar://problem/45569984 (where we couldn’t
demangle a builtin vector type). A more extensive fix will require us
to add a general runtime facility for creating opaque type metadata
with specific size/alignment/stride/uniquing name.
2018-10-26 16:05:31 -07:00
Doug Gregor
54615ff699 [IRGen] Use symbolic references to (file)private entities in mangled names.
(file)private entities are always available in the current file, so use
symbolic references to refer to them within mangled names (always). This
also eliminates problems stemming from our inability to demangle names
referring to private entities, because we (intentionally) don't allow
lookup for them.

Should fix rdar://problem/44977236.
2018-10-23 20:48:40 -07:00
Doug Gregor
7d88a7d335 [Runtime] Demangle @autoclosure function types to metadata.
@autoclosure is currently represented in mangled names, but the
demangle-to-metadata path did not handle it. Add basic support for it
so we can round-trip.
2018-10-18 21:53:48 -07:00
Doug Gregor
c5e226bb16 [Runtime] Use CF superclass metadata in runtime lookups.
When searching the superclasses at runtime, e.g., to find a suitable
protocol conformance record, also consider the superclasses of CF
types, which were recorded in the metadata but otherwise unused.
2018-10-16 21:42:02 -07:00
Greg Parker
46b105e4d6 Revert "[IRGen] Use symbolic references to (file)private entities in mangled names" 2018-10-13 04:56:02 -07:00