Commit Graph

17 Commits

Author SHA1 Message Date
Saleem Abdulrasool
39c238a7ea Runtime: add MSVC architecture spelling (NFCI)
Add `_M_ARM64` to mirror `__aarch64__`.
2023-07-10 08:37:19 -07:00
Rokhini Prabhu
3c0f4f79fe Provide a convenience for addStatusRecord for clients who have already
done the load or who need the oldStatus information after adding the
status record.

Change some of the memory barrier logic since we can take advantage of
load-through HW address dependency.

Radar-Id: rdar://problem/105634683
2023-02-20 23:14:47 -08:00
Alastair Houghton
dc809f8723 [Threading] A few include tweaks.
The threading implementations need to include Impl.h, not just their
specific variant, to pick up the `stack_bounds` type.

Also fix a newly exposed problem with Atomic.h.

rdar://90776105
2022-06-07 07:39:53 +01:00
Alex Hoppen
4aa2bbbf06 Revert "Merge pull request #42447 from al45tair/eng/PR-90776105"
This reverts commit 8bcb71140f, reversing
changes made to c4dd271d36.
2022-06-02 18:03:23 +02:00
Alastair Houghton
1c6618eca7 [Threading] A few include tweaks.
The threading implementations need to include Impl.h, not just their
specific variant, to pick up the `stack_bounds` type.

Also fix a newly exposed problem with Atomic.h.

rdar://90776105
2022-05-24 14:57:42 +01:00
Jonathan Grynspan
b749dd395d Revert "runtime: allow over-aligned types in the runtime"
This reverts commit b694ce4634.
2022-05-05 11:10:12 -04:00
Josh Soref
871634b9f3 Spelling include (#42616)
* spelling: accessible

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: are

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: assume

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: attempt

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: children

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: convenience

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: creation

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: default

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: dereference

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: deserialization

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: embedded

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: enriched

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: excluding

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: for

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: global

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: guarantee

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: initialization

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: initialize

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: label

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: lifting

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: mangled

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: metadata

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: minimum

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: offset

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: only

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: otherwise

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: output

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: overall

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: parameter

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: passed

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: performance

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: referenced

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: standard

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: syntax

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: that

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: the

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: trivia

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: truncate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: undesirable

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: uniformly

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: uninitialized

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: value

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: verification

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-25 09:00:59 -07:00
Saleem Abdulrasool
312f25874a Runtime: correct invalid C++ workaround
The placement new operator is only available when `<new>` has been
included.  Add the missing include to the header to allow us to get the
definition of the placement new allocator.  This allows us to remove the
workaround that was there for Windows, and should hopefully repair the
Android build as well.

Thanks to @grynspan for helping identify the underlying issue!
2022-04-13 10:28:03 -07:00
Saleem Abdulrasool
b694ce4634 runtime: allow over-aligned types in the runtime
Not all targets have a 16-byte type alignment guarantee.  For the types
which are not naturally aligned, provide a type specific `operator new`
overload to ensure that we are properly aligning the type on allocation
as we run the risk of under-aligned allocations otherwise.

This should no longer be needed with C++17 and newer which do a two
phase `operator new` lookup preferring
`operator new(std::size, std::align_val_t)` if needed.  The base type
would be fully pre-processed away.  The empty base class optimization
should help ensure that we do not pay any extra size costs for the
alignment fixes.

As we are a C++14 codebase, we must locally implement some of the
standard type_traits utilities, namely `void_t`.  We take the minimal
definition here, assuming that the compiler is up-to-date with C++14 DR
reports which fixed an issue in SFINAE.  We use the SFINAE for detecting
the presence of the `operator new` overload to guide the over-alignment,
which is inherited through the new `swift::overaligned_type<>`  base
type.

Annotate the known classes which request explicit alignment which is
non-pointer alignment.  This list was identified by
`git grep ' alignas(.*) '`.
2022-04-04 18:26:20 -07:00
Saleem Abdulrasool
1b5b9d3573 Runtime: change atomic implementation for AllocationPool
The `AllocationPool` type is reflected upon and inspected by debugging
tools.  This requires that the layout of the atomically wrapped type
must store the value at offset 0.  However, the `std::atomic` does not
make any such guarantees, and a layout differing would render debug
utilities useless.  Switch instead from a `std::atomic` to
`swift::atomic`.  In order to do so, we also need to introduce the
`compare_exchange_strong` helper which maps to
`compare_exchange_strong_explicit` mirroring `compare_exchange_weak`.
2022-02-06 12:37:48 -08:00
Saleem Abdulrasool
74496f3bad Runtime: correct the location of windows header inclusion
We would previously include a header inside the `swift::impl` namespace,
which would prevent the proper declaration of the functions and
enumerators.  This corrects the location of the header inclusion to fix
this issue.
2021-09-01 14:12:43 -07:00
John McCall
f0977ac2fc Fixes to swift::atomic: load is const, provide a store. 2021-07-14 15:51:02 -04:00
John McCall
c346d94655 Fix the build and implementation of the 16-byte atomics for MSVC.
Credit for the cmake fix here goes to Saleem Abdulrasool.

The substantive fix is embarrassing; I didn't pay close attention
to the intrinsic's argument order and just assumed that the first
argument for the replacement value was the low half (the part
you'd find at index 0 if it were an array), but in fact it's the
high half (the part you'd find at index 1).

I also change the code to be much more reinterpret_casty, which
isolates the type-punning mostly "within" the intrinsic, and
which seems to match how other code uses it.
2020-12-04 01:51:29 -05:00
John McCall
a53d83f4db Disable the swift::atomic<..., 16> specialization until we can
figure out how to convince clang-cl to accept it.

We need to make progress.
2020-12-02 18:47:13 -05:00
John McCall
ca16548470 Add a swift::atomic<T> which uses a better ABI than MSVC's 128-bit std::atomic. 2020-12-02 18:47:02 -05:00
Saleem Abdulrasool
2d04b8491b stdlib: check for ARM/ARM64 more thoroughly (NFC)
Update the instances of checks for architectures to be more broad for different
spellings of the architecture macro.  Certain targets use `_M_ARM` and others
use `__arm__`.  Similarly, arm64/aarch64 has `_M_ARM64`, `__arm64__` and
`__aarch64__` as spellings.  This just mechanically goes through and encodes the
various spellings.

Take the opportunity to replace some raw checks with `defined` checks which
avoids a pedantic warning due to the undefined macro when performing the check
as the preprocessor may warn about an undefined condition evaluating to `0`.
2018-09-21 11:24:03 -07:00
Mike Ash
da4fa67d7e [Runtime] Move ConcurrentReadableArray's allocate/deallocate functions into Storage. Mark ConcurrentReadableArray as un-copyable, un-assignable, and un-movable. Use SWIFT_MEMORY_ORDER_CONSUME instead of std::memory_order_consume. Make read() pass a const pointer.
rdar://problem/37173156
2018-05-15 15:27:33 -04:00