Commit Graph

952 Commits

Author SHA1 Message Date
Anton
e39f82f969 [FreeBSD] Fix a crash of produced executable 2017-10-26 18:26:09 -07:00
Roman Levenstein
6d3fd90948 Merge pull request #12605 from swiftix/resilience-performance1
Address post-commit review comments on PR #11910
2017-10-25 01:27:26 -07:00
Arnold Schwaighofer
c53807714a Fix small_memcpy of three bytes 2017-10-24 15:57:20 -07:00
Roman Levenstein
68d7778add Address post-commit review comments on PR #11910
- 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
2017-10-24 15:49:37 -07:00
Arnold Schwaighofer
0d06bea602 Fix generic *EnumTagSinglePayload implementation 2017-10-24 13:45:27 -07:00
Greg Parker
58c9b45c78 [runtime] Clean up symbols in StdlibUnittest and the internal leak checker.
* Export fewer symbols.
* Prefix exported but not-public symbols with `_swift_`.
2017-10-24 13:13:43 -07:00
Greg Parker
ac6e0bd164 [runtime] Remove function pointer hooks from Error implementation. 2017-10-24 13:13:09 -07:00
Greg Parker
0fa818ed6b [runtime] Make ivars in the runtime's ObjC classes private. 2017-10-23 18:30:28 -07:00
Greg Parker
24be7ec680 Merge pull request #12515 from gparker42/GrP-PR-B214D8DD-7BCA-4F55-BB7E-3A86D30CA9BD
[runtime] Don't use C++ thread_local on two old Apple simulators.
2017-10-23 14:17:22 -07:00
Arnold Schwaighofer
43b9d13a2e Add value witnesses for single payload enums
So far single payload enums were implemented in terms of runtime functions which
internally emitted several calls to value witnesses.

This commit adds value witnesses to get and store the enum tag side stepping the
need for witness calls as this information is statically available in many cases

/// int (*getEnumTagSinglePayload)(const T* enum, UINT_TYPE emptyCases)
/// Given an instance of valid single payload enum with a payload of this
/// witness table's type (e.g Optional<ThisType>) , get the tag of the enum.

/// void (*storeEnumTagSinglePayload)(T* enum, INT_TYPE whichCase,
///                                   UINT_TYPE emptyCases)
/// Given uninitialized memory for an instance of a single payload enum with a
/// payload of this witness table's type (e.g Optional<ThisType>), store the
/// tag.

A simple 'for element in array' loop in generic code operating on a
ContigousArray of Int is ~25% faster on arm64.

rdar://31408033
2017-10-23 13:31:46 -07:00
Saleem Abdulrasool
f3680a2783 stdlib: re-add include paths for swift headers
This adds the swift include path manually to the builds for the stubs
and the runtime.  This has no impact for the build currently.  However,
adding the additional include directory will enable a standalone build
for the stdlib.
2017-10-22 21:01:28 -07:00
Greg Parker
1a0e3e7c31 [runtime] Don't use C++ thread_local on two old Apple simulators.
32-bit iOS 9 simulator and 32-bit watchOS 2 simulator do not support
C++ thread_local, even though clang's has_feature(cxx_thread_local)
thinks they do.

rdar://35063043
2017-10-19 16:55:19 -07:00
Pavel Yaskevich
0ccf4fabd7 Merge pull request #12320 from xedin/rdar-31408030
[IRGen/Runtime] Update Function Metadata
2017-10-12 17:45:09 -07:00
Pavel Yaskevich
c5cff769c7 [IRGen] Update Function Metadata to use AnyFunctionType::Param
This changes layout of the parameter metadata from single tuple record
(in case of materializable type) to N records each corresponding to
invididual function parameter, where functions with no parameters
`() -> Void` get 0 records allocated.
2017-10-12 15:58:19 -07:00
Saleem Abdulrasool
2f41cc216c Merge pull request #12012 from paulmenage/asan
[Metadata] Unpoison memory being returned from the metadata allocator
2017-10-12 14:27:30 -07:00
Jacopo Andrea Giola
bcb9571079 Add fix in Casting.cpp for SR-6032 (#12298)
Private classes doesn't add extra stuff when passed to String(describing:)
2017-10-09 14:06:34 -07:00
Saleem Abdulrasool
d7fc6a0359 stdlib: initialize va_list variables (NFC)
This silences `-Wuninitialized` warnings from clang when building the
swift stdlib for Windows ARM.  NFC.
2017-10-06 15:33:43 -07:00
Joe Groff
9e7b60326c Runtime: Remove API for getting generic metadata pattern from nominal type descriptors.
The NTD now references the metadata accessor function for the type, which is a better interface for most things one would want to do with type metadata from a nominal type. The only remaining use in the runtime self really has no requirement to do so. For now, don't disturb the binary layout to prevent breaking downstream clients.
2017-10-04 12:42:06 -07:00
Joe Groff
0f137aaae2 Runtime: Remove apparently-unused Metadata::getGenericPattern() method. 2017-10-04 11:47:27 -07:00
Saleem Abdulrasool
086c12114d IRGen: switch to absolute pointers for nominal type descriptors
Alter the value metadata layout to use an absolute pointer for the
nominal type descriptor rather than a relative offset relative to the
complete type metadata.  Although this is slightly less efficient in
terms of load times, this is more portable across different
environments.  For example, PE/COFF does not provide a cross-section
relative offset relocation.  Other platform ports are unable to provide
a 64-bit relative offset encoding.

Given that the value witness table reference in the value metadata is
currently an absolute pointer, this page is most likely going to be
dirtied by the loader.
2017-10-03 14:45:45 -07:00
Slava Pestov
3ab5b6fa19 IRGen/Runtime: Remove parent field from type metadata
We no longer need this for anything, so remove it from metadata
altogether. This simplifies logic for emitting type metadata and
makes type metadata smaller.

We still pass the parent metadata pointer to type constructors;
removing that is a separate change.
2017-09-25 15:45:17 -07:00
Slava Pestov
9bdb71b614 Runtime: Stop looking at parent type metadata in _buildDemanglingForNominalType()
Wean the routine that builds a mangling tree from metadata from
looking at the parent metadata pointer, instead using the nested
depth to partition the arguments into a list of arguments for
each nesting depth.
2017-09-25 15:45:16 -07:00
Saleem Abdulrasool
58e89b3fff Merge pull request #11998 from compnerd/qualifiers
runtime: clean up last of -Wqual-cast warnings
2017-09-23 10:09:37 -07:00
Calvin Hill
aee81d272f Add Initial platform support for Haiku. (#11583) 2017-09-22 21:06:56 -04:00
Saleem Abdulrasool
7bd2256120 runtime: clean up last of -Wqual-cast warnings
This fixes up the remaining cast qualifier warnings from GCC 6.  Use
multiple casts to adjust the const qualification.  Prefer C++ style
casts.  NFC.
2017-09-22 14:14:13 -07:00
Saleem Abdulrasool
fec7fe17dc runtime: fix the DLL storage attribute
Ensure that the proper DLL storage is annotated on the declaration.
This currently mismatched on Windows.  On non-COFF targets, we would
just honour the visibility as specified on the definition.
2017-09-22 13:07:28 -07:00
Paul Menage
0766f03182 [Metadata] Unpoison memory being returned from the metadata allocator
Call __asan_unpoison_memory_region() rather than __asan_poison_memory_region()
2017-09-19 16:46:49 -07:00
Arnold Schwaighofer
3ae6d7cb4d runtime/IRGen: return the argument from swift_retain family of functions
On architectures where the calling convention uses the same argument register as
return register this allows the argument register to be live through the calls.

We use LLVM's 'returned' attribute on the parameter to facilitate this.

We used to perform this optimization via an optimization pass. This was ripped
out some time ago around commit 955e4ed652.
By using LLVM's 'returned' attribute on swift_*retain, we get the same
optimization from the LLVM backend.
2017-09-19 07:16:37 -07:00
Saleem Abdulrasool
7ae7cc5b17 Merge pull request #11976 from compnerd/llp64
runtime: make LLP64 clean
2017-09-18 21:26:12 -07:00
Roman Levenstein
937352a03b Merge pull request #11910 from swiftix/resilience-performance1
Add experimental support for tracking the invocations of runtime functions
2017-09-18 16:23:00 -07:00
Saleem Abdulrasool
8bf538cab1 Merge pull request #11947 from compnerd/windows-demangling
runtime: add undecoration support for Windows
2017-09-18 14:50:33 -07:00
Roman Levenstein
acff3212b5 Add a comment explaining why the file needs to be compiled even in no-asserts builds 2017-09-18 13:18:27 -07:00
Roman Levenstein
51bb830763 #include should be on the next line after #define 2017-09-18 13:17:48 -07:00
Roman Levenstein
d8c5238449 Move FUNCTION_TO_TRACK definitions closer to the includes of "RuntimeInvocationsTracking.def" 2017-09-18 12:52:40 -07:00
Roman Levenstein
7aa8d6f2b6 Warn if FUNCTION_TO_TRACK is not defined 2017-09-18 12:51:30 -07:00
Roman Levenstein
460de35b82 Expose runtime APIs for runtime function counters in such a way that they can be used from C 2017-09-18 12:50:59 -07:00
Saleem Abdulrasool
635bb00d61 runtime: make LLP64 clean
This is a blanket pass replacing use of `__LP64__` with
`__POINTER_WIDTH__ == 64`.  The latter is more expressive and also LLP64
clean.  This change is needed to enable support for Windows x86_64 which
is a LLP64 environment.
2017-09-17 18:41:10 -07:00
swift-ci
f39d4319ee Merge pull request #11974 from compnerd/const-is-your-friend 2017-09-17 18:03:27 -07:00
Saleem Abdulrasool
ef70671f77 runtime: clean up some warnings
This is a smorgasbord of warning cleanups in the runtime.  This just
adjusts the casts for the various types.  There were a number of casts
which lost const qualifiers on the type.
2017-09-17 16:20:16 -07:00
Saleem Abdulrasool
13183f87b9 Merge pull request #11946 from compnerd/runtime-warnings
Runtime warnings
2017-09-17 14:58:27 -07:00
Saleem Abdulrasool
a22fc82535 runtime: clean up -Wformat warning
Add explicit casts to convert the `void *` to an integral value to
convert via printf.  NFC.
2017-09-15 17:52:37 -07:00
Saleem Abdulrasool
fb68207f0c runtime: add undecoration support for Windows
Use the Windows API `UnDecorateSymbolName` rather than `__cxa_demangle`
to undecorate the C++ symbols.  `__cxa_demangle` is only available in
the itanium ABI, not under MS ABI.  This allows us to properly
undecorate symbols on Windows.
2017-09-15 17:48:43 -07:00
Roman Levenstein
2012451eb1 Fix a macro-definition 2017-09-15 17:31:15 -07:00
Roman Levenstein
1996d5fb64 Address review comments. 2017-09-15 16:39:08 -07:00
Arnold Schwaighofer
90f51f2599 runtime: Also return the destination argument of the unknownWeak- and unknownUnownedInit/Assign functions
rdar://18172130
2017-09-15 11:28:27 -07:00
Saleem Abdulrasool
d0a6131b53 runtime: clean up -Wunused-function warning
This function is only used when backtracing is enabled.  Use a
preprocessor guard to avoid defining the function when not used.  This
prevents a -Wunused-function warning.  NFC.
2017-09-15 10:12:34 -07:00
Roman Levenstein
3392b765ea Provide runtime function counters for object allocation, deallocation and initialization of static or stack-promoted objects 2017-09-15 09:24:56 -07:00
Roman Levenstein
ec1e051a36 Add runtime library support for tracking the invocations of runtime functions. 2017-09-14 16:43:13 -07:00
Arnold Schwaighofer
efe22fc9e6 runtime: return the destination address in swift_weakInit/Assign/Copy/Take operations
rdar://18172130
2017-09-13 14:10:21 -07:00
Arnold Schwaighofer
5326fb73f7 Merge pull request #11877 from aschwaighofer/replace_array_witnesses
Use array copy runtime implementation instead of the array value witnesses
2017-09-13 07:54:13 -07:00