Commit Graph

37 Commits

Author SHA1 Message Date
Nate Chandler
525e25603f [IRGen] Pass argument/table to builders.
Previously, the various generic builders implemented the methods
addGenericArgument and addGenericWitnessTable without being provided
what argument or witness table they were to add (because it was not
previously needed).  Now, the GenericRequirement is passed along to both
methods.
2020-01-09 17:25:31 -08:00
technicated
b0e424f469 Added support for tuples with dynamic layout (ie generic tuples)
Extracted a base CRTP class MetadataVisitor from NominalMetadataVisitor
Added new tuple metadata visitors extending the new MetadataVisitor
2019-02-18 10:19:43 +01:00
Slava Pestov
1023f27d67 Revert "IRGen: Use an invariant load to load metadata base offset" 2018-12-03 20:49:54 -05:00
Slava Pestov
1649188d86 IRGen: Use an invariant load to load metadata base offset 2018-12-02 18:42:01 -05:00
Slava Pestov
ff09603f30 IRGen: @_fixed_layout classes still have resilient metadata 2018-11-29 23:20:02 -05:00
Slava Pestov
0eb762fec3 IRGen: Remove a few unused methods 2018-09-07 12:15:24 -07:00
Slava Pestov
41aebf8e5a IRGen: Simplify NominalMetadataVisitor's treatment of generic requirements
We don't need to substitute the superclass type as we walk up a
class hierarchy, or look up the generic parameters and conformances
to check if they're concrete, since we're always just emitting
null pointers in place of the generic parameters and requirements,
to be filled at runtime.

Also, don't leave space for generic parameters and requirements from
Objective-C superclasses, since that's not how they're represented.
2018-08-14 00:20:12 -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
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
Joe Groff
9c9fa8545a IRGen: Use base-relative offsets to identify methods in fragile subclasses of resilient bases in key paths.
The resilient methods will all be keyed by their dispatch thunks, so for methods of local subclasses, we can use the offsets relative to the dynamic base as identifiers without having to adjust for that dynamic base.
2018-07-27 13:15:49 -07:00
Slava Pestov
47267e45f2 IRGen: Tighten up assertions around foreign class metadata
ClassDecl::isForeign() is true for both CF types and runtime-only classes.
In some places, we do not expect to see the latter.
2018-04-10 17:25:45 -07:00
Pavel Yaskevich
78822bc23e [IRGen] Adjust element size of offset vector to 32-bit for structs
Type of elements contained by field offsets vector can be adjusted
to 32-bit integers (from being pointer sized) to safe space in the
binary since segment size is limited to 4 GB.

Resolves: rdar://problem/36560486
2018-04-03 13:32:06 -07:00
John McCall
aaa40ee82b Move metadata-accessing IRGen out of GenMeta. NFC.
Abstract type/heap metadata access goes into MetadataRequest.
Metadata access starting from a heap object goes into GenHeap.
Accessing various components of class metadata goes into GenClass
or MetadataLayout.
2018-03-18 23:53:11 -04:00
John McCall
dff0031b02 Apply generic metadata patterns to all types and change their layout.
The layout changes to become relative-address based.  For this to be
truly immutable (at least on Darwin), things like the RO data patterns
must be moved out of the pattern header.  Additionally, compress the
pattern header so that we do not include metadata about patterns that
are not needed for the type.

Value metadata patterns just include the metadata kind and VWT.

The design here is meant to accomodate non-default instantiation
patterns should that become an interesting thing to support in the
future, e.g. for v-table specialization.
2018-03-05 19:05:41 -05:00
John McCall
a7c5c80799 Compute class metadata bounds solely from class-descriptor chain information.
Change the "metadata base offset" variable into a "class metadata bounds"
variable that contains the base offset and the +/- bounds on the class.
Link this variable from the class descriptor when the class has a resilient
superclass; otherwise, store the +/- bounds there.  Use this variable to
compute the immediate-members offset for various runtime queries.  Teach the
runtime to fill it in lazily and remove the code to compute it from the
generated code for instantiation.  Identify generic arguments with the start
of the immediate class metadata members / end of the {struct,enum} metadata
header and remove the generic-arguments offset from generic type descriptors.
2018-03-04 02:14:32 -05:00
Slava Pestov
3269b9ad2a Merge pull request #13718 from slavapestov/class-resilience-part-12
Class resilience part 12
2018-01-04 11:57:39 -08:00
Doug Gregor
12a774abec [Runtime] Fill in the superclass of foreign class metadata.
When emitting foreign class metadata (e.g., for an imported CF type), fill
in the superclass when we have one. The superclass will itself be a foreign
metadata candidate, so also register an initialization function that uniques
the superclass metadata once we've picked the canonical foreign class
metadata.
2018-01-04 10:15:32 -08:00
Slava Pestov
93af58dead IRGen: Correctly calculate base offset variable for generic classes
If a generic class has non-resilient ancestry, we cannot use
the template size so far as the constant value of the base offset
variable, because the template will not contain entries for all
metadata members; instead, use metadata layout as with everything
else.
2018-01-03 22:11:41 -08:00
Slava Pestov
6af8d18a00 IRGen: Remove -enable-class-resilience staging flag 2018-01-03 00:26:10 -08:00
Slava Pestov
e3d6a2b9a2 IRGen: Correctly set class metadata base offset variable
We need to subtract the address point from the metadata size,
since the metadata size includes prefix matter.
2018-01-02 22:29:08 -08:00
Slava Pestov
0103cf6e75 IRGen: Use dynamic offsets in resilient class metadata 2017-12-25 00:00:44 -08:00
Slava Pestov
829be3d306 IRGen: When computing dynamic offsets, peephole away an add of zero 2017-12-24 20:39:11 -08:00
Slava Pestov
2df1b0a501 IRGen: Support dynamic offsets for various metadata fields
Not hooked up until some more MetadataLayout changes land.
2017-12-23 16:18:53 -08:00
Slava Pestov
dd7f09d8de IRGen: Change the meaning of a dynamic StoredOffset
Instead of storing an llvm::Constant, store an offset relative to
the class metadata base.
2017-12-23 16:18:52 -08:00
Slava Pestov
76499a3ce3 IRGen: Emit immediate class member offset global variable
Not used to access metadata members just yet.
2017-12-19 02:58:35 -07:00
Slava Pestov
354f4989e1 IRGen: Store type declaration in the NominalMetadataLayout 2017-12-19 00:36:47 -08:00
Slava Pestov
e65d3a7019 IRGen: Note metadata size offset in metadata layout 2017-12-19 00:36:47 -08:00
Slava Pestov
5dcc6b13ed IRGen: Count number of immediate class members in ClassMetadataLayout 2017-12-07 14:21:59 -08:00
Slava Pestov
c19478ab3f IRGen: Offset::offsetBy() should take an Offset and a Size 2017-12-07 14:21:58 -08: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
293f50251a IRGen: Another MetadataScanner => MetadataLayout refactoring 2017-08-15 01:32:12 -04:00
Slava Pestov
72c4974212 IRGen: Store start of vtable in MetadataLayout 2017-08-15 01:31:23 -04:00
Slava Pestov
aa20f404e9 IRGen: Remove MetadataSizer 2017-08-10 22:14:21 -07:00
Slava Pestov
9f6507cee8 IRGen: Use MetadataLayout in more places 2017-08-10 19:42:24 -07:00
Slava Pestov
ea5a99a3f7 IRGen: Record start of field offset vector in StructMetadataLayout 2017-08-09 01:07:08 -07:00
Slava Pestov
f7152c0979 IRGen: Tabs-to-spaces for MetadataLayout.cpp 2017-08-09 01:07:08 -07:00
John McCall
4e48bc0ff7 Cache type-metadata layouts instead of using scanners everywhere. NFC.
Also counts as incremental work towards metadata resilience.
2017-08-03 04:13:53 -04:00