Commit Graph

1782 Commits

Author SHA1 Message Date
Mike Ash
49c3547449 Merge remote-tracking branch 'origin/master' into rename-conflicting-classes-and-methods 2018-09-21 15:52:38 -04:00
Saleem Abdulrasool
2d04b8491b stdlib: check for ARM/ARM64 more thoroughly (NFC)
Update the instances of checks for architectures to be more broad for different
spellings of the architecture macro.  Certain targets use `_M_ARM` and others
use `__arm__`.  Similarly, arm64/aarch64 has `_M_ARM64`, `__arm64__` and
`__aarch64__` as spellings.  This just mechanically goes through and encodes the
various spellings.

Take the opportunity to replace some raw checks with `defined` checks which
avoids a pedantic warning due to the undefined macro when performing the check
as the preprocessor may warn about an undefined condition evaluating to `0`.
2018-09-21 11:24:03 -07:00
Joe Groff
c87d2a8be2 Merge pull request #19340 from jckarter/generalize-tuple-extra-inhabitants
Generalize extra inhabitants of tuples.
2018-09-20 18:55:31 -07:00
Jordan Rose
6930a0f25a [runtime] Directly reference objc_setHook_getImageName (#19414)
(instead of using dlsym)

The original use went in before <objc/runtime.h> was updated, but now
it should be present in all Xcode 10 SDKs.

rdar://problem/42137765
2018-09-20 18:13:14 -07:00
Joe Groff
7f22a266b3 Merge pull request #19437 from jckarter/extra-inhabitant-warnings
Quell some warnings about casting in the runtime.
2018-09-20 18:03:45 -07:00
Joe Groff
06a1c388b3 Quell some warnings about casting. 2018-09-20 16:24:28 -07:00
Joe Groff
bbbf02e5f8 Merge pull request #19415 from jckarter/better-missing-metadata-warnings
Make runtime warnings about missing metadata more descriptive.
2018-09-20 15:40:17 -07:00
Joe Groff
93d85997e8 Generalize extra inhabitants of tuples.
Like we did for structs, make it so that tuple types can also get extra inhabitants from whichever element with the most, not only the first. This lets us move all of the extra inhabitant handling functionality between structs and tuples in IRGen up to the common RecordTypeInfo CRTP base.
2018-09-20 15:39:44 -07:00
Saleem Abdulrasool
687aeaa37d runtime: remove unnecessary preprocessor condition, flip cases (NFC)
The use of `__APPLE__` is unnecessary as the case is guarded by the
`SWIFT_DARWIN_ENABLE_STABLE_ABI_BIT` preprocessor guard which is implicitly
specific to that environment.  Additionally, flip the condition around so that
the positive (which is the future) appears ahead of the negative case.
2018-09-20 15:27:48 -07:00
Joe Groff
e9b45178a0 Make runtime warnings about missing metadata more descriptive.
Describe the consequences of missing metadata instead of just posting a scary
message about a bug.  Furthermore, since these warnings tend to show up in
playgrounds, and probably aren't relevant to the user of a playground, suppress
them when running in a playground. rdar://problem/44642942
2018-09-20 13:03:54 -07:00
Mike Ash
317451c8ee [Runtime][Stdlib][Overlays] Add comments to all the renamed classes explaining the rename and noting that the old name cannot be used due to conflicts.
rdar://problem/35768222
2018-09-20 12:07:30 -04:00
Mike Ash
9210830351 Merge pull request #19389 from mikeash/patch-bundleforclass
[Runtime][Foundation] Supplement the class_getImageName patch with a patch to +[NSBundle bundleForClass:] on older "embedded" targets
2018-09-20 09:08:24 -04:00
Doug Gregor
72ff34e937 Merge pull request #19410 from DougGregor/runtime-remove-duplicate-witnes-check
[Runtime] Remove duplicate witness checking for now.
2018-09-19 22:26:15 -07:00
Doug Gregor
cc32f50691 [Runtime] Remove duplicate witness checking for now.
It's breaking on SwiftPM, so remove it for now and follow-up to
investigate with rdar://problem/44627274.
2018-09-19 20:16:52 -07:00
swift-ci
922c4f0808 Merge pull request #19403 from DougGregor/runtime-remove-warning 2018-09-19 19:12:24 -07:00
Doug Gregor
93f9dc8e76 [Runtime] Remove warning about "missing" witness table entries.
It introduces spurious results.
2018-09-19 15:41:33 -07:00
swift-ci
e5c9d6417e Merge pull request #19398 from DougGregor/resilient-table-init-empty-proto 2018-09-19 15:18:04 -07:00
Doug Gregor
3ed69d4ee7 [Runtime] Instantiate witness tables even with no resilient witnesses.
The witness table for an empty, resilient protocol might need to be
instantiated, if a newer version of the protocol contains defaulted
associated type requirements. In such cases, we would either fail to
instantiate or assert in the runtime. Replace the assertion with a
proper check (to require instantiation in such cases) and cope with
filling in defaults even when the provided generic witness table has
no resilient witnesses.
2018-09-19 14:00:28 -07:00
Doug Gregor
32fd274f5e Merge pull request #19391 from DougGregor/assoc-conformance-default-witnesses
[ABI] Associated conformance defaults
2018-09-19 13:15:46 -07:00
Doug Gregor
ef0aeed788 [Runtime] Reimplement initialization of resilient witness tables.
Replace the quadratic algorithm (currently O(m*n) where m is the number of requirements and n is the number of witnesses) with an O(m+n) algorithm.
Harden the algorithm a against bad and unexpected inputs:
* Fail if the requirement descriptor is out-of-bounds for the protocol
* Skip the witness if the requirement descriptor is null; this can happen
when the witness table was compiled against a newer version of the
protocol, but is deployed to a library containing an older version of the
protocol. It is expected.
* In debug builds of the runtime, complain if an entry is initialized twice
* In debug builds of the runtime, complain if an entry is NULL

Fixes rdar://problem/44434793, which covers the second bullet (backward 
deployment).
2018-09-19 11:46:29 -07:00
Mike Ash
e704dd0353 [Runtime][Foundation] Supplement the class_getImageName patch with a patch to +[NSBundle bundleForClass:] on older "embedded" targets. The patch technique of editing the symbol table doesn't work for +bundleForClass:'s call to class_getImageName when +bundleForClass: is in an embedded shared cache.
rdar://problem/44489216
2018-09-19 13:29:10 -04:00
Doug Gregor
d076e41f32 [IRGen] Put associated conformance accessors in resilient witness table
For a resilient conformance, emit the associated conformance accessor
functions into the resilient witness table (keyed on the associated
conformance descriptor) rather than in the fixed part of the witness
table. This is another part of resilience for associated conformances,
and a step toward defaults for associated conformances.
2018-09-17 21:58:56 -07:00
Joe Groff
08419544e4 Fix linker error in debug builds. (#19355) 2018-09-17 16:41:36 -07:00
Joe Groff
fbd21e1bd4 Merge pull request #19296 from jckarter/opaque-existential-extra-inhabitants
Give opaque existential containers extra inhabitants.
2018-09-17 10:48:20 -07:00
Doug Gregor
78f3017436 Merge pull request #19266 from DougGregor/associated-type-resilience
Associated type resilience
2018-09-15 21:03:13 -07:00
Doug Gregor
350391db9d [ABI] Use associated type descriptors for generic parameter references.
Generic parameter references, which occur in generic requirement
metadata, were hardcoding associated type indices. Instead, use
relative references to associated type descriptors and perform the
index calculation at runtime.

Associated types can now be reordered resiliently (without relying on 
sorting), which is the first main step toward rdar://problem/44167982.
2018-09-14 20:59:03 -07:00
Doug Gregor
cab6bfa6af [ABI] Emit associated type witnesses resiliently.
Emit associated type witnesses into resilient conformance tables, so they
can be re-ordered within the protocol without breaking clients. This will
(eventually) permit adding new, defaulted associated types to protocols
resiliently.
2018-09-14 20:59:03 -07:00
Doug Gregor
50d12e05db [Runtime] Fix _ObjectiveCBridgeableWitnessTable::ObjectiveCType
The signature of this function pointer was incorrect, because it had not
yet been updated for the metadata request/response architecture. We
were getting lucky (!).
2018-09-14 20:59:03 -07:00
Joe Groff
b4abe8503a Give opaque existential containers extra inhabitants.
We can use the extra inhabitants of the type metadata field as extra inhabitants of the entire
existential container, allowing `Any?` and similar types to be the same size as non-optional
existentials.
2018-09-14 12:07:58 -07:00
Saleem Abdulrasool
1b47910cd9 stdlib: repair the Windows runtime build
Fix syntactic issues in the swift runtime build from the recent TLS changes.
Move the helper definitions into the TLS stubs rather than emitting them
everywhere.  This allows the runtime to build again on Windows.
2018-09-14 11:12:57 -07:00
Mike Ash
798edb9d0e [Runtime][Stdlib][Overlays] Rename various Objective-C classes and methods that would conflict when loading old Swift libraries into a process alongside ABI-stable libraries.
rdar://problem/35768222
2018-09-13 16:55:10 -04:00
Mike Ash
29ff3de4ab [Runtime][Stdlib] Use dedicated thread-local storage keys when possible.
rdar://problem/32275323 rdar://problem/44104305
2018-09-13 14:36:57 -04:00
Slava Pestov
ca58db21b4 Runtime: Introduce swift_lookUpClassMethod() 2018-09-07 21:50:58 -07:00
Mike Ash
0c2d874bf8 Merge pull request #18920 from mikeash/willthrow-error-register
[Runtime][ABI] Have swift_willThrow take the error value in the return register.
2018-09-06 18:00:43 -04:00
Saleem Abdulrasool
381195c68e Merge pull request #19122 from compnerd/inlined
runtime: make the weak definition also inline'd
2018-09-05 22:29:18 -07:00
Anton Pogonets
e33a977a19 Use uninitialized dealloc in swift_deallocError (#19059) 2018-09-05 13:16:53 -07:00
Saleem Abdulrasool
736fbabf92 runtime: move the definition of report_bad_alloc_err
Use the reserved spelling for the weak attribute.  Move the definition into an
implementation file to avoid multiple definitions of the function from being
emitted.  PE/COFF does not support weak symbols, however, the runtime will never
link against LLVMSupport, so provide a single, strong definition of the
function.  Mark it as hidden visibility so that we do not expose it outside of
the runtime.
2018-09-05 09:41:34 -07:00
Slava Pestov
b7449d5621 IRGen/Runtime: Method override descriptors 2018-09-04 14:46:34 -07:00
Slava Pestov
04143abaf1 Runtime: Refactor getVTableOffset() and getFieldOffsetVectorOffset()
Instead of taking class metadata as a parameter, we can recover
the immediate member offset from the descriptor itself.
2018-09-04 14:46:34 -07:00
Mike Ash
940c0fd1ba Merge branch 'master' into willthrow-error-register 2018-08-31 17:21:55 -04:00
Slava Pestov
fcbe997e72 IRGen/Runtime: Use method descriptors instead of dispatch thunks as keys in resilient witness tables 2018-08-31 00:16:22 -07:00
Mike Ash
1abf0d83c4 Merge branch 'master' into willthrow-error-register 2018-08-28 10:57:25 -04:00
John McCall
140ee562d3 Merge pull request #18840 from rjmccall/dematerializeForSet
Replace materializeForSet with the modify coroutine
2018-08-27 21:02:24 -04:00
eeckstein
649c326956 Merge pull request #18959 from eeckstein/remove-rt-pinning
Remove pinning in reference counting and pinning runtime entry points
2018-08-27 14:33:43 -07:00
Joe Groff
75d9e567dd Merge pull request #18630 from jckarter/extra-inhabitants-from-any-fixed-layout-struct-field
IRGen: Use any field of fixed-layout structs for extra inhabitants.
2018-08-27 09:46:42 -07:00
John McCall
b80618fc80 Replace materializeForSet with the modify coroutine.
Most of this patch is just removing special cases for materializeForSet
or other fairly mechanical replacements.  Unfortunately, the rest is
still a fairly big change, and not one that can be easily split apart
because of the quite reasonable reliance on metaprogramming throughout
the compiler.  And, of course, there are a bunch of test updates that
have to be sync'ed with the actual change to code-generation.

This is SR-7134.
2018-08-27 03:24:43 -04:00
Erik Eckstein
8f35a3eff7 runtime: remove pinning in reference counting and pinning runtime entry points
rdar://problem/35401813
2018-08-25 11:14:18 -07:00
Slava Pestov
8be09fef74 IRGen/Runtime: Rename "InPlaceMetadata" to "SingletonMetadata"
It's not actually "in-place" for resilient classes, which have a
pattern with an allocation function.
2018-08-24 00:52:36 -07:00
Slava Pestov
03cb6d1ff4 IRGen/Runtime: Use a true-const pattern to initialize non-generic resilient class metadata
Previously we would emit class metadata for classes with resilient
ancestry, and relocate it at runtime once the correct size was known.

However most of the fields were blank, so it makes more sense to
construct the metadata from scratch, and store the few bits that we
do need in a true-const pattern where we can use relative pointers.
2018-08-23 23:40:08 -07:00
Mike Ash
3e4a5a2d79 [Runtime][ABI] Have swift_willThrow take the error value in the return register.
rdar://problem/37578477
2018-08-22 15:04:49 -04:00