Commit Graph

3245 Commits

Author SHA1 Message Date
Guillaume Lessard
9ead7d039d [stdlib] relax stride check in UnsafePointer.withMemoryRebound (#41553)
* [stdlib] relax stride check

- The stride check in `UnsafePointer.withMemoryRebound` makes less sense when rebinding memory for a single element.
- This skips the stride-matching portion of the `_debugPrecondition` in `withMemoryRebound` when `count == 1`.

* [test] UnsafePointer.withMemoryRebound with capacity 1
2022-02-25 09:54:32 -05:00
Guillaume Lessard
c9e86b4a93 [test] UnsafePointer.withMemoryRebound with capacity 1 2022-02-24 22:00:47 -07:00
Robert Widmann
496da9dda9 Merge pull request #40977 from buttaface/droid-test 2022-02-21 22:46:42 -08:00
Karoy Lorentey
5274295e3f [test] Update tests for new (conditional) _debugPrecondition behavior 2022-02-18 21:54:02 -08:00
Philippe Hausler
e675b310f8 [SE-0329] Clock/Instant/Duration (#40609)
* [WIP] Initial draft at v2 Clock/Instant/Duration

* Ensure the literal types for _DoubleWide are able to be at least 64 bits on 32 bit platforms

* static cast timespec members to long

* Remove runtime exports from clock functions

* Export clock functions in implementations as they are in headers

* Clean up internal properties by adding leading underscores, refine availability to a TBD marker macro, and break at 80 lines to match style

* Shift operators to concrete Instant types to avoid complexity in solver resolution

* Adjust diagnostic note and error expectation of ambiguities to reflect new potential solver (perhaps incorrect) solutions

* Update stdlib/public/Concurrency/TaskSleep.swift

Co-authored-by: Karoy Lorentey <klorentey@apple.com>

* [stdlib][NFC] Remove trailing whitespace

* [stdlib] Remove _DoubleWidth from stdlib's ABI

* [stdlib] Strip downd _DoubleWidth to _[U]Int128

* Additional adjustments to diagnostic notes and errors expectation of ambiguities to reflect new potential solver (perhaps incorrect) solutions

* Disable type checker performance validation for operator overload inferences (rdar://33958047)

* Decorate Duration, DurationProtocol, Instant and clocks with @available(SwiftStdlib 9999, *)

* Restore diagnostic ambiguity test assertion (due to availability)

* Add a rough attempt at implementing time accessors on win32

* Remove unused clock id, rename SPI for swift clock ids and correct a few more missing availabilities

* remove obsolete case of realtime clock for dispatch after callout

* Use the default implementation of ~ for Int128 and UInt128

* Ensure diagnostic ambiguitiy applies evenly to all platforms and their resolved types

* Restore the simd vector build modifications (merge damage)

* Update to latest naming results for Instant.Duration

* Updates to latest proposal initializers and accessors and adjust encoding/decoding to string based serialization

* Update availability for Clock/Instant/Duration methods and types to be 5.7

* Correct *Clock.now to report via the correct runtime API

* Ensure the hashing of Duration is based upon the attoseconds hashing

* Avoid string based encoding and resort back to high and low bit encoding/decoding but as unkeyed

* Adjust naming of component initializer to use suffixes on parameters

* Duration decoding should use a mutable container for decoding

* fix up components initializer and decode access

* Add platform base initializers for timespec and tiemval to and from Duration

* Add some first draft documentation for standard library types Duration, DurationProtocol and InstantProtocol

* Another round of documentation prose and some drive-by availability fixes

* InstantProtocol availability should be 5.7

* Correct linux timeval creation to be Int and not Int32

Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2022-02-17 09:32:46 -08:00
Alejandro Alonso
657c17fa39 Setup grapheme breaking tests 2022-02-15 17:16:36 -08:00
Butta
26aafe66f6 [android] Fix some tests and a doc flag
Use off_t for a recently failing stdlib test, remove Python hacks for some
tests that now work without them, and correct build flag in the docs.
2022-02-14 03:02:04 +05:30
Kuba (Brecka) Mracek
2fa79689fa Turn build-swift-stdlib-static-print on for freestanding preset (#41260) 2022-02-09 05:41:04 -08:00
Kuba (Brecka) Mracek
15400c3ef7 Set build-swift-stdlib-unicode-data=0 for the freestanding preset (#41258) 2022-02-08 12:31:49 -08:00
Allan Shortlidge
70a7d85e4a Merge pull request #41112 from tshortli/diagnose-available-wrapped-properties
[Sema] Diagnose @available attribute on wrapped and lazy properties
2022-02-07 10:26:53 -08:00
Kuba (Brecka) Mracek
d2957338f8 Set SWIFT_STDLIB_ENABLE_VECTOR_TYPES=0 for the freestanding stdlib (#41169) 2022-02-06 07:47:57 -08:00
Guillaume Lessard
1161f92bd7 Merge pull request #39529 from glessard/se-withMemoryRebound 2022-02-05 09:01:05 -07:00
Kuba (Brecka) Mracek
1781715d58 constant_vprintf: Add a mode where prints are silenced when -DPRINT_DISABLED is present on the client side (#41177) 2022-02-04 11:38:00 -08:00
Allan Shortlidge
e34196df0b Fix tests that depended on availability for lazy vars. 2022-02-04 10:28:11 -08:00
Mike Ash
a82ea120a4 [RemoteMirror][swift-inspect] Add a command to inspect the state of the concurrency runtime.
Most of the new inspection logic is in Remote Mirror. New code in swift-inspect calls the new Remote Mirror functions and formats the resulting information for display.

Specific Remote Mirror changes:

* Add a call to check if a given metadata is an actor.
* Add calls to get information about actors and tasks.
* Add a `readObj` call to MemoryReader that combines the read and the cast, greatly simplifying code chasing pointers in the remote process.
* Add a generalized facility to the C shims that can allocate a temporary object that remains valid until at least the next call, which is used to return various temporary arrays from the new calls. Remove the existing `lastString` and `lastChunks` member variables in favor of this new facility.

Swift-inspect changes:

* Add a new dump-concurrency command.
* Add a new `ConcurrencyDumper.swift` file with the implementation. The dumper needs to do some additional work with the results from Remote Mirror to build up the task tree and this keeps it all organized.
* Extend `Inspector` to query the target's threads and fetch each thread's current task.

Concurrency runtime changes:

* Add `_swift_concurrency_debug` variables pointing to the various future adapters. Remote Mirror uses these to provide a better view of a tasks's resume pointer.

rdar://85231338
2022-02-04 09:28:32 -05:00
Guillaume Lessard
9f2c4b5959 [test] rebinding raw memory 2022-02-03 20:02:33 -07:00
Guillaume Lessard
69aa3c36bc [test] rebinding typed memory to wider and narrower types 2022-02-03 20:02:33 -07:00
Guillaume Lessard
2eb37a84fe [gardening] fix warnings in tests 2022-02-03 20:02:33 -07:00
Max Desiatov
372ada0e24 test: add handling for Wasm/WASI (#39519)
This change adds support for WASI in stdlib tests. Some tests that expect a crash to happen had to be disabled, since there's currently no way to observe such crash from a WASI host.
2022-01-12 14:24:50 +00:00
Robert Widmann
9429514268 Merge pull request #40659 from buttaface/stdlib-remove-icu
[build] Remove last vestiges of ICU for anything other than Foundation
2022-01-07 00:36:13 -08:00
Kuba (Brecka) Mracek
5076af2ae4 Add a codesize check of the freestanding/minimal stdlib to prevent large codesize regressions (#40653) 2022-01-05 15:12:02 -08:00
Kuba (Brecka) Mracek
1ad13c0a55 Fix propagation of SWIFT_ENABLE_REFLECTION from CMake into lit.cfg and re-enable 'REQUIRES: reflection' tests (#40720) 2022-01-04 19:31:56 -08:00
Butta
2890d15da7 [build] Remove last vestiges of ICU for anything other than Foundation 2021-12-25 21:16:34 +05:30
Kuba (Brecka) Mracek
663a6fb771 Introduce SWIFT_STDLIB_HAS_TYPE_PRINTING flag to remove the ability to print types at runtime (to save codesize) (#40649) 2021-12-21 17:47:54 -08:00
Kuba (Brecka) Mracek
f7291f0b21 Add SWIFT_STDLIB_HAS_LOCALE CMake to build stdlib without locale.h and locale based float parsing (#40405) 2021-12-21 11:22:54 -08:00
Arnold Schwaighofer
3e2c4ac24c Require optimized stdlib for stdlib/move_function test
rdar://86543481
2021-12-17 08:09:06 -08:00
Michael Gottesman
35a9acfdb9 Fix bots by adding optimized_stdlib flag to a test. 2021-12-15 15:07:55 -08:00
Michael Gottesman
5aa34f43f8 [move-function] Add tests around var uniqueness properties of move. 2021-12-13 10:39:07 -08:00
Michael Gottesman
396f510d06 [move-function] Add support for properly checking let x: Int without an initial value.
We process these as loadable vars. This is really useful since it ensures that
uniqueness is preserved in this case:

```
  let x: K2
  do {
      x = self.k2
  }
  switch _move(x)[userHandle] {
  case .foo:
      assert(_isUnique(&self.k2))
  }
```

I added a test that proves this.
2021-12-11 00:18:09 -08:00
Eric Miotto
403ccd4072 Extend freestanding to support targeting Darwin platforms (#40202)
* add an option to add freestanding to the Darwin platform, so that
  to get expected compile behaviours (e.g. setting the install name)
* rework testing configuration to relax assumptions about freestanding
* add a preset to test such configuration (at least for PR testing)

Addresses rdar://85465396
2021-12-08 07:09:44 -08:00
swift-ci
7b2eb1f821 Merge pull request #39987 from Catfish-Man/printf-in-this-economy 2021-12-03 05:23:56 -08:00
David Smith
fc3e718771 Initial support for compile-time generation of vprintf format strings, behind the SWIFT_STDLIB_STATIC_PRINT flag 2021-12-02 16:58:36 -08:00
Doug Gregor
c0f5502269 Leverage error-to-warnings downgrades for non-ephemeral conversion diagnostics
There were slight wording changes between the warning and error
diagnostics, but they don't seem to justify the duplication here.
2021-12-02 11:12:07 -08:00
Devin Coughlin
3abd7b0e1f Add a targetOSVersionAtLeast builtin.
This allows the compiler to parse the Swift swiftinterface file of a recent SDK.
2021-11-22 11:59:56 +01:00
Karoy Lorentey
b76fa8bd18 Merge pull request #40135 from lorentey/fix-KVOKeyPath-backdeployment
[test] Adjust KVOKeyPaths test for back deployment
2021-11-11 19:40:59 -08:00
Karoy Lorentey
227213f0da Apply review notes 2021-11-11 13:39:03 -08:00
Karoy Lorentey
2af9f53d34 [test] Adjust KVOKeyPaths test for back deployment
C.f. https://github.com/apple/swift/pull/40051

rdar://85274909
2021-11-10 16:30:57 -08:00
Joe Groff
5c404acbde SIL: More robust substituted function type lowering.
This change separates out the formation of the generic signature and
substitutions for a SIL substituted function type as a pre-pass
before doing the actual function type lowering. The only input we
really need to form this signature is the original abstraction pattern
that a type is being lowered against, and pre-computing it should make
the code less side-effecty and confusing. It also allows us to handle
generic nominal types in a more robust way; we transfer over all of
the nominal type requirements to the generalized generic signature,
then when recursively visiting the bindings, we same-type-constrain
the generic parameters used in those requirements to the newly-generalized
generic arguments. This ensures that the minimized signature preserves
any non-trivial requirements imposed by the nominal type, such as
conditional conformances on its type arguments, same-type constraints
among associated types, etc.

This approach does lead to less-than-optimal generalized generic
signatures getting generated, since nominal type generic arguments
get same-type-bound either to other generic arguments or fixed to
concrete types almost always. It would be useful to do a minimization
pass on the final generic signature to eliminate these unnecessary
generic arguments, but that can be done in a follow-up PR.
2021-11-10 12:45:34 -08:00
Michael Gottesman
97b19206e2 [moveOnly] Emit an error diagnostic if a user applies _move to a value that the compiler doesn't know how to check (non-let, non-param today).
The error diagnostic tells the user that the compiler can't check the value. It
then instructs the user to make a feature request and provide the test case if
they think it is reasonable. I also provided an option to disable the diagnostic
to unblock people.

The reason why I think this is the right thing to do is we want people to know
that _move means they do not need to worry about the given binding being used
later in the program in some way without having to reason. For now I am doing
this by banning _move on non-lets, non-params. This is implemented by noting
that:

1. _move inserts move_value [allows_diagnostics].
2. The checker always removes [allows_diagnostics] after checking a _move.

Thus we know after we check, any move_value that is still marked with
[allows_diagnostic], it was a _move that we never used in any checking.

I added some test cases where this known triggers. I am either going to
implement some sort of support for performing _move on them or give a more
specific diagnostic. This is just an initial incremental step.
2021-11-06 01:26:43 -07:00
Alejandro Alonso
98feb5e6ec Add availability to a few new tests (#40048)
its available, not availabile
2021-11-05 16:01:19 -07:00
Mike Ash
c916a42252 Merge pull request #40051 from mikeash/fix-kvokeypaths-test-back-deployment
[Test] Make KVOKeyPaths.swift work with un-nested Optionals.
2021-11-04 16:42:18 -04:00
Mike Ash
ef341aa5ca [Test] Make KVOKeyPaths.swift work with un-nested Optionals.
Older runtimes will un-nest nil Optionals when casting, which broke this test when running against older runtimes.

rdar://84992292
2021-11-04 09:36:34 -04:00
Karoy Lorentey
d54e56bf1d Merge pull request #40006 from lorentey/deninenineninenine-codable-additions 2021-11-03 22:05:42 -07:00
Karoy Lorentey
5f65686cfc [test] Replace some more 9999 availabilities with SwiftStdlib 5.6 2021-11-02 20:43:35 -07:00
Kuba (Brecka) Mracek
367b4c1355 Enable -experimental-hermetic-seal-at-link for the stdlib on 'freestanding' (#39961) 2021-11-02 10:05:33 -07:00
Karoy Lorentey
e2cfab4f28 [stdlib][test] Adopt availability macros in tests 2021-10-31 15:00:58 -07:00
Karoy Lorentey
8e154a415a Merge pull request #39962 from lorentey/concurrency-availability
[stdlib] Introduce availability macros
2021-10-31 14:23:57 -07:00
Morten Bek Ditlevsen
0251957ae3 [SE-0320] Added protocol CodingKeyRepresentable (#34458) 2021-10-30 11:33:42 +01:00
Michael Gottesman
3a5049fa15 [stdlib] Mark _move as public.
Just a thinko on my part.
2021-10-29 15:37:46 -07:00
Michael Gottesman
f9122a79b7 [moveOnly] Implement a new _copy function that performs an explicit copy value.
The key thing is that the move checker will not consider the explicit copy value
to be a copy_value that can be rewritten, ensuring that any uses of the result
of the explicit copy_value (consuming or other wise) are not checked.

Similar to the _move operator I recently introduced, this is a transparent
function so we can perform one level of specialization and thus at least be
generic over all concrete types.
2021-10-29 15:37:46 -07:00