Commit Graph

35 Commits

Author SHA1 Message Date
Mike Ash
bf58357e54 [Reflection] Change ReadBytesFunction to return a pointer rather than copying data, and adjust its users accordingly.
rdar://problem/37538580
2018-02-21 12:17:28 -05:00
Joe Groff
953dddd5d3 IRGen/Runtime: Allow mangled type refs to embed "symbolic references" to type context descriptors.
This makes resolving mangled names to nominal types in the same module more efficient, and for eventual secrecy improvements, also allows types in the same module to be referenced from mangled typerefs without encoding any source-level name information about them.
2018-02-10 10:43:47 -08:00
Arnold Schwaighofer
17cd95efa4 Rename swift3 section and global names to swift5
Such that old and new runtimes can co-exists
rdar://36363251
2018-01-22 10:04:46 -08:00
Doug Gregor
132075f870 [NFC] Move TypeDecoder into the Demangling library.
The remote reflection library has a fantastic utility class, TypeDecoder,
to take a mangled type and form an abstract type from it. Move this facility
into the Demangling library so other clients can use it.
2018-01-05 15:42:45 -08:00
Saleem Abdulrasool
df54b2af11 reflection: handle LMA != VMA for ELF
ELF is segment mapped, where the segment which contains a particular
section may be mapped to an address which does not correspond to the
address on disk.  Since the reflection dumper does not use the loader to
load the image into memory, we must manually account for any section
offsets.  Calculate this value when we query the mmap'ed image and wire
it through to the relative direct pointer accesses.

When switching to the linker table approach for the ELF metadata
introspection, this was uncovered as the segment containing the orphaned
sections was coalesced into a separate PT_LOAD header which had a non-0
offset for the mapping.
2017-11-29 17:56:15 -08:00
Saleem Abdulrasool
0c42b57962 ELF: restructure image metadata registration
Restructure the ELF handling to be completely agnostic to the OS.
Rather than usng the loader to query the section information, use the
linker to construct linker tables and synthetic markers for the
beginning and of the table.  Save off the values of these pointers and
pass them along through the constructor to the runtime for registration.

This removes the need for the begin/end objects.  Remove the special
construction of the begin/end objects through the special assembly
constructs, preferring to do this in C with a bit of inline assembly to
ensure that the section is always allocated.

Remove the special handling for the various targets, the empty object
file can be linked on all the targets.

The new object file has no requirements on the ordering.  It needs to
simply be injected into the link.

Name the replacement file `swiftrt.o` mirroring `crt.o` from libc.  Merge
the constructor and the definition into a single object file.

This approach is generally more portable, overall simpler to implement,
and more robust.

Thanks to Orlando Bassotto for help analyzing some of the odd behaviours
when switching over.
2017-11-28 10:04:04 -08: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
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
Bob Wilson
37e7d1c627 Merge remote-tracking branch 'origin/master' into master-next 2017-01-08 17:07:46 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Bob Wilson
deddf19aae Merge remote-tracking branch 'origin/master' into master-next 2016-12-13 10:23:03 -08:00
Hugh Bellamy
137b2ab295 Fix errors and warnings building swift/reflection on Windows with MSVC 2016-12-11 10:00:32 +00:00
Bob Wilson
13da3fa8b1 Merge remote-tracking branch 'origin/master' into master-next 2016-12-04 18:16:09 -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
9cc68d6c9f Update for clang r283671: remove use of clEnumValEnd. 2016-10-15 11:02:20 -07:00
Michael Gottesman
cb5aa4d093 Merge pull request #3007 from compnerd/expected-more
[master-next] swift-reflection-dump: Expected more
2016-06-25 02:14:04 -07:00
Michael Gottesman
8d00a6cb59 Merge remote-tracking branch 'origin/master' into master-next
Conflicts:
	stdlib/public/SDK/GameplayKit/CMakeLists.txt
	test/DebugInfo/bound-namealiastype.swift
	test/DebugInfo/structs.swift
	test/IRGen/c_globals.swift
	test/SourceKit/DocSupport/doc_clang_module.swift
	test/SourceKit/Indexing/index_with_clang_module.swift
	utils/update-checkout
2016-06-25 01:13:50 -07:00
Saleem Abdulrasool
aff54d5d80 swift-reflection-dump: Expected more
Now that more APIs are returning expected, just change unwrap to use the
Expected interface and remove the Expected to Error conversion.
2016-06-13 14:45:12 -07:00
Slava Pestov
5cc4ce1760 Reflection: Looking up CaptureDescriptors by remote address
Remote metadata for closure contexts points to a capture descriptor.
We have a local copy of all capture descriptors. Translate the
address by recording the local and remote start address of
reflection metadata.
2016-05-09 13:40:57 -07:00
Mark Lacey
b044c4d74f Fixes for uses of new Expected<T> type in LLVM. 2016-05-03 17:02:54 -07:00
Slava Pestov
71d28691ef Reflection: Plumb through capture descriptor section 2016-05-02 01:16:25 -07:00
Slava Pestov
faecfda594 Reflection: Consolidate some code for passing around reflection sections
I'm about to add a new section, and I'd like to update as few
places as possible.
2016-04-30 15:12:38 -07:00
Slava Pestov
95d648779b Reflection: Fix some bugs in swift-reflection-test
- Improper handling of read() returning an incomplete read
- Update SwiftReflectionTest library for new builtin types section

Only tested manually so far; automated tests coming soon.
2016-04-27 18:17:25 -07:00
Slava Pestov
2380f9f957 Re-apply "Reflection: Preliminary implementation of struct and tuple type lowering"
Re-apply now that reflection metadata is emitted by default and
the test can actually pass. Oops...
2016-04-21 15:15:38 -07:00
Greg Parker
4f98a54eb4 Revert "Reflection: Preliminary implementation of struct and tuple type lowering" and "Reflection: Fix a nit"
Test Reflection/typeref_lowering.swift failed on a bot:
https://ci.swift.org/job/oss-swift-package-osx/1346/

This reverts commits 52f475c0b0 and f4af29b53c.
2016-04-19 01:51:48 -07:00
Slava Pestov
52f475c0b0 Reflection: Preliminary implementation of struct and tuple type lowering
Now that we can parse and substitute typerefs, and look up field
types, we finally have enough infrastructure in place to do some
basic layout of struct and tuple types from within the Reflection
library.

To facilitate testing, swift-reflection-dump now accepts multiple
-binary-filename flags, allowing types defined in the standard
library to be looked up.

More detailed end-to-end tests will come once I finish the
typeref-to-metadata builder.
2016-04-18 23:13:50 -07:00
Slava Pestov
3936cd2f78 Reflection: swift-reflection-dump now only needs a TypeRefBuilder and not a ReflectionContext, NFC
Since swift-reflection-dump does not have a remote address space,
it doesn't need a full ReflectionContext. Now that TypeRefBuilder
has been refactored, we can use that instead.
2016-04-16 02:19:29 -07:00
Slava Pestov
824bd7544d IRGen: Emit typerefs for all builtin types referenced from reflection metadata sections
In order to perform layout, the remote mirrors library needs to know
about the size, alignment and extra inhabitants of builtin types.

Ideally we would emit a reflection info section in libswiftRuntime.o,
but in the meantime just duplicate builtin type metadata for all
builtin types referenced from the current module instead.

In practice only the stdlib and a handful of overlays like the SIMD
overlay use builtin types, and only a few at a time.

Tested manually by running swift-reflection-tool on the standard
library -- I'll add automated tests by using -parse-stdlib to
reference Builtin types in a subsequent patch that adds more layout
logic.

NFC if -enable-reflection-metadata is off.
2016-04-15 00:12:11 -07:00
Chris Lattner
2f9e91d267 make an 'else' block unconditional, aborting if the cast<> fails. The
old code would end up dereferencing an uninitialized pointer in the case
where the cast would fail, it is better to explode violently.
2016-04-12 21:07:28 -07:00
Slava Pestov
b898f43972 Reflection: Fix memory management issue in swift-reflection-dump
MachOUniversalBinary::getObjectForArch() returns a value containing
a unique_ptr; if we just fish out the unique_ptr value using get(),
it will be freed too soon.

Instead, hold on to the unique_ptr until we are done with everything.
2016-04-12 19:15:37 -07:00
Slava Pestov
39f0fff19d Reflection: Small stylistic cleanups, NFC 2016-04-12 19:15:36 -07:00
John McCall
91f02848df Organize the MemoryReader interface headers to better support
multiple clients.
2016-04-12 16:05:29 -07:00
David Farler
358a0fefe8 Add SwiftRemoteMirror library
This will wrap the ./lib/Reflection functionality in a C
interface.
2016-04-05 13:45:46 -07:00
practicalswift
cd41538162 [gardening] Fix file header formatting. 2016-03-30 18:20:50 +02:00
David Farler
5ea5bb06a3 Split swift-refleciton-test into host and target test targets
swift-reflection-test is now the test that forks a swift executable
and performs remote reflection, making it runnable on other targets,
such as the iOS simulator.

swift-reflection-dump is now a host-side tool that dumps the remote
reflection sections for any platform binary and will continue to
link in LLVM object file support.

This necessitates finally moving lib/Refleciton into stdlib/public,
since we're linking target-specific versions of the test tool and
we would eventually like to adopt some of this functionality in
the runtime anyway.
2016-03-28 16:34:44 -07:00