Commit Graph

1572 Commits

Author SHA1 Message Date
Slava Pestov
fe514e57b7 IRGen: Remove unused function 2018-09-10 21:54:30 -07:00
Arnold Schwaighofer
73df12c09f Remove dead constant_string_literal
constant_string_literal was added to support a one word representation
of String that never materialized.
2018-09-05 12:13:57 -07:00
Slava Pestov
49a8cd2300 IRGen: Move linkage computation to Linkage.cpp 2018-09-04 14:46:34 -07:00
Slava Pestov
101e55e03c IRGen: Constructor method descriptors for open classes inherit linkage from their class
Even if the constructor is internal or private, the method
descriptor can be referenced from another module if the
class is subclassed.
2018-09-04 14:46:34 -07: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
Slava Pestov
dd19b69bc4 IRGen: Factor out part of defineTypeMetadata()
When we define type metadata, the 'full' symbol points at the
entire struct, whereas the 'address point' symbol points at an
offset inside.

The logic for setting this up is a bit tricky because the
'address point' symbol may have been forward declared, and
has to be replaced.
2018-08-31 00:20:38 -06:00
Slava Pestov
dad44cdd4a IRGen: Introduce 'method descriptor' mangling 2018-08-31 00:20:38 -06: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
Slava Pestov
120be251db IRGen: Metadata patterns are always true-const
They were, already, but remove the isConstant parameter to
getAddrOfTypeMetadataPattern(), and just assert that its true for
patterns in defineTypeMetadata() instead.

Also, metadata patterns are i8*, not i8**. In fact they don't contain any
absolute pointers at all.

Should be NFC other than the LLVM type change.
2018-08-23 23:40:08 -07:00
Slava Pestov
d7a9a2a010 IRGen: Remove unused 'isIndirect' parameter to defineTypeMetadata() 2018-08-21 22:29:16 -07:00
Slava Pestov
6150e34508 Runtime/IRGen: Two-phase metadata initialization for resilient classes
Similar to the non-resilient case, except we also emit a 'relocation
function'. The class descriptor now contains this relocation function
if the class has resilient ancestry, and the relocation function
calls the runtime's swift_relocateClassMetadata() entry point.

The metadata completion function calls swift_initClassMetadata() and
does layout, just like the non-resilient case.

Fixes <rdar://problem/40810002>.
2018-08-20 16:26:47 -07:00
Slava Pestov
a86a71de1e Runtime/IRGen: Two-phase metadata initialization for non-resilient classes
Note that this patch also consolidates the recursive metadata tests
into one place while adding an execution test.
2018-08-20 16:23:07 -07:00
Slava Pestov
4069fa68db Sema: Lift restriction on @objc categories of concrete subclasses of generic classes
In-place initialization means the class has a symbol we can reference
from the category, so there's nothing to do on the IRGen side.

For JIT mode, we just need to realize the class metadata by calling an
accessor instead of directly referencing the symbol though.
2018-08-20 16:23:07 -07:00
Joe Groff
2166dfcfdd Merge pull request #18746 from jckarter/nominal-type-field-info-xref
IRGen/Runtime: Reference field descriptor directly from type context descriptors.
2018-08-20 13:32:39 -07:00
Jordan Rose
537954fb93 [AST] Rename several DeclContext methods to be clearer and shorter (#18798)
- getAsDeclOrDeclExtensionContext -> getAsDecl

This is basically the same as a dyn_cast, so it should use a 'getAs'
name like TypeBase does.

- getAsNominalTypeOrNominalTypeExtensionContext -> getSelfNominalTypeDecl
- getAsClassOrClassExtensionContext -> getSelfClassDecl
- getAsEnumOrEnumExtensionContext -> getSelfEnumDecl
- getAsStructOrStructExtensionContext -> getSelfStructDecl
- getAsProtocolOrProtocolExtensionContext -> getSelfProtocolDecl
- getAsTypeOrTypeExtensionContext -> getSelfTypeDecl (private)

These do /not/ return some form of 'this'; instead, they get the
extended types when 'this' is an extension. They started off life with
'is' names, which makes sense, but changed to this at some point.  The
names I went with match up with getSelfInterfaceType and
getSelfTypeInContext, even though strictly speaking they're closer to
what getDeclaredInterfaceType does. But it didn't seem right to claim
that an extension "declares" the ClassDecl here.

- getAsProtocolExtensionContext -> getExtendedProtocolDecl

Like the above, this didn't return the ExtensionDecl; it returned its
extended type.

This entire commit is a mechanical change: find-and-replace, followed
by manual reformatted but no code changes.
2018-08-17 14:05:24 -07:00
Joe Groff
2a8b7f76bf Runtime: Don't register fieldmd sections.
They're no longer necessary to track separately from types.
2018-08-15 16:20:53 -07:00
Joe Groff
6f45c2a36e IRGen/Runtime: Reference field descriptor directly from type context descriptors.
This saves us some expensive cross-referencing and caching in the runtime, and lets us reclaim the `isReflectable` bit from the context descriptor flags (since a null field descriptor is a suitable and more accurate indicator of whether a type is reflectable).
2018-08-15 14:19:53 -07:00
Jordan Rose
84f471b031 [IRGen] Handle ProtocolInfo for protocols whose members aren't used (#18692)
Certain uses of protocols only formally need the requirement
signature, not any of the method requirements. This results in IRGen
seeing a protocol where none of the members have been validated except
the associated types. Account for this by allowing ProtocolInfo to
only contain the layout for the base protocols and associated types,
if requested.

Note that this relies on the layout of a witness table always putting
the "requirement signature part" at the front, or at least at offsets
that aren't affected by function requirements.

rdar://problem/43260117
2018-08-14 11:10:02 -07:00
Slava Pestov
9f5505d95c IRGen: Don't make values constant in getAddrOfSimpleVariable()
We also use this for field offset globals, which are not always
constant. I think in practice everything was getting set
correctly, but it was hard to follow the logic.
2018-08-10 00:42:34 -07:00
swift-ci
71f0248b0a Merge remote-tracking branch 'origin/master' into master-next 2018-08-06 11:07:55 -07:00
Doug Gregor
bd5f5d80e4 [AST] Add ExtensionDecl::getExtendedNominal().
Introduce ExtensionDecl::getExtendedNominal() to provide the nominal
type declaration that the extension declaration extends. Move most
of the existing callers of the callers to getExtendedType() over to
getExtendedNominal(), because they don’t need the full type information.

ExtensionDecl::getExtendedNominal() is itself not very interesting yet,
because it depends on getExtendedType().
2018-08-03 11:26:48 -07:00
swift-ci
8feb9e0e81 Merge remote-tracking branch 'origin/master' into master-next 2018-08-03 10:49:49 -07:00
Doug Gregor
3c1f6f72c9 [IRGen] Only emit conformances local to a nominal type along with its metadata.
Rather than using getAllConformances() to emit all conformances for a
nominal type whenever we emit its type metadata, use
getLocalConformances() consistently--on the nominal type and on any
extension--to emit the conformances in the appropriate source files.
2018-08-03 09:23:26 -07:00
swift-ci
f7b8996498 Merge remote-tracking branch 'origin/master' into master-next 2018-07-30 20:59:23 -07:00
Slava Pestov
2d17ea34f4 IRGen: Move type layout verifier implementation to TypeLayoutVerifier.cpp 2018-07-30 18:37:09 -07:00
swift-ci
8247c2ba15 Merge remote-tracking branch 'origin/master' into master-next 2018-07-30 13:09:54 -07:00
Joe Groff
f8e5ebe873 Merge pull request #18299 from jckarter/enable-key-path-resilience
Enable key path resilience.
2018-07-30 13:00:43 -07:00
swift-ci
7f536bef9a Merge remote-tracking branch 'origin/master' into master-next 2018-07-29 10:49:08 -07:00
John McCall
db8f23df74 Update the ABI for uniquing foreign type metadata.
- `swift_getForeignTypeMetadata` is now a request/response function.

- The initialization function is now a completion function, and the
  pointer to it has moved into the type descriptor.

- The cache variable is no longer part of the ABI; it's an
  implementation detail of the access function.

- The two points above mean that there is no special header on foreign
  type metadata and therefore that they can be marked constant when
  there isn't something about them that needs to be initialized.

The only foreign-metadata initialization we actually do right now is
of the superclass field of a foreign class, and since that relationship
is a proper DAG, it's not actually possible to have recursive
initialization problems.  But this is the right long-term thing to do,
and it removes one of the last two clients of once-based initialization.
2018-07-29 03:16:35 -04:00
swift-ci
0d5cb630cc Merge remote-tracking branch 'origin/master' into master-next 2018-07-28 10:09:14 -07:00
John McCall
d10239313f Reference runtime-only ObjC classes with bare strings.
As part of this, rename TypeMetadataRecordKind to TypeReferenceKind
and consistently give it three bits of storage.

The better modelling of these type references appears to have been
sufficient to make dynamic conformance checks succeed, which is good
but unexpected.
2018-07-27 22:55:22 -04:00
Joe Groff
9cc6d94b49 Adjust TBDGen rules for property descriptors.
- Move the filter checks in SILGen for skipping emitting certain property descriptors into the AbstractStorageDecl::exportsPropertyDescriptor() predicate, to ensure that TBDGen and SILGen are in sync
- Fix the linkage of property descriptors to be based on the getter's linkage rather than the property's, since a property may be internal but have usableFromInline accessors
2018-07-27 13:11:31 -07:00
swift-ci
97d4d925fc Merge remote-tracking branch 'origin/master' into master-next 2018-07-25 14:09:23 -07:00
John McCall
dc052e6364 Resolve metadata cycles through non-generic value types with resilient layout.
The central thrust of this patch is to get these metadata initializations
off of `swift_once` and onto the metadata-request system where we can
properly detect and resolve dependencies.  We do this by first introducing
runtime support for resolving metadata requests for "in-place"
initializations (committed previously) and then teaching IRGen to actually
generate code to use them (this patch).

A non-trivial amount of this patch is just renaming and refactoring some of
existing infrastructure that was being used for in-place initializations to
try to avoid unnecessary confusion.

The remaining cases that are still using `swift_once` resolution of
metadata initialization are:

- non-generic classes that can't statically fill their superclass or
  have resilient internal layout

- foreign type metadata

Classes require more work because I'd like to switch at least the
resilient-superclass case over to using a pattern much more like what
we do with generic class instantiation.  That is, I'd like in-place
initialization to be reserved for classes that actually don't need
relocation.

Foreign metadata should also be updated to the request/dependency scheme
before we declare ABI stability.  I'm not sure why foreign metadata
would ever require a type to be resolved, but let's assume it's possible.

Fixes part of SR-7876.
2018-07-25 15:21:55 -04:00
swift-ci
f0fe310f44 Merge remote-tracking branch 'origin/master' into master-next 2018-07-24 19:29:28 -07:00
Doug Gregor
a2b2798de2 [ABI] Eliminate the now-unused protocol requirement array.
This is a holdover from the old protocol descriptor layout, which is no
longer useful.
2018-07-24 17:33:16 -07:00
Bob Wilson
b254041121 Merge remote-tracking branch 'origin/master' into master-next 2018-06-28 23:23:29 -07:00
Slava Pestov
fcfa1786c8 IRGen: Add another lldb resilience hack
When accessing global variables defined in the REPL, lldb does not consult
debug info, so it does not see that the DW_OP_deref was emitted.

So instead, set a special bit on globals defined in the REPL which bypasses
resilience for them altogether.

Part of the fix <rdar://problem/39722386>.
2018-06-28 16:56:55 -07:00
swift-ci
bea73f7bce Merge remote-tracking branch 'origin/master' into master-next 2018-06-26 17:29:54 -07:00
Arnold Schwaighofer
61c9276809 Fix compile error 2018-06-26 06:17:18 -07:00
Arnold Schwaighofer
d430bb0074 Sink the logic into getResilienceExpansionForLayout
This clearly satisfies the postcondition that 'Calling isResilient() with this scope will always return false.'
2018-06-25 19:25:10 -07:00
swift-ci
60a0e52c88 Merge remote-tracking branch 'origin/master' into master-next 2018-06-22 08:29:52 -07:00
Slava Pestov
cb013b5881 DebugInfo: Bypass resilience to calculate if a global is indirect or not
Progress on <rdar://problem/39722386>.
2018-06-22 01:15:11 -07:00
swift-ci
243d603ffe Merge remote-tracking branch 'origin/master' into master-next 2018-06-15 08:29:11 -07:00
Jordan Rose
7938272c42 [DebugInfo] Don't record that the standard library imports itself (#17226)
This causes problems for cross-compilation -parse-stdlib tests that
emit debug info. At the moment we have zero of those, but we're
trying to add one.

Also, don't try to load new modules when recording imports. (This
isn't harmful, just inefficient.)
2018-06-15 08:23:11 -07:00
swift-ci
72f5e8d124 Merge remote-tracking branch 'origin/master' into master-next 2018-06-13 10:49:12 -07:00
Joe Groff
14fd26a6ed IRGen: More specifically curtail JIT use of relative references to the integrated REPL.
The other JIT modes all still build an entire local context into one LLVM module, so it's safe to form relative references, and necessary for reflection to work with private and local contexts. Only the integrated REPL needs this prohibition. Fixes rdar://problem/40607819.
2018-06-12 14:11:36 -07:00
swift-ci
b87ea23124 Merge remote-tracking branch 'origin/master' into master-next 2018-06-06 17:29:44 -07:00
Erik Little
863f3a19ff Rename @effects to @_effects
@effects is too low a level, and not meant for general usage outside
the standard library. Therefore it deserves to be underscored like
other such attributes.
2018-06-06 12:53:03 -04:00