Commit Graph

21665 Commits

Author SHA1 Message Date
Dave Abrahams
004998e63e [stdlib] Move SliceBuffer into its own file
Swift SVN r15766
2014-04-02 02:47:34 +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
0e8de87f05 Runtime: more SwiftObject API completeness
Swift SVN r15696
2014-03-31 22:50:19 +00:00
Dave Zarzycki
09f2e9ed57 WIP Runtime: Zone cleanup to use C++ more. NFC.
All of the malloc zone APIs are clumsy object-oriented design in C, but that
does not mean we should be too. This should clarify the design more too.

Swift SVN r15690
2014-03-31 20:06:16 +00:00
Dave Abrahams
800cba5125 [stdlib] Bring most of ArrayType into the stdlib
The ArrayType protocol is developed for NewArray is a good basis for
what we want, but the ability to create arrays without value semantics
is adding complexity but questionable value.  It isn't clear that we can
usefully expose a type called SharedArray<T>, even internally, if it
ceases to be truly shared when one copy grows, and therefore has its
buffer reallocated. Therefore, leave the NewArray test with a
ArrayType2, a refinement of ArrayType, that adds the ability to report
on its value semantics.

If we really want the optimizations that can be had in a large-scale
mutation by first unique'ing the array and making mutations in-place
thereafter, we can fall back to operating on NativeArrayBuffer<T>
directly.

Swift SVN r15673
2014-03-31 08:42:55 +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
Michael Gottesman
c98c4d54b1 Move Benchmark.swift out of the stdlib now that we can deserialize from the stdlib.
rdar://15797364.

Swift SVN r15636
2014-03-29 22:19:34 +00:00
Dave Abrahams
9ef1ba13c0 [stdlib] Rename file ArrayBridge => ArrayCore
Swift SVN r15618
2014-03-29 10:43:45 +00:00
Dave Zarzycki
095633f4ba Runtime: Enable Instruments object lifecycle support
One needs to either set SWIFT_ZONE_DEBUG before launch or call SPI.

Swift SVN r15586
2014-03-28 20:46:40 +00:00
Dave Zarzycki
ce0c5899d8 Runtime: crude enumeration to generate statistics
This is foundational work for 'leaks', etc.

Swift SVN r15490
2014-03-26 06:13:03 +00:00
Joe Groff
f2ed6dd49b Reflection: Add additional dispositions and an 'AttributedString' QuickLookObject case.
<rdar://problem/16412965> and <rdar://problem/16413366>.

Swift SVN r15438
2014-03-25 02:55:20 +00:00
Dave Abrahams
29c004d516 [stdlib] NewArray slicing, finally
More tests are needed, but the basics are there

Swift SVN r15413
2014-03-24 15:52:07 +00:00
Joe Groff
08a6a68f41 Runtime: Don't double-free existential containers when destroying them generically.
Fixes <rdar://problem/16384633>.

Swift SVN r15338
2014-03-21 21:55:36 +00:00
Dave Zarzycki
c2b486fb91 Runtime: assert on trivial double-free()s
Swift SVN r15336
2014-03-21 21:32:10 +00:00
Dave Zarzycki
c9d5bd8a92 Runtime: fix a leak during thread exit
Swift SVN r15334
2014-03-21 20:59:10 +00:00
Joe Groff
3f6b616211 Runtime: 'destroyPOD' needs to at least deallocate the box.
Fixes <rdar://problem/16245165>.

Swift SVN r15328
2014-03-21 17:56:06 +00:00
Dave Zarzycki
2b412b4626 Runtime: fix a copy-and-paste error
<rdar://problem/16386805> Assertion failed: (bytes != 0), function swift_slowDealloc

Swift SVN r15325
2014-03-21 05:52:04 +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
2cd0940d16 Runtime: make 'vmmap' tool report better data
Swift SVN r15296
2014-03-20 21:02:06 +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
Dave Zarzycki
6e27d2db1e Runtime: Cleanup constants. NFC.
Swift SVN r15272
2014-03-20 18:20:19 +00:00
Dave Zarzycki
f0777b69b4 Runtime: malloc zone huge allocation support
Swift SVN r15271
2014-03-20 18:20:17 +00:00
Dave Zarzycki
9816e2ab05 Runtime: the Swift heap/zone
Good:
* We now no longer wrap the system malloc zone.
* Tiny allocation quantum is pointer sized, not 16 bytes.
* Far less metadata overhead than the system malloc zone.
Bad:
* Our heap density isn't quite as good as the default zone. This is a O(1)
  versus O(N) tradeoff. The default malloc zone has been trending in this
  direction too.
TODO:
* Introspection
* Tune secondary fast paths
* Huge allocations

Swift SVN r15269
2014-03-20 17:43:56 +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
Jordan Rose
934eacea61 BlockShims: fix shims with repeated use of BOOL.
Our shim symbols weren't using substitutions, but the real manglings do.

<rdar://problem/16368602>

Swift SVN r15252
2014-03-20 00:07:52 +00:00
Dave Zarzycki
784630d9b2 Runtime: Fix assembly CFI data
This should fix: <rdar://problem/16188027>

Swift SVN r15249
2014-03-19 21:24:42 +00:00
Joe Groff
c76cb6f6db Reflection: Have 'QuickLookObject.Int' take an Int64, and add a UInt(UInt64) case.
So we can accurately represent all common integer types.

Swift SVN r15237
2014-03-19 15:31:52 +00:00
Joe Groff
dcd47ec879 Reflection: Add QuickLookObject tags for ints and floats.
Playgrounds want to be able to represent numbers different from strings, so provide different tags for types that represent numbers distinct from strings. Set up the Int and Double mirrors to return quick look objects of the appropriate cases, and hook up the magic ObjC mirror to do the same for NSNumbers. <rdar://problem/16360758>

Swift SVN r15219
2014-03-19 02:27:22 +00:00
Joe Groff
589fe7f930 Reflection: Move the less magic parts into Swift.
Only the bits that actually need to grovel metadata really need to be written in C++, so define away hopefully most of the potential for memory safety or corruption bugs from screwing up calling convention matchups by moving most of the magic mirror implementations into pure Swift.

Swift SVN r15180
2014-03-18 01:12:30 +00:00
Dave Abrahams
f465e34f88 [stdlib] Generate NSDictionaryBase
We'll need to apply the same tricks we're using for Array to Dictionary
and String, so prepare to generate base classes for those buffers as
well.  Actually generate and use the one for Dictionary, but don't
actually bridge it yet.

Swift SVN r15167
2014-03-17 23:12:19 +00:00
Dave Abrahams
d016db3285 [stdlib] Factor common non-ObjC instance members
Make sure that if the object layout changes, we don't have to update the
stdlib in too many places.

Swift SVN r15166
2014-03-17 23:12:18 +00:00
John McCall
40be8390c3 Factor BlockShims.mm to make it easier to change the
mangling of imported ObjC pointer types.

Swift SVN r15130
2014-03-17 07:02:00 +00:00
Dave Zarzycki
b8d736ffc7 stdlib: NSSwiftArrayBase magic
Swift SVN r15086
2014-03-14 22:34:46 +00:00
Dave Abrahams
bfc6cfa5b6 [stdlib] Give Array bridging a home of its own
Also create a simple NSSwiftArray class that DaveZ can use to test our
bridging strategy.

Swift SVN r15081
2014-03-14 22:07:14 +00:00
Dave Zarzycki
49bee35d1a Runtime: magic numbers are bad
Swift SVN r15012
2014-03-13 23:15:07 +00:00
Joe Groff
3827f6b1af Reflection: Set the metadata of default ObjC quicklook object Anys correctly.
We want the metadata of the ObjC class, not the opaque Builtin.ObjCPointer metadata. This allows the Any to actually be downcast to an expected type on the client side.

Swift SVN r15009
2014-03-13 21:59:44 +00:00
Dave Zarzycki
1ef22d5e03 Runtime: make the thread-specific logic work with the public SDK
Swift SVN r15007
2014-03-13 21:32:45 +00:00
Dave Zarzycki
dbd1c1a2bf Runtime: zap dead code
Swift SVN r15005
2014-03-13 21:21:13 +00:00
Jordan Rose
5509605e1d Add a void(^)(NSError*, NSString*) block shim.
Requested by Beto in <rdar://problem/16306097>.

Swift SVN r14986
2014-03-13 00:41:55 +00:00
Dave Abrahams
0aa818f680 [stdlib] Delete obsolete verification functions
These functions were used for runtime assertions that are now being
checked at compile-time.

Swift SVN r14983
2014-03-12 23:59:46 +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
75da504b42 Reflection: Add more cases to QuickLookObject.
Add 'Sound', 'Color', and 'BezierPath', as requested by Enrico, as well as a '_Raw' case that can be used for internal experimentation.

Swift SVN r14978
2014-03-12 22:42:27 +00:00
Joe Groff
6c576f110b Hide the implementation details of String from MagicMirror.
NFC, just reduce the possibility of forming Strings without going through a stdlib-approved interface.

Swift SVN r14977
2014-03-12 22:42:26 +00:00
Jordan Rose
db31ad6b68 [CMake] Add the shims headers as sources for the copy_shim_headers target.
This makes them show up in Xcode.

Swift SVN r14970
2014-03-12 22:17:04 +00:00
Jordan Rose
27d1746467 [CMake] Move the install command for the Clang headers to the shims target too.
For consistency with r14968.

Swift SVN r14969
2014-03-12 22:17:02 +00:00
Jordan Rose
1c4d9b78a4 [CMake] Symlink Clang's headers into lib/swift as part of copy_shim_headers.
Turns out CMake's PRE_BUILD mode for custom commands doesn't work with the
Ninja or Makefile generators (not sure about Xcode). Just do it as part of
an earlier target instead.

Swift SVN r14968
2014-03-12 22:11:26 +00:00