Commit Graph

910 Commits

Author SHA1 Message Date
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
2e0070e229 Emit metaclass stub objects for swift classes.
Swift SVN r3740
2013-01-11 08:08:50 +00:00
John McCall
f6c2e0a92b Support for emitting references to ObjC metaclasses.
Swift SVN r3739
2013-01-11 08:08:48 +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
Chris Lattner
47dbc4051c update for mainline LLVM header file moves.
Swift SVN r3634
2013-01-02 14:38:42 +00:00
Doug Gregor
662861fd66 Implement runtime checking for super-to-archetype casts, finishing <rdar://problem/12768631>.
Introduce a new swift_dynamicCast pair that take in a general metatype
pointer, rather than the more specific class-metatype pointer used for
class downcasts, and grab the class out of that general metatype
pointer, which may actually be an Objective-C wrapper. This is
slightly slower, but it works for the super-to-archetype cases like
T(an_NSObject), where T can have either kind of metadata.

NSTypedArray<T> is actually run-time type checked now, yay!


Swift SVN r3564
2012-12-20 18:47:39 +00:00
Doug Gregor
5a857292bb Rename swift_dynamicCast to swift_dynamicCastClass.
This variant of swift_dynamicCast requires us to have data that's
guaranteed to be class metadata, but it's not always natural to
generate class metadata. No functionality change yet.


Swift SVN r3562
2012-12-20 18:07:08 +00:00
Doug Gregor
b9667e701a Perform runtime checking of downcasts, aborting if they fail <rdar://problem/12768631>.
We add a new runtime entry point, swift_dynamicCastUnconditional(),
that aborts when the cast fails. We'll probably want to throw an
exception in the future, but this is fine for now.


Swift SVN r3554
2012-12-19 23:42:10 +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
b90adfa000 Add linking support for field-offset variables.
Not actually using them anywhere yet.

Swift SVN r3479
2012-12-13 10:28:35 +00:00
John McCall
d09d59d83d Add a convenient way to query whether a type is POD.
This also has the pleasant side-effect of allowing the
TypeInfo for tuples/etc to not be unnecessarily built.

Swift SVN r3475
2012-12-13 10:28:20 +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
1722411007 When we're referring to the SEL type in IRGen, use a names alias for i8*.
Swift SVN r3404
2012-12-07 17:19:39 +00:00
Doug Gregor
07be3f3e7f Use the Objective-C runtime to unique selectors in JIT'd code.
When generating IR for the JIT, use sel_registerName() to unique the
selector references we generate. Static code doesn't need this
pessimization. Fixes <rdar://problem/12764732>.


Swift SVN r3403
2012-12-07 17:13:27 +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
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
Doug Gregor
f80ff2c565 Make sure that generated selector symbols actually get uniqued.
First, keep track of each of the selectors we emit and dump them into the
llvm.used global so that they don't get thrown away by the
optimizer. Second, emit Objective-C module-level named metadata so
that the linker knows it needs to unique selectors. Otherwise,
uniquing doesn't happen when Swift code is compiled into a separate
dylib.


Swift SVN r3287
2012-11-29 00:56:41 +00:00
John McCall
3c053a7b98 In preparation for shifting the metadata layout, widen
the metadata kind field to a full word.

Swift SVN r3183
2012-11-14 08:45:29 +00:00
John McCall
5eb36187d6 Teach IR-gen how to emit metatypes for metatypes.
Swift SVN r3180
2012-11-14 08:45:17 +00:00
John McCall
7c277001a4 Implement basic objc_msgSend capabilities.
Swift SVN r3104
2012-11-03 00:26:56 +00:00
John McCall
7a95ef9a5f Add code to generate the globals behind selectors.
Untestable so far.

Swift SVN r3090
2012-10-30 00:21:16 +00:00
John McCall
0548cc7cff Cache local metadata in the scope in which we compute it,
to avoid some obvious redundancies.  This also gives us a
more general framework with which to exploit other ways
in which metadata is known.

Swift SVN r3047
2012-10-23 23:30:23 +00:00
John McCall
85490080c2 Make protocol thunks expect a metatype pointer (for This) as
their last argument.  Pass it down correctly.

Swift SVN r3042
2012-10-23 07:59:35 +00:00
John McCall
f4dd62dee7 Metatypes for class types have non-trivial representation.
Swift SVN r2971
2012-10-11 00:36:05 +00:00
Eli Friedman
dd299a35af Fix for LLVM TargetData -> DataLayout rename.
Swift SVN r2959
2012-10-09 23:18:24 +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
34da6d1650 Implement grabbing an external value witness table. I
described this mangling in a previous commit, and the runtime
is already using it for some standard tables.

Swift SVN r2870
2012-09-19 06:33:36 +00:00
John McCall
2c21ee7796 Add the compiler infrastructure for emitting references to tuple and
function metadata.

Swift SVN r2864
2012-09-18 07:23:51 +00:00
John McCall
1529e0ddd4 Arrange for general mangling of type metadata.
Swift SVN r2853
2012-09-13 21:26:07 +00:00
John McCall
8499117b59 The value witnesses for size/alignment/stride can just be size_t's.
This requires us to potentially copy the value witness tables for
generic struct types as part of computing layout, but that's not
the end of the world (although it will rely on a future patch
to split value witnesses out from protocol witness tables).

Oh, and add a value witness for stride, changing Builtin.strideof
to use that.

Swift SVN r2829
2012-09-06 08:23:14 +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
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
cfaedbf6c4 More miscellaneous fixes towards getting slice_test to work.
Sadly, it doesn't yet --- some sort of unbound archetype.

Swift SVN r2622
2012-08-13 09:04:13 +00:00
Ted Kremenek
219b7bd430 Move LLVM.h to libBasic.
Swift SVN r2550
2012-08-03 23:54:29 +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
John McCall
011df45944 Fix the emission of member functions on generic types.
Swift SVN r2482
2012-07-27 18:37:09 +00:00
John McCall
ed38caaa04 Support generic return types, as long as they don't differ
by abstraction from the concrete return type.

This basically gets generic calls working totally as long
as there's no remapping required.

Swift SVN r2402
2012-07-23 07:06:28 +00:00
John McCall
da8c01938e Reorg, monster comment.
Swift SVN r2391
2012-07-22 07:59:22 +00:00
John McCall
3950a6af41 Generic calls status code dump activate!
Swift SVN r2386
2012-07-20 21:59:14 +00:00
Eli Friedman
29b3994cca Add a new entry point for allocating classes. This API probably isn't really
right, but we need something in the meantime to make the optimizer understand
that there could be non-trivial destructors involved.



Swift SVN r2366
2012-07-17 23:25:02 +00:00
Eli Friedman
c9cb594eb3 IRGen for destructors. (This code is likely to change a lot once we design classes properly, but it should be a decent start.)
Swift SVN r2365
2012-07-17 22:41:23 +00:00
John McCall
b1d5c33e19 Support for trivial protocol compositon types.
Swift SVN r2362
2012-07-17 06:20:29 +00:00
John McCall
b86d764397 Add some basic structures for protocol composition types.
Swift SVN r2355
2012-07-14 06:50:53 +00:00
Eli Friedman
6b4a248f04 Parsing and AST support for destructors on classes.
Swift SVN r2348
2012-07-12 01:26:02 +00:00