Commit Graph

33 Commits

Author SHA1 Message Date
Roman Levenstein
199e76d6d4 Fixes for a lookup of functions by name
Among other things it fixes a bug in the function signature optimization where it would use an already existing mangled name for a different function
2017-02-10 18:07:30 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Erik Eckstein
a01e9d4e41 Remove dead code in SIL linker
... which is not only dead but also broken.
NFC
2016-11-02 10:30:10 -07:00
Roman Levenstein
9234eb3ca7 [sil-linker] Improve the implementation of the hasSILFunction API
It it now possible to check if a function with a given name and a given linkage exists in one of the modules,
even if the current module contains a function with this name but a difference linkage.
This is useful e.g. for performing a lookup of pre-specializations.
2016-04-13 15:46:57 -07:00
Slava Pestov
116ac3d1f2 SIL Serialization: Serialize default witness tables
This will be used by SILGen to look up default witnesses for
requirements of protocols in other modules.
2016-03-17 10:39:34 -07:00
Roman Levenstein
94c3ae4c3c Add APIs to check if a function with a given name exists and to invalidate a SIL linker entry for a function.
These APIs are useful e.g. for quickly finding pre-specialisations by their names.
The existence check is very light-weight and does not try to deserialize bodies of SIL functions.
2016-02-26 22:10:59 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Roman Levenstein
f69c17568b Add the ability to lookup/link a SILFunction in the SILModule by its mangled name.
This feature is required for the implementation of pre-specialization, because one needs to check if a specialized SIL function with a given name exists in the standard library.

Swift SVN r30307
2015-07-17 06:52:04 +00:00
Luqman Aden
f7403e38c0 SILGen shouldn't know about ModuleFile, use FileUnit instead.
Swift SVN r26577
2015-03-26 03:33:41 +00:00
Luqman Aden
3f83973928 Handle multiple sib inputs.
Swift SVN r26572
2015-03-26 01:21:21 +00:00
Roman Levenstein
517992a51f [sil-linker] Use SILDeclRef instead of StringRef in SerializedSILLoader.
Addresses Michael's comments. And really uses the mangled name.

Swift SVN r26268
2015-03-18 17:45:06 +00:00
Roman Levenstein
1f875b9bcb Extend SILModule with an API for linking of SILFunctions by their SILDeclRef.
Before, providing a full SILFunction declaration object with a proper SILType was the only way to link a function. And constructing such a SILFunction declaration by hand using low-level SIL APIs is very annoying and requires a lot of code to be written. This new linkFunction API allows for a lookup using SILDeclRef and essentially performs linking of a SILFunction by its mangled name (assuming this name is unique), which is much easier to invoke. The new API is useful, e.g. when you need to link a well-known function from a standard library.

Swift SVN r26252
2015-03-18 06:11:22 +00:00
Luqman Aden
34b74cfa1c [driver] Add -emit-sib primary action.
Swift SVN r25783
2015-03-05 19:15:07 +00:00
Jordan Rose
dbd3b60f6b [Serialization] Move (Module)Status and validateSerializedAST into a namespace.
Also into a separate file.

Before (swift/Serialization/SerializedModuleLoader.h):
  ModuleStatus
  SerializedModuleLoader::ValidationInfo
  SerializedModuleLoader::ExtendedValidationInfo
  SerializedModuleLoader::isSerializedAST
  SerializedModuleLoader::validateSerializedAST

After (swift/Serialization/Validation.h):
  serialization::Status
  serialization::ValidationInfo
  serialization::ExtendedValidationInfo
  serialization::isSerializedAST
  serialization::validateSerializedAST

No functionality change, just a lot of renaming and a bit of reorganizing.

Swift SVN r25226
2015-02-12 05:32:25 +00:00
Erik Eckstein
daeed72153 Simplify and chose a better name for invalidating the Deserializer's function cache.
Swift SVN r22838
2014-10-20 12:51:56 +00:00
Jordan Rose
4eebcb9853 Change ASTContext's LoadedModules map to be keyed by Identifiers, not strings.
No intended functionality change, but there's no reason to be performing
string lookups here.

Swift SVN r20902
2014-08-01 18:03:47 +00:00
Manman Ren
b3e72be9d9 Remove unused deserialized SILFunctions.
The deserializer holds a reference to the deserialized SILFunction, which
prevents Dead Function Elimination from erasing them. 

We have a tradeoff on how often we should clean up the unused deserialized
SILFunctions. If we clean up at every optimization iteration, we may
end up deserializing the same SILFunction multiple times. For now, we clean
up only after we are done with the optimization iteration.

rdar://17046033


Swift SVN r18697
2014-06-04 00:30:34 +00:00
Manman Ren
8d7236f6a7 [SILSerializer] keep looking for a SILFunction when we find a declaration.
It is reasonable that one module has a declaration for a SILFunction while
another module has the definition. We return from lookupSILFunction when
we find a definition and keep looking when a declaration is found from
a module.
 
rdar://16815627


Swift SVN r17586
2014-05-06 23:47:20 +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
e3081a2027 [deserialization] Add debug logging to SerializedSILLoader so one can
easily tell the order that deserializers are being visited.

Swift SVN r15067
2014-03-14 20:27:20 +00:00
Dmitri Hrybenko
30ab76d3c3 Remove unused private member
Swift SVN r14207
2014-02-21 15:22:15 +00:00
Michael Gottesman
ec52d16f57 Teach SerializedSILLoader how to load all SILFunctions. Also add SerializedSILLoader::getAll().
getAll deserializes all SIL (except for globals). This enables us to iterate
over the SILModules once instead of once for first SILFunctions, then VTables,
then WitnessTables which is just inefficient.

Swift SVN r14176
2014-02-20 22:22:20 +00:00
Michael Gottesman
9311672c33 Move ModuleFile.h, ModuleFormat.h, and DeclTypeRecordNodes.def to include/swift/Serialization.
This allows for a secondary tool to access the deserialized Module inside the SerializedASTFile's ModuleFile.

Swift SVN r14173
2014-02-20 22:03:55 +00:00
Michael Gottesman
5fbb110de7 When ever we deserialize SIL, verify it.
Swift SVN r13292
2014-02-01 05:51:20 +00:00
Manman Ren
eaad8df51a SILSerializer: handle SILWitnessTable.
We add two records in sil_block to specify a witness table record and a method
entry record. Out of the four entry types, only "Method" is handled in this
commit.

Two records are also added to sil_index_block to search for a specific witness
table given a unique identifier. The interface lookupWitnessTable is not
implemented yet.

Right now, we serialize a witness table only when sil-serialize-all is on and
deserialize all witness tables in the module when sil-link-all is on.

rdar://15722175


Swift SVN r13000
2014-01-27 19:30:43 +00:00
John McCall
5da6defa1f Clean up the linkage model and the computation of linkage.
In general, this forces SILGen and IRGen code that's grabbing
a declaration to state whether it's doing so to define it.

Change SIL serialization to serialize the linkage of functions
and global variables, which means also serializing declarations.

Change the deserializer to use this stored linkage, even when
only deserializing a declaration, and to call a callback to
inform the client that it has deserialized a new entity.

Take advantage of that callback in the linking pass to alter
the deserialized linkage as appropriate for the fact that we
imported the declaration.  This computation should really take
advantage of the relationship between modules, but currently
it does not.

Swift SVN r12090
2014-01-09 08:58:07 +00:00
Jordan Rose
417b5d3982 Merge TranslationUnit into Module, and eliminate the term "translation unit".
This completes the FileUnit refactoring. A module consists of multiple
FileUnits, which provide decls from various file-like sources. I say
"file-like" because the Builtin module is implemented with a single
BuiltinUnit, and imported Clang modules are just a single FileUnit source
within a module.

Most modules, therefore, contain a single file unit; only the main module
will contain multiple source files (and eventually partial AST files).

The term "translation unit" has been scrubbed from the project. To refer
to the context of declarations outside of any other declarations, use
"top-level" or "module scope". To refer to a .swift file or its DeclContext,
use "source file". To refer to a single unit of compilation, use "module",
since the model is that an entire module will be compiled with a single
driver call. (It will still be possible to compile a single source file
through the direct-to-frontend interface, but only in the context of the
whole module.)

Swift SVN r10837
2013-12-05 01:51:15 +00:00
Jordan Rose
8b8cc8ee62 Turn SerializedModule into SerializedASTFile.
Part of the FileUnit restructuring. A serialized module is now represented as
a TranslationUnit containing a single SerializedASTFile.

As part of this change, the FileUnit interface has been made virtual, rather
than switching on the Kind in every accessor. We think the operations
performed on files are sufficiently high-level that this shouldn't affect us.

A nice side effect of all this is that we now properly model the visibility
of modules imported into source files. Previously, we would always consider
the top-level imports of all files within a target, whether re-exported or
not.

We may still end up wanting to distinguish properties of a complete Swift
module file from a partial AST file, but we can do that within
SerializedModuleLoader.

Swift SVN r10832
2013-12-05 01:51:09 +00:00
Manman Ren
b2bd2e9f8d SIL Serialization: handle SILVTable.
We add two records in sil_block to specify a Vtable and its entry list. Two
records are also added in sil_index_block for mapping from name to ID and
from ID to bit offset.

Two functions are added to SerializedSILLoader: to look up a specific VTable
given the class name or to deserialize all VTables in all SILModules. The latter
is mostly used for testing.

We serialize a VTable if the class is fragile and deserialize it via
SerializedSILLoader::lookupVTable.


Swift SVN r9746
2013-10-28 23:38:48 +00:00
Argyrios Kyrtzidis
963b6f0579 [serialization] Introduce 'FailedImportModule', which is used to track of when a module file failed to load (e.g. because of missing dependencies).
Swift SVN r8934
2013-10-04 21:29:24 +00:00
Manman Ren
b78939e748 SIL Serialization: handle partial_apply.
Add command line argument -sil-link-all and -sil-serialize-all for testing
purpose.

Do not create new SILFunction for de-serialized SIL, instead update the
existing declaration with the de-serialized SILFunction.

Add testing case to cover partial_apply.


Swift SVN r8410
2013-09-18 18:51:04 +00:00
Manman Ren
fa0acc9328 SIL Serialiation: add implementation to deserialize SIL and a wrapper class
SerializedSILLoader to hold a list of SIL deserializers.

Also add an intial implementation of a linking pass that is run right after
SILGen to link the declaration of SILFunction to the actual definition in
the serialized module.

We add two blocks to the serialized module: a sil index block that
maps identifier to a function ID and also holds a list of function offsets,
and a sil block for the actual SILFunctions. We can probably use subblock
instead of two top-level blocks.

The serialization/de-serialization of the function hash table and the function
offsets are implemented. But we are missing handling of types (see FIXME in
the code).

ModuleFile::Serialized is made public to be used by SIL deserializer, as well
as ModuleFile::getType.

The SIL deserializer holds a pointer to the ModuleFile, it gets the sil cursor
and the sil index cursor from the ModuleFile. The other option is for SIL
deserializer to find the start of the two sil blocks within itself, thus having
less coupling with ModuleFile.

No testing case yet because we are missing handling of types.


Swift SVN r8206
2013-09-13 17:44:41 +00:00