Commit Graph

519 Commits

Author SHA1 Message Date
Connor Wakamo
b7aec0e72c [driver] Added a DummyTaskQueue class, which calls TaskBeganCallback/TaskFinishedCallback but does not actually execute subtasks.
While this is not yet used, Compilation will be able to adopt this for easier testing of driver-level task execution (instead of forcing all driver-level tests to invoke the frontend, linker, etc.).

Swift SVN r12349
2014-01-15 21:27:55 +00:00
Connor Wakamo
dd9614e80c [driver] Add TaskQueue::getNumberOfParallelTasks().
For the Unix implementation, this returns NumberOfParallelTasks (unless that value is 0, in which case it returns the default value of 1).
For the Default implementation, this always returns 1, since it does not support parallelism.

Swift SVN r12348
2014-01-15 21:27:50 +00:00
Connor Wakamo
cc00fd1048 [driver] Rework the Unix implementation of TaskQueue::execute() to support reading from pipes as they fill, instead of all at once at the end.
Instead of always calling waitpid() and looking for the termination of a task, call poll() and watch for events on the pipes which are used for buffering subtask output. When we receive a POLLIN or POLLPRI event, ask the corresponding Task to read from the pipe; when we receive a POLLHUP or POLLERR event, wait for the subtask to finish and then ask the Task to perform its post-execution tasks.

Now that the Unix implementation properly handles large amounts of subtask output, re-enable the Unix implementation (if supported).

This fixes <rdar://problem/15795234>.

Swift SVN r12293
2014-01-14 20:39:23 +00:00
John McCall
817e80bde5 Implicit conversions for UncheckedOptional.
rdar://15189000
rdar://15189009

Swift SVN r12260
2014-01-13 23:15:03 +00:00
Doug Gregor
fc7dfb2fae Start emitting .cxx_construct methods for Objective-C-derived classes.
When we're using Objective-C's memory allocation, emit .cxx_construct
methods whenever we have instance variables with in-class
initializers. Presently, these methods are just empty stubs.

Swift SVN r12211
2014-01-12 04:31:52 +00:00
Doug Gregor
3524a79fa0 Emit .cxx_destruct for destruction of ivars in Objective-C-derived classes.
The Objective-C runtime executes the .cxx_destruct method after the
last -dealloc has executed when destroying an object, allowing the
instance variables to remain live even after the subclass's
destructor/-dealloc has executed, which is important for memory
safety. This fixes the majority of <rdar://problem/15136592>.

Note that IRGenModule::getAddrOfIVarDestroyer() contains  an egregious
hack to find the ivar destructor SIL function via a linear
search. We need a better way to find SIL functions that we know exist,
because LinkEntity does not suffice.

Swift SVN r12206
2014-01-12 00:17:42 +00:00
Connor Wakamo
aec43d811a [driver] Disable the Unix implementation of TaskQueue.
The current implementation does not read() from each Task's pipe until execution
finishes. This causes subtasks to block in write() if the pipe is full, which
only happens if there is a large amount of output (such as in -dump-ast mode).

Fixing output buffering and reenabling the Unix TaskQueue implementation is
tracked by <rdar://problem/15795234>.

Swift SVN r12135
2014-01-10 21:56:18 +00:00
Connor Wakamo
ed061a5bfa [driver] Introduced a new TaskQueue class for parallel execution and output buffering.
Due to the nature of this class, there are two implementations of TaskQueue:
a Unix-specific implementation which supports both parallel execution and output
buffering, and a default implementation which supports neither of these features.
(The default implementation uses the functions from llvm/Support/Program.h for execution.)

TaskQueue allows clients to provide a TaskBeganCallback and a TaskFinishedCallback,
each of which will be called when a new task begins or when a task finishes execution,
respectively. Clients may add tasks to the TaskQueue in either of these callbacks,
and clients can stop further execution by returning TaskFinishedResponse::StopExecution
from the TaskFinishedCallback.

Swift SVN r12059
2014-01-08 19:10:41 +00:00
John McCall
aa26b55c1e Variable initializer manglings don't have types.
Fixes rdar://15753317

Note that the mangling we're actually generating here is clearly
wrong.

Swift SVN r11943
2014-01-06 20:05:14 +00:00
John McCall
b30ab409df Prettify crashes in the demangler.
Revert "add a hackaround for rdar://15753317.  I don't unerstand the code enough to tell if this is the right fix."

This reverts commit 416983b0734dde6979c98971948068c7a157e336.

Swift SVN r11942
2014-01-06 20:05:12 +00:00
Chris Lattner
31c328bdcf add a hackaround for rdar://15753317. I don't unerstand the code enough to tell if this is the right fix.
Swift SVN r11927
2014-01-06 16:48:13 +00:00
John McCall
deeb98cb1e Fix trivial bug.
Probably should have waited for those tests to run, no matter
how trivial the refactor seemed.

Swift SVN r11903
2014-01-04 09:52:02 +00:00
John McCall
1d2697f176 More random demangling stylings. Probably done here for now. :)
Swift SVN r11902
2014-01-04 09:49:38 +00:00
John McCall
2b99a66204 Rename toString* to print*.
Swift SVN r11901
2014-01-04 09:49:37 +00:00
John McCall
552c3efad6 Unnest NodePointer::toString.
Swift SVN r11900
2014-01-04 09:49:37 +00:00
John McCall
c5d2d972ee Add an x-macro system for demangling nodes and use it to
generate getNodeKindString automatically.

Swift SVN r11899
2014-01-04 09:49:35 +00:00
John McCall
e9e928d509 Remove the last vestiges of the 'L' local-linkage mangling prefix.
Swift SVN r11896
2014-01-04 09:11:16 +00:00
John McCall
4355a21a62 Mangle closures using their context and discriminator.
Swift SVN r11885
2014-01-04 04:37:57 +00:00
John McCall
ad1e198a3a Recognize unmangled suffixes at the end of a mangling.
Swift SVN r11866
2014-01-03 19:39:08 +00:00
John McCall
5df03ce334 Abstract out a utility for printing strings in quotes.
Swift SVN r11865
2014-01-03 19:39:07 +00:00
John McCall
d5b65b2d7f Improve and test the demangling of local declarations.
Swift SVN r11526
2013-12-20 23:20:15 +00:00
John McCall
186c0243f1 Mangle the discriminator into local declaration names.
Swift SVN r11522
2013-12-20 22:50:51 +00:00
John McCall
4b48c8915c Demangle reabstraction thunks (and impl-function-type generally).
Swift SVN r11493
2013-12-20 00:46:56 +00:00
Joe Groff
017440165e Fix the weird capitalization of MetaTypeType.
Swift SVN r11475
2013-12-19 18:43:08 +00:00
John McCall
8505c4a00d Further refactoring/simplification of the demangler.
Not NFC: changes some of the demangling tree schemata (in
interest of regularity and expressivity) and, incidentally,
improves support for initializer manglings.

The main schema change is that Path is now gone, and instead
the first child of an entity is its context.  All contexts
are now labelled with their kind (variable/function/etc.)
rather than that being much more obscure or missing.

A secondary change is that the top-level node is now a
single node with the <global> and all its attributes as
children, rather than being weirdly sibling-linked.

Also, the representation has changed so that nodes link
only to their children, not to siblings or parents, which
means that it is no longer necessary to clone nodes when
replacing substitutions.

Finally, dump/print was brought in from swift-demangler
and made part of the core API for debugging purposes.

Swift SVN r11470
2013-12-19 08:57:06 +00:00
John McCall
c9aad99674 Further reduce the API surface area and complexity of demangling nodes.
Swift SVN r11469
2013-12-19 08:57:05 +00:00
John McCall
1d8d2d15ed Remove the need for Node::setKind.
Swift SVN r11468
2013-12-19 08:57:04 +00:00
John McCall
1751c6d3e4 Bring the demangler closer to Swift code style. NFC.
Swift SVN r11443
2013-12-18 22:22:15 +00:00
John McCall
c5aa41ffd1 Change around some manglings to make them carry more
information and be easier to demangle.

Swift SVN r11423
2013-12-18 08:33:52 +00:00
Enrico Granata
0109df6ddd This would not affect the display of the demangled type name, but would cause LLDB to fail to retrieve the type, as it went looking for the wrong kind of thing
Swift SVN r10976
2013-12-07 03:24:50 +00:00
Connor Wakamo
ed2038585f Initial set of changes to add a new 'swift_driver' executable.
- Added a couple of new targets:
  - libswiftDriver, which contains most of the driver implementation
  - swift_driver, which produces the actual executable

- Added centralized version information into libswiftBasic.

- Added a new "Driver Design & Internals" document, which currently describes
  the high-level design of the Swift driver.

- Implemented an early version of the functionality of the driver, including
  versions of the Parse, Pipeline, Bind, Translate, and Execute driver stages.
  Parse, Pipeline, and Bind are largely implemented; Translate and Execute are
  early placeholders. (Translate produces "swift_driver --version" and "ld -v"
  commands, while Execute performs all subtasks sequentially, rather than in
  parallel.)

This is just the starting point for the Swift driver. Tests for the existing
behavior are forthcoming.

Swift SVN r10933
2013-12-06 21:23:01 +00:00
Dave Abrahams
7ab9d369aa [stdlib] Rename Char => UnicodeScalar
Swift SVN r10864
2013-12-05 17:30:37 +00:00
Adrian Prantl
7e3cfd48e8 demangler: don't consume the same character twice
Swift SVN r10793
2013-12-04 21:45:18 +00:00
Connor Wakamo
c7c15d68b8 Added missing newlines to the end of a few files.
Swift SVN r10791
2013-12-04 21:37:17 +00:00
Enrico Granata
627488fe04 Add an option to the Demangler to not show the type of ivars when displaying their "field offset" symbols
iVars of a given type should be unique by name and so in certain cases, their types will not actually add information to a consumer of the demangled string
This mode is mostly useful for LLDB. When searching for a field offset by name in a generic scenario, the search can succeed or fail depending on whether archetypes are
obtained through the Demangler ("A","B","C") or through the module (which will vend proper archetype names when poked the right way)
This mode removes that ambiguity



Swift SVN r10761
2013-12-03 22:37:43 +00:00
Adrian Prantl
41e92af7ae Mangler: Add a DWARF-only mangling for type aliases that includes the
decl context of the type alias.
This implements <rdar://problem/15290346> "typealias sugar needs to be
mangled into debug info mangled type names".

Swift SVN r10749
2013-12-03 17:15:18 +00:00
Dave Zarzycki
8bd3582d3e 15242776 stdlib: rename Slice to Array
The "HArray" name is temporary.

Swift SVN r10707
2013-12-01 08:16:30 +00:00
Adrian Prantl
4fc5c9637b Mangler: Eliminate an ambiguity in the mangling of contexts.
<rdar://problem/15444866> Mangling is ambiguous -- may want prefix for functions

Swift SVN r10669
2013-11-23 00:56:16 +00:00
Enrico Granata
1d46859477 This is a temporary Demangler change to allow demangling of function decl-contexts when part of a qualified archetype
This "greedy" demangling should not be necessary anymore once <rdar://problem/15444866> goes in
As of now, this extension should help LLDB support generics in functions



Swift SVN r10493
2013-11-15 18:27:05 +00:00
Joe Groff
cdb6e7b8bd Handle 'Bw' -> 'Builtin.Word' mangling in the demangler.
Swift SVN r10485
2013-11-15 01:22:11 +00:00
Enrico Granata
aa0bc1f697 Start demangling the new Qq production that Adrian introduced in r10470
Swift SVN r10478
2013-11-15 00:18:45 +00:00
Enrico Granata
dc1c1104bc Don't let the demangler crash when presented an incomplete generic type
Fixes <rdar://problem/15444832>



Swift SVN r10390
2013-11-13 00:14:15 +00:00
Enrico Granata
5c8c45624b Removing a few unused Demangler node kinds
Swift SVN r10379
2013-11-12 22:24:20 +00:00
Argyrios Kyrtzidis
6fb1dce5c1 [Frontend] When setting up the buffers for a CompilerInstance, allow a memory buffer to
provide the contents of a filename, based on its buffer identifier.

Swift SVN r10042
2013-11-08 18:29:38 +00:00
Enrico Granata
6e666c7c22 <rdar://problem/15321132>
Demangle nominal type descriptor _TMn correctly



Swift SVN r9675
2013-10-25 18:02:46 +00:00
Argyrios Kyrtzidis
bb068725b4 [libBasic] Add documentation comments for ThreadSafeRefCounted.h
Swift SVN r9654
2013-10-24 21:33:22 +00:00
Argyrios Kyrtzidis
60edb9683d [libBasic] Introduce a thread-safe version of llvm::RefCountedBase.
This is to be used by the code-completion infrastructure while managing its global caches.

Swift SVN r9652
2013-10-24 20:34:32 +00:00
Argyrios Kyrtzidis
49a5f53e19 [libBasic] Introduce a caching mechanism, that evicts its entries when there is memory pressure.
The underlying mechanism uses darwin's libcache library (if not building on darwin there is a default implementation).

This was originally introduced in SourceKit, but we are moving it to libswiftBasic so it can be utilized by libswiftIDE
for caching code-completion results.

Swift SVN r9610
2013-10-23 00:41:55 +00:00
Sonny Falk
df693fd744 Make the CharSourceRange constructor take the SourceManager parameter as const.
Swift SVN r9596
2013-10-22 20:48:15 +00:00
Enrico Granata
ef9a1b32d4 <rdar://problem/15213551>
This checkin extends the Demangler to allow printing sugar on demangled types
Namely, it introduces a DemanglerOptions class with just one field SynthesizeSugarOnTypes which has the same functionality as PrintOptions::SynthesizeSugarOnTypes
This changes outputs like _TtGSqC5sugar7MyClass_ ---> swift.Optional<sugar.MyClass> into _TtGSqC5sugar7MyClass_ ---> sugar.MyClass?

By default this flag is false, so that existing clients of the Demangler API do not break

OTOH, the command-line tool swift-demangle flags sets the flag to true, unless the -no-sugar option is passed on the command-line

Test cases included



Swift SVN r9502
2013-10-18 22:05:08 +00:00