Commit Graph

32 Commits

Author SHA1 Message Date
LamTrinh.Dev
971048907b Update existentials.swift
Adding more comment for "UNSUPPORTED: asan".
2024-07-27 17:59:08 +07:00
Doug Gregor
c76a99ba02 [SE-0352] Enable implicit opening of existentials by default 2022-04-20 17:51:04 -07:00
Augusto Noronha
f41d192b48 Implement projectExistentialAndUnwrapClass
Implement a version of projectExistential tailored for LLDB. There are 2
differences when projecting existentials for LLDB:

1 - When it comes to existentials, LLDB stores the address of the error
    pointer, which must be dereferenced.
2 - When the existential wraps a class type, LLDB expects the address
    returned is the class instance itself and not the address of the
    reference.

This patch also adapts the swift reflection test machinery to test
projectExistentialAndUnwrapClass as well. This is done by exposing
the new functionality from swift reflection test.  It is tested in
existentials.swift, and ensures that the typeref information is
exactly the same as what is expected from projectExistential,
except the out address.

(cherry picked from commit 55e971e06750c3ba29722d558cc5400298f6bdaf)
2021-06-16 08:54:50 -03:00
Adrian Prantl
56b2e906da Support MetatypeTypeRefs in DemanglingForTypeRef. 2020-08-25 15:44:28 -07:00
Adrian Prantl
9287707520 Support generic parent contexts in DemanglingForTypeRef. 2020-08-25 15:30:50 -07:00
Augusto Noronha
a6e2f8b7a0 Conditionalize 'num_extra_inhabitants' in 64 bit platforms' tests (#33136) 2020-07-29 18:49:58 -07:00
Mike Ash
625768e976 [Reflection] Fix up Reflection/existentials.swift test.
rdar://problem/59909982
2020-03-27 10:11:19 -04:00
Mike Ash
e05720cd09 [RemoteMirror] Add a call to get the demangled name for a typeref.
rdar://problem/59909982
2020-03-23 13:53:35 -04:00
Mike Ash
76a6f88b3a [Test] Mark Reflection/existentials.swift as unsupported when testing against the OS stdlib, as the test looks for a recent Remote Mirror addition to print the mangled name of a typeref.
rdar://problem/58939662
2020-01-27 21:04:32 -05:00
Adrian Prantl
ea2b5eced9 Reflection: Implement a TypeRef -> Demangle tree adapter.
To allow more pervasive use of TypeRefs in LLDB, we need a way to build mangled
names from TypeRef pointers to allow round-tripping between TypeRefs and AST
types. The goal is to experiment with making lldb::CompilerType backed by
TypeRefs instead of AST types.

<rdar://problem/55412775>
2020-01-14 17:50:01 -08:00
Slava Pestov
00c1279dbb Reflection: Compute if types are bitwise takable
Bitwise takability is now part of the layout of a type, because
non-bitwise takable types are never stored inline in an
existential or resilient global's buffer, even if they would
fit.

The basic rule is that weak references, unknown-refcounted
unowned references, and aggregates that contain them, are not
bitwise takable, whereas everything else is bitwise takable.

Also, since the bitwise takable for an unowned reference
depends on the reference counting style, we have to record the
superclass of a protocol, if any, to correctly determine the
reference counting style of the protocol existential.
2018-11-07 00:32:12 -05:00
Joe Groff
b4abe8503a Give opaque existential containers extra inhabitants.
We can use the extra inhabitants of the type metadata field as extra inhabitants of the entire
existential container, allowing `Any?` and similar types to be the same size as non-optional
existentials.
2018-09-14 12:07:58 -07:00
Jordan Rose
b7aacec9ce [test] Fix swift-reflection-test issues for all test run environments (#19171)
I stopped trying to guess and actually tested them all, including the
Apple-internal tool I keep breaking. As a bonus, the RUN lines in
validation-test/Reflection/ go back to being simple.

rdar://problem/44154961
2018-09-06 16:05:56 -07:00
Jordan Rose
e3f3e939cb [test] Fix target-based reflection tests for real (#19098)
- Hard-link %target-swift-reflection-test into %t/ for %target-run
  implementations that copy executables, like remote-run.
- Use DYLD_LIBRARY_PATH to undo that for %target-run implementations
  that run the executable in place (host and simulators)

rdar://problem/43809613
2018-09-04 08:45:25 -07:00
Jordan Rose
11bddb49a0 [test] Temporarily disable Reflection tests on non-macOS (#19031)
utils/remote-run will only run things in %t.
An Apple-internal tool doesn't follow symlinks.
Normal macOS and simulator runs find the support libraries relative to
the binary.

I'm not sure what to do yet, but for now let's unbreak the
Apple-internal bots I broke in 01a0de2.
2018-08-29 11:38:27 -07:00
Jordan Rose
01a0de27ec [test] Update for remote-run-ing tests on a different macOS (#18966)
Most of this is just "remember to specify the inputs and outputs on
the command line, so remote-run can see them". A bit is "prefix
environment variables with '%env-'". And the last few are "yeah,
this was never going to work in a remote environment".

In the few cases where I couldn't think of anything reasonable, I just
marked the test as "UNSUPPORTED: remote_run", a new "feature".
2018-08-27 14:50:40 -07:00
Arnold Schwaighofer
5ebc6e77e7 Codesign the reflection tests 2018-08-09 09:18:04 -07:00
Dmitri Gribenko
486cab447d tests: replace 'rm -rf %t && mkdir -p %t' with '%empty-directory(%t)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Rintaro Ishizaki
0a40f10bb4 [SE-0095] Migrate remaining use of protocol<> syntax 2016-07-20 19:18:46 +09:00
Doug Gregor
823c24b355 [SE-0112] Rename ErrorProtocol to Error.
This is bullet (5) of the proposed solution in SE-0112, and the last
major piece to be implemented.
2016-07-12 10:53:52 -07:00
Slava Pestov
48c928938a Reflection: Single-payload enum layout
Attempt to lay out single-payload enums, using knowledge of extra
inhabitants where possible.

- The extra inhabitants of an aggregate are the extra inhabitants of
  the first field. If the first field is empty, there are no extra
  inhabitants, and subsequent fields do not affect anything.

- Function pointers and metatypes have different extra inhabitants
  than Builtin.RawPointer, so have IRGen emit distinct builtin type
  descriptors for those.

- Opaque existentials do not have extra inhabitants.

- Weak references do not have extra inhabitants.

Also, fix IRGen to emit more accurate enum reflection metadata in
these two cases:

- We now record whether enum cases are indirect or not. An indirect
  case is the same as a payload case with Builtin.NativeObject.

- We now record whether a case is empty or not using the same logic
  as the rest of IRGen. Previously, we would incorrectly emit a
  payload type for a case with a payload that is an empty struct,
  for example.

At this point we don't have a way to get the currently inhabited
enum case from a value. However, this is still an improvement because
we can still reflect other fields of aggregates containing enums,
instead of just giving up.

Finally make some methods on TypeCoverter private, and use 'friend'
to allow them to be accessed from other internal classes, making the
public API simpler.
2016-06-30 12:57:14 -06:00
Dmitri Gribenko
d0725fecf4 tests: annotate executable tests with corresponding requirements 2016-05-31 00:48:23 -07:00
David Farler
a38a4ce596 SwiftRemoteMirror: Turn on reflection metadata by default
Flip the enable flags to disable and make these IRGen options
true by default.

rdar://problem/26206547
2016-05-21 17:40:37 -07:00
David Farler
e42fd92fbb SwiftReflectionTest: Don't exit until the parent asks for an instance
Child processes were exiting too early before the parent has a chance
to read a null pointer from the child, indicating that there are no
more instances to reflect. This wasn't a problem on OS X because the
I/O latency is so small compared to the iOS simulator, where the
problem would come up under heavy load. This makes the end-to-end
remote mirror tests deterministic again.

rdar://problem/26230879
2016-05-18 02:27:53 -07:00
David Farler
cbfc93924b Temporarily fix end-to-end remote mirror tests to OS X
There is an issue with writing to pipes under heavy load in the iOS
simulator but is intermittent. Disabling the tests there while I
investigate.

rdar://problem/26230879
2016-05-17 18:52:25 -07:00
Slava Pestov
710d7ede71 Reflection: Break out SWIFT_RAW_POINTER vs SWIFT_BUILTIN in the C API
Also, use "opaque existential" consistently to refer to non-class
existentials, and clean up some other random bits.
2016-05-12 18:27:35 -07:00
David Farler
9dddc6492b SwiftRemoteMirror: Project error existentials
Error existentials have a kind of special heap layout and can also
be compatible as NSError instances, too.
2016-05-10 12:50:31 -07:00
David Farler
2fd0b39751 SwiftRemoteMirror: move dump APIs to print to stdout instead of stderr
Rather than move file descriptors around in the tools, just tell the
underlying ::dump methods to print to stdout instead.
2016-05-09 14:29:33 -07:00
Slava Pestov
75bd780aca Reflection: Add support for closure contexts to readMetadataFromInstance()
Also add end-to-end tests for this finally, and fix a bug in
the SwiftReflectionTest library where we would give up on an
module completely if it did not have a field metadata section.
This is of course wrong if the module defines closures but
not nominal types.
2016-05-09 13:41:56 -07:00
Slava Pestov
14b17379f5 Reflection: Try to fix validation tests 2016-05-05 14:41:25 -07:00
David Farler
87e1ab5dcf SwiftRemoteMirror: Add validation test for projecting existentials 2016-05-04 15:57:44 -07:00