Commit Graph

95 Commits

Author SHA1 Message Date
practicalswift
176f487d76 Fix incorrect filenames in headers. 2015-12-20 23:59:05 +01:00
Erik Eckstein
68fa1c2c34 Support for stack promotion in IRGen.
This means: handling of alloc_ref [stack].
It can be configured with two new options. See Option/FrontendOptions.td.

As the [stack] attribute is not generated yet, there should be NFC.




Swift SVN r32929
2015-10-28 00:44:25 +00:00
Slava Pestov
76f1168adf Remove dealloc_ref's [constructor] form since its no longer needed
Swift SVN r32688
2015-10-14 22:50:09 +00:00
Slava Pestov
7cc59e01d7 SIL: Add DeallocPartialRefInst
This instruction destroys instance variables in a partially-initialized
object, then frees it.

Swift SVN r32661
2015-10-13 19:56:20 +00:00
Slava Pestov
1628bfc3e2 SIL: Split dealloc_ref into [constructor] and [destructor] kinds
dealloc_ref [destructor] is the existing behavior. It expects the
reference count to have reached zero and the isDeallocating bit to
be set.

The new [constructor] variant first drops the initial strong
reference.

This allows DI to properly free uninitialized instances in
constructors. Previously this would fail with an assertion if the
runtime was built with debugging enabled.

Progress on <rdar://problem/21991742>.

Swift SVN r31142
2015-08-11 18:38:00 +00:00
John McCall
73258f2b21 Generate method/property @encodings from the foreign
SILFunctionType of the method instead of its formal type.

Gives more accurate information to the @encoding, makes
foreign error conventions work implicitly, and allows
IRGen's Swift-to-Clang to avoid duplicating arbitrary
amounts of the bridging logic from SILGen.

Some finagling was required in order to avoid calling
getConstantFunctionType from within other kinds of
lowering, which might have re-entered a generic context.

Also required fixing a bug with the type lowering of
optional DynamicSelfTypes where we would end up with
a substituted type in the lowered type.

Also, for some reason, our @encoding for -dealloc
methods was pretending that there was a formal parameter.
There didn't seem to be any justification for this,
and it's not like Clang does that.  Fixed.

This commit reapplies r29266 with a conservative build fix
that disables ObjC property descriptors for @objc properties
that lack a getter.  That should only be possible in SIL
files, because @objc should force accessors to be synthesized.
Arguably, Sema shouldn't be marking things implicitly @objc
in SIL files, but I'll leave that decision open for now.

Swift SVN r29272
2015-06-03 04:59:54 +00:00
Dmitri Hrybenko
8d8a462ee1 Revert "Generate method/property @encodings from the foreign"
This reverts commit r29266.  It broke buildbots.

Swift SVN r29271
2015-06-03 03:49:32 +00:00
John McCall
ed68d261e7 Generate method/property @encodings from the foreign
SILFunctionType of the method instead of its formal type.

Gives more accurate information to the @encoding, makes
foreign error conventions work implicitly, and allows
IRGen's Swift-to-Clang to avoid duplicating arbitrary
amounts of the bridging logic from SILGen.

Some finagling was required in order to avoid calling
getConstantFunctionType from within other kinds of
lowering, which might have re-entered a generic context.

Also required fixing a bug with the type lowering of
optional DynamicSelfTypes where we would end up with
a substituted type in the lowered type.

Also, for some reason, our @encoding for -dealloc
methods was pretending that there was a formal parameter.
There didn't seem to be any justification for this,
and it's not like Clang does that.  Fixed.

Swift SVN r29266
2015-06-03 02:33:38 +00:00
Jordan Rose
686a1f49e5 Remove unused IRGen function hasObjCClassRepresentation().
Swift SVN r26273
2015-03-18 18:55:53 +00:00
Joe Groff
d178b88847 IRGen: Don't reference ivar offsets for empty ObjC ivars.
They don't need storage because they're empty, so we don't emit their offsets, but we still emitted references to their offset variable. Fix this by lowering ref_element_addr to an undef for empty fields.

Swift SVN r23317
2014-11-14 02:11:25 +00:00
Joe Groff
cd5a624bbc IRGen: Emit more accurate property metadata.
Instead of hacking together inaccurate metadata only for object-typed properties, make an effort to produce accurate metadata for all types of properties, and accurately capture the "copy", "dynamic", and "weak" semantics of some properties. This is necessary for Core Data to accurately synthesize property accessors for non-object properties; currently it will generate bogus object accessors over properties with non-object type. <rdar://problem/17373368>

This isn't fully accurate, since Clang hides property type encoding behind a 'getObjCEncodingForPropertyDecl' that only accepts an ObjCPropertyDecl. With some refactoring, it should be possible to expose this.

Swift SVN r19567
2014-07-04 15:58:18 +00:00
Joe Groff
43cc4a28f2 IRGen: Instantiate ObjC metaclasses and rodata with generic classes.
If we officially register our classes with the ObjC runtime, we can't get away with generic class instances sharing a runtime name or a metaclass anymore, so pack the metaclass and rodata templates into the generic metadata template and add codegen to the fill function to wire up the references at instantiation time. Since we don't have a runtime mangler yet, create a stupid unique name for classes by tacking on the pointer value.

Swift SVN r17882
2014-05-11 19:42:38 +00:00
Joe Groff
0cb9bb50c1 IRGen: Get 'isa' pointers via object_getClass for ObjC-heritage classes.
We can't know whether a mixed-heritage class has a non-pointer isa, so use object_getClass to get its isa pointer. Fixes <rdar://problem/16656489>.

Swift SVN r16549
2014-04-18 21:28:41 +00:00
Joe Groff
def2f97944 IRGen: Generalize 'hasSwiftRefcount' into an enum of reference counting mechanisms.
Replace HeapTypeInfo::hasSwiftRefcount with a "getSwiftRefcounting" method, returning an enum indicating whether a heap object has native/ObjC/block/unknown refcounting semantics. Use _Block_copy and _Block_release for block refcounting.

Swift SVN r16041
2014-04-08 02:43:16 +00:00
Doug Gregor
1d733d5646 IR generation for alloc_ref_dynamic.
Swift SVN r14561
2014-03-01 22:33:01 +00:00
John McCall
93d7bc4f0d Remove unnecessary Expr uses from IR-gen.
Swift SVN r12428
2014-01-16 22:32:35 +00:00
Doug Gregor
1b746bc3b5 Move the creation of deallocating destructors from IRGen to SILGen.
This is the first (and only) use of the dealloc_ref instruction.

Swift SVN r12145
2014-01-10 22:32:55 +00:00
Doug Gregor
993754c1fe IR generation for the dealloc_ref SIL instruction.
Note that this lowering currently assumes that the static type of the class is its dynamic type. This should be a flag on the dealloc_ref instruction, not an assumption.

Swift SVN r12144
2014-01-10 22:32:52 +00:00
Doug Gregor
3f09a9891d Add an [objc] bit to the alloc_ref instruction to indicate when to use Objective-C's +allocWithZone:.
Swift SVN r12099
2014-01-09 21:35:55 +00:00
Joe Groff
f164a88615 IRGen: Emit ObjC protocol records for protocols used in casts.
Greg indicated that objc_getProtocol only works if somebody actually reifies a protocol_t record for the protocol with the runtime, so we need to emit our own protocol_t for every Protocol* value we do a checked cast with. Hijack the ClassDataBuilder to also build protocol_t records.

Swift SVN r9420
2013-10-16 21:50:56 +00:00
Joe Groff
ab04ce9f34 IRGen: Populate fixed offsets in class metadata when we have them.
In particular, when a nongeneric class inherits a fragile generic class, we need to populate the field offsets for the instantiated base class because we can't rely on the runtime to populate it for us.

Swift SVN r9258
2013-10-12 14:56:47 +00:00
Joe Groff
9ab5414609 IRGen: Load dependent class instance size and alignment from metadata.
When allocating and deallocating dependent generic class instances, load the instance size and alignment from the metadata instead of trying to use a static size from the compile-time class layout.

Swift SVN r9250
2013-10-12 02:57:41 +00:00
Joe Groff
4ff3c62ef6 IRGen: Include instance size and alignment mask in class metadata.
We need these for dependent-layout generic classes so we know the allocation/deallocation size and alignment. When I figure out ObjC interop with generic subclasses these should move to the rodata so they get handled resiliently by the ObjC runtime, but for generic class bringup this is convenient.

Swift SVN r9249
2013-10-12 01:51:18 +00:00
Doug Gregor
786f9d299b Fold GenericMemberRefExpr into MemberRefExpr.
MemberRefExpr now uses ConcreteDeclRef to refer to its member, which
includes the substitutions and obviates the need for
GenericMemberRefExpr.


Swift SVN r7842
2013-09-03 15:49:19 +00:00
Dmitri Hrybenko
69cfa73640 More 'this' -> 'self' replacements
Swift SVN r7657
2013-08-28 02:57:21 +00:00
Joe Groff
56a4220eeb IRGen: Use superclass repr and refcount for superclass archetypes.
If an archetype has a superclass bound, we can assume the superclass's
retain semantics for the type. We can also use the superclass's storage pointer type to cut down on some bitcast IR noise when calling superclass methods on the archetype value.

Swift SVN r5642
2013-06-18 03:42:27 +00:00
Joe Groff
72e53052dc IRGen: Build method/property encodings based on bridged type.
This gives [objc] properties or property-ish methods of String type encodings as their NSString counterparts in the ObjC world.

Swift SVN r5365
2013-05-28 21:05:14 +00:00
Joe Groff
3d2cd72330 IRGen: Push SILTypes into emitClassAllocation.
Swift SVN r5188
2013-05-16 21:52:28 +00:00
Joe Groff
193e7c3b13 IRGen: Kill CanType version of projectPhysicalClassMemberAddress.
ObjC thunking was the last use of it.

Swift SVN r5181
2013-05-16 19:06:52 +00:00
Joe Groff
b439e49625 IRGen: Use SILTypes in field projection functions.
Swift SVN r5154
2013-05-10 23:17:08 +00:00
Chris Lattner
47e508c24d remove LValue, PathComponent, and LValue.h as a whole.
Swift SVN r4792
2013-04-18 04:50:03 +00:00
Chris Lattner
20a712a2fc remove emitAddressLValue and PhysicalPathComponent.
Swift SVN r4791
2013-04-18 04:46:41 +00:00
Joe Groff
a9f747ec1f IRGen: Emit categories for ObjC class extensions.
Emit ObjC stubs and categories for methods defined in extensions of ObjC-compatible classes. This makes extensions of ObjC classes available to ObjC in statically compiled code. For immediate-mode code we'll still need to dynamically register extension methods using the ObjC runtime.

Swift SVN r4149
2013-02-22 05:40:09 +00:00
Joe Groff
7a7e14a9c5 IRGen: Emit SIL destructors.
Emit the SIL destructor as a destroying destructor, then emit a deallocating destructor shim that calls into it and then returns the heap size. (The actual deallocation still happens in swift_release--I talked to John about that and I'll fix it later.) This gets the broken SIL/IRGen class tests passing again.

Swift SVN r3838
2013-01-22 23:36:37 +00:00
Joe Groff
ae396e3905 IRGen: SIL AllocRefInst.
Implement AllocRefInst so that SIL-emitted constructors can be irgenned. Factor the code for allocating a class instance from GenClass's emitClassConstructor function.

Swift SVN r3826
2013-01-22 02:45:25 +00:00
Joe Groff
312e4872e9 IRGen: SIL class accessors.
Implement IRGen for RefElementAddr so that class accessors work. Add a loadUnmanaged method to TypeInfo classes so that we can populate Explosions without accruing unwanted cleanups.

Swift SVN r3779
2013-01-16 22:12:21 +00:00
John McCall
86f4aacdad Basic infrastructure for emitting class_ro_t structures.
Swift SVN r3476
2012-12-13 10:28:24 +00:00
John McCall
32cc48dc84 More restructuring and start emitting struct metadata.
Swift SVN r2892
2012-09-21 07:53:02 +00:00
John McCall
2d03d842f5 Move class metadata emission into GenMeta.cpp. The main
motivation for this is to re-use code involving generic nominal
types.

Swift SVN r2891
2012-09-21 07:52:58 +00:00
John McCall
5b10c5df32 Move emitClassMetadataRef to GenMeta.cpp and make it work for
an arbitrary metadata type.

Swift SVN r2862
2012-09-18 07:23:44 +00:00
John McCall
c4c8c5cbe7 Expose an API to fetch a class metadata pointer.
Swift SVN r2861
2012-09-18 07:23:40 +00:00
John McCall
17027b8d8e Basic support for members of generic types.
Swift SVN r2619
2012-08-13 09:03:40 +00:00
Eli Friedman
ea6348f446 Make NewReferenceExpr inherit from ApplyExpr; this lets us delete some redundant code.
Swift SVN r2447
2012-07-25 20:55:51 +00:00
Eli Friedman
33f20a14e0 Add NewReferenceExpr, for allocating class objects.
Swift SVN r1867
2012-05-16 01:36:03 +00:00
Eli Friedman
98933b8510 More work on ClassDecls; this is enough to get member access working.
Swift SVN r1863
2012-05-16 00:22:09 +00:00