Commit Graph

622 Commits

Author SHA1 Message Date
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
45ed2ef355 Emit correct ivar bounds and offsets.
I had thought that we could get away with letting the
runtime figure out that these offsets were invalid (and
thus recompute them), but it turns out that the runtime
has some basic consistency requirements:  basically, it
expects the ivars to have been correctly laid out, and
it merely slides them around according to the layout of
the superclass.

Swift SVN r3747
2013-01-11 08:09:08 +00:00
John McCall
d4f80a3993 Introduce a ClassLayoutBuilder and use it to build layouts.
The test changes are that we're setting a class body on
some types that we weren't before.  For some of these,
this is okay;  for others, it's more questionable, but
ultimately not *harmful*.

Swift SVN r3746
2013-01-11 08:09:06 +00:00
John McCall
61dd2646f1 Add a flag (always true) for whether to support ObjC interop.
Swift SVN r3744
2013-01-11 08:09:01 +00:00
John McCall
8c0a464f2e Just one implementation of hasKnownSwiftImplementation.
Swift SVN r3742
2013-01-11 08:08:55 +00:00
John McCall
b3aa330e40 [objc] doesn't make a class ObjC refcounted.
Swift SVN r3741
2013-01-11 08:08:53 +00:00
John McCall
2e0070e229 Emit metaclass stub objects for swift classes.
Swift SVN r3740
2013-01-11 08:08:50 +00:00
John McCall
b15b306314 Emit ObjC metadata and swift-as-ObjC thunks for methods.
Swift SVN r3697
2013-01-05 23:46:24 +00:00
John McCall
8a542a177b Build method entries "online" rather than collecting methods first.
Swift SVN r3695
2013-01-05 23:45:25 +00:00
Chris Lattner
47dbc4051c update for mainline LLVM header file moves.
Swift SVN r3634
2013-01-02 14:38:42 +00:00
John McCall
2fd24f8a86 Language workaround to produce prettier callers.
Swift SVN r3567
2012-12-21 00:16:37 +00:00
Doug Gregor
2b2b2cfc31 Replace the constructor 'alllocates_this' attribute with an 'allocate-this' expression.
By splitting out the expression used to allocate 'this' (which exists
in the AST but cannot be written in the Swift language proper), we
make it possible to emit non-allocating constructors for imported
Objective-C classes, which are the only classes that have an
allocate-this expression.


Swift SVN r3558
2012-12-20 15:28:37 +00:00
John McCall
c028c79763 Emit excessive instance-variable offset global variables.
Swift SVN r3546
2012-12-19 08:46:05 +00:00
John McCall
84e69449df Fix and test resilient-offset class field access.
Swift SVN r3544
2012-12-19 08:45:56 +00:00
John McCall
d01b272531 Untested infrastructure for emitting non-constant field accesses.
Swift SVN r3542
2012-12-19 08:45:47 +00:00
John McCall
e225e4f8fd Implement subclass data layout in the maximally-fragile case.
Swift SVN r3478
2012-12-13 10:28:31 +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
c6374093f6 Add support for messaging Objective-C classes.
Notably, there is still no support for +1 return values,
so we'll leak when doing alloc/init and so on;  but this gets
the fundamentals in place.  A lot of the extra stuff in here
is dealing with mapping between metatypes and class objects.

Swift SVN r3425
2012-12-10 08:18:03 +00:00
John McCall
59d4677b35 Implement metatype references to ObjC classes.
The interesting thing here is that we need runtime support in
order to generate references to metatypes for classes, mostly
because normal ObjC classes don't have all the information we want
in a metatype (which for now just means the VWT pointer).
We'll need to be able to reverse this mapping when finding a
class pointer to hand off to, say, an Objective-C class method,
of course.

Swift SVN r3424
2012-12-10 08:17:57 +00:00
Doug Gregor
1f45f28837 Emit the constructors synthesized by the Clang importer for ObjC init/new methods.
Note that the constructors we emit don't function yet, since they rely
on the not-yet-implemented class message sends to Objective-C
methods.


Swift SVN r3370
2012-12-05 22:01:38 +00:00
Doug Gregor
a221a6986b Rename the "allocating" attribute to "allocates_this".
Swift SVN r3353
2012-12-04 20:20:58 +00:00
Doug Gregor
08c9b5c7b2 Allocating constructors are expected to allocate and assign 'this' on their own.
This implementation is very lame, because we don't currently have a
way to detect (in Sema or SIL) where 'this' gets uniquely assigned,
and turn that assignment into initialization.

Also, I'm starting to hate the name 'allocating' constructor, because
it's the opposite of the Itanium C++'s notion of the allocating
constructor. Will think up a better name.




Swift SVN r3347
2012-12-04 01:06:30 +00:00
John McCall
65db19395d Make metatype layout compatible with struct objc_class.
The principal difficulty here is that we need accessing the
value witness table for a type to be an efficient operation,
but there (obviously) isn't a VWT field for ObjC classes.
Placing this field after the metatype would tend to bloat
metatypes by quite a bit.  Placing it before is best, but
it introduces an unfortunate difference between the address
point of a metatype and the address of the global symbol.
That, however, can be fixed with appropriate linker support.
Still, for now this is rather unfortunately over-subtle.

Swift SVN r3307
2012-11-30 02:47:01 +00:00
Joe Groff
83e1e917d1 Update some inaccurate comments in IRGen
Swift SVN r3139
2012-11-07 18:12:51 +00:00
John McCall
07482e6de1 If the root class in a hierarchy is marked with [objc], we
have to use objc_retain/release.

Swift SVN r3089
2012-10-30 00:20:40 +00:00
John McCall
84f3b7f884 Unify the ObjC and Swift heap pointer TypeInfos.
Swift SVN r3088
2012-10-30 00:19:33 +00:00
John McCall
e8d5f08e94 Fix/suppress some warnings arising in newer clangs
as reported by Chris.

Swift SVN r3044
2012-10-23 08:12:08 +00:00
John McCall
37d024bd38 bindGenericArchetypes is now just how we emit polymorphic
functions on class types, so we can kill all that special code.

Swift SVN r2943
2012-10-05 01:54:52 +00:00
John McCall
1f5b775bc7 Use metatype pointers as generic type arguments. Movements
towards optimizing generic calls to derive things from the
'this' pointer, which is actually crucial for virtual
dispatch (to get all methods to agree about how the
implicit arguments are passed).  Fix a number of assorted
bugs in metadata emission.  Lots of assorted enhancements.

This was proving surprisingly difficult to actually tease
apart into smaller patches.

Swift SVN r2927
2012-10-03 08:57:40 +00:00
John McCall
179e260ea3 Add an abstraction to encapsulate a Decl + explosion level +
uncurrying level, which is something I find myself passing around
quite a bit.  Make sure that it can propagate getter/setter
references in the same way.

Swift SVN r2902
2012-09-28 05:21:24 +00:00
John McCall
3467e63516 Emit pointers to final overriders of member functions into
the metadata objects for classes.  This is currently only
done for methods defined in the main class body, and it's
(naturally) totally fragile, and it's screwed up in a
couple known ways w.r.t. generic classes:  there's no
thunking when the overrider differs by abstraction from
the overridden method, and methods on classes currently
expect to get all the type arguments passed directly
and thus will disagree in signature from members of
non-generic classes.  Also, of course, we're not using
any of this in the call infrastructure.  But it's progress.

Swift SVN r2901
2012-09-27 06:17:46 +00:00
John McCall
ee012c0903 Make IR-gen use canonical types as the basic type currency.
This is kindof a pain in a few places where the type system
doesn't propagate canonicality.  Also, member initializations
are always direct-initializations and so are allowed to use
explicit constructors, which is a hole in our canonicality
tracking.  But overall I like the idea of always working
with canonical types.

Swift SVN r2893
2012-09-21 07:53:08 +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
fe97523a2a Extract out a header for doing class metadata layout.
Also rename a bunch of things to say 'Class' in them in
preparation for other refactoring.

Swift SVN r2890
2012-09-21 07:52:54 +00:00
John McCall
a695354dc1 Make heap metadata use the metadata scheme.
Swift SVN r2871
2012-09-19 06:33:41 +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
77ac36ce66 This hack is no longer necessary. Thanks, Doug!
Swift SVN r2860
2012-09-18 07:23:36 +00:00
John McCall
1529e0ddd4 Arrange for general mangling of type metadata.
Swift SVN r2853
2012-09-13 21:26:07 +00:00
Eli Friedman
ae7c99020b Fix use of uninitialized member.
Swift SVN r2715
2012-08-22 22:50:03 +00:00
Eli Friedman
eb1689710f Delete isa, cast, and dyn_cast on Type. Hopefully, this will lead to fewer stupid mistakes.
Swift SVN r2691
2012-08-20 22:15:10 +00:00
John McCall
8e735aec52 Bind generic parameter witnesses when emitting a generic
class destructor.

Swift SVN r2672
2012-08-17 07:45:09 +00:00
John McCall
20bfc9c1ec Initial, untested support for uniquing generic class metadata,
which is necessary to embed the value witnesses there.

Swift SVN r2671
2012-08-17 06:47:33 +00:00
John McCall
e74432a7b9 More incremenetal progress on metadata layout.
Swift SVN r2670
2012-08-17 06:47:29 +00:00
John McCall
fc630c7f16 Inching towards a more useful idea of heap metadata.
In particular, prepare for storing real v-table-like information
in the heap metadata.  Give the metadata object proper linkage
and emit it as part of emitting the class.

Adjust the manglings of constructors and destructors while I'm
at it.

Swift SVN r2628
2012-08-14 06:51:17 +00:00
John McCall
17027b8d8e Basic support for members of generic types.
Swift SVN r2619
2012-08-13 09:03:40 +00:00
Chris Lattner
cd3f362faf revert r2364, which introduced the swift_allocClass entrypoint. The optimization that it was
trying to block has since been reverted, and I think there are other approachs that will work.


Swift SVN r2547
2012-08-03 23:27:15 +00:00
Eli Friedman
0bfcfbfb8a Change the type of ConstructorDecls to be of the form metatype<T> -> () -> (). Change a bunch of stuff to compensate. Get rid of ConstructorRefExpr, which is no longer used.
Swift SVN r2526
2012-08-03 03:58:44 +00:00
John McCall
f7aca3f7fb Progress towards generic types.
Swift SVN r2454
2012-07-25 22:42:07 +00:00