Commit Graph

3150 Commits

Author SHA1 Message Date
Dmitri Gribenko
5dd3ce9195 Merge pull request #3020 from modocache/sr-1738-add-swift-library-shared-static-args
[SR-1738] add_swift_library takes SHARED/STATIC arg
2016-06-18 15:38:57 -07:00
Dmitri Gribenko
25e0dd3181 Merge pull request #3053 from tinysun212/pr-execstack
[stdlib] Don't make the stack executable
2016-06-18 01:26:19 -07:00
Dmitri Gribenko
4cd1222750 Merge pull request #3025 from compnerd/sched_yield
stdlib: avoid posix sched_yield in favour of C++11
2016-06-17 20:30:22 -07:00
Han Sangjin
1dfe3078f7 [stdlib] Don't make the stack executable
If some object file doesn't contain a section of the name '.note.GNU-stack',
the linker make the stack executable. We append the section to swift_begin.o
and swift_end.o because don't need executable stack.
(reference: http://en.chys.info/2010/12/note-gnu-stack/)
2016-06-18 05:17:32 +09:00
Dmitri Gribenko
2526da3455 Merge pull request #3037 from compnerd/buffer-lengths
Use `sizeof` for buffer lengths in snprintf
2016-06-17 00:23:02 -07:00
swift-ci
85d2167cc6 Merge pull request #3036 from compnerd/win32-lean-and-mean 2016-06-17 00:09:23 -07:00
Brian Gesiak
328de9e280 [SR-1738] add_swift_library takes SHARED/STATIC arg
As a first step to allowing the build script to build *only*
static library versions of the stdlib, change `add_swift_library`
such that callers must pass in `SHARED`, `STATIC`, or `OBJECT_LIBRARY`.

Ideally, only these flags would be used to determine whether to
build shared, static, or object libraries, but that is not currently
the case -- `add_swift_library` also checks whether the library
`IS_STDLIB` before performing certain additional actions. This will be
cleaned up in a future commit.
2016-06-16 13:15:58 -04:00
Saleem Abdulrasool
6a91919509 runtime: add missing include
The use of `std::make_tuple` requires the declaration of the function which is
provided by the C++ standard header `tuple`.  This would get implicitly included
by one of the other C++ headers on the currently tested libraries, but does not
occur with the Microsoft C++ library.  Add the missing include.
2016-06-16 07:51:11 -07:00
Saleem Abdulrasool
e3c2c863d1 stdlib: define WIN32_LEAN_AND_MEAN and NOMINMAX
`WIN32_LEAN_AND_MEAN` prevents "rarely-used" headers from being pulled in.  This
significantly reduced preprocessor pressure, speeding up compile.  It also
reduces the amount of cruft pulled in by the Windows.h.

`NOMINMAX` ensures that the `min` and `max` macros are not defined.  These
macros collide with the use of `min` and `max` from C++ in certain cases: e.g.
`std::limits<T>`.
2016-06-16 07:34:17 -07:00
Saleem Abdulrasool
91a296fad6 stdlib: avoid posix sched_yield in favour of C++11
Use the C++11 std::this_thread::yield to abstract away platform specific
differences for yield execution time.  This makes the code more portable to
non-POSIX environments (i.e. Windows).  NFC.
2016-06-15 18:18:26 -07:00
Saleem Abdulrasool
c553628964 Use sizeof for buffer lengths in snprintf
Rather than duplicating the constant value, use the `sizeof` operator to have
the value propogate from the static buffer allocation.  Any standards conforming
implementation of `snprintf` will null-terminate the output unless the buffer is
NULL (a zero-sized buffer is passed to the call).  On Windows, where this is not
the case, the function is named `_snprintf` which ensures that we do not
accidentally end up with the incorrect behaviour.
2016-06-15 17:41:16 -07:00
practicalswift
4485f76794 [gardening] Use consistent capitalization for "Objective-C". 2016-06-14 22:24:43 +02:00
swift-ci
91ffcd79a7 Merge pull request #1918 from tinysun212/pr-stdlib-msvc-1 2016-06-11 03:55:47 -07:00
Han Sangjin
e6ecc9a3ec Modified for some reviews 2016-06-10 06:26:47 +09:00
practicalswift
1e0a4afeb0 [gardening] Don't compare with FALSE. 2016-06-04 08:41:29 +02:00
swift-ci
4956ba63e5 Merge pull request #2878 from apple/runtime-remove-unused-header 2016-06-03 17:12:23 -07:00
Dmitri Gribenko
f47b53350e Runtime: remove unused include 2016-06-03 15:54:42 -07:00
practicalswift
1fc5723206 [gardening] Fix two recently introduced headers. 2016-06-04 00:06:59 +02:00
Han Sangjin
198441bee9 stdlib/msvc: Runtime with MSVC library
This patch is for libswiftCore.lib, linking with the library set of Visual Studio 2015. Clang with the option -fms-extension is used to build.
2016-06-04 05:16:41 +09:00
Dmitri Gribenko
6a507d6311 Runtime: give each source file a unique basename
CMake Xcode generator does not seem to build libraries properly if we
have both a Foo.cpp and a Foo.mm in one library.
2016-06-02 01:13:40 -07:00
Han Sangjin
be815aabbb [stdlib/msvc] Runtime with MSVC library
This patch is for libswiftCore.lib, linking with the library set of Visual Studio 2015. Clang with the option -fms-extension is used to build this port.
This is the approved subpatch of a large patch.
2016-06-02 08:10:40 +09:00
Dmitri Gribenko
d227aeb64d CMake: use object libraries instead of repacking static archives 2016-06-01 03:06:33 -06:00
Dmitri Gribenko
8ac074687d runtime: remove unused includes 2016-05-30 19:36:26 -07:00
Bryan Chan
71abe8b7ca swift_allocError should use the Swift calling convention 2016-05-24 20:04:03 -04:00
Bryan Chan
85fde8b1fb Add support for Linux s390x. LLVM's Swift calling convention support is used to ensure correct operations of C++ code in the runtime. This patch also includes some (incomplete) changes to enum handling to make enums work in most common cases. 2016-05-24 20:03:28 -04:00
John McCall
b1983621d3 Fix the declaration of shim visibility on ELF platforms.
Declarations with protected visibility are assumed to be defined
within the current linkage unit, so we have to use default visibility
if we don't know that we're building that.  Teach the shim
visibility header to only use protected visibility when the
__SWIFT_CURRENT_DYLIB macro is defined, and define it when building
the standard library.  Eventually we should change
SWIFT_RUNTIME_STDLIB_INTERFACE and SWIFT_RUNTIME_EXPORT to be
parameterized by the defining dylib so that this works for all the
overlay stubs, too; for now, special-casing swiftCore is necessary
to fix the LInux build.
2016-05-19 14:38:34 -06:00
David Farler
2799cabcfb SwiftRemoteMirror: Dig into generic SIL boxes
Part 1: Generic SIL Boxes always have instatiated metadata with kind
HeapGenericLocalVariable, which includes a metadata pointer for the
boxed type.

Part 2, after this, is to provide some kind of outgoing pointer map for
fixed heap boxes, whose metadata may be shared among different but
destructor-compatible types.

rdar://problem/26240419
2016-05-17 01:30:28 -07:00
Michael Gottesman
8308ad85e2 Merge pull request #2485 from gottesmm/change-backtrace-to-use-dladdr-directly-instead-of-backtrace_symbol
When producing backtraces, do not use backtrace_symbol, invoke dladdr…
2016-05-11 17:28:36 -07:00
Michael Gottesman
7523d1a60b When producing backtraces, do not use backtrace_symbol, invoke dladdr directly.
Previously, we were using backtrace_symbol and then parsing/modifying its
output. By just using dladdr directly, we have a cleaner and more robust
solution.

rdar://25064742
2016-05-11 15:40:10 -07:00
Saleem Abdulrasool
81661fca61 stdlib: use the reserved attribute spellings
This is a purely mechanical change replacing the attributes with the reserved
spelling.  Compilers are to not error when they encounter a reserved spelling
for an attribute which they do not support.
2016-05-11 11:30:24 -07:00
Joe Groff
4ce8645501 Wanton microoptimization for -[_SwiftNativeNSError classForCoder]
We have a static cache var for [NSError class], so save an objc_msgSend here
2016-05-09 11:18:34 -07:00
swift-ci
dd715df6a7 Merge pull request #2432 from jckarter/bridged-error-coding 2016-05-07 10:02:45 -07:00
Chris Lattner
7e201996e8 Update the reflection printer to not omit parens from single argument
function types.  This exposes something which I think is a bug in the
reflection encoding, I'll chat with Slava about it.
2016-05-06 21:07:08 -07:00
Joe Groff
f7455a8409 Runtime: Archive _SwiftNativeNSErrors as NSErrors.
_SwiftNativeNSError is a runtime-private subclass, and NSError's inherited NSCoding implementation doesn't handle the Swift payload of bridged errors. We can't really archive arbitrary Swift values anyway yet, so just archive bridged NSError subclasses as regular NSErrors. Fixes rdar://problem/23051728.
2016-05-06 14:31:16 -07:00
Joe Groff
233a2bad9e Runtime: Fix _SwiftNativeNSError's copyWithZone:.
The default implementation from NSObject doesn't know how to copy the Swift error payload, and the object's immutable anyway, so we just need to retain and return the object we already have.
2016-05-06 11:44:23 -07:00
Jacob Mizraji
f8a79282f2 Resolve ambiguity in mutex declaration 2016-05-05 12:01:23 -07:00
rjmccall
9d2dfc0934 Merge pull request #1454 from glessard/weakref-threadsafety
[runtime] Thread safety for weak references
2016-05-04 11:03:46 -07:00
John McCall
50d58b2732 Add a lot of calling-convention annotations to the standard library / runtime.
The general rule here is that something needs to be SWIFT_CC(swift)
if it's just declared in Swift code using _silgen_name, as opposed to
importing something via a header.

Of course, SWIFT_CC(swift) expands to nothing by default for now, and
I haven't made an effort yet to add the indirect-result / context
parameter ABI attributes.  This is just a best-effort first pass.

I also took the opportunity to shift a few files to just implement
their shims header and to demote a few things to be private stdlib
interfaces.
2016-05-04 10:31:23 -07:00
Guillaume Lessard
94a9c512b9 [runtime] thread safety for weak references
It has been fairly easy to cause the runtime to crash on multithreaded read-read access to weak references (e.g. https://bugs.swift.org/browse/SR-192). Although weak references are value types, they can get elevated to the heap in multiple ways, such as when captured by a closure or when used as a property in a class object instance. In such cases, race conditions involving weak references could cause the runtime to perform to multiple decrement operations of the unowned reference count for a single increment; this eventually causes early deallocation, leading to use-after-free, modify-after-free and double-free errors.

This commit changes the weak reference operations to use a spinlock rather than assuming thread-exclusive access, when appropriate.
With this change, the crasher discussed in SR-192 no longer encounters crashes due to modify-after-free or double-free errors.
2016-05-03 20:58:44 -06:00
Brian Gesiak
fd641cdbca Merge pull request #2363 from compnerd/unused-function
stdlib: remove an unused-function
2016-05-03 09:51:57 -07:00
Jacob Mizraji
880026194e Changed StaticUnsafeMutex to have the swift:: namespace
to fix upstream clang build errors.
2016-05-02 18:14:21 -07:00
John McCall
51feb0095e Fix race condition in MetadataAllocator. 2016-05-02 16:10:57 -07:00
Saleem Abdulrasool
a35843c49a stdlib: remove an unused-function
This function is only used in the ObjC interop case.  Control it via the
preprocesor.
2016-05-01 18:52:11 -07:00
practicalswift
8e3ba900b0 [gardening] Fix recently introduced headers. 2016-05-01 12:59:13 +02:00
swift-ci
58eafc7a60 Merge pull request #2331 from rintaro/runtime-cmake-add_custom_command_target 2016-04-28 23:02:59 -07:00
Greg Parker
3af0796d4c [runtime] addressed review comments outlined in #1950 (Merge pull request #2332 from shawnce/SR-946_polish)
[runtime] addressed review comments outlined in #1950
2016-04-28 21:01:25 -07:00
Shawn Erickson
d78c6e3403 [runtime] addressed review comments outlined in #1950 2016-04-28 10:39:35 -07:00
Rintaro Ishizaki
93b4ed151a [Runtime] Don't install libsection_magic_{begin,end}.a 2016-04-29 01:45:06 +09:00
Rintaro Ishizaki
9114293af7 [Runtime] Correct add_custom_command_target usage in CMakeLists.txt
- COMMAND arguments must immediately follow dependency_out_var_name.
- Use generated target name instead of output file names.
- Unify 2 file copy COMMAND into 1 add_custom_command_target.
2016-04-29 01:44:51 +09:00
Joe Groff
804f78bfa8 Runtime: Don't leak bridged object when value-to-bridged-object cast fails.
Fixes a leak when a bridgeable value type is dynamically cast to a class type, and the cast fails, for instance:

  ```
  let x: Any = "string"
  x is NSNumber
  ```

We would fail to release the bridging object after attempting the cast.
2016-04-27 17:21:38 -07:00