Commit Graph

185 Commits

Author SHA1 Message Date
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
7405f4bc77 Runtime: Fix layout of Optional<QuickLookObject> to match Swift's.
Damn tail-alignment. Try a little harder to test quickLookObject on the Swift side too.

Swift SVN r14760
2014-03-06 22:56:17 +00:00
Joe Groff
76870a7a8f Reflection: Try an ObjC object as its own debugQuickLookObject.
If the object doesn't respond to -debugQuickLookObject, check if the object itself is a quick look object.

Swift SVN r14673
2014-03-05 05:34:52 +00:00
Chris Lattner
d758e0dfe3 Eliminate more "DynamicLookup" in favor of "AnyObject", this is the
bulk of finishing rdar://13327098.


Swift SVN r14653
2014-03-04 22:15:46 +00:00
Joe Groff
024b5c0542 runtime: Use -debugQuickLookObject to get text or image quick look objects.
In response to feedback from the Xcode team, change the 'IDERepresentable' type from a protocol into an enum with a limited set of tags, starting with 'Text' and 'Image' for now. In the ObjC mirror, if the ObjC object has a -debugQuickLookObject method, use it to get an object we can try to map to the enum.

Swift SVN r14632
2014-03-04 04:56:54 +00:00
Joe Groff
c752d4e806 runtime: Include the superclass as a child when reflecting ObjC classes.
And stop walking Classes as regular objects—the "isa" chain just noises up the object graph.

Swift SVN r14631
2014-03-04 03:54:32 +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
Jordan Rose
38d176db82 Add a block shim for 'void(^)(NSObject*)'.
Used by XPC.

<rdar://problem/16202338>

Swift SVN r14614
2014-03-03 22:16:08 +00:00
Joe Groff
eafc9ef137 Runtime: Have MagicMirror produce object identifiers for class values.
Swift SVN r14608
2014-03-03 21:20:05 +00:00
Adrian Prantl
649ce05ff9 silence warnings.
Swift SVN r14534
2014-02-28 20:53:04 +00:00
Dave Zarzycki
46d7fc8a46 Runtime: hardcode less about the OS implementation
This also fixes non-fast-path platforms.

Swift SVN r14481
2014-02-27 22:15:22 +00:00
Doug Gregor
904739cb03 Revert "Runtime: hardcode less about the OS implementation"
This reverts r14453, which seems to be breaking the build.

Swift SVN r14480
2014-02-27 21:43:56 +00:00
Dave Zarzycki
5946a56fa3 Runtime: hardcode less about the OS implementation
There is still more to do in this area before we GM.

Swift SVN r14453
2014-02-27 06:14:53 +00:00
Dave Zarzycki
056091461e runtime: fix a build failure with the simulator
Swift SVN r14432
2014-02-26 23:52:43 +00:00
Dave Zarzycki
f8be3a9f1e runtime: always provide swift_retainAndReturnThree()
We've disabled the fast entry points for now on the simulator, but the
ARC optimizer doesn't know that. This is a workaround.

Swift SVN r14425
2014-02-26 23:28:27 +00:00
Dave Zarzycki
33f6978eeb runtime: make the "FastEntryPoints" header and implementation agree
Swift SVN r14421
2014-02-26 22:48:32 +00:00
Ted Kremenek
028f9d0561 Remove rest of Makefile build except for 'docs' and 'www'.
For 'docs' and 'www' it is possible these are still being used,
as they work independent of the Makefile build.  Keeping them for now.

Swift SVN r14418
2014-02-26 22:21:25 +00:00
Dave Zarzycki
ab1efa6ec7 runtime: DI means we don't need heap APIs that take/return zero-initialized memory
Swift SVN r14404
2014-02-26 20:31:11 +00:00
Dave Zarzycki
6e1fcdab30 runtime: Make gmalloc work again
<rdar://problem/16165307> Infinite recursion in malloc_zone_malloc when Reflection test is run under guard malloc

Swift SVN r14398
2014-02-26 17:59:27 +00:00
Dave Zarzycki
52ef19fd3e runtime: route more of the heap through the formal zone
Swift SVN r14397
2014-02-26 17:49:54 +00:00
Dave Zarzycki
8fd6b3a4ab runtime: disable the malloc cache entirely for the simulator
Swift SVN r14396
2014-02-26 17:18:31 +00:00
Joe Groff
98d6fecc99 '.metatype' -> '.Type'
Also, reserve 'type' as a keyword for ensuing syntax changes.

Swift SVN r14375
2014-02-26 04:23:21 +00:00
Greg Parker
17628ee626 Disable swift allocation cache pending rdar://16168244.
Swift SVN r14366
2014-02-26 01:37:36 +00:00
Dave Zarzycki
058ab5a6a1 Runtime: Add assert.h
Swift SVN r14259
2014-02-22 14:31:28 +00:00
Doug Gregor
2d08827a8a Fix trivial build issues
Swift SVN r14241
2014-02-21 23:21:11 +00:00
Chris Lattner
c4d774fa88 unbreak the makefile build.
Swift SVN r14231
2014-02-21 21:52:40 +00:00
Dave Zarzycki
aebc28f7fe Runtime: silence a harmless warning
Swift SVN r14229
2014-02-21 20:37:22 +00:00
Dave Zarzycki
a85b2a3d78 Runtime: Rename Alloc.* to HeapObject.* (NFC)
Swift SVN r14228
2014-02-21 20:12:07 +00:00
Dave Zarzycki
d0696c60fc Runtime: Move heap logic to Heap.cpp (NFC)
Swift SVN r14227
2014-02-21 20:12:01 +00:00
Dave Zarzycki
b32a02a75f Runtime: wire up wrapper zone around the default zone
Swift SVN r14226
2014-02-21 20:11:48 +00:00
Joe Groff
56d4f3ef40 runtime: Feed strings back into Swift through a DaveA-certified interface.
Swift SVN r14209
2014-02-21 16:19:26 +00:00
Joe Groff
3c15aff85b Expose unsafeReflect to the stdlib.
A useful unsafe optimization for potential implementations of Mirror that have existing heap storage to share from the value, like for Array or Dictionary.

Swift SVN r14186
2014-02-21 00:09:32 +00:00
Joe Groff
67205668ae runtime: Implement tuple destructuring in the default mirror.
Not quite ready for prime-time. This leaks memory for want of a proper way to copy a C string into a Swift String.

Swift SVN r14168
2014-02-20 21:19:11 +00:00
Dave Abrahams
1bdf9d915d [stdlib] Make unique reference checking work
Think the scenarios through more carefully, create more reliable tests.
Fixes <rdar://problem/16105759> Too many retains for COW optimization

Swift SVN r14140
2014-02-20 11:14:09 +00:00
Joe Groff
73e564428f stdlib/runtime: Stub out a mechanism for introspecting value structure.
Define a "Mirror" protocol with methods for querying the number of children a structured value has, getting the name and mirror for each of those children, and a string and "IDE representation" of the value, as needed by playgrounds and by our planned generic printing facility.

In the runtime, define a "reflect" function that can provide a Mirror for any object, either using a "Reflectable" protocol conformance if available, or falling back to a magic implementation in the runtime that grovels the type metadata. Stub out a bare minimum default implementation.

Swift SVN r14139
2014-02-20 08:26:27 +00:00
Dave Zarzycki
618b052674 Followup to r14097
We were bypassing the cache in an edge case.

Swift SVN r14125
2014-02-20 01:48:45 +00:00
Dave Zarzycki
435a481bdd Runtime performance: avoid llvm::RoundUpToAlignment(size, mask + 1)
If we have a power-of-two mask, we don't need to bother with arbitrary
size alignment and the integer division fallout.

Swift SVN r14097
2014-02-19 21:09:57 +00:00
Dave Zarzycki
3f567c8d55 Runtime+Performance: always use our fast malloc cache
Please never call malloc/calloc/free directly in the stdlib/runtime now.

<rdar://problem/16104269> Fix 16023119 the right way -- make all runtime entry points use the malloc cache

Swift SVN r14091
2014-02-19 18:51:40 +00:00
Joe Groff
614bd7f23d Runtime: We never use the small allocation cache yet, so always call down to 'free' in swift_slowDealloc and swift_slowRawDealloc.
We were leaking memory in cases where we happened to match one of the allocation cache ranges. Fixes <rdar://problem/16023119>.

Swift SVN r14064
2014-02-19 00:12:13 +00:00
Joe Groff
3e0c1cebcf Runtime: Update the 'inline storage' flag properly for single-payload enums.
It cannot be simply inherited from the payload value witness table; it needs to be recalculated for the new type's size.

Swift SVN r14060
2014-02-18 23:37:24 +00:00
Joe Groff
99ad50b762 SIL: Lower @objc_blocks with the correct calling and ownership conventions.
Force @objc_blocks to use the @cc(cdecl) calling convention, so that calling them undergoes bridging conversions in SILGen, and give them the correct ownership conventions so that the callee, arguments, and result are passed +0. This unfortunately ruins our ability to verify bridge_to_block instructions at all, but bridge_to_block is a hack anyway, and this is a necessary prerequisite to actually being able to call blocks in IRGen.

Swift SVN r13923
2014-02-14 22:08:09 +00:00
Dmitri Hrybenko
571c9b3c5e Split 'type' keyword into 'static' and 'class'
rdar://15911697


Swift SVN r13908
2014-02-14 14:50:32 +00:00
Joe Groff
09d7d5e66d runtime: Handle tuples in printAny.
Because we can.

Swift SVN r13903
2014-02-14 06:54:11 +00:00
Joe Groff
3fded63cac stdlib: Proof-of-concept 'print' implementation for an arbitrary Array.
Mock up a naive Printable protocol, and do some dirty tricks in the runtime to implement a 'printAny' function that uses swift_conformsToProtocol to look up a conformance to Printable if the type has one, or falls back to a dumb opaque printing if it doesn't. Use this to make Array<T> Printable in some way or another for all T.

Swift SVN r13902
2014-02-14 05:15:33 +00:00
Joe Groff
802df0bdf3 Runtime: Do awful things to implement "swift_conformsToProtocol" for Swift protocols.
Given our constraints for 1.0, we can actually sort-of look up protocol conformances just by dlsym'ing the symbol for their protocol witness table, since we won't be implementing runtime witness table instantiation or private conformances anytime soon. To make this work for generic types, distastefully regress our mangling for protocol conformances by assuming all generic conformances are completely general to the unbound generic type and leave the generic parameters out of the mangling.

Swift SVN r13901
2014-02-14 05:15:32 +00:00
Dave Zarzycki
9ba8eba87c stdlib+runtime: skeleton of "NSSwiftString" heap storage
This is gross, and about to get very gross -- but very fast.

Swift SVN r13861
2014-02-13 07:09:51 +00:00
Dave Zarzycki
648080994b Runtime: drop calloc for malloc
This was supposed to be done a long time ago after DI landed, but a
weird bug in our getopt wrapper blocked this. That code is gone now, so
let's make the switch.

Swift SVN r13786
2014-02-11 18:26:05 +00:00
Adrian Prantl
dc3c6e845a silence warning
Swift SVN r13365
2014-02-03 19:32:44 +00:00
Joe Groff
a0a2c1014a Runtime: Preserve the linked list of metadata cache entries.
This is easier for out-of-process clients like LLDB or DTrace to understand, and will let us mess with the runtime metadata cache data structure without forcing churn on the debugger team.

Swift SVN r13221
2014-01-31 17:33:10 +00:00
Joe Groff
418dee24a0 runtime: Use hashtables for metadata caches (again).
Using a linked list for metadata caches is pretty lame. Pull in llvm::DenseMap and hash_combine_range and use them to index instantiated metadata.

The previous attempt at this failed because tuple type metadata was laid out in a way that smashed the metadata cache key. Cache keys used to be laid out like this:

CacheEntry struct
-----------------
cache key
-----------------
variable-sized payload

And TupleTypeMetadata tried to tail-emplace its element array immediately after the main CacheEntry, forgetting the cache key was there. When we actually try to use that cache key to implement a hash table, bad things happen. Rearrange cache entries into the less error-prone layout:

cache key
-----------------
CacheEntry struct
-----------------
variable-sized payload

This also nicely avoids the need for a dynamic offset from the CacheEntry struct to its payload. A tail-allocated payload is likely to be more hot than the cache key, which is only needed at instantiation and lookup time.

Swift SVN r13205
2014-01-31 06:21:07 +00:00