Commit Graph

14787 Commits

Author SHA1 Message Date
Ben Rimmington
d2495f87f0 [stdlib] Reinstate the FixedPointConversion tests (#36205)
* [stdlib] Reinstate the FixedPointConversion tests

* [stdlib] Update the FixedPointConversion tests

* [stdlib] Generate the FixedPointConversion tests

* [stdlib] FixedPointConversion_Release32: long_test
2021-03-09 22:24:03 -05:00
tbkka
f2544aafcc Release node factory storage after each demangling operation (#35961)
* Release node factory storage after each demangling operation

This adds missing clear() operations to a number of places in
RemoteMirror in order to reclaim memory after (de)mangling results
are no longer needed.

Before this, the RemoteMirror library had an unfortunate tendency to use
excessive amounts of memory as the demangler kept appending data to its
internal slab allocator.

Resolves rdar://72958641

* Include payload cases even if we cannot retrieve the typeinfo

Otherwise, we end up with inconsistent counts of payload and non-payload
cases, which screws up some of the enum management.

* Add a very basic check of enum with CF payload.
2021-03-09 16:37:39 -08:00
Robert Widmann
f9a5c29bca [NFC] Fixup StdlibUnittest to Use Member Operators for Equatable and Comparable 2021-03-09 15:08:46 -08:00
Kavon Farvardin
01b1043ce5 Fix a memory issue with actors in the runtime system, by @phausler 2021-03-09 14:47:36 -08:00
Joe Groff
872afda50b Merge pull request #36298 from jckarter/created-task-closure-context-leak
SIL: Clean up ownership handling in `createAsyncTask` builtins.
2021-03-09 14:17:13 -08:00
Joe Groff
d9798c0868 Concurrency: Redo non-_f variants of swift_task_create to accept closures as is.
In their previous form, the non-`_f` variants of these entry points were unused, and IRGen
lowered the `createAsyncTask` builtins to use the `_f` variants with a large amount of caller-side
codegen to manually unpack closure values. Amid all this, it also failed to make anyone responsible
for releasing the closure context after the task completed, causing every task creation to leak.
Redo the `swift_task_create_*` entry points to accept the two words of an async closure value
directly, and unpack the closure to get its invocation entry point and initial context size
inside the runtime. (Also get rid of the non-future `swift_task_create` variant, since it's unused
and it's subtly different in a lot of hairy ways from the future forms. Better to add it later
when it's needed than to have a broken unexercised version now.)
2021-03-08 16:54:19 -08:00
Erik Eckstein
375f289597 stdlib: fix ARC for getting an ArraySlice of an CocoaArray with non-contiguous storage.
For this special case we copied the objects out of the cocoa array without retaining them.
This lead to a double-free crash.

Unfortunately I could not come up with an isolated test case.

rdar://74624065
2021-03-08 20:34:19 +01:00
Erik Eckstein
5be350a975 stdlib: add a semantic attribute on the String.utf8CString and define it as "readonly"
Needed for StringOptimization.
2021-03-08 08:34:53 +01:00
Konrad `ktoso` Malawski
2467f6aaea [Concurrency] Task.withGroup can be rethrows 2021-03-08 13:39:12 +09:00
Doug Gregor
84cdeb7372 Merge pull request #36322 from DougGregor/resurrect-unsafe-throwing-continuation 2021-03-05 17:18:30 -08:00
Mike Ash
0f7f060abe Merge pull request #36290 from mikeash/cache-global-dispatch-queues
[Concurrency] Cache the queue returned from dispatch_get_global_queue.
2021-03-05 18:43:19 -05:00
Doug Gregor
32702203c5 Add UnsafeThrowingContinuation back as a deprecated typealias.
This helps migrate clients that reference this type.
Fixes rdar://75104903.
2021-03-05 12:21:54 -08:00
Joe Groff
016496384e Concurrency: Remove currently-unused non-_f variants of swift_task_create
I'm about to replace these with new variations that correctly handle spawning a task with
a closure as its initial entry point, without leaking or requiring large amounts of caller-side
code generation.
2021-03-05 12:01:06 -08:00
Doug Gregor
3eb73a59ca Merge pull request #36305 from DougGregor/remove-actor-enqueue-partial-task 2021-03-05 07:23:14 -08:00
Mike Ash
01f1a2dfb1 [Concurrency] Cache the queue returned from dispatch_get_global_queue.
We'll be using these queues a lot, so avoid calling that function every single time.

rdar://70578614
2021-03-05 10:19:22 -05:00
Mike Ash
48ef52fc34 Merge pull request #36257 from mikeash/conditionalize-shared-cache-calls
[Runtime] NULL check shared cache calls.
2021-03-05 09:57:55 -05:00
Doug Gregor
47b0abfda4 Remove Actor.enqueue(partialTask:) and all its magic.
The backs out of some early decisions we made about actor layout
that we don't need. Custom actors will use a different approach.

This should suffice for the remainder of rdar://70146827.
2021-03-04 22:49:10 -08:00
Konrad `ktoso` Malawski
0ec038c449 [Concurrency] remove Task.hasTaskLocalValues, they all do 2021-03-05 10:11:29 +09:00
Dario Rexin
54e78cc015 Fix after rebase 2021-03-04 09:37:59 -08:00
Dario Rexin
4bb52ccfbd Workaround for rdar://74957357 2021-03-04 09:37:59 -08:00
Dario Rexin
af4b6bc068 [Concurrency] Add asynchronous Task.sleep function 2021-03-04 09:37:58 -08:00
Mike Ash
e06c978cf8 [Runtime] NULL/availability check shared cache calls.
Avoid a dynamic linker failure if the calls aren't available at runtime.

rdar://74965969
2021-03-04 09:49:09 -05:00
Mike Ash
33cd6390af Merge pull request #36240 from mikeash/fix-warnings-objc-api
[Runtime] Silence warnings on NULL checks of ObjC function addresses.
2021-03-03 15:42:46 -05:00
Evan Wilde
2ee7a322a5 Merge pull request #36239 from etcwilde/ewilde/run-async-main-on-main-thread
[Concurrency] Run async main code on main thread
2021-03-03 09:47:18 -08:00
Evan Wilde
a643fe418e Run async main code on main thread
This patch moves the actual running of the main code onto the main
thread by making it part of the main actor. This should be more
consistent with what folks are expecting.
2021-03-02 22:36:12 -08:00
Konrad `ktoso` Malawski
550018574a [Concurrency] remove unimplemented Task APIs: yield, startingOn 2021-03-03 14:31:01 +09:00
Konrad `ktoso` Malawski
5427986255 Merge pull request #36228 from ktoso/wip-groups-towards-clean-abi
[TaskGroup] Towards ABI stability of groups
2021-03-03 11:46:22 +09:00
Saleem Abdulrasool
ce0a3a2dbc Merge pull request #36204 from compnerd/comctl32
Platform: link against ComCtl32 when using Common Controls
2021-03-02 16:45:13 -08:00
Mike Ash
7c1b968666 [Runtime] Silence warnings on NULL checks of ObjC function addresses.
Some ObjC runtime calls are weak or strong depending on the deployment target. When strong, we get warnings that the NULL checks always succeed; silence them.

Some of the adjacent code looked up functions using dlsym when they aren't provided by the SDK. Our current minimum SDK always has them, so remove the dlsym workaround.
2021-03-02 15:44:45 -05:00
Xiaodi Wu
d4300dd7fe [stdlib] Fix conversion from Float16 to unsigned integer types (#36219)
* [stdlib] Fix conversion from Float16 to unsigned integer types

* [stdlib] Tighten up concrete Float16-to-integer conversions
2021-03-02 08:57:41 -05:00
Konrad `ktoso` Malawski
aedbbe615d [TaskGroup] Towards ABI stability of groups 2021-03-02 20:25:22 +09:00
Konrad `ktoso` Malawski
fcb1c01a36 [TaskLocal] Use the task-local stack discipline allocator 2021-03-02 11:14:41 +09:00
Julian Lettner
ea5bb777e2 Fix TSan symbol lookup on Windows 2021-03-01 16:08:34 -08:00
Julian Lettner
a3ccdd29d8 Teach TSan about Swift Task and Actor model
I have identified the following conceptual synchronization points at
which task data and computation can cross thread boundaries.  We need to
model these in TSan to avoid false positives:

Awaiting an async task (`AsyncTask::waitFuture`), which has two cases:
1) The task has completed (`AsyncTask::completeFuture`).  Everything
   that happened during task execution "happened before" before the
   point where we access its result.  We synchronize on the *awaited*
   task.
2) The task is still executing: the current execution is suspended and
   the waiting task is put into the list of "waiters".  Once the awaited
   task completes, the waiters will be scheduled.  In this case, we
   synchronize on the *waiting* task.

Note: there is a similar relationship for task groups which I still have
to investigate.  I will follow-up with an additional patch and tests.

Actor job execution (`swift::runJobInExecutorContext`):
Job scheduling (`swift::swift_task_enqueue`) precedes/happens before job
execution.  Also all job executions (switching actors or suspend/resume)
are serially ordered.

Note: the happens-before edge for schedule->execute isn't strictly
needed in most cases since scheduling calls through to libdispatch's
`dispatch_async_f`, which we already intercept and model in TSan.
However, I am trying to model Swift Task semantics to increase the
chance of things to continue to work in case the "task backend" is
switched out.

rdar://74256733
2021-03-01 13:41:55 -08:00
Julian Lettner
5187382f25 Add support for calling TSan's acquire()/release() 2021-03-01 13:35:03 -08:00
Konrad `ktoso` Malawski
d7169edc21 [TaskLocals] Cleanly separate locals impl from Task, no need for fragment 2021-03-02 00:54:47 +09:00
Saleem Abdulrasool
621a4207f8 Platform: link against ComCtl32 when using Common Controls
This adds a missing link directive to the ComCtl32 module.  This allows
use of the module without requiring the user to explicitly add the
linked library to the target when building code against this module.
2021-02-27 12:28:45 -08:00
Karoy Lorentey
0836707303 [stdlib] Deprecate MutableCollection._withUnsafeMutableBufferPointerIfSupported (#36003)
* [stdlib] Deprecate MutableCollection._withUnsafeMutableBufferPointerIfSupported

In Swift 5.0, [SE-0237] introduced the public `MutableCollection.withContiguousMutableStorageIfAvailable` method. It’s time we migrated off the old, underscored variant and deprecated it.

The default `MutableCollection.sort` and `.partition(by:)` implementations are currently calling this hidden method rather than the documented interface, preventing custom Collection implementations from achieving good performance, even if they have contiguous storage.

[SE-0237]: https://github.com/apple/swift-evolution/blob/master/proposals/0237-contiguous-collection.md

* [test] Update tests for stdlib behavior changes

* Update stdlib/private/StdlibCollectionUnittest/CheckMutableCollectionType.swift

Co-authored-by: Nate Cook <natecook@apple.com>

* Update stdlib/private/StdlibCollectionUnittest/CheckMutableCollectionType.swift

Co-authored-by: Nate Cook <natecook@apple.com>

* Apply suggestions from code review

Co-authored-by: Nate Cook <natecook@apple.com>

* [test] LoggingMutableCollection: Fix logging targets

* [stdlib] Fix warning by restoring original workaround

Co-authored-by: Nate Cook <natecook@apple.com>
2021-02-26 11:32:27 -08:00
Karoy Lorentey
aede1cca1a [stdlib] Document a fatal surprise with Sequence._copyContents
Array’s _copyContents implementation traps if given too small a buffer. This prevents Sequence._copyContents from being used to speed up copying data into discontiguous memory. (We have to require a Collection conformance and run _copyContents on slices instead).

Document the underlying requirement.
2021-02-26 00:43:19 -08:00
Konrad `ktoso` Malawski
1cb3000a7e [TaskGroup] group is not NativeObject, just an opqeue value 2021-02-26 16:03:30 +09:00
Konrad `ktoso` Malawski
2ab160e7da Merge branch 'main' into wip-no-escape-group 2021-02-26 07:56:00 +09:00
Dave Lee
88c73c63d8 Merge pull request #36150 from apple/runtime-Remove-unused-lldb-symbols
[runtime] Remove unused lldb symbols
2021-02-25 08:52:22 -08:00
Konrad `ktoso` Malawski
cdd136096f reworked includes to stop hitting undefined symbols 2021-02-25 15:15:02 +09:00
Konrad `ktoso` Malawski
599572ba54 cleanups of tests after merge 2021-02-25 14:24:43 +09:00
Dave Lee
31a9a345ff remove ErrorObjectConstants.cpp from cmake 2021-02-24 20:41:35 -08:00
Dave Lee
8ac54a5bde [runtime] Remove unused lldb symbols 2021-02-24 18:11:50 -08:00
Konrad `ktoso` Malawski
6e525d7469 Merge branch 'main' into wip-no-escape-group 2021-02-25 10:37:20 +09:00
Mike Ash
2b3a627375 [Runtime] Conditionalize shared cache conformance acceleration on ObjC interop.
rdar://74698200
2021-02-24 13:06:34 -05:00
Doug Gregor
b802e5bfb4 Merge pull request #36126 from ktoso/wip-task-tl
[Concurrency] Taks APIs fully implemented via ActiveTask internal TL
2021-02-24 08:41:26 -08:00
Konrad `ktoso` Malawski
22283d9487 Merge branch 'main' into wip-no-escape-group 2021-02-24 20:09:26 +09:00