Commit Graph

42 Commits

Author SHA1 Message Date
Erik Eckstein
fcd79c044d Mangling: consider bound generic types for substitutions
This shrinks the name length if the same bound generic type is used multiple times, like: func foo(_ x: [Int], _ y: [Int])
2017-03-05 17:40:07 -08:00
Erik Eckstein
5db45a474b demangler: A few more cosmetic performance improvements.
Avoid some string copies.
Although it has no significant measurable effect, it makes me feel better.
2017-03-05 15:57:33 -08:00
Erik Eckstein
f220a3b727 Demangler: further speed improvements.
Avoid using std::string and std::vector in the demangler. Instead use vectors/strings with storage allocated by the NodeFactory’s bump pointer allocator.
This brings another 35% speedup. Especially in the case the Demangle::Context is not reused for subsequent demanglings.
2017-03-03 14:44:21 -08:00
Erik Eckstein
a41312288d demangler: add an API function to get the target of a thunk symbol.
rdar://problem/30820093
2017-03-02 17:21:45 -08:00
Erik Eckstein
f8f172a46b demangler: also support the future mangling prefix ‘_S’ 2017-03-01 14:16:38 -08:00
Erik Eckstein
be986d753c demangler: add an API to check if a function has the swiftcc calling convention 2017-03-01 14:16:38 -08:00
Hugh Bellamy
edc3031a2e Merge branch 'master' into IndexType 2017-02-27 09:40:39 +07:00
Saleem Abdulrasool
44ffe01e4d Basic: use IndexType instead of unsigned
Explicitly specify the aliased type (IndexType) rather than the
underlying type (unsigned) when invoking `CreateNode` to disambiguate
overload when targeting Windows.  NFC.
2017-02-26 17:24:54 -08:00
Hugh Bellamy
7b092ae009 Fix Windows build with new demangling changes 2017-02-26 17:44:06 +07: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
a35cd0e36c Demangler: fix the function specialization de-mangling
The order in which the argument parameters were de-mangled was wrong.

rdar://problem/30592808
2017-02-20 16:39:37 -08:00
Erik Eckstein
2df8d5e8ad Let the demangler handle old-style mangled ObjC runtime type names.
This avoids linking the full old demangler into the swift runtime.
2017-02-16 18:20:05 -08:00
Erik Eckstein
86e7bdeed8 Demangler: Use a fixed-size array for Word substitutions.
There can be at most 26 word substitutions.
This avoids some memory allocations and is a work-around for the asan problem rdar://problem/30406870
2017-02-15 09:47:22 -08:00
Hugh Bellamy
f001b7562b Use relatively new LLVM_FALLLTHROUGH instead of our own SWIFT_FALLTHROUGH 2017-02-12 10:47:03 +07:00
Erik Eckstein
ebe19757e1 Demangler: add a new API for the demangler which enables bump-pointer allocation of demangling nodes.
Instead of a global demangleSymbolAsNode, which returns a reference-counted NodePointer, there is now a Context class which owns the nodes.
So now demangleSymbolAsNode is a member of Context and the returned NodePointer is alive as long as the Context is alive.

This is still a NFC: the new ABI still maps to the old functions.
The purpose of this change is to let lldb adapt to the new API and then we can switch to the new implementation.
2017-02-10 12:25:58 -08:00
Erik Eckstein
ee1aa04c11 Mangling: don’t use llvm_unreachable in Remangler because we don’t have this if the Remangler linked into the swift runtime library 2017-02-07 08:36:21 -08:00
Erik Eckstein
e6f2e7bc88 Mangling: add a few utility functions in the new mangler and demangler which will be used by reflection mangling 2017-02-07 08:36:21 -08:00
Erik Eckstein
8730f9d5fb Mangling: correct de-mangling of type aliases when used in debug type mangling 2017-01-23 17:49:00 -08:00
Hugh Bellamy
2445862e1b FIx recently introduced MSVC control path warnings 2017-01-14 12:40:41 +00:00
Slava Pestov
ee295ddbb8 AST: Nuke the unqualified archetype mangling 2017-01-12 23:20:35 -08:00
Roman Levenstein
8b6a0315a4 (De)Mangling of layout constraints and requirements. 2017-01-12 00:57:06 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Erik Eckstein
8cf641ce2b Mangling: fix crash when mangling an identifier which has a unicode char as first character and a digit as second char. 2017-01-04 16:20:09 -08:00
Joe Shajrawi
ee5ed7bdc6 [IRGen] Code Size Reduction: Outline Copy/Consume (Loadable) Enum 2016-12-22 17:08:15 -08:00
Erik Eckstein
a8eec59008 Mangling: demangling/remangling of property behavior conformances 2016-12-20 13:47:48 -08: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
3c207ae936 Mangling: fix de-mangling of ‘MC’ 2016-12-20 13:47:48 -08:00
practicalswift
853ace8b3d [gardening] Use correct end-of-namespace comments. 2016-12-17 22:33:09 +01:00
Erik Eckstein
eb9cadb501 Mangling: add a substitution for optional types (bound generic enum Swift.Optional) 2016-12-14 16:40:13 -08:00
Erik Eckstein
4a492fc5a7 Mangling: Change new mangling for bound generic types.
Putting the nominal type in the first place increases the changes for common prefixes (for the trie).
2016-12-14 16:39:00 -08:00
Erik Eckstein
62e32a1044 Mangling: support for mangling of partial specializations 2016-12-13 11:03:21 -08:00
Erik Eckstein
c285044706 Mangling: fix re-mangling of AssociatedTypeWitnessTableAccessor 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
Erik Eckstein
7cadbb29c1 Mangling: correct mangling/demangling/remangling of the error and unknown type 2016-12-09 09:05:18 -08:00
Erik Eckstein
d94dd580f6 Mangling: de- and re-mangling of GenericTypeParamDecl
This is also missing in the old mangling
2016-12-09 09:05:17 -08:00
Erik Eckstein
b0c95278e1 Mangling: introduce ‘D’ for mangled types for the debugger.
This is what ‘_Tt’ was in the old mangling.
Maybe we don’t need this eventually. But currently at least swift-ide-test relies on having a special mangling for such symbols
2016-12-09 09:05:16 -08:00
Joe Groff
7429ffb228 Mangle SILBoxTypes with their layout.
Use a new mangling scheme that describes the layout of compound boxes. For compatibility with reflection-based clients, continue to use the legacy mangling for single-field boxes when emitting reflection TypeRefs until we fully support reflection for the new box implementation.
2016-12-08 20:02:44 -08:00
Michael Gottesman
1af1cbfb76 [gardening] Add a bunch of end namespace comments found by clang-tidy. 2016-12-06 19:22:52 -08:00
practicalswift
cfdaf9f14a [gardening] Fix invalid Swift URLs. 2016-12-06 20:12:20 +01:00
Erik Eckstein
e7489462de Mangling: fix a problem with punycode encoded identifiers which begin with an underscore 2016-12-05 14:07:05 -08:00
Erik Eckstein
786bd67bd0 Mangling: fix new mangling and de-mangling of private operators 2016-12-05 12:34:25 -08: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