The return type of getNumRuntimeFunctionCounters is defined as uint64_t in RuntimeInvocationsTracking.cpp, but it has return type Int in RuntimeFunctionCounters.swift.
Found when compiling the stdlib for WebAssembly, as WebAssembly validates return types. uint64_t corresponds to i64, but Int is i32, so the program fails validation.
The old-style mirrors were the basis for non-custom, reflection based Mirrors. As part of removing old-style mirrors, reflection based Mirrors are reimplemented without them. Reflection.mm is deleted and replaced with ReflectionMirror.mm, which borrows a chunk of the old code but presents a simpler API to the Swift side. ReflectionMirror.swift then uses that API to implement a reflection-based Mirror init.
rdar://problem/20356017
Also update how the variable is managed in the build system to allow the test to be conditional based on it, and make it more natural to set it on the command line.
- Use SWIFT_RUNTIME_EXPORT instead of SWIFT_RT_ENTRY_VISIBILITY for exposed functions
- Use `_swift_` prefixes on the names of exposed functions
- Make the global counters and per-object counters cache thread-safe by using locks
When building the stdlib for Windows x86_64, we would see the following error:
swift/stdlib/public/core/RuntimeFunctionCounters.swift:95:19: error: '(UnsafeRawPointer, Int64) -> Void' is not representable in Objective-C, so it cannot be used with '@convention(c)'
@convention(c) (_ object: UnsafeRawPointer, _ functionId: Int64) -> Void
^
This is caused by `Int64` not being mapped as on Windows x86_64, `CLong`
is mapped to `Int32` and `CLongLong` is mapped to `Int`. This causes
the `Int64` to fail to be reverse-mapped to a C type causing the FFI
construction failure.
It allows for collecting the state of runtime function counters, which are used to determine how many times a given runtime function was called.
It is possible to get the global counters, which represent the total number of invocations, or per-object counters, which represent the number of runtime functions calls for a specific object.