Commit Graph

69 Commits

Author SHA1 Message Date
Joe Groff
fe7ecec60c Runtime: Provide value witness implementations for class existentials.
Same deal as for opaque existentials--pre-instantiate a static witness table for one-witness-table types (the zero-witness-tables case is nicely handled by Builtin.ObjCPointer's value witness), and generate a vwtable using dynamic witness implementations for each different-sized container on demand as necessary.

Swift SVN r9850
2013-10-31 18:38:54 +00:00
Joe Groff
c38ad6458e Runtime: Expose assignExistentialWithCopy entry points.
The assign-with-copy operation on existentials is complex enough to be emitted as a function call, which is currently generated on-demand by IRGen for every existential layout. We can instead use the implementation out of the runtime. Provide entry points for zero, one, and any number of witness tables.

Swift SVN r9815
2013-10-30 21:58:36 +00:00
Joe Groff
922358797d Runtime: Provide a specialization for zero-witness-table existential container layout.
So compilers don't complain about nonstandard use of zero-sized arrays.

Swift SVN r9797
2013-10-30 17:07:04 +00:00
Chris Lattner
cb6cf87f1e revert r9785, it isn't correct.
Swift SVN r9793
2013-10-30 16:02:55 +00:00
Chris Lattner
9ed8986d12 silence a warning:
Metadata.cpp:1280:26: warning: zero size arrays are an extension [-Wzero-length-array]
  const void *_witnesses[NUM_VALUE_WITNESSES];
                         ^~~~~~~~~~~~~~~~~~~
Metadata.cpp:1366:12: note: in instantiation of member class
      '<anonymous>::OpaqueExistentialValueWitnesses<0>::Container' requested here
  /*size*/ Container::size(),
           ^
Metadata.cpp:1448:51: note: in instantiation of static data member '<anonymous
      namespace>::OpaqueExistentialValueWitnesses<0>::ValueWitnessTable' requested here
      return &OpaqueExistentialValueWitnesses<0>::ValueWitnessTable;
                                                  ^
1 warning generated.

As an aside, putting a template argument in ALL_CAPS is kinda wierd.



Swift SVN r9787
2013-10-30 13:49:43 +00:00
Joe Groff
45d0ae05f8 Runtime: Add value witness forwarders to Metadata type.
Add member functions to Metadata that call into the value witness table and pass 'self' automatically.

Swift SVN r9758
2013-10-29 16:07:22 +00:00
Joe Groff
47a77e1c8c Runtime: Provide implementations of opaque existential witnesses.
Instantiate static value witness implementations for the common zero- and one-witness-table cases, which correspond to the "Any" type protocol<> and to single-protocol types. For protocol compositions, instantiate a value witness table that uses the layout information from existential metadata to perform the value witness operations.

Swift SVN r9752
2013-10-29 03:08:21 +00:00
Joe Groff
37e652b2ba Runtime: Add swift_getExistentialMetadata entry point.
Set up a metadata cache for existential type metadata. Instantiate existential metadata by first sorting the protocol list, so that it is order invariant, precomputing the overall witness table count and class constraint of the composition so it can be cached in the existential metadata.

We still need to implement value witnesses for existential containers in the runtime before this is complete. We can at least test the uniquing and flags computations at this point.

Swift SVN r9727
2013-10-28 20:53:20 +00:00
Joe Groff
b233f5fd2a runtime: Start class layout from superclass's size and alignment.
If we instantiate metadata for a generic class, start laying out its fields relative to its base class's fragile size and alignment.

Swift SVN r9300
2013-10-14 02:45:58 +00:00
Joe Groff
280fc60ce9 IRGen, runtime: Poke generic size and alignment into class metadata.
This should get us actually allocating and deallocating generic root class instances.

Swift SVN r9251
2013-10-12 03:34:27 +00:00
Joe Groff
43dd2f76d3 runtime: Add swift_initClassMetadata function.
Similar to swift_initStructMetadata, takes a vector of field type metadata and calculates the offsets of all of the fields.

Swift SVN r9237
2013-10-11 23:56:53 +00:00
Joe Groff
ef58b853f7 runtime: Add a swift_initStructMetadata entry point.
Does what it says on the tin: lays out the fields, storing their offsets into the metadata, and initializes the size, flags, and stride of the value witness table.

Swift SVN r9120
2013-10-10 00:55:51 +00:00
Joe Groff
e88786b32c runtime: Factor out basic layout from getTupleTypeMetadata.
We'll want to use the same logic to lay out generic struct fields at runtime. While we're here, fix a bug where we weren't aligning field offsets prior to storing them in the tuple metadata.

Swift SVN r9117
2013-10-10 00:42:04 +00:00
Greg Parker
ec31b01246 Remove incorrect optimization of dynamic casts of non-ObjC objects.
Swift SVN r8907
2013-10-04 04:17:26 +00:00
Joe Groff
e109124186 Replace 'union' keyword with 'enum'.
This only touches the compiler and tests. Doc updates to follow.

Swift SVN r8478
2013-09-20 01:33:14 +00:00
Joe Groff
33d2122ce9 IRGen/Runtime: Change generic metadata template to use a fill function.
Instead of hardcoding a walk of a list of fill ops, have generic metadata templates carry a pointer to a fill function for swift_getGenericMetadata to invoke to perform the fill operations. For types with dynamic layout, we will need to be able to perform more complex fill operations than a simple transfer of arguments into generic metadata slots.

Swift SVN r7893
2013-09-04 02:13:34 +00:00
Jordan Rose
674a03b085 Replace "oneof" with "union"...everywhere.
We haven't fully updated references to union cases, and enums still are not
their own thing yet, but "oneof" is gone. Long live "union"!

Swift SVN r6783
2013-07-31 21:33:33 +00:00
John McCall
7b86817b3c Basic value structure for [weak] and [unowned] references.
Add a bunch of new entrypoints and give them terrible
implementations.

Swift SVN r6322
2013-07-17 09:20:20 +00:00
Dmitri Hrybenko
ea43c46262 Splitting the standard library: move runtime -> stdlib/runtime
Swift SVN r5887
2013-06-28 22:41:38 +00:00