Commit Graph

1782 Commits

Author SHA1 Message Date
Mike Ash
cf3ee980a8 Merge pull request #14283 from mikeash/fix-urc-overflow-to-side-table-in-deinit
[Runtime] Fix unowned refcount overflow to side table during deinit.
2018-03-22 09:15:20 -07:00
Mike Ash
d024fd7487 [Runtime] Fill out a bunch more compatibility hooks.
rdar://problem/36997475
2018-03-22 09:14:55 -07:00
Mike Ash
f2b89d1b94 Merge branch 'master' into fix-urc-overflow-to-side-table-in-deinit 2018-03-21 15:32:01 -07:00
Mike Ash
6ed2628883 [Runtime] Clean up the compatibility hooking mechanism a bit. Add a hook to swift_conformsToProtocol.
rdar://problem/36997475
2018-03-21 14:16:41 -07:00
swift-ci
893d163241 Merge remote-tracking branch 'origin/master' into master-next 2018-03-21 10:29:45 -07:00
Mike Ash
9e8d4da76f [Runtime] Add a hooking mechanism to allow future apps to extend dynamic casting and type lookup. Make swift_dynamicCast and swift_getTypeByMangledName use these hooks.
rdar://problem/36997475
2018-03-20 16:33:37 -07:00
Arnold Schwaighofer
9d8c381ab4 Remove resilient tag indices 2018-03-20 13:19:56 -07:00
swift-ci
a948e52936 Merge remote-tracking branch 'origin/master' into master-next 2018-03-19 10:43:42 -07:00
John McCall
31f2eec044 Change type metadata accessors to support incomplete metadata.
This includes global generic and non-generic global access
functions, protocol associated type access functions,
swift_getGenericMetadata, and generic type completion functions.

The main part of this change is that the functions now need to take
a MetadataRequest and return a MetadataResponse, which is capable
of expressing that the request can fail.  The state of the returned
metadata is reported as an second, independent return value; this
allows the caller to easily check the possibility of failure without
having to mask it out from the returned metadata pointer, as well
as allowing it to be easily ignored.

Also, change metadata access functions to use swiftcc to ensure that
this return value is indeed returned in two separate registers.

Also, change protocol associated conformance access functions to use
swiftcc.  This isn't really related, but for some reason it snuck in.
Since it's clearly the right thing to do, and since I really didn't
want to retroactively tease that back out from all the rest of the
test changes, I've left it in.

Also, change generic metadata access functions to either pass all
the generic arguments directly or pass them all indirectly.  I don't
know how we ended up with the hybrid approach.  I needed to change all
the code-generation and calls here anyway in order to pass the request
parameter, and I figured I might as well change the ABI to something
sensible.
2018-03-18 21:38:08 -04:00
swift-ci
188ecdd102 Merge remote-tracking branch 'origin/master' into master-next 2018-03-17 10:49:11 -07:00
John McCall
1d4fc1933b Let the runtime copy generic arguments into place. 2018-03-17 11:40:31 -04:00
John McCall
aa0658decf Allow value witness tables to advertise themselves as incomplete
and use that when evaluating how complete an incomplete metadata is.
2018-03-17 11:40:30 -04:00
John McCall
3d5d643b9e Substantially simplify the synchronization scheme for metadata caches.
I was trying to make the entry-delegation thing do *way* too much.
Just give the entry access to the lock/queue and introduce subclasses
which simplify most of the work.

Also, fix some bad reasoning around the attempts to avoid acquiring
locks in the absence of waiters.  It really is always necessary to
acquire the lock when notifying; waiters cannot atomically set the
has-waiters flag and wait, so we have to protect against the
possibility that we notify before they can wait.
2018-03-17 11:40:30 -04:00
John McCall
3cf9a6f91a Add the caching machinery for arbitrary metadata dependencies.
We aren't taking advantage of this yet.
2018-03-17 11:40:30 -04:00
swift-ci
f168a79875 Merge remote-tracking branch 'origin/master' into master-next 2018-03-14 15:36:54 -07:00
Arnold Schwaighofer
0c11e1a0a3 Mark swift sections as swift4 for Swift 4.2
rdar://36363251
2018-03-14 10:27:28 -07:00
swift-ci
7eb158fadd Merge remote-tracking branch 'origin/master' into master-next 2018-03-12 09:49:23 -07:00
swift-ci
f764e685c2 Merge pull request #15177 from darquro/excise-iostream-from-metadata 2018-03-12 09:39:11 -07:00
swift-ci
43dfbf05b3 Merge remote-tracking branch 'origin/master' into master-next 2018-03-12 07:09:15 -07:00
Joe Groff
3fd2d2165e Merge pull request #15145 from jckarter/trimming-metadata
Trimming metadata
2018-03-12 06:55:59 -07:00
darquro
71e27406dd [stdlib] Excise #include <iostream> from Metadata.cpp. (SR-7164) 2018-03-12 20:29:27 +09:00
swift-ci
9fc03c25c4 Merge remote-tracking branch 'origin/master' into master-next 2018-03-10 10:28:59 -08:00
Michael Gottesman
763bbf971e Merge pull request #15114 from gottesmm/pr-ad4fc16a11b85ee79426be965870d165e866a298
[+0-all-args] Swift expects the returned object from bridgeErrorToNSE…
2018-03-10 10:19:25 -08:00
Joe Groff
98ee6a5d7d Runtime: Prefab metadata records for Any and AnyObject.
Metadata for these types gets demanded fairly frequently, and it's a decent code size savings not having to emit a runtime call to access them.
2018-03-10 10:15:42 -08:00
Joe Groff
57d6772d48 Runtime: Use type context descriptors to unique foreign metadata.
Now that every foreign type has a type context descriptor, we can use that for a uniquing key instead of a dedicated mangled string, saving some code size especially in code that makes heavy use of imported types. rdar://problem/37537241
2018-03-10 10:15:38 -08:00
swift-ci
81624e22a8 Merge remote-tracking branch 'origin/master' into master-next 2018-03-10 09:09:03 -08:00
Arnold Schwaighofer
f01d84c4b9 Merge pull request #15132 from aschwaighofer/fix_linux_link_issue_attempt
Speculative fix for linux bot linker failure
2018-03-10 09:03:57 -08:00
swift-ci
4a343a43c2 Merge remote-tracking branch 'origin/master' into master-next 2018-03-10 03:29:07 -08:00
swift-ci
ca3acfd2b7 Merge pull request #15039 from gottesmm/pr-8840a7d3dda61ba61ad551cc6cece87b78fece99 2018-03-10 03:26:46 -08:00
swift-ci
b7b59e03e9 Merge remote-tracking branch 'origin/master' into master-next 2018-03-10 03:08:59 -08:00
Joe Groff
0d7c42ce66 Runtime: Do the bare minimum balancing for bridge casting at +0.
The logic here is causing leaks in some situations, and it's likely we'll want
bridging calls to go back to +1 again anyway, so do the minimum adaptation to
the +0 convention for now.

rdar://34222540
2018-03-10 02:17:24 -08:00
Joe Groff
7f9e322d98 [+0-all-args] Knock out some inappropriate "unreachable"s in the runtime.
Future Swifts may add new metadata kinds, so it isn't appropriate to crash when
we see one. In the case of reflection, we can fall back to opaque behavior.

rdar://34222540
2018-03-09 22:44:04 -08:00
Arnold Schwaighofer
e106161d8f Speculative fix for linux bot linker failure 2018-03-09 17:55:39 -08:00
Michael Gottesman
bb8a273386 [+0-all-args] Swift expects the returned object from bridgeErrorToNSError to be at +1 even if the bridge is a no-op.
rdar://34222540
2018-03-09 10:53:08 -08:00
swift-ci
ecd7a48bb2 Merge remote-tracking branch 'origin/master' into master-next 2018-03-09 09:49:07 -08:00
John McCall
9313aa04a1 Merge pull request #15071 from rjmccall/metadata-cache-entries
Rewrite MetadataCache to be a more natural extension of ConcurrentMap
2018-03-09 12:44:37 -05:00
Arnold Schwaighofer
1e4f55de8d Merge pull request #15046 from aschwaighofer/without_actually_escaping_verification
Implement withoutActuallyEscaping verification
2018-03-09 09:34:06 -08:00
swift-ci
164b94971a Merge remote-tracking branch 'origin/master' into master-next 2018-03-08 14:09:07 -08:00
swift-ci
4cef8ae59d Merge pull request #15082 from DougGregor/runtime-conformance-null-descriptor 2018-03-08 14:03:20 -08:00
Doug Gregor
2dd61a948a [Runtime] Don't use NULL as a conformance cache key.
The runtime hash table for protocol conformances is keyed by (type, protocol),
where the type can be either a type metadata pointer or a type context
descriptor. The latter is preferred for generic and resilient types, because
a single entry in the cache can work for any instantiation.

However, not all type metadata has a corresponding type context descriptor.
For example, a class that is dynamically subclassed by the Objective-C
runtime won't have a type context descriptor. In such cases, our key
into the hash table was (NULL, protocol) leading to mistaken
conformances for different dynamically-subclassed types.

Introduce a NULL check for the type of the hash table key, which
illustrates the problem in a number of existing tests that exercise
the runtime, and teach the runtime to use the type context descriptor
as the key only when it's non-NULL, falling back to the type metadata
pointer otherwise.

Fixes rdar://problem/38053213.
2018-03-08 13:31:57 -08:00
John McCall
f304c321f3 Rewrite MetadataCache to be a more natural extension of ConcurrentMap.
Change generic witness table instantiation to use a more lightweight
entry scheme that allocates the witness table as part of the entry.

In contrast, change generic metadata instantiation to use a more
straightforward allocation scheme where the metadata is a totally
independent allocation.

This is preparation for proper cyclic-dependency handling.
2018-03-08 02:29:20 -05:00
swift-ci
97b732d8cc Merge remote-tracking branch 'origin/master' into master-next 2018-03-07 18:29:16 -08:00
Huon Wilson
e307e54098 [AST] Explicitly track things marked __owned. 2018-03-08 12:36:24 +11:00
Arnold Schwaighofer
b9602754cd Untangle the dependency on swiftStdlibStubs from swiftRuntime that I introduced
rdar://35525730
2018-03-07 11:17:19 -08:00
Arnold Schwaighofer
89e972f5a8 SILGen: Implement withoutActuallyEscaping verification
Check that an ``withoutActuallyEscaping(noescape_closure) { // scope}`` closure
has not escaped in the scope using the ``is_escaping_closure %closure``
instruction.

rdar://35525730
2018-03-07 09:00:12 -08:00
Arnold Schwaighofer
5940796cc1 SIL: Add an is_escaping_closure instruction
Will be used to verify that withoutActuallyEscaping's block does not
escape the closure.

``%escaping = is_escaping_closure %closure`` tests the reference count. If the
closure is not uniquely referenced it prints out and error message and
returns true. Otherwise, it returns false. The returned result can be
used with a ``cond_fail %escaping`` instruction to abort the program.

rdar://35525730
2018-03-07 08:56:00 -08:00
swift-ci
d92f84478b Merge remote-tracking branch 'origin/master' into master-next 2018-03-07 00:29:23 -08:00
John McCall
9c8bdf24a7 Fill in the field-offset vector and payload size for fixed-layout value metadata.
This regression wasn't caught by normal testing because the emission
pattern substantially changed anyway, breaking tests that were looking for
the field-offset vector, and because normal execution testing doesn't
actually use the field-offset vector and enum payload size fields.
Reflection, which does use these fields, was skating by for common types
because metadata is typically allocated out of freshly zeroed pages and
most such types have only one field.

Also, don't emit a completion function for value metadata with fixed layout.

We really shouldn't have to emit field-offset vectors for fixed-layout types;
the layout should just go in the type descriptor.  But for now, this is what
we have to do.
2018-03-07 01:18:44 -05:00
swift-ci
632dce19ce Merge remote-tracking branch 'origin/master' into master-next 2018-03-06 02:49:18 -08:00
swift-ci
9bd1ac9b60 Merge pull request #15016 from rjmccall/split-metadata-instantiation 2018-03-06 02:38:02 -08:00