Commit Graph

82 Commits

Author SHA1 Message Date
Hugh Bellamy
bb34e2a959 Fix attribute fallout from new refcount representation 2017-03-02 19:44:37 +07:00
Hugh Bellamy
3a96ded085 Don't use certain attributes in shims or stubs if the attribute doesn't exist 2017-02-20 10:16:30 +07:00
Stephen Canon
e6c84d7a63 Mark libc math shims with always_inline attribute (#6956)
* Mark libc math shims with always_inline attribute

We want these to always be inlined, so mark them with ... always_inline.
The compiler happened to do the right thing with them previously, but we
shouldn't depend on that.

<rdar://problem/30043258> master-next: IRGen/builtin_math.swift failing because sqrt(4) is not constant folded
2017-01-20 18:09:30 -05:00
Stephen Canon
d89f8f423e Go back to using static inline stubs for sqrt and remainder (#6769)
* Go back to using static inline implementations of sqrt and remainder now that SR-2089 is resolved.

* Fix typo: sqrt -> squareRoot.

* Added test for constant-folding sqrt with -O.

* Added test case requested by jrose.
2017-01-13 13:26:46 -05:00
Max Moiseev
195691523f [stdlib] Eliminating some 'unsafeBitcast' related warnings 2017-01-10 12:36:22 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Hugh Bellamy
60e1cd1271 Fix condition in the runtime from _MSC_VER to _WIN32 2016-12-08 21:23:45 +00:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Dmitri Gribenko
51381cf3cf stdlib: annotate LibcShims.h with nullability 2016-09-05 22:47:24 -07:00
Stephen Canon
5564f94867 Intrinsics instead of shims (#3530)
* Use intrinsics instead of Libc stubs where we can.

This replaces most of the stubs used for basic operations on these
types with intrinsics, eliminating a level of indirection for fma,
ceil, floor, round, trunc.

square root and remainder still require stubs because there is no
remainder intrinsic and we can't use the square root intrinsic because
its behavior is undefined for negative inputs.  A previous commit
apparently either the compiler annotates static inline stubs wrong
or the SIL verifier can't handle them, so that change was backed out.

* Explicitly CHECK-NOT @llvm.sqrt instead of looking for @sqrt.
2016-07-15 12:08:25 -05:00
Andrew Trick
b1bf920a36 Revert "Use builtins instead of shims in FloatingPointTypes. (#3454)"
This reverts commit 999885fc8d.

This breaks the stdlib serialization tests:

Assertion failed: (!hasSharedVisibility(F->getLinkage()) && "external declaration of SILFunction with shared visibility is not " "allowed"), function visitSILFunction, file /s/sptr/swift/lib/SIL/SILVerifier.cpp, line 3267.
2016-07-15 08:58:53 -07:00
Stephen Canon
999885fc8d Use builtins instead of shims in FloatingPointTypes. (#3454)
* Map .round, .squareRoot, .addProduct, and .formRemainder onto builtins instead of shims where possible.
2016-07-14 17:50:30 -04:00
Stephen Canon
9c08fbf4ed SE-0113 + residual SE-0067 work (#3443)
Implemented SE-0113 + residual SE-0067 operations.

- adds `rounded` and `round` to `FloatingPoint`, from SE-0113.
- adds `remainder`, `squareRoot`, and `addingProduct`, from SE-0067.
- adds basic test coverage for all of the above.
- provides a default implementation of `nextDown` on `FloatingPoint`.
2016-07-11 09:38:25 -04:00
Saleem Abdulrasool
b86da25823 shims: repair cygwin build
This was a typo in the commit.  Unfortunately, we dont have any tests for the
cygwin target, so this wasnt caught.  The alternate code path is for the MSVC
code path which is under development via cross-compilation.
2016-06-22 21:37:03 -07:00
Saleem Abdulrasool
924e8cd690 shims: correct __swift_size_t for Windows
Windows uses `unsigned int` for `__SIZE_TYPE__` on the 32-bit targets and `long
long unsigned int` for 64-bit targets.  Reflect this for the `__swift_size_t`
type definition.
2016-06-22 06:49:37 -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
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
Zhuowei Zhang
7c502b6344 Port to Android
This adds an Android target for the stdlib. It is also the first
example of cross-compiling outside of Darwin.

Mailing list discussions:

1. https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151207/000171.html
2. https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000492.html

The Android variant of Swift may be built using the following `build-script`
invocation:

```
$ utils/build-script \
  -R \                                           # Build in ReleaseAssert mode.
  --android \                                    # Build for Android.
  --android-ndk ~/android-ndk-r10e \             # Path to an Android NDK.
  --android-ndk-version 21 \
  --android-icu-uc ~/libicu-android/armeabi-v7a/libicuuc.so \
  --android-icu-uc-include ~/libicu-android/armeabi-v7a/icu/source/common \
  --android-icu-i18n ~/libicu-android/armeabi-v7a/libicui18n.so \
  --android-icu-i18n-include ~/libicu-android/armeabi-v7a/icu/source/i18n/
```

Android builds have the following dependencies, as can be seen in
the build script invocation:

1. An Android NDK of version 21 or greater, available to download
   here: http://developer.android.com/ndk/downloads/index.html.
2. A libicu compatible with android-armv7.
2016-04-12 19:26:21 -04:00
Han Sangjin
5c1854bfcf stdlib: Portable random function
Changed rand32() implementation using a random engine in C++11 <random>.
2016-03-31 04:39:46 +09:00
Ian Partridge
fbf11ce054 [stdlib] Fix indentation 2016-03-01 20:49:53 +00:00
Ian Partridge
259d57bbe7 [stdlib] Use fwrite(3) in print() 2016-03-01 15:55:52 +00:00
Joe Groff
f7291b21ec Runtime: Build with -fvisibility=hidden.
...and explicitly mark symbols we export, either for use by executables or for runtime-stdlib interaction. Until the stdlib supports resilience we have to allow programs to link to these SPI symbols.
2016-02-08 08:06:02 -08:00
Dmitri Gribenko
b2ca7712f6 Merge pull request #929 from kballard/remove-reundant-locking-from-print
[Stdlib] Remove all redundant stdout locking when printing
2016-02-04 09:15:24 -08:00
Michael Gottesman
25ee4b9e83 [runtime] Mark swift_stdlib_malloc_size as being readnone.
This entry point /does/ read memory but this is not memory that is
visible to the compiler.
2016-02-02 15:39:15 -08:00
Michael Gottesman
27b5f930d8 [gardening] Fix two small indentation issues. NFC. 2016-02-02 15:39:14 -08:00
Kevin Ballard
ac1996000e [Stdlib] Remove all redundant stdout locking when printing
* Switch to calling `putchar_unlocked()` instead of `putchar()` for
  actual printing. We're already locking stdout with `flockfile()`, so
  there's no need for the redundant lock that `putchar()` uses.
* Add an explicit lock to the output stream in `dump()`. This means the
  entire dump is printed with the lock held, which will prevent the
  output of `dump()` from mixing with prints on other threads.
* Use `_debugPrint_unlocked()` instead of `debugPrint()` in
  `_adHocPrint()`. The output stream is already locked while this
  function is executing. Rename the function to `_adHocPrint_unlocked()`
  to make this explicit.
* Use `targetStream.write()` and `_print_unlocked()` instead of
  `print()` in `_dumpObject()`. This removes the redundant locking, and
  also eliminates the creation of intermediate strings. Rename the
  function to `_dumpObject_unlocked()` to make this explicit.
* Use `targetStream.write()`, `_print_unlocked()`, and
  `_debugPrint_unlocked()` in `_dumpSuperclass()`. This removes the
  redundant locking, and also eliminates the creation of intermediate
  strings. Rename the function to `_dumpSuperclass_unlocked()` to make
  this explicit.
* Use `_debugPrint_unlocked()` instead of `debugPrint()` in
  `String.init(reflecting:)`. This shouldn't really make much of a
  difference but it matches the usage of `_print_unlocked()` in
  `String.init(_:)`.

The net result is that all printing is still covered under locks like
before, but stdout is never recursively locked. This should result in
slightly faster printing. In addition, `dump()` is now covered under a
single lock so it can't mix its output with prints from other threads.
2016-02-02 13:40:55 -08:00
practicalswift
a3f857ca7b [gardening] Add "-*- C++ -*-" to header files currently missing it 2016-01-23 11:53:05 +01:00
practicalswift
50baf2e53b Use consistent formatting in top of file headers. 2016-01-04 02:17:48 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
William Dillon
4bf81e09da Build working on ARMv7l 2015-12-12 22:06:13 -08:00
Nadav Rotem
6f68cd56c7 Mark the stdlib memcopy and strlen as readonly (pure).
Swift SVN r32476
2015-10-06 23:53:52 +00:00
Dmitri Hrybenko
153d95efc6 SwiftShims: don't redeclare libc functions
Clang importer thinks that SwiftShims is the primary module where they
live, and this confuses code completion.

rdar://22488333

Swift SVN r32218
2015-09-25 03:33:50 +00:00