Commit Graph

14 Commits

Author SHA1 Message Date
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Johan K. Jensen
fa76656c82 Remove instances of duplicated words 2015-12-03 20:00:29 +01:00
Nadav Rotem
16bd644825 [IRGen] Remove an extra null comparison in 'exact' checked_cast_br.
rdar://22666588

This change removes a comparison and a branch on every virtual call. Before this
change we were generating code for comparing the metadata to figure out if the
incoming instance is an 'exact' cast, and then we checked if the result of the
cast was zero. This is unnecessary because we can simply reuse the result of the
exact metadata comparison. Moreover, we know that the metadata instance can't be
zero because we've emitted a load to that address that did not trap.

  %1 = getelementptr inbounds %C4main1X, %C4main1X* %0 ...
  %.metadata = load %swift.type*, %swift.type** %1  // Loading %0
  %2 = icmp eq %swift.type* %.metadata, bitcast (...)
  %3 = icmp ne %C4main1X* %0, null   ; <-----------  %0 can't be null.
  %4 = and i1 %3, %2
  br i1 %4, label %5, label %7

Swift SVN r31920
2015-09-12 05:10:53 +00:00
Joe Groff
7e78ff68d1 IRGen/Runtime: Make dynamic metatype-to-AnyObject casts work.
Bonus fix for rdar://problem/19624697.

Swift SVN r24808
2015-01-28 23:06:45 +00:00
Joe Groff
5ed6e2731b IRGen: Code gen for casts to existential metatype.
The code path here is mostly the same as the class cast case--we have to test the ObjC class (if it is a class) against any ObjC protocols, then look up conformances for the native protocols.

Swift SVN r23184
2014-11-09 02:40:25 +00:00
Joe Groff
f229840161 IRGen: Code generation for general class existential casts.
Emit a helper that invokes conformsToProtocol the appropriate number of times for the destination protocol type.

Swift SVN r23176
2014-11-08 04:53:46 +00:00
Joe Groff
2047cec286 IRGen: Remove more obsolete casting entry points.
Swift SVN r23137
2014-11-06 22:09:48 +00:00
Joe Groff
64a2838ff9 Remove dead function.
Swift SVN r23136
2014-11-06 21:50:06 +00:00
Joe Groff
1c4e08a9c8 Fix up a tangle of issues related to reabstraction.
- A spot fix in SILGen for reabstracting the result of a downcast, which fixes checked casts to function types.
- Associate the layout information in type metadata records with the most abstract representation of the type. This is the correct thing to do in cases where we need the metadata as a tag for an opaque value--if we store a value in an Any, or pass it as an unconstrained generic parameter, we must maximally reabstract it. This fixes the value semantics of existentials containing trivial metatypes.
- To ensure that we get runtime layout of structs and enums correct when they contain reabstractable types, introduce a "metadata for layout" concept, which doesn't need to describe the canonical metadata for the type, but only needs to describe a type with equivalent layout and value semantics. This is a correctness fix that allows us to correctly lay out generic types containing dependent tuples and functions, and although we don't really take advantage of it here, it's also a potential runtime performance win down the road, because we could potentially produce direct metadata for a primitive type that's layout-equivalent with a runtime-instantiated type. To aid in type safety here, push SILType deeper into IRGen in places where we potentially care about specific representations of types.
- Finally, fix an inconsistency between the runtime and IRGen's concept of what spare bits unmanaged references and thick metatypes have.

Together, these fixes address rdar://problem/16406907, rdar://problem/17822208, rdar://problem/18189508, and likely many other related issues, and also fixes crash suite cases 012 and 024.

Swift SVN r21963
2014-09-16 01:44:34 +00:00
John McCall
f0e14f7e65 Carry the formal types of the arguments in the indirect-cast
instructions.

Swift SVN r18934
2014-06-16 17:35:43 +00:00
Nadav Rotem
bb0438f27b [Early Binding of Virtual Calls] Add a new kind of unconditional_checked_cast: Identical cast. This cast checks that the class that we inspect is exactly the type we expect, and not a subclass of that type.
Swift SVN r18859
2014-06-13 06:15:14 +00:00
Joe Groff
1f203ab6a9 IRGen: Lower metatype conversion instructions.
Implement IR lowering for the metatype conversion SIL instructions.

Swift SVN r18844
2014-06-12 23:17:43 +00:00
John McCall
9f5736880e Basic IR-generation support for checked_cast_addr
in terms of swift_dynamicCast.

Swift SVN r18825
2014-06-12 08:08:20 +00:00
John McCall
6fb1dc2db1 Centralize more dynamic-casting code into GenCast.cpp. NFC.
Swift SVN r18818
2014-06-12 01:00:23 +00:00