Commit Graph

21502 Commits

Author SHA1 Message Date
Dave Zarzycki
b92b64617b Heap: avoid reentrancy when Instruments enables ObjectAlloc
We need a custom but simple map table for two reasons:
1) To precisely control our allocations to avoid reentrancy via Instruments.
2) To prepare for out-of-process introspection via Mach VM calls.

This fixes: <rdar://problem/16718231> Swift allocator must not call malloc nor global operator new

Swift SVN r17769
2014-05-09 08:56:37 +00:00
Greg Parker
fba2e4bd7c Add overlay covers for DISPATCH_QUEUE_CONCURRENT and DISPATCH_SOURCE_TYPE_*.
Swift SVN r17766
2014-05-09 07:06:10 +00:00
Argyrios Kyrtzidis
786ab593dd Revert "[CMake] Build the SDK overlays with -autolink-force-load."
This reverts commit r17752, because it caused link failures of Interpreter and stdlib tests.

Swift SVN r17758
2014-05-09 04:02:54 +00:00
Jordan Rose
20fb4513e2 [CMake] Fix dependencies for swiftDispatch.
Without proper dependencies among the overlays, we may try to load an
outdated overlay module while building another overlay.

Swift SVN r17753
2014-05-09 01:20:34 +00:00
Jordan Rose
90c5fbe029 [CMake] Build the SDK overlays with -autolink-force-load.
Final part of <rdar://problem/16829587>

Swift SVN r17752
2014-05-09 01:20:33 +00:00
Argyrios Kyrtzidis
4f0776936a [stdlib] Dispatch depends on Darwin.
Swift SVN r17749
2014-05-09 01:04:44 +00:00
Dave Zarzycki
06731bbe21 Heap feedback: rename _swift_zone_init_ to _swift_zone_initImpl
Swift SVN r17729
2014-05-08 23:20:49 +00:00
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
Enrico Granata
720478bf96 Add a URL case to QuickLookObject
This is to be used by playgrounds to provide a better sidebar representation of web pages than simply showing the URL text

Part of rdar://16799088



Swift SVN r17710
2014-05-08 19:15:36 +00:00
Greg Parker
f1d020e11a <rdar://16848707> Add Dispatch overlay with covers for some libdispatch macros.
Swift SVN r17693
2014-05-08 09:47:00 +00:00
Ted Kremenek
05e9efb093 Don't compile XCTest overlay as being Application Extension safe.
Swift SVN r17682
2014-05-08 04:49:00 +00:00
Dmitri Hrybenko
63c5a145b4 stdlib: factor out _SwiftNSFastEnumerationState initialization
Swift SVN r17624
2014-05-07 12:54:17 +00:00
Dave Abrahams
3606513c36 [stdlib] Factor out _fixLifetime
Apparently Builtin.fixLifetime isn't yet respected
(<rdar://problem/16464507>) and calls to that and swift_keepAlive were
getting scattered around randomly.  Let's have a convenient library
function instead.

Swift SVN r17493
2014-05-05 23:21:47 +00:00
Dave Abrahams
7f29548040 [stdlib] Re-alphabetize CMakeLists.txt
Swift SVN r17489
2014-05-05 21:24:45 +00:00
Dave Abrahams
23f98db278 [stdlib] A .utf16 property for String
Also, test the .utf8 property

Swift SVN r17488
2014-05-05 21:23:48 +00:00
Dave Abrahams
c20f08c596 [stdlib] Don't bake refcounting details into apps
DaveZ says: In the future we're likely to store "associated objects,"
which will make inlining the introspection of the reference count
problematic.

Swift SVN r17481
2014-05-05 19:26:43 +00:00
Enrico Granata
46780871a8 Add a separate .Sprite quickLookObject type for SpriteKit objects
We still want to send out image data for those, but UI consumers need to be able to differentiate - should they so desire - a true image from a software sprite rendered in pictorial form

Part of the fix for rdar://16806238



Swift SVN r17471
2014-05-05 18:17:12 +00:00
Joe Groff
c76da32358 runtime: Cache the results of swift_conformsToProtocol.
Playground and array bridging code spends a lot of time here, so instead of brazenly dlsyming each and every time we want to look up a conformance, cache results in a DenseMap. <rdar://problem/16809482>

Swift SVN r17464
2014-05-05 17:41:37 +00:00
John McCall
bafeb84a56 Generate unique type metadata for foreign classes.
Swift SVN r17430
2014-05-05 06:45:42 +00:00
Enrico Granata
88e841ce10 Mis-ordering of cases - thanks Joe!
Swift SVN r17391
2014-05-04 18:05:46 +00:00
Enrico Granata
cb53af1bd1 Add a View tag to the QuickLookObject enum
This tag is meant to trade in image data, but be explicit about the fact that this is a "screenshot" of a UI view rather than a plain ol' picture

Fixes the swift library part of rdar://16796532



Swift SVN r17390
2014-05-04 18:03:13 +00:00
Greg Parker
3353e15270 [runtime] Don't free() a static empty string.
iOS device's CrashReporterClient is currently a no-op that is 
incompatible with malloc/free usage.


Swift SVN r17375
2014-05-04 09:13:34 +00:00
Greg Parker
cb94a2be54 [runtime] Use asl_log() instead of asl_log_message() to log to system console.
asl_log_message() is not available on OS X 10.9.


Swift SVN r17373
2014-05-04 08:21:37 +00:00
Ted Kremenek
3d248270ca Add prototype for KVO API overlay ("KVOContext") to NSObject, and provide test case.
This change adds a new variant of "addObserver:forKeyPath:options:context:"
that takes a "KVOContext" instead of an unsafe void*.  The variant
delegates to the original method, but first 'retain's the object
before turning it into an unsafe pointer.  The API is then matched
with a variant of 'removeObserver:forKeyPath:context:' which
delegates to the original method and then 'release's it.

This vision here is that Swift clients of this API will use this
variant, and not the unsafe one.  A refinement (later) is to
not expose the original methods at all, and provide a new method
'observeValueForKeyPath:ofObject:change:kvoContext:' that implements
a thunk that delegates to 'observeValueForKeyPath:ofObject:change:context:'
and does the void* cast (which the code in the test case does).

This needs to go through API review; names are strawman names.

Swift SVN r17325
2014-05-03 20:06:28 +00:00
Doug Gregor
f3c390e94b Disable use of asl_log_message for now
Swift SVN r17318
2014-05-03 17:12:04 +00:00
Greg Parker
47efdd9885 [runtime] Write fatal error messages to crash logs (where available).
Swift SVN r17306
2014-05-03 02:57:32 +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
05a9a266e4 Revert "Use the first element of an enum as a source for"
This reverts commit r17242. We can't simply forward tuple element extra
inhabitant witnesses for the same reason laid out in the previous commit.

Swift SVN r17252
2014-05-02 16:22:44 +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
John McCall
422df2e3bb Use the first element of an enum as a source for
extra inhabitants.

This is obviously not as general as it should be,
but it actually helps a lot.

I started doing enums assuming it would teach me
something about how to do it for structs, and it
kindof worked.

Swift SVN r17242
2014-05-02 10:29:53 +00:00
Ted Kremenek
050fd53af7 Rename UncheckedOptional to ImplicitlyUnwrappedOptional.
Swift SVN r17232
2014-05-02 06:13:57 +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
Greg Parker
4c9c52fb81 <rdar://15931346> Fix KVO.
* Temporarily turn on -link-objc-runtime by default. This will be 
  removed again in rdar://16753644.
* Symlink XcodeDefault.xctoolchain's copies of arclite into the Swift build's 
  resource directory so tests can see it.
* Enable the KVO test.


Swift SVN r17132
2014-05-01 01:39:23 +00:00
Dave Zarzycki
fcd4667f08 Runtime heap: add some missing locking
Swift SVN r17104
2014-04-30 19:29:56 +00:00
Dmitri Hrybenko
9d4bd6da69 stdlib: remove Keyboard
rdar://16205673


Swift SVN r17089
2014-04-30 13:00:08 +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
Dave Abrahams
efe08045ba [stdlib] Kill (Contiguous|Opaque)String
Detritus makes it hard to do API review, so kill it off.

Along the way we got a generic lexicographicalCompare algorithm.

Swift SVN r17064
2014-04-30 01:49:34 +00:00
Enrico Granata
4fb2175901 The default Mirror implementation used to have a special case for NSString-typed things, such that they would quicklook as their own string data
However, this broke for Swift subclasses of NSString because the Swift mirror took precedence over the ObjC NSString choice
Notably, it broke for NSContiguousString

This patch fixes that by explicitly making NSString reflectable, so that its subclasses will automagically do the right thing here

Fixes rdar://16758974



Swift SVN r17059
2014-04-30 00:06:54 +00:00
Enrico Granata
39a45d8004 Add a custom Mirror for NSRange, and export a Range(UInt64, UInt64) as the quicklook object for it
This is the last chunk of stdlib work for rdar://16681498


Swift SVN r17040
2014-04-29 19:11:07 +00:00
Enrico Granata
9ab5cea296 Add a new case to the QuickLookObject enum: Logical(Bool)
This is meant to represent to UI consumers the notion of a logical truth value
Previously, we were using a String case to represent such values, but that loses potentially useful information to UI layers

This fixes rdar://16719431



Swift SVN r17037
2014-04-29 16:36:40 +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
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 Abrahams
18c7b0e440 [stdlib] Kill StringByteData
StringByteData was legacy detritus containing an in-memory UTF8
representation of a Swift string.  Since we switched to a UTF16 base
representation, use the new stuff in StringUTF8 instead.

Swift SVN r16968
2014-04-28 08:32:41 +00:00
Dave Abrahams
1dd3b76e97 [stdlib] Add a lazy UTF8 view of String
We need something here so we can rip out StringByteData.  Ideally this
would have BidirectionalIndex'es, but this will do for now.  It has to
be a Collection so we can represent its multi-pass-ness.

Swift SVN r16966
2014-04-28 08:32:40 +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