Commit Graph

120 Commits

Author SHA1 Message Date
Arnold Schwaighofer
cc7f207cec Rename swift sections from swift4 to swift5
rdar://38465220
2018-05-23 12:18:08 -07:00
Doug Gregor
d457f1c752 [IRGen/SIL] More widespread use of SubstitutionMap. 2018-05-11 13:18:06 -07:00
David Zarzycki
8c0c55539f [SIL] NFC: Rename misleading getSwiftRValueType() to getASTType()
Reference storage types are not RValues. Also, use more SILType helper
methods to avoid line wrap.
2018-05-04 08:14:38 -04:00
Slava Pestov
ea293c08b5 IRGen: Move getTypeRef() to a method on IRGenModule and clean up 2018-04-20 19:32:41 -07:00
Slava Pestov
11dfc1c357 IRGen: Don't pass around a ModuleDecl for mangling typerefs 2018-04-20 19:30:03 -07:00
Slava Pestov
a8b1723624 Reflection: Don't use the old box mangling
The TypeDecoder doesn't support the new box mangling yet and instead
just decodes it as Builtin.NativeObject, but that's OK because the
Remote Mirrors lowered the old box mangling as Builtin.NativeObject
anyway.
2018-04-20 19:24:08 -07:00
Mike Ash
0f73e32cfe [IRGen] Blacklist some more globals that caused trouble with ASAN on Linux.
rdar://problem/39128762
2018-04-11 15:21:13 -04:00
Mike Ash
e13c58dd56 [IRGen] Blacklist metadata globals from address sanitizer. Otherwise asan pads them in an attempt to detect overflows, which messes with other code which assumes that metadata is contiguous.
rdar://problem/39128762
2018-04-09 15:11:06 -04:00
Arnold Schwaighofer
0c11e1a0a3 Mark swift sections as swift4 for Swift 4.2
rdar://36363251
2018-03-14 10:27:28 -07:00
Pavel Yaskevich
877c70bae9 [Runtime/Metadata] Add support for dynamic field descriptor registration 2018-02-20 18:20:09 -08: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
Pavel Yaskevich
478ba2693a [IRGen] Emit type field descriptors for imported structs 2018-02-06 15:50:52 -08:00
Mark Lacey
8667eb6f91 Revert "[WIP][IRGen] Emit type field descriptors for imported structs" 2018-02-03 10:27:34 -08:00
Pavel Yaskevich
9e08ea4c56 [Reflection] Add support for imported structs with recorded fields
Update IRGen to trigger generation of type metadata for foreign
struct types found in fields. And fix TypeRefBuilder to handle
the case where struct has fields but at the same time has opaque
metadata.
2018-02-02 15:54:12 -08:00
Pavel Yaskevich
ca1fd0706c [IRGen] Emit type field descriptors for imported structs 2018-02-02 15:38:32 -08:00
Joe Groff
3258902f77 Preserve whether fields are var or let in the reflection metadata.
Useful for future mutable reflection features to know whether they're allowed to mutate a field after initialization.
2018-01-31 19:04:39 -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
e28e856595 [Runtime] Use bare protocol mangling for protocol descriptors.
The mangled name of protocol descriptors was the “protocol composition”
type consisting of a single protocol, which is a little odd. Instead,
use a bare protocol reference (e.g., “6Module5ProtoP”) with the “$S”
prefer to be more in line with nominal type descriptor names while still
making it clear that this is a Swift (not an Objective-C) protocol.
2018-01-09 10:21:55 -08:00
Saleem Abdulrasool
899103cfa8 COFF: restructure metadata registration
Restructure the COFF metadata handling to use the linker section
grouping to emit section start/stop markers in the appropriate location.
This allows us to lookup the sections statically without having to the
walk the entire image structure.

Introduce a constructor for PE/COFF binaries.  This will ensure that the
registration occurs for all modules appropriately.  This should resolve
rdar://problem/19045112.  The registration should occur prior to
`DllMain` being invoked from `DllMainCRTStartup`.
2017-12-08 16:15:07 -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
Huon Wilson
5f70f68c0d [AST] Store only interface types in NormalProtocolConformances.
Rather than storing contextual types in the type witnesses and associated
conformances of NormalProtocolConformance, store only interface types.

@huonw did most of the work here, and @DougGregor patched things up to
complete the change.
2017-11-16 11:45:18 -08:00
Slava Pestov
2920b4fd1c AST: Remove DeclContext::mapTypeOutOfContext() 2017-11-15 22:52:28 -08:00
Slava Pestov
cce30cc9bb SIL: Remove SILFunction::mapTypeOutOfContext() 2017-11-15 22:52:28 -08:00
Slava Pestov
55cd329cb3 Reflection: Remove logic for the parent metadata source 2017-09-25 15:45:17 -07:00
John McCall
6d9294f565 Random improvements for ArrayRefView. 2017-09-25 02:05:23 -04:00
Slava Pestov
5f1b85e704 IRGen: Fix emission of reflection metadata for @objc enums
@objc enums lower as their raw type, so should go through the same
code path as imported enums.

Fixes <https://bugs.swift.org/browse/SR-5625> and
<rdar://problem/33683103>.
2017-08-03 20:33:09 -07:00
John McCall
7f22faf968 Substantially rework how SILGen handles bridging as part of laying the
ground work for the syntactic bridging peephole.

- Pass source and dest formal types to the bridging routines in addition
  to the dest lowered type.  The dest lowered type is still necessary
  in order to handle non-standard abstraction patterns for the dest type.

- Change bridging abstraction patterns to store bridged formal types
  instead of the formal type.

- Improve how SIL type lowering deals with import-as-member patterns.

- Fix some AST bugs where inadequate information was being stored in
  various expressions.

- Introduce the idea of a converting SGFContext and use it to regularize
  the existing id-as-Any conversion peephole.

- Improve various places in SILGen to emit directly into contexts.
2017-07-11 12:45:13 -04:00
Alex Hoppen
949968a182 Adjust printing to take into account special DeclNames
Print DeclBaseNames using a new userFacingStr() method to prepare for
DeclBaseNames that are not backed by Identifiers
2017-06-24 11:39:09 +02:00
Doug Gregor
68164ade6d [AST] Use ParenType for the input type of canonical function types.
As a step toward eliminating the single input type
representation of function parameters, add more constraints on that
input type. It can be one of:

* A tuple type, for multiple parameters,
* A parenthesized type, for a single parameter, or
* A type variable type, for specific cases in the type checker

Enforce these constraints for *canonical* types as well, so the
canonical form of:

    typealias MyInt = Int
    typealias MyFuncType = (MyInt) -> Int

is now:

    (Int) -> Int

rather than:

    Int -> Int

This affects canonicalization of FunctionType and
GenericFunctionType. Enchance both, as well as their Can*Type
counterparts, with "get" operators that take an array of
AnyFunctionType::Param, and start switching a few clients over to this
new, preferred API.
2017-06-23 10:48:06 -07:00
Slava Pestov
ab4d37a422 Reflection: Record superclass as its own field instead of an associated type of AnyObject
The "superclass as associated type" modeling was put in to
maintain backward compatibility.

We just bumped the version number because of new mangling so
we may as well fix this sillyness too.
2017-05-02 01:18:49 -07:00
Slava Pestov
cb95ee3581 IRGen: Don't crash when emitting a capture descriptor containing an opened existential 2017-04-25 01:32:45 -07:00
Slava Pestov
f4b91cd118 AST: Remove unused 'resolver' argument from TypeBase::getSuperclass() 2017-04-20 00:37:38 -07:00
Doug Gregor
ebdd56a1f0 [AST] Eliminate the "interface type" from protocol conformances.
We don't need this notion.
2017-04-18 17:15:15 -07:00
Slava Pestov
497336c4bc IRGen: Use the right reference counting for subclass existentials 2017-04-17 17:22:28 -06:00
Slava Pestov
d58f049608 AST: Introduce ASTContext::getAnyObjectType()
This replaces a number of usages of KnownProtocolKind::AnyObject,
which is soon going away.
2017-04-13 21:17:05 -07:00
Slava Pestov
d49f8fb6d9 AST: Introduce primitive AnyObject type
Add a 'hasExplicitAnyObject()' bit to ProtocolCompositionType
to represent canonical composition types containing '& AnyObject'.

Serialize this bit and take it into account when building
ExistentialLayouts.

Rename ProtocolCompositionType::getProtocols() to getMembers()
since it can contain classes now, and update a few usages that
need further attention with FIXMEs or asserts.

For now, nothing actually constructs these types, and they will
trigger arounds asserts. Upcoming patches will introduce support
for this.
2017-04-13 21:17:05 -07:00
Huon Wilson
31b92b1b46 Merge pull request #8473 from huonw/symbol-list-2
Remove dependency on IRGenModule of some linkage computations
2017-04-05 16:39:04 -07:00
Doug Gregor
5c89eb84f0 [AST] Drop substitutions from type witnesses.
Nobody is using the actual substitutions, but we sure did a lot of
work to cope with them.
2017-04-05 11:21:38 -07:00
Huon Wilson
3105c6ed00 [IRGen] Expose LinkInfo publicly, like LinkEntity. 2017-04-05 09:54:19 -07:00
John McCall
3c5de5fa0a Preserve type canonicality better in several places and
idiomatize some uses of SILType::getSwiftRValueType().
2017-03-14 14:59:43 -04:00
John McCall
f0cc98a71e Adopt ConstantInitBuilder in reflection metadata emission. NFC. 2017-03-06 15:15:49 -05:00
Erik Eckstein
2d127e4192 Reinstate ”Use the new mangling for reflection."
It also uses the new mangling for type names in meta-data (except for top-level non-generic classes).
lldb has now support for new mangled metadata type names.

This reinstates commit 21ba292943.
2017-02-15 09:47:22 -08:00
Slava Pestov
5296d02485 AST: More include-what-you-use gardening 2017-02-12 00:51:26 -08:00
Erik Eckstein
254f36aba5 Revert "Use the new mangling for reflection."
This needs some changes in lldb.
Disabled for now until lldb supports the new mangling.

This reverts commit 21ba292943.
2017-02-08 09:01:51 -08:00
David Farler
1b141d368e Fix two more duplicate case llvm::Triple::Wasm 2017-02-07 17:20:00 -08:00
Hugh Bellamy
86d204c6fe Merge pull request #7052 from hughbe/object-model
Fix warnings for llvm::Triple::Wasm after updating LLVM to upstream
2017-02-08 08:01:55 +07:00
Erik Eckstein
21ba292943 Use the new mangling for reflection.
For this we are linking the new re-mangler instead of the old one into the swift runtime library.
Also we are linking the new de-mangling into the swift runtime library.

It also switches to the new mangling for class names of generic swift classes in the metadata.
Note that for non-generic class we still have to use the old mangling, because the ObjC runtime in the OS depends on it (it de-mangles the class names).
But names of generic classes are not handled by the ObjC runtime anyway, so there should be no problem to change the mangling for those.
The reason for this change is that it avoids linking the old re-mangler into the runtime library.
2017-02-07 08:36:21 -08:00
Slava Pestov
36433f126e IRGen: Fix some non-exhaustive switch warnings 2017-02-06 22:39:26 -08:00
Slava Pestov
3519e0cd25 AST: Introduce new SubstitutionList type to replace ArrayRef<Substitution>
SubstitutionList is going to be a more compact representation of
a SubstitutionMap, suitable for inline allocation inside another
object.

For now, it's just a typedef for ArrayRef<Substitution>.
2017-02-06 21:36:33 -08:00
Hugh Bellamy
35eaf68461 Fix warnings for llvm::Triple::Wasm after updating LLVM to upstream
> warning C4062: enumerator 'llvm::Triple::Wasm' in switch of enum
'llvm::Triple::ObjectFormatType' is not handled
2017-01-26 10:12:23 +00:00