Commit Graph

68 Commits

Author SHA1 Message Date
Dmitri Hrybenko
33379954c3 Clang-format the new shims header, CoreFoundationShims.h
Swift SVN r25033
2015-02-06 03:55:37 +00:00
Dmitri Hrybenko
fa539e8533 stdlib/shims: declare CoreFoundation APIs only when we have ObjC interop
Swift SVN r25021
2015-02-06 01:10:53 +00:00
Dave Abrahams
94965036d5 [stdlib] Move ObjC Mirrors out of Foundation
These mirrors are the default mirrors that get used for all objective-C
object, including some that aren't defined in Foundation:

  import Dispatch
  println(dispatch_get_global_queue(0,0))

This example isn't fixed yet, because we need to pull all the string
bridging goop out of Foundation and into the core standard library.

Swift SVN r25012
2015-02-05 19:18:33 +00:00
Dave Abrahams
a89c2e11ae [stdlib] Create shims for CFString access in core
...and use these shims in place of our previous inelegant dispatch
through 'C' code.

Swift SVN r25010
2015-02-05 19:18:31 +00:00
Dmitri Hrybenko
375b414ca4 CMake: restore compatibility with CMake 2.8.12
Looks like pre-3.0 versions will refuse to overwrite a symlink with the
create_symlink command.

Swift SVN r24684
2015-01-23 08:33:31 +00:00
Dmitri Hrybenko
9ac070a545 Install Clang builtin headers in the Clang resource dir
Also, stop installing Clang builtin headers in Apple B&I builds.  We
will rely on real Clang headers.

Swift SVN r24675
2015-01-23 03:09:56 +00:00
Arnold Schwaighofer
d143e2d003 RefCount: Add an assert and some documentation
Incorporate John's feedback.

Swift SVN r24560
2015-01-20 20:40:08 +00:00
Arnold Schwaighofer
80a46cdae2 RefCount: Use rotate right in isUniquelyReferencedOrPinned
This generates more efficient code.

Swift SVN r24555
2015-01-20 17:00:12 +00:00
John McCall
524a0afee0 Strengthen and clarify the assertions in
swift_release and swift_unpin.

Swift SVN r24422
2015-01-14 19:14:26 +00:00
John McCall
a027f3bc46 Flesh out the pinning API to cover all the cases
we need for arrays.

Swift SVN r24421
2015-01-14 19:14:24 +00:00
Argyrios Kyrtzidis
a8d7c8d475 [CMake] When initially configuring for non-standalone the clang headers are not setup yet,
so don't error about it.

Swift SVN r24288
2015-01-08 23:46:17 +00:00
Dmitri Hrybenko
269de5fa7f CMake: allow mixed configurations of LLVM and Swift with Xcode
Swift SVN r24177
2015-01-05 07:18:13 +00:00
Dmitri Hrybenko
6670bb76ec Rewrite the CMake build system
Swift SVN r24124
2014-12-23 22:15:30 +00:00
Dmitri Hrybenko
9177107940 stdlib/Hashing: move the hash seed variable to C++ code to avoid
dispatch_once calls on every load from it

Performance improvements, as reported by the perf testing buildbot:

Histogram       -18.81%
TwoSum          -17.42%
RGBHistogram    -9.65%

Regressions:

InsertionSort                5.59%
ArrayOfRef                   3.99%
SwiftStructuresInsertionSort 5.29%
PrimeNum                     6.09%

These regressions are bogus.  The tests that "regressed" don't do any
hashing at all.

Swift SVN r23995
2014-12-17 23:45:29 +00:00
John McCall
3f46b30ca4 Add runtime functions to "pin" a native Swift object.
Pinning an object prevents it from being deallocated,
just like retaining it, but only one client can own the
pin at once.  Sensible "sharing" of the pin can occur
if attempts are perfectly nested.  It is efficient to
simultaneously query the pin state of an object in
conjunction with its strong reference count.

This combination of traits makes pinning suitable for
use in tracking whether a data structure backed by
an object is undergoing a non-structural modification:

- A structural change would require unique ownership
  of the object, but two non-structural changes (to
  different parts of the object) can occur at once
  without harm.  So a non-structural change can check
  for either uniqueness or a pin and then, if necessary,
  assert the pin for the duration of the change.
  Meanwhile, this act of asserting the pin prevents
  simultaneous structural changes.

- A very simple code-generation discipline leads to
  changes being perfectly nested as long as they're
  all performed by a single thread (or synchronously).
  Asynchrony can introduce imperfect nesting, but it's
  easy to write that off as a race condition and hence
  undefined behavior.

See Accessors.rst for more on both of these points.

Swift SVN r23761
2014-12-06 09:46:01 +00:00
John McCall
147fb8790a Comment some of the isUniquelyReferenced entrypoints
and remove _swift_isUniquelyReferenced_native_spareBits,
which was killed in favor of BridgeObject.

Swift SVN r23760
2014-12-06 09:45:59 +00:00
Joe Groff
b60a30c84b stdlib: Make isUniquelyReferenced shims properly return bool.
rdar://problem/18573806 is fixed.

Swift SVN r23547
2014-11-22 05:36:38 +00:00
Maxwell Swadling
530ae1777a Added ASCII fast paths for common string operations
- ==, <, lowercaseString and uppercaseString on String now have ASCII fast paths
- Fixes rdar://problem/17962640

Swift SVN r23494
2014-11-21 00:07:32 +00:00
Graham Batty
0aaf9af5c9 Use a type_traits shim for is_trivially_constructible.
Swift SVN r23383
2014-11-17 21:23:20 +00:00
Graham Batty
243fb6de51 Don't do is_trivial_constrictible on libstdc++.
This is currently unimplemented as of this macro being 20141011,
when it is implemented in libstdc++ the check should be changed
to a < the version that implemented it.

Swift SVN r23368
2014-11-17 17:15:11 +00:00
Andrew Trick
96688dea2f Silince unused variable warnings.
Swift SVN r23341
2014-11-15 00:37:34 +00:00
Graham Batty
04f8efbdf5 Correctly calculate non-objc instance size and rename to reflect.
Renames swift_class_getInstanceSize to
swift_class_getInstancePositiveExtentSize to reflect that it is
the size of the object after the instance address point.

Swift SVN r23333
2014-11-14 22:09:20 +00:00
Joe Groff
b9bd3a2fea Ensure HeapObject and RefCount objects are trivially constructible and destructible.
We don't want them to trigger .cxx_*struct behavior in our ObjC base classes after Clang is fixed.

Swift SVN r23332
2014-11-14 21:54:48 +00:00
Dave Abrahams
9fa1cc7a3a [stdlib] BridgeObject uniqueness checking
Also, more complete testing overall

Swift SVN r23268
2014-11-12 15:00:57 +00:00
Dmitri Hrybenko
f9290896cd SwiftShims: restore compatibility with Clang < 3.5 as a host compiler
Swift SVN r23233
2014-11-11 07:52:53 +00:00
Dmitri Hrybenko
af9515d754 Break a circular dependency between SwiftShims and the Darwin module
stdint.h and stddef.h are shipped with CLang, but they not included in
Clang's module.map, which causes Clang to import libc versions instead
(and Clang's stdint.h is dispatching to libc).  This was causing
hard-to-debug transient failures during incremental rebuilds, like this:

error: module file was created by an older version of the compiler: .../Darwin.swiftmodule

Swift SVN r23230
2014-11-11 02:26:06 +00:00
Dmitri Hrybenko
90624fd7a2 Use defined() instead of using a possibly not defined macra
Swift SVN r23229
2014-11-11 02:26:05 +00:00
Dmitri Hrybenko
caf00310fa Remove trailing whitespace
Swift SVN r23228
2014-11-11 02:25:54 +00:00
Dmitri Hrybenko
e954ac9534 CMake: normalize checks for Apple operating systems
Swift SVN r23056
2014-11-01 04:14:36 +00:00
Graham Batty
eaf22e9661 Make malloc_size a platform stub called swift_malloc_size.
Swift SVN r22971
2014-10-27 17:16:24 +00:00
Greg Parker
c6a88262cf [stdlib] Scrap bit-rotted FastEntryPoints.s. Rewrite refcounts using __atomic.
Generated code on x86_64 for swift_retain and swift_release and 
swift_allocObject are unchanged. arm64 is improved by using weaker 
memory barriers, fixing rdar://17423624.


Swift SVN r22887
2014-10-23 08:22:48 +00:00
Dave Abrahams
56c4cb2d42 [stdlib] Kill off _isUniquelyReferenced
It was doing an unsafeBitCast and possibly not managing lifetimes;
replace it with more-typesafe and memory-safe calls where possible.

Swift SVN r22779
2014-10-15 22:25:12 +00:00
Dave Abrahams
506a1b07a6 [stdlib] Modernize ArrayBuffer uniqueness check
Swift SVN r22773
2014-10-15 21:17:31 +00:00
Dmitri Hrybenko
5b9cd8d4ee Revert "[CMake] Remove shims/ folder as an explicit output of copy_shim_headers."
This reverts commit r22606.  It breaks the clean build.

Swift SVN r22704
2014-10-13 18:19:04 +00:00
Dave Abrahams
5c33278e63 [stdlib] Add ManagedBufferPointer
A revamped version of HeapBuffer that doesn't allow null buffer
references.  Something like this is needed for killing the null array
state.

Swift SVN r22683
2014-10-11 01:10:38 +00:00
Jordan Rose
f8ce21d5b6 [CMake] Remove shims/ folder as an explicit output of copy_shim_headers.
Cleaning this output sometimes fails to delete the folder, as does CMake's
heavy-handed sop to Xcode's suboptimal dependency analysis ("delete any
dependents"). Since the contents of the folder are already listed as outputs,
we should be fine.

Swift SVN r22606
2014-10-08 17:50:57 +00:00
Dave Abrahams
74e27aaab1 [stdlib] uniqueness checking for users
Make unique reference checking available to users, making ManagedBuffer
a complete facility for building COW value types.  Also rationalize the
way we name and organize the runtime primitives we ultimately call.

Swift SVN r22594
2014-10-08 04:48:52 +00:00
Dave Abrahams
512da79b7a [stdlib] Switch some shims to use id
Since ObjC functions take their arguments at +0, we don't need to erase
"object-ness" in order to avoid disturbing reference counts.  This
interacts much better with lifetime optimizations, since the caller must
ensure the argument isn't released until these functions return.

Swift SVN r22580
2014-10-07 22:15:11 +00:00
Dave Abrahams
cc9bc0c274 [stdlib] Kill _swift_isUniquelyReferenced @asmname
Swift SVN r22576
2014-10-07 21:40:48 +00:00
Dave Abrahams
6c235c83b0 [stdlib] Migrate some @asmnames into SwiftShims
One of them still needs a type declaration change, so an @asmname for it
remains, temporarily.

Swift SVN r22575
2014-10-07 21:40:46 +00:00
Dave Abrahams
b108945c46 [stdlib] Break up shims.h
More things are going to be declared in shims, in part to reduce the use
of @asmname, and we'll want to keep this organized.

Swift SVN r22574
2014-10-07 21:40:45 +00:00
Dave Abrahams
eac8ca27f9 [stdlib] Use a universal empty array buffer
NFC, and no significant performance change expected.  This is part one
of a move to eliminate nil checks from the array implementation.

Swift SVN r22526
2014-10-05 17:55:11 +00:00
Dave Abrahams
b740ad0df9 Revert "[stdlib] Use a universal empty array buffer"
This reverts commit r22495, because it wroke havoc with SIL and the perf
test suite somehow.

Swift SVN r22499
2014-10-03 18:52:11 +00:00
Dave Abrahams
f2f068c3dc [stdlib] Use a universal empty array buffer
NFC, and no significant performance change expected.  This is part one
of a move to eliminate nil checks from the array implementation.

Swift SVN r22495
2014-10-03 16:01:50 +00:00
Dmitri Hrybenko
b2b19c6cc3 SwiftShims: #ifdef-guard uses of Objective-C constructs
Swift SVN r22461
2014-10-02 09:28:16 +00:00
Dmitri Hrybenko
932953eacb Allow CMake to succeed on non-Darwin systems
Swift SVN r22312
2014-09-27 21:56:41 +00:00
Devin Coughlin
9c7d27c4eb Add an OS version check for API availability to standard library and runtime.
This patch adds a compiler entry point to the standard library that checks
whether the running OS version is greater than or equal to a given version
triple. The idea is that #os(...) will get SILGen'd into a call to this
function.

The standard library function calls a runtime function to actually get the OS
version. This runtime function uses -[NSProcessInfo operatingSystemVersion] when
possible, otherwise it loads the SystemVersion plist. When running under the
simulator, we use an environmental variable set by the simulator to look up the
version for the simulated OS and not the host OS.

At the moment, there is no caching for version info. I will add this in a later
patch.


Swift SVN r22303
2014-09-26 18:26:29 +00:00
Dave Abrahams
d65284ced0 [stdlib] Fix circular module dependency
Swift SVN r21648
2014-09-02 19:35:02 +00:00
Dave Abrahams
27809a507a [stdlib] Don't @asmname POSIX APIs
For reasons not entirely clear yet, this can cause problems in the
compiler when some modules bring in the same names via the Darwin
module (see <rdar://problem/18184795>).  Use SwiftShims instead.

Swift SVN r21646
2014-09-02 17:26:03 +00:00
Dave Abrahams
d00e888d95 [stdlib] Rename reinterpretCast => unsafeBitCast
Also give unsafeBitCast an explicit type parameter.  So

  let x: T = reinterpretCast(y)

becomes

  let x = unsafeBitCast(y, T.self)

Swift SVN r20487
2014-07-24 13:17:36 +00:00