Commit Graph

18 Commits

Author SHA1 Message Date
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
Slava Pestov
db79762c3b Reflection: Fix class layout start offset calculations
Fixes <rdar://problem/29115967>.
2016-11-11 03:13:22 -08:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -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
Slava Pestov
127961795e Reflection: Fix tests to pass when optimizations are on
Prevent the optimizer from eliminating alloc_box instructions
in box_descriptors.sil by returning the boxes, and inhibit
literal capture propagation in functions.swift.

Fixes <rdar://problem/26561954>.
2016-06-02 23:43:58 -07:00
David Farler
1e94e3f382 SwiftRemoteMirror: Add a test for unowned-self captures
NFC.
2016-06-01 18:19:46 -07:00
David Farler
a7fd48a52f SwiftRemoteMirror: Add a test for weak-self captures
NFC.
2016-06-01 18:17:31 -07:00
Andrew Trick
f424f24017 Temporarily disable Reflection/functions.swift.
The test needs to be fixed: rdar://26561954
It was accidentally enabled recently, but was already broken.
2016-05-31 14:30:55 -07:00
Dmitri Gribenko
d0725fecf4 tests: annotate executable tests with corresponding requirements 2016-05-31 00:48:23 -07:00
Slava Pestov
e2cf23d971 Reflection: Don't emit builtin descriptors for imported classes
Previously we would emit both a builtin descriptor and field
descriptor for imported classes, but we only need the latter.

Untangle some code and fix a crash with imported Objective-C
generics in the process.

Fixes <rdar://problem/26498484>.
2016-05-26 19:32:59 -07:00
Slava Pestov
803a6b095b Reflection: Emit metadata for fixed-layout SIL boxes
We were recovering metadata from generic boxes by reading
the instantiated payload metadata from the box's metadata,
but this approach doesn't work for fixed-size boxes, whose
metadata does not store the payload metadata at all.

Instead, emit a capture descriptor with no metadata sources
and a single capture, using the lowered AST type appearing
in the alloc_box instruction that emitted the box.

Since box metadata is shared by all POD types of the same
size, and all single-retainable pointer payloads, the
AST type might not accurately reflect what is actually in
the box.

However, this type is *layout compatible* with the box
payload, at least enough to know where the retainable
pointers are, because after all IRGen uses this type to
synthesize the destructor.

Fixes <rdar://problem/26314060>.
2016-05-26 19:32:57 -07:00
David Farler
8f86719f9f Add more Remote Mirror closure tests with different arity/capture count 2016-05-23 16:34:54 -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
David Farler
c9e0df7d4d Add an opaque field for necessary bindings struct
Without this, offsets of captures in closure contexts may be
incorrect if there is a non-empty necessary bindings structure
at the front.

rdar://problem/26312900
2016-05-16 20:25:35 -07:00
Slava Pestov
c90ee3c322 Reflection: Fix for last-minute fix for 32-bit platforms that broke 64-bit platforms 2016-05-09 14:18:04 -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