Commit Graph

1960 Commits

Author SHA1 Message Date
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
Greg Parker
0bae31c1f0 [runtime] Add some missing -isNSWhatever__ methods to SwiftObject. (#11891)
SR-5636, rdar://33764085
2017-09-13 03:01:37 -07:00
Arnold Schwaighofer
8a85a9efd5 Use array copy runtime implementation instead of the array value witnesses
And add builtins for the added runtime functions (assign-take, assign-copy).

rdar://27412867
SR-3376
2017-09-12 12:43:26 -07:00
Arnold Schwaighofer
0a97f6787b Merge pull request #11823 from aschwaighofer/array_witnesses_runtime_impl
Runtime implementation of array witnesses
2017-09-11 07:24:08 -07:00
Arnold Schwaighofer
1292d30099 Move local types into anonymous namespace 2017-09-09 08:12:38 -07:00
Glenna Buford
a452f9002a [SR-5814] removes dead code around REFLECT_OBJC_IVARS 2017-09-09 17:09:32 +02:00
Arnold Schwaighofer
aa12b26192 Runtime implementation of array witnesses
(using these to replace the current array witnesses is next)

rdar://27412867
SR-3376
2017-09-08 15:20:36 -07:00
Greg Parker
dd38ace506 [runtime] Fix more const cast warnings. (#11725)
* [runtime] Fix more const cast warnings.
2017-09-05 13:13:01 -07:00
Greg Parker
c262440e70 [runtime] Fix some const cast warnings. 2017-08-31 18:22:17 -07:00
Amr Aboelela
2447658199 In case of Android and the library is in /system/lib, or if the library doesn't end with .so, we will give warning only and return empty sectionInfo. 2017-08-30 10:27:15 -07:00
Kuba (Brecka) Mracek
d03a575279 Unify the capitalization across all user-visible error messages (#11599)
* Unify the capitalization across all user-visible error messages (fatal errors, assertion failures, precondition failures) produced by the runtime, standard library and the compiler.

* Update some more tests to the new expectations.
2017-08-29 12:16:04 -07:00
John McCall
936f8ddddb Use void* as the target pointer type for relative references to
opaque functions.
2017-08-25 20:02:57 -04:00
John McCall
9a228e96e1 Change the structure of emitted protocol and generic-wtable metadata:
- Always include an array of requirement descriptors in the protocol
  descriptor.  For now, this doesn't contain anything except a general
  requirement kind and an optional default implementation, but eventually
  this can be augmented with type / name metadata.  This array is always
  emitted as constant.

- Guarantee the value of the extent fields in a protocol descriptor and
  slightly tweak their meaning.

- Move the private-data field out of line in a generic witness table
  descriptor so that the main descriptor can be emitted as constant.

- Rely on IRGen's notion of the witness-table layout instead of assuming
  that SILWitnessTable and SILDefaultWitnessTable match the actual
  physical layout.

This version of the patch uses a hack in which we assign internal rather
than private linkage to certain symbols in order to work around a Darwin
linker bug.
2017-08-25 01:42:44 -04:00
Slava Pestov
d73712d79b IRGen/Runtime: Initialize generic and resilient class vtables from nominal type descriptor
Previous patches changed the runtime to copy the vtable from the
superclass rather than IRGen emitting it statically for generic
and resilient classes.

However for generic classes we would still copy the vtable entries
for methods defined in the immediate class from the template.

Instead, store them in the nominal type descriptor, where they use
less space since we can use relative pointers, and copy them out of
there.

This will allow us to 'slim down' generic class templates eventually.
2017-08-24 15:42:08 -07:00
Slava Pestov
ed8ced5665 IRGen/Runtime: Use relative pointers in default witness table entries
This to shrink the size of the protocol descriptor, removes a 32-bit
padding field, and reduces the number of relocations.
2017-08-24 04:31:24 -07:00
Greg Parker
f3bd55eb52 [runtime] Implement SwiftObject -methodForSelector: and +instanceMethodForSelector:.
Fixes SR-5577 and rdar://33606034.
2017-08-23 17:11:47 -07:00
Erik Eckstein
f4f1298286 runtime: add a runtime function to initialize the header of a statically allocated object 2017-08-23 09:15:01 -07:00
John McCall
bfd71a80e7 Prefer anonymous functions instead of member pointers here.
This is blocking proper const-correctness for value witness types.
2017-08-22 01:47:47 -04:00
John McCall
9f8093f376 Create a central x-macro database of value witnesses. NFC. 2017-08-21 20:17:02 -04:00
Slava Pestov
6f3160084f IRGen/Runtime: Dynamic vtable initialization for generic and resilient classes
Instead of emitting the vtable statically, copy it from the
superclass, and fill in method overrides, if any.

For now this is only done for classes initialized by
swift_initClassMetadata_UniversalStrategy(); I need to
add a new entry point for classes with static field
layout but a dynamic vtable.
2017-08-16 16:30:11 -04:00
Greg Parker
d5d5d8aa98 [stdlib] Don't call object_isClass(). (#11467)
object_isClass() is unavailable on Swift's oldest deployment targets.

rdar://33872748
2017-08-15 15:34:02 -07:00
Slava Pestov
9555a593ec IRGen: Refactor swift_initClassMetadata_UniversalStrategy() to use TypeLayout
Both swift_init{Struct,Class}Metadata_UniversalStrategy() wish to
avoid instantiating type metadata for field types if possible.

The struct version took an array of the more general TypeLayout objects,
whereas the class version was implemented earlier and took an array
of size/alignment pairs.

Since we can emit static TypeLayouts for all fixed-size types,
the class version can use the more general TypeLayout type also.
2017-08-09 01:07:09 -07:00
Arnold Schwaighofer
d8abd2fed9 runtime: Fix overflow of swift_unownedRetain reference counts
On 32bit platforms there are 7 bits reserved for the unowned retain count. This
makes overflow a likely scenario. Implement overflow into the side table.

rdar://33495003
2017-08-02 07:12:47 -07:00
Saleem Abdulrasool
21a27b05e6 stdlib: tweak printf specifier to be more portable
This just adjusts the printf specifier to use the standard defined
printf conversion specifier rather than assuming that %zd will convert
properly.  NFC.
2017-07-19 10:14:03 -07:00
Jordan Rose
1e38b4b624 Merge pull request #10893 from jrose-apple/are-you-having-issues
[stdlib] Surface NSKeyedArchiver issues in Xcode.
2017-07-13 12:53:01 -07:00
Jordan Rose
9c10398514 [runtime] Expose reportToDebugger as swift_reportToDebugger.
...so that the overlays can use it. See next commit.
2017-07-13 11:18:41 -07:00
Greg Parker
79e33808f1 Fix swift_getObjectType() of class objects. 2017-07-12 20:37:20 -07:00
Greg Parker
fb1b8c9d75 Simply no-ObjC-interop case. 2017-07-12 20:37:20 -07:00
Greg Parker
05de18dc0a [runtime] swift_getObjectType() must ignore KVO's artificial subclasses.
Fixes SR-4363.
2017-07-12 20:37:20 -07:00
swift-ci
846617fe3c Merge pull request #10907 from CodaFi/mangolia 2017-07-12 16:05:14 -07:00
Robert Widmann
dabe18d2f9 Merge pull request #9605 from tinysun212/pr-no-freelibrary
[stdlib] Fixed image inspection for Win32
2017-07-12 14:44:18 -07:00
Anna Zaks
36a07e9a6b Update swift_demangle and tests to use new symbol mangling. 2017-07-12 13:41:07 -07:00
giginet
74eca0dd2f Fix warning on Xcode 9 beta2 2017-07-10 14:28:21 -07:00
Andrew Trick
91405a7f91 Remove the hash function from the runtime's exclusive access checks.
I expect this to improve the following Onone benchmarks:
- 1.09x accessGlobal
- 1.08x accessInMatSet
- 1.06x accessIndependent

And the preexisting benchmarks:

| TEST                    | DELTA | SPEEDUP   |
|                         |       |           |
| Random                  | -7.9% | **1.09x** |
| MatMul                  | -7.6% | **1.08x** |
| XorShift                | -7.2% | **1.08x** |
| PolymorphicCalls        | -6.2% | **1.07x** |
| NopDeinit               | -6.1% | **1.06x** |
| Ary                     | -6.0% | **1.06x** |
| Integrate               | -5.8% | **1.06x** |
| StringWalk              | -5.5% | **1.06x** |
| ArrayInClass            | -5.2% | **1.06x** |
| MultiFileTogether       | -5.2% | **1.06x** |
| DictionaryHashableClass | -5.2% | **1.05x** |
| MultiFileSeparate       | -4.9% | **1.05x** |
2017-06-29 16:32:35 -07:00
Kuba (Brecka) Mracek
150696f8f6 On Linux, make swift_reportError always print backtraces (#10638)
On Linux, make swift_reportError always print backtraces.
2017-06-27 21:53:55 -07:00
Kuba (Brecka) Mracek
8cb95b8fcd Improve reporting of @objc inference issues from the Swift runtime (#10406)
* Extend Swift runtime issue reporting for @objc inference to include details about the declaration of the method (that is missing the @objc annotation) and a suggested fix-it. This changes the ABI of RuntimeErrorDetails, so we're also bumping the version.

* Update SwiftObject.mm
2017-06-22 21:35:48 -07:00
Kuba (Brecka) Mracek
d29557bd24 Change the signature of reportToDebugger and _swift_runtime_on_report to avoid using 'bool'. It's much easier to work with native-width integers only in LLDB. (#10523) 2017-06-22 21:22:27 -07:00
John McCall
842558058a Merge pull request #10452 from rjmccall/linked-lists-are-really-hard-okay
Fix a linked-list bug with the exclusivity runtime when accesses are not strictly nested
2017-06-22 00:10:26 -04:00
Kuba (Brecka) Mracek
dc3e6c1116 Prevent _swift_runtime_on_report from having its arguments optimized out. Turns out an empty "asm volatile" isn't enough and we need to explicitly ask that the arguments are also not optimized out. (#10456) 2017-06-21 16:54:54 -07:00
John McCall
4399bd37fa Fix some embarrassing list-management bugs with the exclusivity runtime
which can arise when accesses are not strictly nested.
2017-06-21 19:04:46 -04:00
Kuba (Brecka) Mracek
fec8d72ea3 Debugger hook/breakpoint for issue reporting from the Swift runtime (#10293)
* Implements a debugger hook (breakpoint) API and data structure. This structure is passed to the debugger and describes extra information about a fatal error or a non-fatal warning, which should be logged as a runtime issue.

This debugger hook is then used from two places, which currently only log to stderr:
- Runtime exclusivity violations.
- Swift 3 implicit Obj-C entrypoints.

A subsequent LLDB support will be able to catch these callbacks and show the runtime issues in a better way than just logging them to stderr.  When the debugger is not attached, this shouldn't have any effect.
2017-06-19 14:28:19 -07:00
Arnold Schwaighofer
62c1f215ce Fix layering violation I introduced by putting _EmptyBoxStorage into the stubs library (#10373)
* Fix layering violation I introduced by putting _EmptyBoxStorage into the stubs library

Should fix the linkage issue on linux
2017-06-19 10:59:05 -07:00
Arnold Schwaighofer
48e889b51b IRGen: EmptyBoxType's representation cannot be nil because of a conflict with extra inhabitant assumption in indirect enums (#10326)
* IRGen: EmptyBoxType's representation cannot be nil because of a conflict with extra inhabitant assumption in indirect enums

We map nil to the .None case of Optional. Instead use a singleton object.

SR-5148
rdar://32618580
2017-06-17 09:33:41 -07:00