**Background:**
Each RemoteMirror test runs two processes: A host process runs the
RemoteMirror library and queries memory data from a target process. The host
and target communicate by passing strings back and forth with requests to read
particular information in memory. The target is pure Swift; the host is
C/C++.
**What this change does:**
Without this, the host makes very many small requests to the target.
Each of those requests has to be individually parsed by the target
using String operations from the debug stdlib. Actually transferring
the raw bytes is relatively quick.
With this, the host requests and caches "pages" of about 4k and
satisfies most requests from previously-fetched data. This dramatically
reduces the total number of operations.
**Performance notes:**
The following notes only count the time to compile and run the 78 tests in the
validation-tests/Reflection directory using `lit.py`; it does not include time
to rebuild the project before running tests.
**Performance with debug stdlib:**
(That is: `build-script -ra --debug-swift-stdlib`) Before this change, I got
tired of waiting after about 15 minutes and it was about 1/4 done. Some very
simplistic profiling showed >99% of the time being spent in stdlib String
operations in the target process. Activity Monitor shows that individual tests
run for about 6 minutes of CPU time each.
With this change, the tests run in about 70s of wall time. Almost all of the
time seems to spent compiling the tests; the tests themselves run too quickly to
even show up in the Activity Monitor.
**Performance with release stdlib:**
(That is: `build-script -ra`)
The tests run in about 70s of wall time with or without this change.
The subscript function from CxxRandomAccessCollection did not perform any bounds-checks.
This means that C++ containers that don't provide the operator[] (or C++ containers used in generic contexts) didn't have bounds-checks.
Fixes rdar://126570011
SWIFT_DEBUG_VALIDATE_UNCHECKED_CONTINUATIONS works by tracking the context pointers of active continuations, and verifying that a resumed context is in the set of active continuations. However, the resume calls are passed the task pointer, not the context pointer. The context pointer is recovered from the task. If the task has been destroyed, the context pointer is invalid. This can result in a weird error message or it can crash if the context pointer is used before checking it against the active continuations.
Instead, track tasks that are suspended pending an unchecked continuation. If the task is destroyed, we'll still be passed the dangling pointer and check that pointer against the tracking info. We must be sure to check that before trying to use anything inside it.
rdar://131858544
- when compiling embedded cross compile target standard libraries, include AVR
- add 16-bit pointer as a conditional compilation condition and get the void pointer size right for gyb sources
- attempt to fix clang importer not importing __swift_intptr_t correctly on 16 bit platforms
- changed the unit test target to avr-none-none-elf to match the cmake build
[AVR] got the standard library compiling in a somewhat restricted form:
General
- updated the Embedded Runtime
- tweaked CTypes.swift to fix clang import on 16 bit platforms
Strings
- as discussed in https://forums.swift.org/t/stringguts-stringobject-internals-how-to-layout-on-16-bit-platforms/73130, I went for just using the same basic layout in 16 bit as 32 bit but with 16 bit pointers/ints... the conversation is ongoing, I think something more efficient is possible but at least this compiles and will probably work (inefficiently)
Unicode
- the huge arrays of unicode stuff in UnicodeStubs would not compile, so I skipped it for AVR for now.
Synchronization
- disabled building the Synchronization library on AVR for now. It's arguable if it adds value on this platform anyway.
Extend the _unsafeInheritExecutor_ workaround to all remaining APIs in the
Concurrency library that have adopted `#isolation` default arguments to
(safely) stay in the caller's isolation domain...
... except one. Clock.measure() is currently running into problems with
the type checker workaround and needs a little more thought.
Fixes rdar://131760111.
When initializing a range set with a group of overlapping, identical,
or empty ranges, the initializer can exhibit poor performance due
to removing the unneeded ranges during processing. This change uses
a partitioning scheme instead, only removing the unnecessary ranges
at the end of initialization.
It should no longer be necessary to provide an `@_alwaysEmitIntoClient` version
of `_diagnoseUnavailableCodeReached()`. This workaround was originally added to
provide compatibility with projects that were misconfigured to compile against
a newer stdlib but link against an older one.
Resolves rdar://119892482.
It cannot be used for executing general-purpose work, because such function would need to have a different signature to pass isolated actor instance.
And being explicit about using this method only for deinit allows to use object pointer for comparison with executor identity.
Fix an unused variable warning in `Errors.cpp`.
Use brace initialization syntax in `SymbolInfo.cpp` rather than using
a constructor call.
rdar://130992923
This inserts a suitably named function into the stack trace whenever
a dynamic cast failure involves a NULL source or target type.
Very often, crash logs include backtraces with function names but
no log output; with this change, such a backtrace might look like
the following -- note `TARGET_TYPE_NULL` in the function name
here to mark the missing type information:
```
frame #0: __pthread_kill + 8
frame #1: pthread_kill + 288
frame #2: abort + 128
frame #3: swift::fatalErrorv()
frame #4: swift::fatalError()
frame #5: swift_dynamicCastFailure_TARGET_TYPE_NULL()
frame #6: swift::swift_dynamicCastFailure()
frame #7: ::swift_dynamicCast()
```
Resolves rdar://130630157