Commit Graph

86 Commits

Author SHA1 Message Date
Slava Pestov
26be491a3d Basic: Fix a warning 2017-03-17 15:01:25 -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
437d4da38d Demangling: Remove StringRef-versions of demangling functions from demangle_wrappers because they are now available in Demangle itself.
This is just refactoring. NFC.
2017-02-24 15:19:18 -08:00
Hugh Bellamy
b564a917be Port swiftSyntax to Windows 2017-02-21 08:24:56 +07:00
Hugh Bellamy
d4cebb5947 Don't use a uint8_t random distruction in DiverseStack unit tests 2017-02-18 16:18:10 +07:00
Michael Gottesman
de47e4fe3a [diverse-stack] Add some more helper methods to diverse stack and unittests for that functionality.
rdar://29791263
2017-02-14 11:14:16 -08:00
practicalswift
3e40296cfa [gardening] Fix inconsistent headers 2017-02-13 15:21:52 +01:00
Michael Gottesman
3c58e42983 Add unittests for DiverseStack. 2017-02-09 22:30:44 -08:00
Michael Gottesman
6d1058cf0b [gardening] Quiet verbose output from BlotMapVectorTest unless it is requested via llvm debug. 2017-02-09 22:23:22 -08:00
Michael Gottesman
e678f4979b [gardening] Add swift license headers to all files in ./unittests/Basic/*. 2017-02-09 22:02:42 -08:00
Michael Gottesman
942f7eb5e2 [gardening] Sort unittest names in ./unittests/Basic/CMakeLists.txt. 2017-02-09 21:55:29 -08:00
Michael Gottesman
af61ed85a4 [gardening] Standardize ./unittests/Basic so that all tests have the Test.cpp suffix. 2017-02-09 21:50:57 -08:00
Michael Gottesman
79c4034bb1 [gardening] Split ADTTests.cpp into separate test files. 2017-02-09 21:48:30 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Michael Gottesman
b95a34a797 Add a new utility called reverse_range(start, end) that returns a reverse range from (start, end]. 2017-01-03 17:01:20 -08:00
practicalswift
a8df7410cb [gardening] Use the correct Swift URL 2016-12-20 10:06:28 +01:00
Michael Gottesman
6f3c1ee658 Add a new ArrayRefView like structure called TransformArrayRef.
The difference is that TransformArrayRef stores its function as an std::function
instead of using a template parameter. This is useful in situations where one
wants to define such a type in a header on forward declared pointers. If one had
to define the function to be used as a template parameter, one would have to
define the function or provide a forward declared version
2016-12-18 01:11:14 -08:00
practicalswift
38be6125e5 [gardening] C++ gardening: Terminate namespaces, fix argument names, ...
Changes:
* Terminate all namespaces with the correct closing comment.
* Make sure argument names in comments match the corresponding parameter name.
* Remove redundant get() calls on smart pointers.
* Prefer using "override" or "final" instead of "virtual". Remove "virtual" where appropriate.
2016-12-17 00:32:42 +01:00
Michael Gottesman
35edd1364a [gardening] Remove unneeded implementations of none_of/count_if/count.
These are now provided upstream by LLVM.
2016-12-04 03:50:00 -08: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
Bob Wilson
fa85278ea9 Fix more ArrayRef problems in ImmutablePointerSetTests unit tests.
These are more instances of the problem with ArrayRef capturing a
reference to a temporary. The problem is exposed when compiling with a
recent version of clang. rdar://problem/28700044
2016-10-10 22:38:46 -07:00
Ben Langmuir
350441d1e3 Fix ThreadSafeRefCountedBase*::Release()
C++ atomic's fetch_sub returns the previous value, where we want to
check the new value. This was causing massive memory leaks in SourceKit.

For ThreadSafeRefCountedBase, just switch to the one in LLVM that's
already correct.  We should move the VPTR one to LLVM as well and then
we can get rid of this header.

rdar://problem/27358273
2016-07-21 16:25:44 -07:00
Doug Gregor
5bea187b0f [Omit needless words] Fix lowercasing of initialisms with two-letter initial words.
Fixes rdar://problem/26643039.
2016-06-13 18:15:43 -07:00
practicalswift
db452dcbe9 [gardening] "[ a, b ]" → "[a, b]" 2016-04-17 21:26:08 +02:00
practicalswift
c760f6dfbf [gardening] Add whitespace: "foo,bar" → "foo, bar" 2016-04-12 22:31:46 +02:00
Brian Gesiak
6c4ba79f33 [unittests] Include header for llvm::outs()
`unittests/Basic/BlotMapVectorTest.cpp` references `llvm::outs()`, which is defined in `llvm/Support/raw_ostream.h`. I believe this currently works without the import because it is transitively included via some CMake incantations and conditionals in the googletest headers invovling `GTEST_NO_LLVM_RAW_OSTREAM`. I'm not sure.

In any case, including the header is more explicit. The file uses `llvm::outs()`, so it should include the header that defines it.
2016-03-23 01:48:51 -04:00
Michael Gottesman
bb15808554 Convert some trivial std::count_if invocations on ranges to use the provided range adaptor. 2016-03-08 14:58:13 -08:00
Michael Gottesman
0612d886e9 Add a "hasEmptyIntersection" method to ImmutablePointerSet.
We do this by doing a traversal of our sorted lists in a similar manner as one
would when one is merging two such sets, i.e. one has two iterators and always
advances the iterator that has a value that is less than the other. If we ever
hit a situation where the two iterators equal, we must have a non-empty
intersection.

A unittest that exercises very basic functionality is provided as well.
2016-03-08 14:05:10 -08:00
practicalswift
f6d6585ee0 [Python] Improve Python consistency: Use function_name(…) throughout (PEP8) 2016-02-29 22:49:19 +01:00
practicalswift
34188788a1 [gardening] Sort file listings in CMakeLists.txt files 2016-02-27 19:50:30 +01:00
Michael Gottesman
90dcaa7de3 Rename ImmutablePointerSet::concat => ImmutablePointerSet::merge. 2016-02-16 02:13:56 -08:00
Michael Gottesman
6434e5b032 Some small fixes suggested by Jordan to ImmutablePointerSet.
The larger changes are coming in a subsequent commit.
2016-02-16 02:13:55 -08:00
Michael Gottesman
0936d3d4b8 [arc] Add a new data structure called ImmutablePointerSet.
This is an immutable data structure with the following properties:

1. All of the sets are sorted and can be iterated over.
2. It takes in a bump ptr allocator and uses that allocator for all
allocations.
3. All concatenation operations involve only one bump ptr allocation.
4. Since we are only storing pointers, the data structure does not need any
destructors to be invoked to be cleaned up. The bumpptrallocator memory just
needs to be freed.

I am going to use this to improve the compile time performance of ARC.
2016-02-14 15:26:59 -08:00
Doug Gregor
8a3a2958e7 [Omit needless words] Improve our handling of plural acronyms. 2016-02-08 22:41:16 -08:00
Nadav Rotem
193a285453 [Compression] Remove the compression prototype. 2016-01-20 17:08:41 -08:00
practicalswift
21c3d93bea Remove unused imports. 2016-01-09 01:39:22 +01:00
Michael Gottesman
3e002b7649 Use IsTriviallyCopyable instead of std::is_trivially_copyable to work around issues on Linux. 2016-01-07 13:16:59 -08:00
Michael Gottesman
328c146569 [ptrintenum] Cleanup equality method. 2016-01-07 13:14:21 -08:00
Michael Gottesman
1c5ffe6dea Change PointerIntEnum to a new better representation.
The big differences here are that:

1. We no longer use the 4096 trick.

2. Now we store all indices inline so no mallocing is required and the
value is trivially copyable. We allow for much larger indices to be
stored inline which makes having an unrepresentable index a much smaller
issue. For instance on a 32 bit platform, in NewProjection, we are able
to represent an index of up to (1 << 26) - 1, which should be more than
enough to handle any interesting case.

3. We can now have up to 7 ptr cases and many more index cases (with each extra
bit needed to represent the index cases lowering the representable range of
indices).

The whole data structure is much simpler and easier to understand as a
bonus. A high level description of the ADT is as follows:

1. A PointerIntEnum for which bits [0, (num_tagged_bits(T*)-1)] are not all
set to 1 represent an enum with a pointer case. This means that one can have
at most ((1 << num_tagged_bits(T*)) - 2) enum cases associated with
pointers.

2. A PointerIntEnum for which bits [0, (num_tagged_bits(T*)-1)] are all set
is either an invalid PointerIntEnum or an index.

3. A PointerIntEnum with all bits set is an invalid PointerIntEnum.

4. A PointerIntEnum for which bits [0, (num_tagged_bits(T*)-1)] are all set
but for which the upper bits are not all set is an index enum. The case bits
for the index PointerIntEnum are stored in bits [num_tagged_bits(T*),
num_tagged_bits(T*) + num_index_case_bits]. Then the actual index is stored
in the remaining top bits. For the case in which this is used in swift
currently, we use 3 index bits meaning that on a 32 bit system we have 26
bits for representing indices meaning we can represent indices up to
67_108_862. Any index larger than that will result in an invalid
PointerIntEnum. On 64 bit we have many more bits than that.

By using this representation, we can make PointerIntEnum a true value type
that is trivially constructable and destructable without needing to malloc
memory.

In order for all of this to work, the user of this needs to construct an
enum with the appropriate case structure that allows the data structure to
determine what cases are pointer and which are indices. For instance the one
used by Projection in swift is:

   enum class NewProjectionKind : unsigned {
     // PointerProjectionKinds
     Upcast = 0,
     RefCast = 1,
     BitwiseCast = 2,
     FirstPointerKind = Upcast,
     LastPointerKind = BitwiseCast,

     // This needs to be set to ((1 << num_tagged_bits(T*)) - 1). It
     // represents the first NonPointerKind.
     FirstIndexKind = 7,

     // Index Projection Kinds
     Struct = PointerIntEnumIndexKindValue<0, EnumTy>::value,
     Tuple = PointerIntEnumIndexKindValue<1, EnumTy>::value,
     Index = PointerIntEnumIndexKindValue<2, EnumTy>::value,
     Class = PointerIntEnumIndexKindValue<3, EnumTy>::value,
     Enum = PointerIntEnumIndexKindValue<4, EnumTy>::value,
     LastIndexKind = Enum,
   };
2016-01-06 18:20:26 -08:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
Chris Lattner
a30ae2bf55 Merge pull request #836 from zachpanz88/new-year
Update copyright date
2015-12-31 19:36:14 -08:00
Nadav Rotem
e5ed7689c6 [Mangler] Add "$" (dollar sign) to the list of legal encoding characters. 2015-12-31 17:18:55 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Nadav Rotem
2d6f3c3ed5 Reapply "[Mangler] Add unit tests to the compression routines.""
This reverts commit f4ccef2436.
2015-12-31 15:23:26 -08:00
Dmitri Gribenko
f4ccef2436 Revert "[Mangler] Add unit tests to the compression routines."
This reverts commit 25832d39b2.  The tests
don't pass.
2015-12-31 16:07:10 -07:00
Nadav Rotem
25832d39b2 [Mangler] Add unit tests to the compression routines. 2015-12-31 09:27:40 -08:00
Nadav Rotem
83c46b7462 [Mangling] Add the name compression routines.
This commit adds a number of compression routines:
1. A dictionary based compression.
2. Huffman based compression.
3. A compression algorithm for swift names that's based on the other two.

This commit also adds two large autogenerated files: CBCTables.h and HuffTables.h.

These files contain the autogenerated string tables and auto-generated code for
fast compression/decompression.  The internal tree data structures are lowered
into code that does the variable length encoding/decoding and searching of
fragments in the codebook. The files were generated by processing the symbols
from several large swift applications (stdlib, unittests, simd, ui app, etc).
The list of the programs is listed as part of the output of the tool in the
header file.

I decided to commit the auto-generated files for two reasons. First, we have a
cyclic dependency problem where we need to analyze the output of the compiler
(swift files) in order to generate the tables.  And second, these tables will
become a part of the Swift ABI and should remain constant.

It should be possible to split the code that generates the Trie-based data
structure and auto-generate it as part of the Swift build process.
2015-12-31 09:16:20 -08:00
Michael Gottesman
9fa6e31f9e [projection] Add a new data structure for use in NewProjection called PointerIntEnum.
PointerIntEnum is a more powerful PointerIntPair data structure. It uses
an enum with special cases to understand characteristics of the data and
then uses this information and the some tricks to be able to
represent:

1. Up to tagged bit number of pointer cases. The cases are stored inline.
2. Inline indices up to 4096.
3. Out of line indices > 4096.

It takes advantage of the trick that we use in the runtime already to
distinguish pointers from indices: namely that the zero page on modern
OSes do not allocate the zero page.

I made unittests for all of the operations so it is pretty well tested
out.

I am going to use this in a subsequent commit to compress projection in
the common case (the inline case) down to 1/3 of its size. The reason
why the inline case is common is that in most cases where projection is
used it will be targeting relative offsets in an array which are not
likely to be greater than a page. The mallocing of memory just enables
us to degrade gracefully.
2015-12-29 22:06:13 -06:00
practicalswift
149b50d901 Fix typos in code (non-comment/documentation typos). 2015-12-28 11:42:15 +01:00
Nadav Rotem
19ebd058c6 [ADT] Add a new data structure to enumerate values.
This data structure enumerates values and gives them unqiue indices.  This data
structure will be used by the AliasAnalysis Cache.
2015-12-07 09:24:59 -08:00