Commit Graph

17 Commits

Author SHA1 Message Date
Slava Pestov
cb95ee3581 IRGen: Don't crash when emitting a capture descriptor containing an opened existential 2017-04-25 01:32:45 -07:00
Arnold Schwaighofer
09246d3718 IRGen: Fix partial_apply of arguments that lower to empty values
We would run into an assertion during building the partial apply forwarding
thunk because we passed down a parameter convention of an empty argument
although we ignore it for the purpose of adding to the closure context.
However, the code path for the non-allocated closure context (0 or one capture)
would assert that there is only one convention.

Reconcile this by not adding the empty parameter to the convention array.

rdar://31487947
2017-04-08 08:17:30 -07:00
Slava Pestov
02e669b449 Reflection: Re-enable some tests on no-ASAN builds
These tests fail because we incorrectly build some parts of the reflection
library with the swift-clang, and link it against code built with the
host-clang. ASAN doesn't support this.

Until we fix this, make sure we skip the tests only in ASAN builds, instead
of disabling them altogether.
2017-01-19 22:02:12 -08:00
Xi Ge
818b3a4d4e [test] Disable failing reflection tests to unblock CI. rdar://29605167 (#6228) 2016-12-12 10:48:08 -08:00
Joe Groff
277608a69b Print and parse SILBoxTypes with a new syntax.
Use a syntax that declares the layout's generic parameters and fields,
followed by the generic arguments to apply to the layout:

  { var Int, let String } // A concrete box layout with a mutable Int
                          // and immutable String field
  <T, U> { var T, let U } <Int, String> // A generic box layout,
                                        // applied to Int and String
                                        // arguments
2016-12-02 13:44:22 -08:00
Joe Groff
e1e7e19248 SIL: Construct alloc_box insns with the type of the box.
This becomes necessary with generalized boxes, since the box type isn't derivable from a single field type.
2016-11-03 19:26:42 -07:00
Slava Pestov
6f074f7677 IRGen: Fix capture descriptor emission for @pseudogeneric functions
Pseudogeneric functions do not have runtime type metadata in
their closure context, so don't try to emit metadata sources
in the capture descriptor for reflection.

Also, erase generic type parameters in capture types down to
AnyObject, since the reflection library won't be able to
substitute them.
2016-09-15 21:45:52 -07:00
John McCall
34fb15e375 Abstract the object type of an optional type according to the
abstraction pattern of the type rather than always using the
most-general pattern, and erase ImplicitlyUnwrappedOptional from
the SIL type system.
2016-09-08 23:26:19 -07:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -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
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
Slava Pestov
c392b3beb4 Remote: demangling of existential metatype with representation
Just drop the representation for now.
2016-05-09 13:40:58 -07:00
Chris Lattner
226a675ffc Update more tests to use ()'s around function types. 2016-05-06 21:07:08 -07:00
Slava Pestov
d6c04816d6 Reflection: We need to distinguish metatype from reference sources
Getting metadata from a metatype source just means loading from an offset;
with a reference source we have to dereference the isa pointer first.

Thanks to @bitjammer for pointing out this was broken.
2016-05-05 14:58:33 -07:00
Slava Pestov
ffaba2598a Reflection: Demangling for lowered function types
Lowered function types appear in capture descriptors.

For now, we completely punt on demangling parameters and
results, and just hackishly map the SIL function type
representation to an AST function type representation.

This is good enough, because all we care about is whether
we have a raw function pointer, raw function pointer with
context, or a block.
2016-05-05 13:47:54 -07:00
Slava Pestov
27b951e1e5 Reflection: Demangling for lowered metatypes
Lowered types appear in capture descriptors.
2016-05-05 13:47:54 -07:00
Slava Pestov
bb8d1d3416 IRGen: Fixes for capture descriptor emission
- Fix caller/callee confusion, and use the right SIL function type
  for obtaining the generic signature.
- Correctly interpret the NecessaryBindings structure and the
  substitutions therein.
- Fix alignment for capture and builtin type descriptors
- Put capture descriptor typerefs in the correct section

Add new SIL-level tests to precisely trigger various scenarios.
2016-05-05 13:47:54 -07:00