Commit Graph

124 Commits

Author SHA1 Message Date
Dave Zarzycki
8b0c9d4e74 Heap: Let Instruments ensure that the heap is setup correctly at launch
Swift SVN r17723
2014-05-08 23:12:57 +00:00
Joe Groff
1dce36edd2 Make 'T.self is U.Type' work.
Fix up all of type-checking, SILGen, IRGen, and the runtime to support checked casts of metatypes. <rdar://problem/16847453>

Swift SVN r17719
2014-05-08 22:55:14 +00:00
Dave Abrahams
1e66774acd [stdlib] swift_isClassOrObjCExistentialImpl fix
If we're going to claim to check for ObjC existential-ness, we should
actually do so.

Swift SVN r17712
2014-05-08 20:31:07 +00:00
Dave Zarzycki
0a0dbdc36c Runtime: make the index <-> size functions easier to lookup dynamically
Swift SVN r17711
2014-05-08 19:25:29 +00:00
John McCall
bafeb84a56 Generate unique type metadata for foreign classes.
Swift SVN r17430
2014-05-05 06:45:42 +00:00
Dave Zarzycki
1326006ed8 Runtime heap/introspection: Instruments team feedback
Swift SVN r17274
2014-05-02 21:41:16 +00:00
John McCall
c57dac63ae Use the first element of structs and tuples as a source
for extra inhabitants.

For structs in particular, this eliminates a major source
of abstraction penatlies.  For example, an optional struct
containing an object pointer is now represented the same
way as an optional object pointer, which is critical for
correctly importing CF types as Unmanaged<T>!.

In time, we should generalize this to consider all elements
as sources for extra inhabitants, as well as exploiting
spare bits in the representation, but getting the
single-element case right really provides the bulk of the
benefit.

This commit restores r17242 and r17243 with a fix to use
value witnesses that actually forward the right type metadata
down.  We were already generating these value witnesses in
the dependent struct VWT pattern, but I was being too clever
and trying to use the underlying value witness directly.

Swift SVN r17267
2014-05-02 20:17:14 +00:00
Joe Groff
0e6ec12b57 Revert "Use the first element of a struct as a source for"
This reverts commit r17243. We can't just forward the extra inhabitant payloads
from a field, because they will end up receiving metadata for the incorrect
type and crashing.

Swift SVN r17251
2014-05-02 16:22:41 +00:00
John McCall
c0e4242bec Use the first element of a struct as a source for
extra inhabitants.

Obviously this should eventually be generalized to
take from any element, but this is good enough to
give us zero-cost abstraction via single-field structs.

Contains some bugfixes for the tuple-extra-inhabitant
changes as well, because test coverage for optional
structs is obviously quite a bit richer than for
optional tuples.

All of this is leading towards unblocking IRGen for
importing CFStringRef as Unmanaged<CFString>!.

Swift SVN r17243
2014-05-02 10:29:55 +00:00
Dave Zarzycki
1930222f3b Runtime: Instruments support plan B
Rather than go through reentrant and problematic contortions to make Swift
work with the existing Instruments hooks, they agreed to just patch some
globals that we provide to get their logic to be activated.

Swift SVN r17144
2014-05-01 06:39:45 +00:00
Dave Zarzycki
d0e88b4060 Mangler hack for various subsystems feedback
Swift SVN r17069
2014-04-30 04:20:54 +00:00
Dave Zarzycki
5338ad9223 Runtime: add a crude mangler for Interface Builder
Someday we'll have time to disentagle the real mangler from the rest of the compiler. For now, this is a hack.

<rdar://problem/16671220> Add a simple mangler API just for handling "Module.ClassName" and "Module.ProtocolName" cases

Swift SVN r17066
2014-04-30 03:13:23 +00:00
Joe Groff
71678b4bdf IRGen/Runtime: Expose the 'isBitwiseTakable' bit in the value witness flags.
Set a bit for types that are non-bitwise-takable, and calculate it as part of runtime struct and enum layout. Include 'bitwise takable' as part of the runtime 'is inline' calculation to be consistent with the compile-time policy change in r17008.

Swift SVN r17036
2014-04-29 15:23:14 +00:00
Greg Parker
cdc3953a55 [runtime] Note that libobjc knows about some of ClassMetadata's fields.
Swift SVN r17026
2014-04-29 07:30:47 +00:00
Dave Zarzycki
fae27e3357 Runtime: provide inline friendly isa mask/shift variables for 1.0
<rdar://problem/16663586> provide a global isa mask so v-table dispatch doesn't have to call object_getClass

Swift SVN r16980
2014-04-28 15:33:41 +00:00
Doug Gregor
18c4ef0cf0 Revert r16960, which is causing build failures due to missing _objc_debug_isa_class_mask.
Swift SVN r16978
2014-04-28 13:41:12 +00:00
Dave Zarzycki
e5f7cddded Runtime: provide inline friendly isa mask/shift variables for 1.0
<rdar://problem/16663586> provide a global isa mask so v-table dispatch doesn't have to call object_getClass

Swift SVN r16960
2014-04-28 05:47:55 +00:00
Dave Zarzycki
6da5c57926 Runtime: part 1 of work to enable CoreData
Until we lock down the Swift ABI and ship with the OS, we need to be resilient
in the face of ObjC dynamic subclassing and OS changes. In practice, this means
that we need to have a swift runtime ABI to read the isa out of objects. I've
added it as of r. See: swift_getClassMetadata()

We can and will optimize swift_getClassMetadata into a single instruction once
we lockdown our ABI and ship with the OS.

See also: <rdar://problem/16735599>

Swift SVN r16889
2014-04-26 20:00:08 +00:00
John McCall
63072df530 Add class size and address point fields to class metadata.
I've put these fields on the class object for now, just
so we can at least theoretically update them.  A superclass
that grew left rather than right could maybe even be made
to work with this schema, but probably not.

rdar://16705821

Swift SVN r16880
2014-04-26 10:57:50 +00:00
John McCall
f3d4513721 Turn some 64-bit metadata fields into 32-bit fields.
We really don't need to support individual objects
this large, much less more than 4 billion fields in
a single type.

Also rearrange the fields to bring the instance
size/alignment fields closer to the class header,
just for a minor locality win.

Swift SVN r16879
2014-04-26 09:43:39 +00:00
Joe Groff
f29a156e83 IRGen/Runtime: Add value witness slots for array witnesses.
Add value witnesses for destroyArray, initializeArrayWithCopy, and initializeArrayWithTake{FrontToBack,BackToFront}, and fill out the runtime value witness table implementations. Stub out the IRGen ones for now.

Swift SVN r16772
2014-04-24 22:25:26 +00:00
Greg Parker
b691055649 Fix an incorrect use of Swift metadata in an ObjC class. Add assertions to
catch such uses in the future.


Swift SVN r16695
2014-04-23 08:55:02 +00:00
Greg Parker
1121b2c132 Revert r16666 because I think my test configuration was wrong.
Swift SVN r16667
2014-04-22 22:24:57 +00:00
Greg Parker
629e7f59b4 Prevent direct ObjC isa dereference when using ObjCClassWrapperMetadata.
This fixes several tests on arm64.


Swift SVN r16666
2014-04-22 22:14:35 +00:00
John McCall
8681963bcb A couple of long-overdue renames.
Builtin.ObjectPointer -> Builtin.NativeObject
Builtin.ObjCPointer -> Builtin.UnknownObject

Swift SVN r16634
2014-04-22 00:17:08 +00:00
Dave Zarzycki
ca634468b4 Runtime: This bit has two meanings
We ought to consolidate on one name.

Swift SVN r16605
2014-04-21 04:34:07 +00:00
John McCall
862d50ac1c Change the layout of opaque existentials so that
the value buffer comes first.

The motivation for doing this is similar to the
motivation for moving it for class existentials:
it eliminates the need for an offset for the most
common accesses, which is particularly important
for the generic value witnesses.

Also try to hard-code that layout in fewer places,
or at least static_assert the places that have to
do so.

Swift SVN r16279
2014-04-13 07:43:08 +00:00
John McCall
46d35ed288 Change the layout of class existentials to put the instance
pointer first.

This most important effect of this is that accesses to that
field don't need to be dynamically offsetted past an arbitrary
number of value witnesses, which is pretty nice for the
generic value witnesses.

Swift SVN r16243
2014-04-12 02:13:16 +00:00
John McCall
85a6cc1309 Make it really easy to generate value witness tables
from C++ types and aggregates thereof.

Swift SVN r16139
2014-04-10 00:01:34 +00:00
Joe Groff
18f6e950a6 Reflection: Look through existential containers.
When we reflect an existential container, reflect the contained value as its dynamic type. Implements <rdar://problem/16427022>.

Swift SVN r15952
2014-04-04 20:16:47 +00:00
John McCall
f1180f5e6d in order to work correctly for non-@objc protocols.
Language features like erasing concrete metatype
values are also left for the future.  Still, baby steps.

The singleton ordinary metatype for existential types
is still potentially useful; we allow it to be written
as P.Protocol.

I've been somewhat cavalier in making code accept
AnyMetatypeType instead of a more specific type, and
it's likely that a number of these places can and
should be more restrictive.
When T is an existential type, parse T.Type as an
ExistentialMetatypeType instead of a MetatypeType.

An existential metatype is the formal type
 \exists t:P . (t.Type)
whereas the ordinary metatype is the formal type
 (\exists t:P . t).Type
which is singleton.  Our inability to express that
difference was leading to an ever-increasing cascade
of hacks where information is shadily passed behind
the scenes in order to make various operations with
static members of protocols work correctly.

This patch takes the first step towards fixing that
by splitting out existential metatypes and giving
them a pointer representation.  Eventually, we will
need them to be able to carry protocol witness tables

Swift SVN r15716
2014-04-01 00:38:28 +00:00
Dave Zarzycki
d8e39d106a Runtime: finish SwiftObject
<rdar://problem/12640667> Implement SwiftObject root class

Swift SVN r15706
2014-03-31 23:10:39 +00:00
Dave Zarzycki
bba63fa14d Runtime: Add LLVM_LIBRARY_VISIBILITY to a few APIs. NFC.
Swift SVN r15697
2014-03-31 22:50:22 +00:00
Dave Zarzycki
0e8de87f05 Runtime: more SwiftObject API completeness
Swift SVN r15696
2014-03-31 22:50:19 +00:00
John McCall
9490da8a1f Inform the runtime that metatype values have extra inhabitants.
Swift SVN r15665
2014-03-31 05:49:18 +00:00
Dave Zarzycki
c07ebee7b1 Runtime: make generic non-assembly entry points use atomics
Our conditional use of atomics goal will have to wait until 2.0.

Swift SVN r15305
2014-03-20 23:32:07 +00:00
Dave Zarzycki
2f4d679fd0 Runtime: Drop the "raw" label on normal memory. NFC.
DI defined away the need for zeroed memory.

Swift SVN r15293
2014-03-20 20:42:27 +00:00
Dave Zarzycki
bd9ce4d42c Runtime: remove dead code
Swift SVN r15291
2014-03-20 20:30:02 +00:00
Joe Groff
002701fd77 Reflection: Implement magic mirror destructuring for classes.
Destructure classes by counting their superclass instance, if any, as their first child, followed by their stored properties.

Swift SVN r15268
2014-03-20 17:43:16 +00:00
Joe Groff
a9c2a7d5b8 Reflection: Implement a magic mirror for structs.
Use the newly-minted field type vector accessors to provide magic mirror destructuring for all structs!

Swift SVN r15261
2014-03-20 02:41:07 +00:00
Joe Groff
4f2656cc7c Runtime: Prefab metadata for Builtin.Int128 (and for similar-sized Float* types).
Swift SVN r15259
2014-03-20 02:02:28 +00:00
John McCall
3135abc950 Make a stab at re-using ABI constant values across targets.
There's still a lot of manual intervention required, but
at least we don't have the constants written in two different
places.

Should be NFC.

Swift SVN r15242
2014-03-19 18:51:52 +00:00
John McCall
cb77899140 Use the same value for LeastValidPointerValue in the
runtime headers and IRGen.  Should fix a miscompile
involving nested optional types.

Swift SVN r15233
2014-03-19 09:42:40 +00:00
Joe Groff
c431509516 IRGen: Reserve a spot in the nominal type descriptor for the field type vector accessor.
Building the field type vector is potentially expensive and the vector isn't needed unless we do reflectiony things to a type, so let's use a lazy accessor. Make room for it, but don't populate it yet, so we can deal with fallout from the metadata layout change.

Swift SVN r15194
2014-03-18 17:30:31 +00:00
Dave Zarzycki
49bee35d1a Runtime: magic numbers are bad
Swift SVN r15012
2014-03-13 23:15:07 +00:00
Dave Zarzycki
8ef7f64619 Runtime: disable the assembly entry points for now
They aren't buying us anything until we thread through the custom ABI
work into Swift. I'm told this won't happen for a while. Until then,
they're just double the intermediate work in this area.

Swift SVN r15004
2014-03-13 21:21:12 +00:00
Dave Abrahams
6eee8e3205 Move HeapObject into the stdlib shim module
Now that we can read definitions directly from "C" headers, stop trying
to maintain a mirror of the HeapObject struct in Swift code in the
standard library.

Swift SVN r14982
2014-03-12 23:48:31 +00:00
Joe Groff
0c55845cc1 Replace Greg's r14771 with a slightly less outrageous hack.
Implicit conversions to and from an unsigned long long enum class give us the calling convention we want for swift_allocBox without totally destroying the API for C callers.

Swift SVN r14919
2014-03-11 16:01:13 +00:00
Greg Parker
338cb2b718 Add an outrageous hack to swift_allocBox() to fix arm (rdar://16257592).
Swift SVN r14771
2014-03-07 05:37:14 +00:00
Joe Groff
5af4e7255b Runtime: Start implementing a default Mirror for ObjC classes.
For ObjC classes, use class_copyIvarList to walk the ivars, and produce the summary string using -debugDescription. Still to come:

- visiting the base class as a child, and
- calling -debugQuickLookObject to get the quicklook object. Still waiting on a final design for the IDERepresentation API.

Swift SVN r14626
2014-03-04 01:42:19 +00:00