Commit Graph

29 Commits

Author SHA1 Message Date
Erik Eckstein
c4a11f4c92 tests: remove the now unused option -new-mangling-for-tests 2017-03-22 11:28:43 -07:00
Erik Eckstein
977b5c05ad Mangling: add a verifier that checks if every mangled symbol can be demangled and remangled. 2017-03-20 16:12:23 -07:00
Erik Eckstein
d70bfc5de2 rename namespace NewMangling -> Mangle 2017-03-20 10:09:30 -07:00
Erik Eckstein
0f87b5efb2 Remove the useNewMangling function
NFC
2017-03-17 16:10:36 -07:00
Erik Eckstein
1625345b90 Remove the old mangler.
NFC
2017-03-17 16:10:36 -07:00
Erik Eckstein
5e80555c9b demangler: put the demangler into a separate library
Previously it was part of swiftBasic.

The demangler library does not depend on llvm (except some header-only utilities like StringRef). Putting it into its own library makes sure that no llvm stuff will be linked into clients which use the demangler library.

This change also contains other refactoring, like moving demangler code into different files. This makes it easier to remove the old demangler from the runtime library when we switch to the new symbol mangling.

Also in this commit: remove some unused API functions from the demangler Context.

fixes rdar://problem/30503344
2017-03-09 13:42:43 -08:00
Erik Eckstein
a04a29af4f mangling: efficient mangling of repeated substitutions
Instead of appending a character for each substitution, we now prefix the substitution with the repeat count, e.g.
AbbbbB -> A5B

The same is done for known-type substitutions, e.g.
SiSiSi -> S3i

This significantly shrinks mangled names which contain large lists of the same type, like
  func foo(_ x: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int))

rdar://problem/30707433
2017-03-05 17:41:43 -08:00
Erik Eckstein
dfcad1a2ca Mangler: print statistic about substitutions, which don’t fit into the a-z range. 2017-03-05 17:40:07 -08:00
Erik Eckstein
7d7dc5aaac Demangler: Use a bump-pointer allocator for node allocation.
This makes the demangler about 10 times faster.
It also changes the lifetimes of nodes. Previously nodes were reference-counted.
Now the returned demangle  node-tree is owned by the Demangler class and it’s lifetime ends with the lifetime of the Demangler.

Therefore the old (and already deprecated) global functions demangleSymbolAsNode and demangleTypeAsNode are no longer available.

Another change is that the demangling for reflection now only supports the new mangling (which should be no problem because
we are generating only new mangled names for reflection).
2017-02-24 19:04:13 -08:00
Erik Eckstein
8542e13bf7 Revert "Temporarily disable the re-mangling check."
rdar://problem/30592808 is fixed

This reverts commit 03a5c2449c.
2017-02-20 16:39:37 -08:00
Erik Eckstein
03a5c2449c Temporarily disable the re-mangling check.
Until rdar://problem/30592808 is fixed
2017-02-18 13:01:51 -08:00
Erik Eckstein
2d127e4192 Reinstate ”Use the new mangling for reflection."
It also uses the new mangling for type names in meta-data (except for top-level non-generic classes).
lldb has now support for new mangled metadata type names.

This reinstates commit 21ba292943.
2017-02-15 09:47:22 -08:00
Erik Eckstein
254f36aba5 Revert "Use the new mangling for reflection."
This needs some changes in lldb.
Disabled for now until lldb supports the new mangling.

This reverts commit 21ba292943.
2017-02-08 09:01:51 -08:00
Erik Eckstein
21ba292943 Use the new mangling for reflection.
For this we are linking the new re-mangler instead of the old one into the swift runtime library.
Also we are linking the new de-mangling into the swift runtime library.

It also switches to the new mangling for class names of generic swift classes in the metadata.
Note that for non-generic class we still have to use the old mangling, because the ObjC runtime in the OS depends on it (it de-mangles the class names).
But names of generic classes are not handled by the ObjC runtime anyway, so there should be no problem to change the mangling for those.
The reason for this change is that it avoids linking the old re-mangler into the runtime library.
2017-02-07 08:36:21 -08:00
Erik Eckstein
2ced2f2b49 Mangling: fix selectMangling for Release build
rdar://problem/30387928
2017-02-06 19:31:29 -08:00
swift-ci
9580f41a0e Merge pull request #7054 from JaSpa/fix-ndebug-linker-error 2017-01-26 11:34:31 -08:00
Erik Eckstein
39c21c92c8 Mangling: better check for the -new-mangling-for-tests option 2017-01-26 08:54:31 -08:00
Janek Spaderna
98f5eaddf6 [Mangling] Fix linker error in NDEBUG build 2017-01-26 11:57:22 +01:00
Erik Eckstein
4c7d68b590 Mangling: fix compile error in release build 2017-01-25 12:37:57 -08:00
Erik Eckstein
f15075f88b Mangling: fix the check if a new mangled name contains an old mangled function name.
This is used to decide whether a symbol should be tested for correct re-mangling.
2017-01-24 17:46:18 -08:00
Erik Eckstein
4d00ac1bba New mangling: add a -new-mangling-for-tests option.
This option enables the new mangling for everything except the Swift stdlib module.
Used to switch test files explicitly to the new mangling.
2017-01-24 15:27:45 -08:00
Erik Eckstein
a56a97c89f Mangling: prepare for using new mangling for USR and debug-info type generation.
Select between old and new mangling as we already do in other places in the compiler.
NFC as long as the new mangling is not enabled yet.
2017-01-23 17:49:00 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Erik Eckstein
947996ceaf Mangling: encode an optional unique ID in the function specialization mangling, instead of appending _unique_suffix 2016-12-20 13:47:48 -08:00
Erik Eckstein
268436aa9d Mangling: check if we can de-mangle everything we mangle
And don't compare old and new mangling trees if the old demangling didn't succeed
2016-12-20 13:47:48 -08:00
Erik Eckstein
ad1c079632 Mangling: support new mangling of partial apply forwarders in IRGen 2016-12-09 10:28:34 -08:00
Erik Eckstein
af24045941 Mangling: correct mangling of partial apply forwarders
Plus some refactoring in the demangler
2016-12-09 09:05:18 -08:00
practicalswift
cfdaf9f14a [gardening] Fix invalid Swift URLs. 2016-12-06 20:12:20 +01:00
Erik Eckstein
684092d7d1 Mangling: mangler, demangler and remangler classes for the new mangling scheme.
Following classes provide symbol mangling for specific purposes:
*) Mangler: the base mangler class, just providing some basic utilities
*) ASTMangler: for mangling AST declarations
*) SpecializationMangler: to be used in the optimizer for mangling specialized function names
*) IRGenMangler: mangling all kind of symbols in IRGen

All those classes are not used yet, so it’s basically a NFC.

Another change is that some demangler node types are added (either because they were missing or the new demangler needs them).
Those new nodes also need to be handled in the old demangler, but this should also be a NFC as those nodes are not created by the old demangler.

My plan is to keep the old and new mangling implementation in parallel for some time. After that we can remove the old mangler.
Currently the new implementation is scoped in the NewMangling namespace. This namespace should be renamed after the old mangler is removed.
2016-12-02 15:55:30 -08:00