Commit Graph

21492 Commits

Author SHA1 Message Date
Arnold Schwaighofer
da6d9152b6 Differentiate between user assertion and preconditions and the like
assert() and fatalError()
These functions are meant to be used in user code. They are enabled in debug
mode and disabled in release or fast mode.

_precondition() and _preconditionFailure()
These functions are meant to be used in library code to check preconditions at
the api boundry. They are enabled in debug mode (with a verbose message) and
release mode (trap). In fast mode they are disabled.

_debugPrecondition() and _debugPreconditionFailure()
These functions are meant to be used in library code to check preconditions that
are not neccesarily comprehensive for safety (UnsafePointer can be null or an
invalid pointer but we can't check both). They are enabled only in debug mode.

_sanityCheck() and _fatalError()
These are meant to be used for internal consistency checks. They are only
enabled when the library is build with -DSWIFT_STDLIB_INTERNAL_CHECKS=ON.

I modified the code in the standard library to the best of my judgement.

rdar://16477198

Swift SVN r18212
2014-05-16 20:49:54 +00:00
Arnold Schwaighofer
ddb874e045 Rename _isDebug and friends to _isDebugAssertConfiguration
Really we want those nullary functions be computed properties using enums.

  var _assertConfiguration : _AssertConfiguration {
    let assertConfig = Int32(Builtin.assert_configuration())
    if assertConfig == 0 {
      return .Debug
    }
    if assertConfig == 1 {
      return .Release
    }
    return .Fast
  }

  if _assertConfiguration == .Debug {
    _fatal_error_message("assertion failed", message, file, line)
  }

In my tests the enums were not optimized away. So for the short term leave
these functions as nullary functions.

Swift SVN r18211
2014-05-16 20:49:50 +00:00
Greg Clayton
2a74838159 Extensions to Objective-C objects fail in REPL if the class is not already initialized and LLDB now gets Objective C categories and extensions initialized properly.
Prior to this fix this would fail:
(swift) import Foundation
(swift) extension NSDate { func foo() { println("foo") }}   

As the Class for NSDate was not initialized.

<rdar://problem/16934080>



Swift SVN r18206
2014-05-16 19:49:41 +00:00
Ted Kremenek
fc47f11a29 Fix crash in CString's 'debugDescription' when the underlying pointer is null.
Fixes <rdar://problem/16227050>

Swift SVN r18202
2014-05-16 18:03:51 +00:00
Ted Kremenek
def1f53b7d Make printing of double's locale-insensitive.
I've never used 'newlocale' before, so I may be using it wrong.

Also, this may not be 100% thread safe; worst case we create
multiple locale objects when swift_doubleToString() is called
at the same time.  We can fix this if we care.

Swift SVN r18201
2014-05-16 17:43:54 +00:00
Dave Zarzycki
dbd023029e Heap: delete dead code
Swift SVN r18200
2014-05-16 17:30:23 +00:00
Dave Zarzycki
4bd4a4a6bc Heap: Add tombstones to make the not-found case faster
This should fix: <rdar://problem/16936107>

Swift SVN r18199
2014-05-16 17:19:13 +00:00
Dave Zarzycki
5455014d96 Heap: fix pointer-to-arena lookup
Swift SVN r18198
2014-05-16 16:43:48 +00:00
Dmitri Hrybenko
92335b2f91 tdlib/Dictionary: address internal API review
Removed 'find:'
Added 'indexForKey:'


Swift SVN r18197
2014-05-16 16:03:56 +00:00
Dmitri Hrybenko
2c1715fe78 stdlib/Dictionary: address internal API review: preallocate storage when
creating a Dictionary from a dictionary literal

Also fixes rdar://16876745, because once the code moved to using lower-level
interfaces, it became trivial to detect duplicate keys without a performance
hit.


Swift SVN r18193
2014-05-16 14:41:03 +00:00
Dmitri Hrybenko
b054a086e8 stdlib/Dictionary: add some comments
Swift SVN r18192
2014-05-16 12:45:23 +00:00
Dmitri Hrybenko
70c062814a stdlib/Dictionary: address internal API review
Removed 'itemsAsArray'


Swift SVN r18190
2014-05-16 11:53:14 +00:00
Dmitri Hrybenko
9abf7a9fa3 stdlib/Dictionary: address internal API review requests
Removed 'add:value:'
Added 'updateValue:forKey:'


Swift SVN r18188
2014-05-16 11:37:25 +00:00
Dmitri Hrybenko
828acd2738 stdlib: hide _NSSwiftArray, _NSSwiftDictionary, _NSSwiftEnumerator
Swift SVN r18187
2014-05-16 08:29:17 +00:00
Dmitri Hrybenko
522f332703 stdlib/bridging: update comments according to runtime function updates.
Swift SVN r18186
2014-05-16 07:59:40 +00:00
Ted Kremenek
178e2a32df Printing routines should append ".0" to floats, *not* taking locales into account.
Implements <rdar://problem/16895801>.

Swift SVN r18185
2014-05-16 07:27:54 +00:00
Nadav Rotem
14f4dd3a97 fix a typo
Swift SVN r18182
2014-05-16 06:06:52 +00:00
Doug Gregor
b756fc29ec Don't require paretheses when mixing optional types and array types...
... unless we actually hit one of the confusing cases involving
multi-dimensional arrays (e.g., Int[]?[]), at which point one needs to
write parentheses <rdar://problem/16737035>.



Swift SVN r18181
2014-05-16 06:03:26 +00:00
Nadav Rotem
70dfa94160 Extend the coverage of the fast path in the UTF16 comparator to more than ascii.
Swift SVN r18180
2014-05-16 05:58:39 +00:00
Ted Kremenek
4bb475a1c8 Rename UnsafePointer.get/set to a "ptr.pointee" property.
Implements <rdar://problem/16531067>.

Swift SVN r18178
2014-05-16 05:48:05 +00:00
Doug Gregor
df4429fc5d Perform the class-or-ObjC-existential checks first in the runtime bridging entrypoints.
We decided that classes and Objective-C existentials are always going
to be bridged verbatim, ignoring any _BridgedToObjectiveC conformances.
While the compiler isn't preventing conformance of a class type to
_BridgedToObjectiveC, we ignore this case and will find a way to lock
it down if _BridgedToObjectiveC loses its underscore.

The motivation here is that (1) we don't really have a use case for a
class that bridges to Objective-C in any way other than just being an
Objective-C class, and (2) the class-or-ObjC-existential check is
ridiculously cheap compared to the
thread-safe-hash-table-over-a-dlsym-call used to find witness tables,
so do the cheap, common check first.



Swift SVN r18177
2014-05-16 05:18:34 +00:00
Nadav Rotem
2d592b6af9 Rename local variables. NFC.
Swift SVN r18176
2014-05-16 05:05:34 +00:00
Nadav Rotem
c1db20d178 Rename member_NthContiguous -> _nthContiguous
Swift SVN r18172
2014-05-16 04:26:10 +00:00
Nadav Rotem
c77b97079c Hoist the check for contiguous storage outside of the comparison loop.
Once we know that the storage is contiguous we use the new API _NthContiguous.
We can further optimize this code by specializing the access to ascii or UTF-16.



Swift SVN r18167
2014-05-16 03:44:32 +00:00
John McCall
e1aaa80ac0 Tweaks to the Unmanaged API: remove the bridge methods,
add conveniences for unsafely bridging unmanaged pointers
into void*.

Swift SVN r18162
2014-05-16 01:48:25 +00:00
John McCall
059ed4cd10 Propagate alignment arguments around through the
slow allocation/deallocation APIs.

Swift SVN r18160
2014-05-16 01:40:36 +00:00
Doug Gregor
ad18ed81fb Start importing NSArray* as (AnyObject[])! by default <rdar://problem/16535097>.
Swift SVN r18157
2014-05-16 01:10:13 +00:00
Greg Parker
3b0e45b497 Fix -[NSUndoManager prepareWithInvocationTarget:].
This method returns a proxy object. Swift cannot current cast proxy objects 
to their proxied types. The workaround for now is to add a generic overlay 
for -prepareWithInvocationTarget: so the declared type of the returned 
proxy is the proxied type. This is good enough to make undo proxies work with 
objc-dispatched calls.


Swift SVN r18155
2014-05-16 01:07:22 +00:00
Dave Zarzycki
60b4a57b4d Heap: Delete old constant that was fixed in an earlier commit
Swift SVN r18153
2014-05-16 00:46:46 +00:00
Dave Zarzycki
5030fe1f83 Heap: make the introspection future proofing build on the buildbot simulator
Swift SVN r18152
2014-05-16 00:46:44 +00:00
Ted Kremenek
172cc3c984 Fix my last commit to accommodate for rename of NativeArray.
Swift SVN r18151
2014-05-16 00:45:48 +00:00
Ted Kremenek
5e966fdd52 Add basic '==' for Array, NativeArray, and Slice.
I suspect this can be made much better.  It only
works for comparing Array<T> and Array<T>,
NativeArray<T> and NativeArray<T>, etc., not
NativeArray<T> and Array<T>.  I also suspect
the implementation can be made better.  The goal
was to make this functional, as this basic
functionality was missing.

Implements <rdar://problem/16768095>.

Swift SVN r18150
2014-05-16 00:32:00 +00:00
Doug Gregor
b723b6c1ff Teach requestNativeBuffer() to return nil on an empty buffer.
The _native computed property that backs this method has a different
contract than requestNativeBuffer() expected: it returned an empty
buffer rather than using an optional and returning nil. We were just
wrapping up that empty buffer and declaring success, which meant we
would bridge from an NSArray wrapping native storage of T to an empty
native array, always.

This change is a necessary prerequisite to importing NSArray* as
(AnyObject[])! per <rdar://problem/16535097>. That (imminent) change
tests this, but we need more targetted testing of this area.




Swift SVN r18143
2014-05-15 23:41:10 +00:00
Dave Abrahams
b666651e3f [stdlib] Rename NativeArray => ContiguousArray
Per API review feedback.

Swift SVN r18140
2014-05-15 23:24:09 +00:00
Dave Abrahams
f4f91a9678 [stdlib] rename [Native=>Contiguous]ArrayBuffer.swift
Swift SVN r18139
2014-05-15 23:24:08 +00:00
Jordan Rose
3f782ceed3 Drop QuartzCore overlay.
The code is incorrect and depends on functions introduced in this year's OSs.
Additionally, CoreImage is a top-level framework on iOS, so we have to be
more careful if/when we add this back.

Swift SVN r18135
2014-05-15 22:59:15 +00:00
Fariborz Jahanian
ee401b6ed5 Fixes a typo.
Swift SVN r18134
2014-05-15 22:52:27 +00:00
Dave Zarzycki
792e9bd6f2 Heap: make introspection future proof against OS changes
Swift SVN r18133
2014-05-15 22:43:14 +00:00
Dmitri Hrybenko
b966c9583f stdlib/{Array, Dictionary}: make debugDescription forward to debugDescription
of container elements

rdar://16929672


Swift SVN r18132
2014-05-15 22:08:07 +00:00
Jordan Rose
6f8dbe907d [CMake] QuartzCore depends on Foundation.
Swift SVN r18130
2014-05-15 22:03:27 +00:00
Dave Zarzycki
6b04e56cce Heap: better hash function names and better hashing
Swift SVN r18124
2014-05-15 20:40:21 +00:00
Fariborz Jahanian
6635feb32b Provide sdk vararg overlays for CIFilter and
CISampler per rdar://16726822
(also removed a comment in Foundation.swift).


Swift SVN r18123
2014-05-15 20:13:55 +00:00
Doug Gregor
01f3f7777e Make _convertNSArrayToArray work for non-verbatim bridged types.
The runtime diagnostics here are awful, but the monkey dances
<rdar://problem/16899681>.



Swift SVN r18121
2014-05-15 19:25:58 +00:00
Doug Gregor
87904b8228 Make ImplicitlyUnwrappedOptional conform to _ConditionallyBridgedToObjectiveC.
This is a better solution to <rdar://problem/16899681> because the
runtime magic is limited to implementing the witnesses of this
conformance.

The type checker fixes are because we can end up using unchecked
optionals in more places, via bridging, than we could before.


Swift SVN r18120
2014-05-15 19:00:52 +00:00
Joe Pamer
a74c44a6e4 Fix two crashing bugs related to checked downcasts - rdar://problem/16093456 and rdar://problem/16892211.
Swift SVN r18118
2014-05-15 18:36:44 +00:00
Dmitri Hrybenko
acb7465f4b stdlib: underscore-prefix NSContiguousString and NSOpaqueString
Swift SVN r18114
2014-05-15 18:02:30 +00:00
Dave Abrahams
634d85f613 [stdlib] Strengthen a sanity check
Swift SVN r18112
2014-05-15 17:51:13 +00:00
Dmitri Hrybenko
586387da7f stdlib: remove unused declarations (the runtime functions are gone already)
Swift SVN r18111
2014-05-15 17:39:03 +00:00
Dave Abrahams
fed492b650 [stdlib] Don't assert on empty NSArrays
Empty NSArrays are usually represented by emptyNSSwiftArray, whose
element type is irrelevant.  So when doing a getObjects:range: on that,
presumably the range's length is zero and we shouldn't do any sanity
checking w.r.t. the element type.

Fixes <rdar://problem/16914909> Assertion failed attempting to append
arrays when subclassing Cocoa class

Swift SVN r18110
2014-05-15 17:25:48 +00:00
Dmitri Hrybenko
d50a8b476d stdlib/Foundation overlay: add Printable conformance to Selector
rdar://16897592


Swift SVN r18109
2014-05-15 17:25:43 +00:00