Commit Graph

29 Commits

Author SHA1 Message Date
Slava Pestov
bbbe307980 SIL: Introduce SILDefaultWitnessTable and start plumbing
This will be used to help IRGen record protocol requirements
with resilient default implementations in protocol metadata.

To enable testing before all the Sema support is in place, this
patch adds SIL parser, printer and verifier support for default
witness tables.

For now, SILGen emits empty default witness tables for protocol
declarations in resilient modules, and IRGen ignores them when
emitting protocol metadata.
2016-02-05 20:57:11 -08:00
Slava Pestov
b9951ade1b SIL: Rename some identifiers, NFC
"VTableLookupTable" just doesn't look right to me.
2016-02-04 17:34:55 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Nadav Rotem
07d4558c1c [Mangler] Change the Swift mangler into a symbol builder.
This commit changes the Swift mangler from a utility that writes tokens into a
stream into a name-builder that has two phases: "building a name", and "ready".
This clear separation is needed for the implementation of the compression layer.

Users of the mangler can continue to build the name using the mangleXXX methods,
but to access the results the users of the mangler need to call the finalize()
method. This method can write the result into a stream, like before, or return
an std::string.
2015-12-25 21:40:25 -08:00
Nadav Rotem
6fa6ca563e [Mangler] Rename some of the mangler methods. NFC. 2015-12-24 14:35:33 -08:00
Nadav Rotem
b5e4197d33 [Mangler] Fix all of the places where users of the Mangler access the underlying buffer.
This commit fixes all of the places where users of the Mangler write to the stream that's used by the Mangler. The plan is to make the Mangler buffered, and this means that users can't assume that the mangler immediately writes the mangled tokens to the output stream.
2015-12-22 22:47:35 -08:00
ken0nek
fcd8fcee91 Convert [Cc]an not -> [Cc]annot 2015-12-23 00:55:48 +09:00
practicalswift
cd7d8dfaff Fix alignment as requested by @gribozavr in #692 2015-12-21 08:54:24 +01:00
practicalswift
176f487d76 Fix incorrect filenames in headers. 2015-12-20 23:59:05 +01:00
Erik Eckstein
f40f3a93a0 New implementation of dead function elimination, which includes dead method elimination.
If vtable or witness methods are never called, e.g. because they are completely devirtualized,
then they are removed from the tables and eliminated.

Another improvement of the new algorithm is that it is able to eliminate dead function cycles
(e.g. A() calls B() and vice versa).



Swift SVN r22969
2014-10-27 16:41:02 +00:00
Erik Eckstein
60cb1a619a Support for eliminated witness methods in SILWitnessTable.
A method entry in SILWitnessTable can now be null.
This will be needed by dead method elimination.



Swift SVN r22914
2014-10-24 16:26:12 +00:00
Erik Eckstein
3eea8e3052 Set SILLinkage of witness tables according to the protocol visibility.
This is the same change as already done for functions and globals
(for details see <rdar://problem/18201785>).




Swift SVN r22907
2014-10-24 09:02:05 +00:00
Chris Lattner
50979a2ff4 implement SILGen and IRGen support for witness table generation of non-objc optional
protocol requirements.  Not testable because sema doesn't allow these to exist.


Swift SVN r21513
2014-08-28 04:20:02 +00:00
Michael Gottesman
4ca16e6e05 [deserialization] Put in assert in SILWitnessTable::create to make sure we don't ever get passed in a null conformance.
Swift SVN r17284
2014-05-02 22:35:34 +00:00
Michael Gottesman
a7bb61265c [deserialization] Tighten up deserialization of witness tables.
We now enforce via an assert that each witness table is unique and that
every protocol conformance that is referenceable from SIL must have a
witness table matched to it.

Also, I taught the linker that it should deserialize witness tables for
InitExistentialRefInst instructions, something that was missed before.

Swift SVN r17283
2014-05-02 22:28:13 +00:00
Doug Gregor
3d3ff6811a Add a pile of missing #includes exposed by pruning includes in top-of-tree LLVM.
Swift SVN r17157
2014-05-01 14:26:34 +00:00
John McCall
a7a4f67f1b Bump the reference count of a function as long as it's sitting
around in the deserializer's .
1,2d
1i
Bump the reference count of a SILFunction as long as it's sitting
around in the deserializer's cache.

If we deserialize a function, then delete it, then deserialize
another reference to it, we'll end up pointing to a deleted
function.  This was causing the bug where IRGen would assert
with "no order number for SIL function definition?"; I can't
seem to find a radar for that, though.

Also, deserialization test cases are hard to write and probably
inherently unstable.

Swift SVN r15908
2014-04-04 00:53:55 +00:00
Michael Gottesman
f4bb049bfc [deserialization] Enable lazy deserialization of witness tables.
This patch adds in the necessary infrastructure for lazily deserializing
witness tables. This is done by following the same approach as the
deserialization/serialization of SILFunction.

Now if one calls SILModule::lookUpWitnessTable and the given witness table is a
definition, the SILModule will attempt to deserialize it from one of the other
modules.

Swift SVN r15403
2014-03-24 09:16:09 +00:00
Michael Gottesman
59a44ca1f2 [deserialization] Add SILWitnessTable::convertToDefinition for converting SILWitnessTable declarations -> definitions.
This will be used for lazy deserialization of witness tables.

Swift SVN r15402
2014-03-24 05:07:21 +00:00
Michael Gottesman
f807249aa8 [deserialization] Store the mangled name of a SILWitnessTable on the instance itself.
The importance of this is that we will be able to use this name during
SIL serialization/deserialization to lookup partially deserialized
witness tables.

I left IRGen's original code alone until I can discuss with Joe/John
combining the logic together.

Swift SVN r15400
2014-03-24 05:07:20 +00:00
Michael Gottesman
69af5467ce Add a witness table to the witness table lookup cache when we create it, not lazily as we perform a search.
This means that every witness table in a SILModule must be in the
protocol conformance -> witness table map. We still return nullptr if
there is no such witness table.

Swift SVN r15399
2014-03-24 04:38:49 +00:00
Michael Gottesman
5b88963e78 [SIL] Implement external SIL Witness Table declarations.
This will help with ensuring that we do not create multiple witness
table "definitions" one of which is null. That situtation yields an
IRGen assertion to be hit since the external declaration (in the guise
of a definition) has a different type from the actual deserialized
definition.

Swift SVN r14999
2014-03-13 19:52:59 +00:00
Joe Groff
945fbaf167 SIL: Add a linkage specifier to SILWitnessTables.
In the short term, we need to be able to emit shared symbols for SILWitnessTables corresponding to Clang-imported modules, and soon, the generic specializer will need to be able to reference *_external witness tables deserialized from library modules.

Swift SVN r14887
2014-03-10 23:14:16 +00:00
Michael Gottesman
fafe76240e [external-witnesstables] Store the entries of a witness table in bump-ptr allocated memory referenced via an ArrayRef instead of a tail allocated array.
This will enable the creation of external witness tables whose entries
can be initialized after the witness table itself has been constructed.
This can occur if the table is deserialized later from a different
module.

Swift SVN r14715
2014-03-06 01:59:15 +00:00
Joe Groff
59d2a169f6 SIL: Rename 'archetype_method' to 'witness_method'.
It has been generalized to get a witness out of an arbitrary protocol conformance, not just for archetypes.

Swift SVN r14497
2014-02-28 05:09:11 +00:00
Argyrios Kyrtzidis
8960a7fff7 Fix a pontential buffer overflow when allocating a SILWitnessTable object.
Swift SVN r12719
2014-01-22 07:10:33 +00:00
Doug Gregor
bb833773f5 Add some newlines at the end of files
Swift SVN r11922
2014-01-06 16:34:12 +00:00
Joe Groff
c76548916e SIL: Have VTables and WitnessTables bump the reference counts of SILFunctions.
Fixes <rdar://problem/15725600>.

Swift SVN r11666
2013-12-27 05:59:19 +00:00
Joe Groff
2a7de8f495 Introduce a SILWitnessTable class.
We will generate these in SILGen when we see a NormalProtocolConformance, to provide a mapping of method requirements to witnesses for types.

Swift SVN r10900
2013-12-06 01:32:36 +00:00