Commit Graph

4650 Commits

Author SHA1 Message Date
Joe Groff
9690bda3a1 Remove dead @asmname declaration. 2015-11-13 08:37:13 -08:00
Joe Groff
49261a03af Runtime/stdlib: Remove _stdlib_getDemangledTypeName.
We don't really need its peculiar behavior characteristics; its uses in the legacy mirror implementations can now be replaced by direct stringification of metatypes.
2015-11-13 08:37:12 -08:00
Joe Groff
c6b6d346bd Move the SwiftNativeNSXXXBase classes and stubs to SwiftStubs.
Move the ObjC internal declarations to a public runtime header so they can be shared, and rename _swift_deallocClassInstance to the more descriptive name swift_rootObjCDealloc (and make it only available with ObjC interop).
2015-11-13 08:37:12 -08:00
Joe Groff
87325891a3 Move FoundationHelpers.mm to SwiftStubs. 2015-11-13 08:37:12 -08:00
Joe Groff
7658ec9783 Move Availability.mm to SwiftStubs.
The functionality is exported as part of the standard library, not the core runtime.
2015-11-13 08:37:12 -08:00
Joe Groff
ffa83c057f static-ize some helpers that don't need to be exported. 2015-11-13 08:37:12 -08:00
Michael Gottesman
e52ef2278c Try to fix the oss bots by including CoreGraphics for UIKit overlay. 2015-11-12 09:57:27 -08:00
Mishal Shah
756dd23c1f Fix Linux build after 69a20622 which renamed a header 2015-11-11 20:46:01 -08:00
Joe Groff
69a206229d Runtime: Start splitting out stubs only needed by the standard library.
Set up a separate libSwiftStubs.a archive for C++ stub functionality that's needed by the standard library but not part of the core runtime interface. Seed it with the Stubs.cpp and LibcShims.cpp files, which consist only of stubs, though a few stubs are still strewn across the runtime code base.
2015-11-11 17:28:57 -08:00
Michael Gottesman
99bd7754a5 Fix typo in StdlibUnittest.swift.gyb. 2015-11-11 16:07:42 -08:00
Maxim Moiseev
0ea9c29acd Remove unnecessary unsafeUnwrap calls.
Since `dropFirst` does not return an `Optional`,
`unsafeUnwrap(xs.dropFirst())` first implicitly wraps result of
`dropFirst` into an optional and then calls `unsafeUnwrap` on that.
2015-11-10 11:03:38 -08:00
Jordan Rose
b78991913a [CMake] Remove the symlink to Xcode's arclite libraries.
With 877b51d, we'll find them using 'xcrun' if Swift isn't located next
to Clang.
2015-11-09 17:44:09 -08:00
David Farler
8f2fbdc93a Make function parameters and refutable patterns always immutable
All refutable patterns and function parameters marked with 'var'
is now an error.

- Using explicit 'let' keyword on function parameters causes a warning.
- Don't suggest making function parameters mutable
- Remove uses in the standard library
- Update tests

rdar://problem/23378003
2015-11-09 16:56:13 -08:00
Chris Willmore
ab1f21ab8a Link libpthread and libdl when importing Glibc module.
libSystem on OS X (and therefore the Darwin module) includes all the functions
that are present in libpthread/libld on Linux. So go ahead and pull those in for
parity.

<rdar://problem/23207607>
2015-11-06 14:26:01 -07:00
John McCall
01c4c6a50d Utility functions in headers need to be 'static inline', not just
'static', or else the compiler will complain when they're unused.
2015-11-06 10:44:26 -08:00
Slava Pestov
ec8d952db0 Runtime: Remove redundant #ifdef that's already nested inside another, NFC 2015-11-05 21:46:04 -08:00
Erik Eckstein
971a680199 Support for stack promotion of array buffers in the stdlib.
The basic idea is to move the allocation of the buffer out of @_semantics("array.uninitialized") so that it can be inlined without inlining the semantics function (on high-level SIL).

This change in the stdlib also requires an adaption of the dead area elimination in DeadObjectElimination.
Otherwise it would just remove the semantics function but not the allocation and we would leak memory.
2015-11-05 16:52:59 -08:00
Slava Pestov
3e7d63085c Revert "Build the Dispatch overlay on Linux"
This broke the build with a dependency issue.

This reverts commit ac6de62b66.
2015-11-05 14:36:40 -08:00
Slava Pestov
ac6de62b66 Build the Dispatch overlay on Linux
This is an optional feature that is off by default, and is enabled by
passing -- -build-swift-dispatch-overlay=1 to utils/build-script.

The libdispatch build I was testing with was old and is missing some
symbols, so perhaps some of the stuff can move out of #if protection
later.

There isn't much here yet, and no tests either.
2015-11-05 14:18:19 -08:00
Maxwell Swadling
5d52666132 Improved the performance of _dictionaryBridgeFromObjectiveCConditional by specifying the minimumCapacity up front. NFC 2015-11-05 12:01:30 -08:00
Maxwell Swadling
933c973551 Revert "Improved the performance of _dictionaryBridgeFromObjectiveCConditional by only allocating a _NativeDictionaryStorage once all the items are bridged. NFC"
This reverts commit e001efc741.

A faster approach is to reserve the memory with minimumCapacity.
2015-11-05 12:01:30 -08:00
Jordan Rose
6e1bf0d10d Rename @exported to @_exported for now.
At some point I want to propose a revised model for exports, but for now
just mark that support for '@exported' is still experimental and subject
to change. (Thanks, Max.)
2015-11-05 11:59:00 -08:00
Maxwell Swadling
e001efc741 Improved the performance of _dictionaryBridgeFromObjectiveCConditional by only allocating a _NativeDictionaryStorage once all the items are bridged. NFC 2015-11-04 14:30:31 -08:00
Slava Pestov
3d19691bab IRGen: Always use Swift reference counting when Obj-C interop is not available
The swift_unknown* entry points are not available on the Linux port.
Previously we would still attempt to use them in a couple of cases:

1) Foreign classes
2) Existentials and archetypes
3) Optionals of boxed existentials

Note that this patch changes IRGen to never emit the
swift_errorRelease/Retain entry points on Linux. We would like to
use them in the future if we ever adopt a tagged-pointer representation
for small errors. In this case, they can be brought back, and the
TypeInfo for optionals will need to be generalized to propagate the
reference counting of the payload type, instead of defaulting to
unknown if the payload type is not natively reference counted.
A similar change will need to be made to support blocks, if we ever
want to use the blocks runtime on Linux.

Fixes <rdar://problem/23335318>, <rdar://problem/23335537>,
<rdar://problem/23335453>.
2015-11-03 13:03:50 -08:00
Joe Groff
f716bb2c3e Runtime: Let allocError take an initial value.
This will let us eventually do tagged pointer optimization for small error values. We don't take advantage of this in IRGen yet, but we can take advantage of it in the dynamic cast code in a few places, so it gets exercised, and doing this now will let us backward-deploy the optimization when we do implement it in the future.
2015-11-02 19:07:20 -08:00
Joe Groff
8c7c2e6c03 Retire now-dead memory_order enum in Stubs.cpp. 2015-11-02 14:58:01 -08:00
Michael Gottesman
654ca4e0c5 Move Lazy.h from stdlib/public/runtime => include/swift/Basic
I am going to use this in a unittest for BlotMapVector.
2015-11-02 09:22:30 -08:00
David Farler
4ac9c80809 Add back remaining files for building and testing in Open Source 2015-10-31 00:19:20 -07:00
Joe Groff
4fb68c8a1a stdlib & Runtime: Replace atomic RMW stubs with builtins.
Swift SVN r32954
2015-10-28 23:47:40 +00:00
Joe Groff
527221ff4d stdlib & Runtime: Replace atomicStore/Load stubs with builtins.
Swift SVN r32953
2015-10-28 23:04:35 +00:00
Enrico Granata
cd26857b0a Take 2 - make NSObject conform to CustomDebugStringConvertible
Comes with a test case, and should now work since Jordan fixed the deserialization test case!



Swift SVN r32948
2015-10-28 21:49:25 +00:00
Joe Groff
eb330480cb stdlib & Runtime: Replace _swift_stdlib_atomicCompareExchangeStrong* stubs with Builtin calls.
NFC intended.

Swift SVN r32934
2015-10-28 01:58:52 +00:00
Erik Eckstein
4a1dffec32 Support for stack promotion in the runtime.
NFC yet.




Swift SVN r32928
2015-10-28 00:43:45 +00:00
Enrico Granata
1f04d0955d Revert my previous commit as it breaks the buildbots
Swift SVN r32912
2015-10-27 17:24:57 +00:00
Enrico Granata
daea9036e5 Make NSObject conform to CustomDebugStringConvertible
NSObject vends a debugDescription member, but it was not marked accordingly in the overlay



Swift SVN r32904
2015-10-27 00:51:13 +00:00
David Farler
a759ca9141 Disallow 'var' bindings in case patterns
Make the following illegal:

switch thing {
  case .A(var x):
    modify(x0
}

And provide a replacement 'var' -> 'let' fix-it.

rdar://problem/23172698

Swift SVN r32883
2015-10-25 18:53:02 +00:00
Dmitri Hrybenko
8df3dd331e Remove standard library hooks for AppKit apps in the integrated REPL
The REPL code can be simplified now.

Swift SVN r32882
2015-10-25 08:27:42 +00:00
Dmitri Hrybenko
2e51d23875 Un-ifdef object literals
Swift SVN r32880
2015-10-25 07:50:53 +00:00
Dmitri Hrybenko
9383927356 stdlib: trap correctly in floating-point to unsigned integer conversion
Uncovered by Dave's fixes to gyb.

<rdar://problem/23247773>

Swift SVN r32879
2015-10-25 04:53:37 +00:00
Dave Abrahams
98f612aef3 [stdlib] warning suppression
Swift SVN r32874
2015-10-24 16:51:36 +00:00
Dave Abrahams
a795fcd12c Remove stray debug print
Left this in by mistake

Swift SVN r32872
2015-10-24 14:48:13 +00:00
Dave Abrahams
b3ca7eed40 gyb parsing fixes
Fixes <rdar://problem/18900352> gyb miscompiles nested loops

Swift SVN r32863
2015-10-24 04:47:57 +00:00
David Farler
3434f9642b Disallow 'var' pattern bindings in if, while, and guard statements
Make the following patterns illegal:

  if var x = ... {
    ...
  }

  guard var x = ... else {
    ...
  }

  while var x = ... {
    ...
  }

And provide a replacement fixit 'var' -> 'let'.

rdar://problem/23172698

Swift SVN r32855
2015-10-24 01:46:30 +00:00
Andrew Trick
60d23310c1 For unsafeReferenceCast rely on type checks in the runtime.
<slight revision of yesterday's reverted commit>

The debugAsserts were nicely self-documenting, but generate an obscene
amount of useless SIL code that is inlined everywhere and sticks around
when we compile the stdlib. The old asserts would need to be fixed to
support Optionals but that makes the situation much worse.

Why is it ok to remove the asserts?
_unsafeReferenceCast remains an internal API.
If the src/dest types are not loadable reference types, the cast will
not be promoted to a value bitcast.
The remanining cases will be dynamically checked by swift_dynamicCast.

Swift SVN r32828
2015-10-22 18:19:24 +00:00
Arnold Schwaighofer
7fa673c6bc Revert "stdlib: Replace unsafeBitCast calls with unsafeCastReference."
Revert "For unsafeReferenceCast rely on static verifier checks."

This reverts commit r32796.
This reverts commit r32795.

They very likely broke a buildbot.

Swift SVN r32813
2015-10-21 22:06:01 +00:00
Michael Gottesman
e696331e06 Fix a duplicate symbol linker error by making an inline definition out of line.
Swift SVN r32801
2015-10-21 21:45:14 +00:00
Andrew Trick
b1b07ef0fa stdlib: Replace unsafeBitCast calls with unsafeCastReference.
unsafeBitCast should only be used when we actually need to lie to the type system (as opposed to just having an unchecked downcast).

Theses are the places where unsafeReferenceCast makes sense:
(In general it makes sense whenever the source & dest are class or class existential types)

- ArrayBuffer.getElement.

  The deferred downcast case cannot be benchmarked. It is never on the critical path.

  The ObjC array case cannot conceivably matter either, however, it is touched by
  DollarChain, JSONHelperDeserialize, and StrSplitter.
  These benchmarks do not regress at -O.

- arrayForceCast

  No regressions at -O based on microbenchmarks.

None of these remaining cases affect PerfTestSuite at -O:

- General ObjC bridging

- Set/Dictionary bridging

- String bridging

- AutoreleasingUnsafeMutablePointer

These are confirmed speedups but I did not investigate the cause:

|.Chars...................|.32.1%.|
|.Sim2DArray..............|.15.4%.|
|.Calculator..............|.13.0%.|
|.RecursiveOwnedParameter.|..7.9%.|

Swift SVN r32796
2015-10-21 19:41:57 +00:00
Andrew Trick
98d17a5236 For unsafeReferenceCast rely on static verifier checks.
The debugAsserts were nicely self-documenting, but generate an obscene
amount of useless SIL code that is inlined everywhere and sticks around
when we compile the stdlib. The old asserts would need to be fixed to
support Optionals but that makes the situation much worse.

Why is it ok to remove the asserts?
_unsafeReferenceCast remains an internal API. The invariants are checked
statically whenever the routine is specialized, and dynamically checked
by the runtime cast.

Swift SVN r32795
2015-10-21 19:41:54 +00:00
Dave Abrahams
912a00cfad [stdlib] More Array Refactoring
w/Dmitri and Arnold, making incremental progress towards comprehensible
code.

Swift SVN r32716
2015-10-16 00:08:03 +00:00
Ben Langmuir
02ec8e63d8 Add an install component to install the clang builtin headers to lib/clang
In cases where our major version of clang is different than the
installed clang this allows us to install the builtin headers ourselves.
This should be used judiciously, since it installs to a path 'owned' by
clang.

Swift SVN r32696
2015-10-14 23:53:39 +00:00