Commit Graph

32 Commits

Author SHA1 Message Date
Allan Shortlidge
95cc7319a1 SIL: Revert public linkage for @_silgen_name forward declarations.
It turns out that the stdlib build depends on `internal` functions with
`@_silgen_name` getting hidden linkage in some configurations. Instead of
messing with the linkage computation, just fix the `stdlib/Error.swift` test by
making `setWillThrowHandler` `public` to give it the right linkage.

Resolves rdar://141590619.
2024-12-17 08:35:01 -08:00
Mishal Shah
af112c1591 Update the Swift version to 6.0 from 5.11 2024-02-19 17:47:16 -08:00
Doug Gregor
3fa07a0e7a Implement swift_willThrow variant for typed throws.
`swift_willThrow` is called with an error right before it is thrown.
This existing entrypoint requires an already-boxed error existential;
with typed errors, we don't have the error existential on hand, so we
would need to allocate the box to throw a typed error. That's not okay.

Introduce a new `swift_willThrowTypedImpl` entry point into the runtime
that will first check for the presence of an error handler and, if one
is present, box the error to provide to the error handler. This
maintains the no-allocations path for typed errors while still
allowing existing error handlers to work.

This new entrypoint isn't available on older Swift runtimes, so create
a back-deployable shim called by the compiler. On new-enough platforms,
this will call through to `swift_willThrowTypedImpl`. On older
platforms, we drop the error and don't call the registered will-throw
handler at all. This is a compromise that avoids boxing when throwing
typed errors, at the cost of a slightly different experience for this
new feature on older runtimes.

Fixes rdar://119828459.
2024-02-05 15:06:55 -08:00
Max Desiatov
8b52415184 test/stdlib/Error.swift: disable crashing tests on WASI 2023-07-22 14:36:57 +01:00
Jonathan Grynspan
e057172b6f Make _swift_willThrow atomic (#62349)
* Make _swift_willThrow atomic
2022-12-03 10:41:56 -05: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
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
Karoy Lorentey
e2cfab4f28 [stdlib][test] Adopt availability macros in tests 2021-10-31 15:00:58 -07:00
Kuba (Brecka) Mracek
8b189d99e4 Turn off SWIFT_ENABLE_REFLECTION on the stdlib_minimal preset (#39030) 2021-09-12 18:54:53 -07:00
Mishal Shah
23c3b15f5f Support Xcode 13 beta
* Updating availability versions
* Remove all remaining overlays in stdlib/public/Darwin/*:
   - ObjectiveC
   - Dispatch
   - CoreFoundation
   - CoreGraphics
   - Foundation
2021-06-07 12:04:31 -07:00
Karoy Lorentey
634c582d0c [test] Fix test regressions in backdeployment bots
Resolves rdar://71902574
2020-12-04 18:56:18 -08:00
Robert Widmann
48614412c4 Merge pull request #34885 from LucianoPAlmeida/warn-class-protocol-inheritance
[Sema] Adding deprecation warning for protocol inheritance 'class' syntax
2020-12-01 10:36:41 -08:00
Luciano Almeida
c29fbb5528 [test] Adjusting test files where class syntax is used for protocol inheritance 2020-11-29 21:43:50 -03:00
Karoy Lorentey
1a051719e3 [runtime] Adjust file/line information in fatal error messages to follow diagnostic conventions
In debug configurations, fatal error messages include file & line number information. This update presents this information in a format matching the diagnostic conventions used by the compiler, which can be a slight productivity boost.

Code compiled with optimizations enabled (which is most production code) does not output this information, so it isn’t affected by this change.

Original format:

    Fatal error: A suffusion of yellow: file calc.swift, line 5

New format:

    calc.swift:5: Fatal error: A suffusion of yellow

Resolves rdar://68484891
2020-11-10 13:23:21 -08:00
Mishal Shah
cc19330c75 Codesign the Error binary before executing 2020-08-19 17:59:59 -07:00
Erik Eckstein
662f03ec4c SILCombine: optimize casts of existential boxes.
Optimize the unconditional_checked_cast_addr in this pattern:

   %box = alloc_existential_box $Error, $ConcreteError
   %a = project_existential_box $ConcreteError in %b : $Error
   store %value to %a : $*ConcreteError
   %err = alloc_stack $Error
   store %box to %err : $*Error
   %dest = alloc_stack $ConcreteError
   unconditional_checked_cast_addr Error in %err : $*Error to ConcreteError in %dest : $*ConcreteError

to:
   ...
   retain_value %value : $ConcreteError
   destroy_addr %err : $*Error
   store %value to %dest $*ConcreteError

This lets the alloc_existential_box become dead and it can be removed in following optimizations.
The same optimization is also done for conditional_checked_cast_addr.

There is also an implication for debugging:
Each "throw" in the code calls the runtime function swift_willThrow. The function is used by the debugger to set a breakpoint and also add hooks.
This optimization can completely eliminate a "throw", including the runtime call.
So, with optimized code, the user might not see the program to break at a throw, whereas in the source code it is actually throwing.
On the other hand, eliminating the existential box is a significant performance win and we don't guarantee any debugging behavior for optimized code anyway. So I think this is a reasonable trade-off.
I added an option "-Xllvm -keep-will-throw-call" to keep the runtime call which can be used if someone want's to reliably break on "throw" in optimized builds.

rdar://problem/66055678
2020-07-29 21:57:51 +02:00
Brent Royal-Gordon
745dbef3ef Use file IDs in generated code
Such as force unwraps, as! casts, etc.
2020-07-13 14:05:13 -07:00
Mishal Shah
e7cd5ab17f Update master to build with Xcode 11.4 2020-03-24 11:30:45 -07:00
Mike Ash
a2cf576d4a [Test] Don't test _swift_willThrow on older runtimes.
rdar://problem/56752866
2019-10-30 15:07:37 -04:00
Mike Ash
09e2e6888b [Runtime] Fix the error callback test for platforms without ObjC interop.
rdar://problem/53400364
2019-10-28 12:34:04 -04:00
Mike Ash
b8f5e841e2 [Runtime] Add a function pointer for intercepting swift_willThrow calls.
rdar://problem/53400364
2019-10-24 14:06:14 -04:00
Saleem Abdulrasool
7ca074bd07 test: port most of the stdlib tests to Windows
This adjusts the standard library test suite to mostly pass on Windows.
The remaining failures are due to various cases:

- memory corruption (`_swift_stdlib_free` in swiftDemangle)
- heap corruption (canGrowUsingRealloc)
- withVAList failure (unresolved)
- unicode handling on the command line
2019-01-15 09:19:06 -08:00
Maxim Moiseev
7c7a976185 Add a test for try! location reporting 2018-09-26 11:22:41 -07:00
Anton Pogonets
e33a977a19 Use uninitialized dealloc in swift_deallocError (#19059) 2018-09-05 13:16:53 -07:00
Doug Gregor
ecf752d54b Revert "Revert " [Foundation] Collapse (SignedInteger|UnsignedInteger) reqts into FixedWidthInteger"" 2018-08-29 13:18:44 -07:00
Mike Ash
8a9065a369 Revert " [Foundation] Collapse (SignedInteger|UnsignedInteger) reqts into FixedWidthInteger" 2018-08-29 13:55:20 -04:00
Doug Gregor
4acd723d16 [Foundation] Handle unsigned error codes without trapping.
When working with Error types with unsigned raw values, numeric-cast into
a UInt and then map the bits over to an Int so we preserve values not
representable in an Int without wrapping.

Thanks to @jrose-apple for pointing this out!
2018-08-28 10:49:01 -07:00
Joe Shajrawi
66d0df6bae Revert "Temporary disable failing armv7 tests"
This reverts commit 78e5e25215.
2017-08-15 13:43:57 -07:00
Joe Shajrawi
78e5e25215 Temporary disable failing armv7 tests 2017-08-08 15:22:14 -07:00
practicalswift
fa7fbdb8b0 [gardening] Remove redundant nil-initialization of optional variable
From the Swift documentation:

"If you define an optional variable without providing a default value,
 the variable is automatically set to nil for you."
2016-09-18 07:40:07 +02:00
Dmitri Gribenko
243a35cd65 Migrate callsites from 'expectEmpty()' to 'expectNil()' 2016-09-10 20:05:42 -07:00
Max Moiseev
9fc37efee4 [test] renaming test/1_stdlib to just test/stdlib 2016-09-01 16:51:43 -07:00