Commit Graph

6605 Commits

Author SHA1 Message Date
Mike Ash
322ffc3d28 Merge pull request #41672 from mikeash/fix-swift-inspect-watchos
[swift-inspect] Fix some missing type conversions when targeting watchOS.
2022-03-09 12:45:36 -05:00
Artem Chikin
4ac647bfea Merge pull request #41680 from artemcm/StaticMirrorFields
[Static Mirror] Refactor gathering of field types from a binary and add SwiftStaticMirror entry-points for collection of field types.
2022-03-08 07:23:51 -08:00
Rintaro Ishizaki
6bbc651f39 [SourceKit] Report comment tags in 'indexsource' request
Comment tags weren't handled at all in SourceKit's 'request.indexsource'
request.

rdar://88728047
2022-03-04 16:14:22 -08:00
Artem Chikin
02e15882d4 [Static Mirror] Add entry-points for querying field type information for properties and enum cases 2022-03-04 16:05:08 -08:00
Artem Chikin
e376af58f5 Refactor gathering of field type info from a binary into two steps: collect and output.
The collect step can then be used for other tools, such as the `BinaryScanningTool`.
2022-03-04 14:41:07 -08:00
Mike Ash
4b85670ffc [swift-inspect] Fix some missing type conversions when targeting watchOS. 2022-03-04 13:56:12 -05:00
Artem Chikin
612ef087d4 Merge pull request #41637 from artemcm/StaticMirrorAssociatedTypes
[Static Mirror] Refactor gathering of associated types from a binary and add SwiftStaticMirror entry-point for it.
2022-03-03 11:58:09 -08:00
Alex Hoppen
f3119b8b9e Merge pull request #41632 from ahoppen/pr/compute-global-type-relations-again
[CodeComplete] Compute type relations for global cached results (again)
2022-03-03 09:19:05 +01:00
Rintaro Ishizaki
912285b0e4 Merge pull request #41606 from rintaro/sourcekit-ifacegen-rdar79927502
[SourceKit] Print custom attributes in interface-gen requests
2022-03-02 23:31:09 -08:00
Artem Chikin
62e07dc339 [Static Mirror] Refactor gathering of associated types from a binary and add SwiftStaticMirror entry-point for it. 2022-03-02 16:28:12 -08:00
Alex Hoppen
94351a2f82 [CodeComplete] Compute type relations for global cached results
Computing the type relation for every item in the code completion cache is way to expensive (~4x slowdown for global completion that imports `SwiftUI`). Instead, compute a type’s supertypes (protocol conformances and superclasses) once and write their USRs to the cache. To compute a type relation we can then check if the contextual type is in the completion item’s supertypes.

This reduces the overhead of computing the type relations (again global completion that imports `SwiftUI`) to ~6% – measured by instructions executed.

Technically, we might miss some conversions like
- retroactive conformances inside another module (because we can’t cache them if that other module isn’t imported)
- complex generic conversions (just too complicated to model using USRs)

Because of this, we never report an `unrelated` type relation for global items but always default to `unknown`.

But I believe this change covers the most common cases and is a good tradeoff between accuracy and performance.

rdar://83846531
2022-03-02 23:13:09 +01:00
Mike Ash
bf4fbdc43a [Runtime] Tiny fix for swift-inspect, let -> var. 2022-03-02 17:00:00 -05:00
Hamish Knight
1f5845d9d9 Revert "[CodeComplete] Compute type relations for global cached results" 2022-03-02 21:43:31 +00:00
Mike Ash
282b8125c9 Merge pull request #41620 from mikeash/fix-swift-inspect-darwin
[swift-inspect] Fix the swift-inspect build on Darwin.
2022-03-02 16:34:04 -05:00
Saleem Abdulrasool
2242dbd3ef Merge pull request #41565 from compnerd/dump-arrays
swift-inspect: enable `dump-arrays` on Windows
2022-03-02 12:53:00 -08:00
Mike Ash
e29434d4de [swift-inspect] Fix the swift-inspect build on Darwin.
We had a few typos and such from the recent reorganization.
2022-03-02 14:29:35 -05:00
Rintaro Ishizaki
b6119018d7 [SourceKit] Print custom attributes in interface-gen requests
Custom attributes were not printed because they are marked
'UserInaccesible'.

* Make CustomAttr 'RejectByParser' instead of 'UserInaccessible'
* Remove special treatment for Result Builder attributes
* Load implicit modules in module/header interface gen requests

rdar://79927502
2022-03-02 11:05:26 -08:00
Alex Hoppen
910c2a412e Merge pull request #41000 from ahoppen/pr/compute-global-type-relations
[CodeComplete] Compute type relations for global cached results
2022-03-02 19:02:09 +01:00
Ben Langmuir
779bdf0bf3 Merge pull request #41550 from benlangmuir/make-next-less-sad
Pre-fix some build failures that we'll see with newer llvm
2022-03-02 09:23:07 -08:00
Alex Hoppen
640cfac61c [CodeComplete] Compute type relations for global cached results
Computing the type relation for every item in the code completion cache is way to expensive (~4x slowdown for global completion that imports `SwiftUI`). Instead, compute a type’s supertypes (protocol conformances and superclasses) once and write their USRs to the cache. To compute a type relation we can then check if the contextual type is in the completion item’s supertypes.

This reduces the overhead of computing the type relations (again global completion that imports `SwiftUI`) to ~6% – measured by instructions executed.

Technically, we might miss some conversions like
- retroactive conformances inside another module (because we can’t cache them if that other module isn’t imported)
- complex generic conversions (just too complicated to model using USRs)

Because of this, we never report an `unrelated` type relation for global items but always default to `unknown`.

But I believe this change covers the most common cases and is a good tradeoff between accuracy and performance.

rdar://83846531
2022-03-01 09:16:23 +01:00
Saleem Abdulrasool
18ec9bffc1 swift-inspect: enable dump-arrays on Windows
Hoist `iterateHeaps` into the `RemoteProcess` protocol, requiring an
implementation on all platforms.  If the platform is unable to implement
heap traversal, it would be possible to simply leave the callback
uncalled.

Be more careful about memory queries, we may receive invalid memory
addresses.
2022-02-25 14:55:18 -08:00
Ben Langmuir
35478637d3 Migrate from SmallVector.set_size to resize_for_overwrite
In the "next" branch, set_size has been made protected. Instead, users
can use resize_for_overwrite, optionally followed by truncate, to
handle the same use cases more safely.
2022-02-24 13:54:22 -08:00
Saleem Abdulrasool
21edf9c322 swift-inspect: more typo/correctness fixes
This cleans up the DumpArray operation and fixes an unintentional,
undesirable change to the heap iteration on Darwin.
2022-02-24 11:04:20 -08:00
Saleem Abdulrasool
4a64b9f8f8 swift-inspect: add some documentation
This adds some documentation about swift-inspect and how to build it on
Windows, which requires additional flags to locate the SwiftRemoteMirror
library from the toolchain.
2022-02-24 08:34:50 -08:00
Alex Hoppen
f124c2f4cd Merge pull request #41525 from ahoppen/pr/split-codecompletion-cpp
[CodeCompletion] Split CodeCompletion.cpp into multiple files
2022-02-24 15:41:47 +01:00
Alex Hoppen
190ee6ecc7 [CodeCompletion] Replace includes of CodeCompletion.h by more specific ones 2022-02-23 17:08:26 +01:00
Saleem Abdulrasool
7f789ba319 swift-inspect: port to windows
This adds an initial port to Windows which allows inspection of the
processes.  It is not possible to port `dump-arrays` or
`dump-concurrency` due to the need to iterate the heap.  This still
allows for gaining some insight into the metadata and protocol caches.
2022-02-21 08:59:27 -08:00
Saleem Abdulrasool
f085f2b42f swift-inspect: fix all the typos/correctness issues
Fix the many typos and missing `)` instances.  Replace the inline array
removal with explicit duplication due to the behaviour of `#if`.  This
allows the tool to build after the changes for the refactoring.
2022-02-20 15:58:37 -08:00
Saleem Abdulrasool
4453571e46 Merge pull request #41373 from compnerd/inspector-gadget
swift-inspect: restructure the project for porting
2022-02-20 10:03:46 -08:00
Michael Gottesman
487234cd09 Merge pull request #41458 from gottesmm/pr-d179a548962e72bacc7ac8a564a69f32567839be
[sil-opt] Propagate to IRGenOptions whether we have debug info and or optimizations enabled.
2022-02-19 12:51:37 -08:00
Saleem Abdulrasool
eef3a8f60a swift-inspect: restructure the project for porting
This restructures and refactors the project to split up the
implementation into smaller fragments.  The majority of the operations
are portable: the ones which are not require iterating the heap
allocations which is not guaranteed to be a portable operation.
Additionally, the `Inspector` class is renamed into `RemoteProcess`
which is also converted to a protocol to allow adding in an
implementation for other targets.  The inspection operations are split
off into individual files to make it easier to follow.  Take the
opportunity to use `@main` for the entry point.
2022-02-18 12:58:11 -08:00
Michael Gottesman
135ab2b1bf [sil-opt] Add an option irgen-debuginfo-level to set the IRGen debug info level for IRGen passes.
This allows for IRGen passes to make decisions based off of the IRGen debug info
level like they can when used by a swift-frontend invocation.
2022-02-18 12:56:36 -08:00
Michael Gottesman
6dde338a11 [sil-opt] Actually pass down IRGenOptions to irgen::createIRGenModule().
Otherwise the options from our invocation that we specialized in sil-opt's main
function will not take effect.
2022-02-18 12:56:36 -08:00
Michael Gottesman
86d4ba1575 [sil-opt] Set the opt level on the IRGenOptions used so it matches the one we set on SILOpt. 2022-02-18 12:56:36 -08:00
Rintaro Ishizaki
3c33debd61 [CodeCompletion] Make all result's string fields null terminated
This is convenient for clients to pass these fields values to C
functions. Introduce NullTerminatedStringRef to guarantee that.
2022-02-18 11:34:45 -08:00
Rintaro Ishizaki
7ef93b2a67 [Basic] Move copyCString to Basic/StringExtras.
Also, use StringRef.copy() instead of copyString().
2022-02-18 11:34:45 -08:00
Rintaro Ishizaki
5ab84ae242 [CodeCompletion] Precompute and cache "filter name"
Filter name for completion item is always used. Also, for cached items,
they are used multiple times for filtering. So precomputing and caching
it improves performance.

rdar://84036006
2022-02-18 11:34:45 -08:00
Rintaro Ishizaki
33ee4d609f [CodeCompletion] 'ContextFreeCodeCompletionResult' factory method
Convert 'ContextFreeCodeCompletionResult' constructor overloads to
'create()' factory methods. This is the consistent interface with
'CodeCompletionString'. NFC
2022-02-18 09:58:26 -08:00
Rintaro Ishizaki
7893f74142 Merge pull request #41384 from rintaro/ide-completion-actorkind-rdar79733313
[CodeCompletion] Add a symbol kind for actors
2022-02-16 15:55:47 -08:00
Alex Hoppen
bac3b67f66 Merge pull request #40999 from ahoppen/pr/compute-type-relation-in-contextual-result
[SourceKit] Compute code completion type relation when wrapping a ContextFreeCodeCompletionResult in a CodeCompletionResult
2022-02-16 22:13:22 +01:00
Alex Hoppen
6bc0de94a2 [SourceKit] Compute code completion type relation when wrapping a ContextFreeCodeCompletionResult in a CodeCompletionResult
[CodeCompletion] Make ExpectedTypeContext a class with explicit getters/setters

This simplifies debugging because you can break when the possible types are set and you can also search for references to `setPossibleType` to figure out where the expected types are being set.
2022-02-16 20:28:13 +01:00
Rintaro Ishizaki
d9011e06b2 [CodeCompletion] Add a symbol kind for actors
rdar://79733313
2022-02-15 13:14:46 -08:00
Rintaro Ishizaki
aa0f5d5deb [swift-ide-test] support multiple '-define-availability' (#41285)
rdar://88596547
2022-02-10 11:29:41 -08:00
Artem Chikin
a64f04e88f Merge pull request #41205 from artemcm/StandaloneStaticMirror
Build `libSwiftStaticMirror` as a standalone library with minimal required dependencies.
2022-02-10 08:32:14 -08:00
Artem Chikin
d24e15812b Build libSwiftStaticMirror as a standalone library with minimal required dependencies.
This separates it from `libSwiftScan` and allows us to build this library without building much of the rest of the compiler.

Also refactor `utils/build-parser-lib` into `utils/build-tooling-libs` which builds both SwiftSyntaxParser and SwiftStaticMirror.
2022-02-09 12:28:21 -08:00
Eric Miotto
f417630054 Add option to reduce build times when using ThinLTO and ld64 (#41058)
Internal configurations targeting Darwin employ ThinLTO to
improve compiler performance, however using it on all executable
causes build time to increase with no matching benefit.

To reduce build times in such configurations, we allow some
ancillary targets to opt out of LLVM IR optimizations when linking
ThinLTO with ld64 (e.g. tools used for bootstrapping or debugging the
Swift compiler) -- this behaviour is opt in through a new flag
`--swift-tools-ld64-lto-codegen-only-for-supporting-targets`.

Addresses rdar://76702687
2022-02-09 08:22:02 -08:00
Mike Ash
f829167882 [swift-inspect] Fix errors when targeting 32-bit.
The C APIs are somewhat inconsistent about what kind of integers they use, so we need a bunch of conversions when targeting 32-bit.
2022-02-08 11:34:37 -05:00
Alex Hoppen
50eafca5bf [Code Completion] Extract CodeCompletionResultTypeRelation to a top-level type
Preliminary work to compute the type relation when constructing a contextual code completion result.
2022-02-08 15:04:38 +01:00
Alex Hoppen
e8c76a1637 Merge pull request #40471 from ahoppen/pr/split-context-free-codecompletion-result
[Code Completion] Split code completion results into context free part that can be cached and contextual part displayed to the user
2022-02-08 15:00:08 +01:00
Keith Smiley
d1eabf182c [swift-stdlib-tool] Fix finding sibling directories (#41110) 2022-02-07 19:45:51 -08:00