Commit Graph

29 Commits

Author SHA1 Message Date
Yuta Saito
65723193a9 [embedded] Use @_extern(c) instead of @_silgen_name for putchar in tests
Using inconsistent attributes between stdlib and tests causes
compilation errors. There are still several misuses of @_silgen_name in
tests, but leaving them as is for now to incrementally fix them.
2024-04-11 10:37:25 +00:00
Evan Wilde
64b19f7f45 Backdeploy task_wait_future fix to Swift 5.6 (#61254)
* Backdeploy swift_task_future_wait

This patch adds the implementation for `swift_task_future_wait`
entrypoint to the backdeploy library.

This involves pulling in `AsyncTask::waitFuture`, which relies on a fair
bit.

Please note, this pulls in the `StaticMutex` implementation from Swift
5.6. There are some challenges here. The concurrency version of the
`StaticMutex` involves a fairly nasty set of ODR violations in the
normal setup. See `public/Concurrency/Mutex.cpp`, which includes the
Mutex implementations cpp files directly, while defining a single macro
to replace the implementation of swift::fatalError with
swift_concurrency_fatalError. We only need the concurrency mutex (at
least for now), so I have hard-coded the `swift_concurrency_fatalError`
version into this library. If we should need the other implementation,
we are forced to include ODR-related undefined behavior.

We need symbols from C++, so I've added an implicit linker flag whenever
the static library is used, namely, it passes `-lc++` to the linker.
Since we only backdeploy on Apple platforms, this should be fine.

Some of the platform runtimes we need to backdeploy to have the
enter/exitThreadLocalContext functions defined, while others don't. We
define our own backdeploy56 shim function that dlsym's the function
pointer for these symbols if we have exclusivity checking available.
Otherwise, it doesn't do anything. If concurrency exclusivity checking
is available, we'll use it, otherwise we wont'.

The same dlsym check is done for `swift_task_escalate`. Not all
platforms we need to backdeploy to have a concurrency runtime. The
symbols that do need to use pieces of the concurrency runtime should not
be getting hit when deploying to systems that don't have concurrency. In
the event that you've gotten around the language blocking you from
calling these symbols and you've managed to call concurrency pieces
without using concurrency, we'll abort because something is seriously
wrong.

* Backdeploy swift_task_future_wait_throwing

Drop the remaining pieces in for adding
`swift_task_future_wait_throwing`.

* Apply task_wait_future fix

Actually apply the fix from ef80a315f8.

This deviates slightly from the original patch.

AsyncTask::PrivateStorage::_Status() does not exist in the Swift 5.6
library. Instead I am using `AsyncTask::PrivateStorage::Status`.

* Workaround missing compiler-rt linking

Working around the missing link against compiler-rt in these test.
They are a bit brittle as if anything in them uses compiler-rt, they
will start failing. The backdeploy 5.6 library uses some symbols from
compiler-rt, thus causes them to fail to link.

Disabling the runtime compatibility version checking to avoid these
symbols. This should be fine for the MicroStdlib test, but we should fix
'%target-ld' to handle this better in the future.
rdar://100868842
2022-10-07 09:36:17 -07:00
David Zarzycki
5dcc32f98f Remove all uses of -force-single-frontend-invocation
The `-force-single-frontend-invocation` flag predates WMO and is now an
alias for `-whole-module-optimization`. We should use the latter and let
the former fade into history.
2020-05-08 06:37:41 -04:00
Arnold Schwaighofer
da2d418fd9 Really fix micro stdlib test case 2019-06-15 07:21:10 -07:00
Arnold Schwaighofer
6f9c50c029 Fix MicroStdlib test 2019-06-14 15:49:23 -07:00
Saleem Abdulrasool
8cb86acab5 tests: add swift_addNewDSOImage to the stubs
This is needed particularly on Windows which does not permit unresolved
symbols and the startup stub (swiftrt.obj) references the runtime
function.
2019-06-03 18:53:29 -07:00
Erik Eckstein
4fb4435d12 IRGen: add an option to disable runtime calls for dynamic replacements.
With the option -Xllvm -basic-dynamic-replacement the runtime functions are not called (so it works with an old swift library).
But calling the original of a replaced function is not supported in this case.
2019-05-30 15:28:16 -07:00
Joe Groff
2a2d40d870 Driver: Link against compatibility library for deploying back to Swift 5.0 runtimes 2019-05-24 12:44:22 -07:00
John McCall
2ba7090fe8 Remove the extra-inhabitant value witness functions.
This is essentially a long-belated follow-up to Arnold's #12606.
The key observation here is that the enum-tag-single-payload witnesses
are strictly more powerful than the XI witnesses: you can simulate
the XI witnesses by using an extra case count that's <= the XI count.
Of course the result is less efficient than the XI witnesses, but
that's less important than overall code size, and we can work on
fast-paths for that.

The extra inhabitant count is stored in a 32-bit field (always present)
following the ValueWitnessFlags, which now occupy a fixed 32 bits.
This inflates non-XI VWTs on 32-bit targets by a word, but the net effect
on XI VWTs is to shrink them by two words, which is likely to be the
more important change.  Also, being able to access the XI count directly
should be a nice win.
2018-12-11 22:18:44 -05:00
John McCall
abdba1d3f4 Change the integer-literal type from Int2048 to IntLiteral.
Part of SR-290.
2018-10-31 23:14:58 -04:00
Doug Gregor
4c47906697 [Runtime] Define type metadata for Builtin.Int1 and Builtin.Int63.
These types are used in the standard library.
2018-10-26 18:04:29 -07:00
Doug Gregor
dd154f6668 [Runtime] Rename swift_instantiateWitnessTable() -> swift_getWitnessTable()
This runtime function doesn’t always perform instantiation; it’s how we
get a witness table given a conformance, type, and set of instantiation
arguments. Name it accordingly.
2018-10-25 20:35:27 -07:00
Doug Gregor
b5bc06e552 [ABI] Eliminate witness table accessors.
Witness table accessors return a witness table for a given type's
conformance to a protocol. They are called directly from IRGen
(when we need the witness table instance) and from runtime conformance
checking (swift_conformsToProtocol digs the access function out of the
protocol conformance record). They have two interesting functions:

1) For witness tables requiring instantiation, they call
swift_instantiateWitnessTable directly.
2) For synthesized witness tables that might not be unique, they call
swift_getForeignWitnessTable.

Extend swift_instantiateWitnessTable() to handle both runtime
uniquing (for #2) as well as handling witness tables that don't have
a "generic table", i.e., don't need any actual instantiation. Use it
as the universal entry point for "get a witness table given a specific
conformance descriptor and type", eliminating witness table accessors
entirely.

Make a few related simplifications:

* Drop the "pattern" from the generic witness table. Instead, store
  the pattern in the main part of the conformance descriptor, always.
* Drop the "conformance kind" from the protocol conformance
  descriptor, since it was only there to distinguish between witness
  table (pattern) vs. witness table accessor.
* Internalize swift_getForeignWitnessTable(); IRGen no longer needs to
  call it.

Reduces the code size of the standard library (+assertions build) by
~149k.

Addresses rdar://problem/45489388.
2018-10-25 20:35:27 -07:00
Erik Eckstein
39bb14b094 change mangling prefix from $S to $s
This is the final ABI mangling prefix

rdar://problem/38471478
2018-09-19 13:55:11 -07:00
Arnold Schwaighofer
8a36d2d8ce Codesign the executable in test MicroStdlib
rdar://40339165
2018-05-17 11:51:53 -07:00
John McCall
583bec3b2c Add a runtime function to query the current runtime state of a metadata.
This functions returns the metadata purely for liveness purposes.
2018-03-26 02:48:52 -04:00
Joe Groff
f01af883fc IRGen: Use known value witness tables for common type layouts.
If a type has the same layout as one of the basic integer types, or has a single refcounted pointer representation, we can use prefab value witness tables from the runtime instead of instantiating new ones. This saves quite a bit of code size, particularly in the Apple SDK overlays, where there are lots of swift_newtype wrappers and option set structs.
2018-03-11 11:04:37 -07:00
Greg Parker
e223f1fc9b [IRGen][runtime] Simplify runtime CCs and entry point ABIs (#14175)
* Remove RegisterPreservingCC. It was unused.
* Remove DefaultCC from the runtime. The distinction between C_CC and DefaultCC
  was unused and inconsistently applied. Separate C_CC and DefaultCC are
  still present in the compiler.
* Remove function pointer indirection from runtime functions except those
  that are used by Instruments. The remaining Instruments interface is
  expected to change later due to function pointer liability.
* Remove swift_rt_ wrappers. Function pointers are an ABI liability that we
  don't want, and there are better ways to get nonlazy binding if we need it.
  The fully custom wrappers were only needed for RegisterPreservingCC and
  for optimizing the Instruments function pointers.
2018-01-29 13:22:30 -08:00
Erik Eckstein
cd3d50a5d9 ABI: Change the mangling prefix from _T0 to $S 2018-01-06 13:55:59 -08:00
John McCall
9bbbe2c418 Update the metadata-initialization ABI:
- Create the value witness table as a separate global object instead
  of concatenating it to the metadata pattern.

- Always pass the metadata to the runtime and let the runtime handle
  instantiating or modifying the value witness table.

- Pass the right layout algorithm version to the runtime; currently
  this is always "Swift 5".

- Create a runtime function to instantiate single-case enums.

Among other things, this makes the copying of the VWT, and any
modifications of it, explicit and in the runtime, which is more
future-proof.
2017-12-21 00:26:37 -05:00
Dmitri Gribenko
984210aa53 tests: replace '// RUN: rm -rf' '// RUN: mkdir' pairs with '%empty-directory(...)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
Arnold Schwaighofer
67e3d27fd9 Copy-on-write existential performance work (#8369)
* IRGen: Change c-o-w existential implementation functions

* initialzeBufferWith(Copy|Take)OfBuffer value witness implementation for cow existentials

Implement and use initialzeBufferWith(Copy|Take)OfBuffer value witnesses for
copy-on-write existentials.

Before we used a free standing function but the overhead of doing so was
noticable (~20-30%) on micro benchmarks.

* IRGen: Use common getCopyOutOfLineBoxPointerFunction

* Add a runtime function to conditionally make a box unique

* Fix compilation of HeapObject.cpp on i386

* Fix IRGen test case

* Fix test case for i386
2017-03-27 20:51:02 -07:00
Erik Eckstein
2a55b26e46 Mangling: enable new mangling for symbols 2017-03-16 12:04:08 -07:00
Dmitri Gribenko
55864d10cb Tests: use 'mkdir -p' 2016-09-02 21:36:45 -07:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
John McCall
108c102c54 Fix test for precedence groups. 2016-07-27 09:00:29 -07:00
Michael Gottesman
7680f418bc Disable test to unbreak the builds.
rdar://27558848
2016-07-26 17:32:40 -07:00
Robert Widmann
f97e5dcb0e [SE-0115][1/2] Rename *LiteralConvertible protocols to ExpressibleBy*Literal. This
change includes both the necessary protocol updates and the deprecation
warnings
suitable for migration.  A future patch will remove the renamings and
make this
a hard error.
2016-07-12 15:25:24 -07:00
Dmitri Gribenko
1d23085a8b Make the MicroStdlib test executable 2016-05-06 12:12:36 -06:00