Commit Graph

916 Commits

Author SHA1 Message Date
Bob Wilson
45317fc03e Merge branch 'master' into master-next 2017-05-08 23:44:23 -07:00
Erik Eckstein
b1d5c77cec Runtime support for the NSArchiver class attributes.
Register class names for NSKeyedArchiver and NSKeyedUnarchiver based on the @NSKeyedArchiveLegacy and @_staticInitializeObjCMetadata class attributes.

@NSKeyedArchiveLegacy registers a class name translation.
@_staticInitializeObjCMetadata just makes sure that the metadata of a class is instantiated.

This registration code is executed as a static initializer, like a C++ global constructor.
2017-05-08 14:00:03 -07:00
Bob Wilson
8d61e93e81 Adapt to LLVM r301812 rename of WeakVH to WeakTrackingVH 2017-05-07 22:25:49 -07:00
Bob Wilson
e24a6f1d30 Adjust addAttributes calls for LLVM r301981
These now take an AttrBuilder argument instead of an AttributeList.
2017-05-06 21:37:22 -07:00
swift-ci
1378be1c6d Merge remote-tracking branch 'origin/master' into master-next 2017-05-01 15:55:31 -07:00
Joe Shajrawi
0d0cac357a retain_value_addr and release_value_addr SIL instructions: take as an input an address, load the value inside it and call retain_value and release_value respectively 2017-04-30 10:23:55 -07:00
swift-ci
4ef7b46971 Merge remote-tracking branch 'origin/master' into master-next 2017-04-21 18:08:32 -07:00
Joe Groff
595e0e4ede Merge branch 'master' into keypaths 2017-04-19 18:38:24 -07:00
swift-ci
ae1eb1197c Merge remote-tracking branch 'origin/master' into master-next 2017-04-18 11:08:33 -07:00
Huon Wilson
53b4e7044f Merge pull request #8822 from huonw/symbol-list-5
Yet more TBDGen work: mostly classes.
2017-04-18 11:04:57 -07:00
swift-ci
3098fc666a Merge remote-tracking branch 'origin/master' into master-next 2017-04-18 10:28:41 -07:00
practicalswift
7eb7d5b109 [gardening] Fix 100 typos. 2017-04-18 17:01:42 +02:00
Joe Groff
aaddafa55b IRGen: Support for generic key path patterns. 2017-04-17 17:50:57 -07:00
Huon Wilson
d26c9791e5 [AST] Classes know their appropriate metaclass. 2017-04-17 11:28:55 -07:00
swift-ci
05aff8998a Merge remote-tracking branch 'origin/master' into master-next 2017-04-13 14:28:31 -07:00
Huon Wilson
22c9e20a9d [IRGen] Completely remove witness table offsets.
These are unused.
2017-04-13 11:44:01 -07:00
Joe Groff
d6ced9d9e4 SIL: Rework KeyPathInst to accommodate computed components.
- Separate out a uniquable KeyPathPattern that describes the context-free shape of the key path, with generic parameters and (eventually) subscript index slots factored out.
- Add component kinds for gettable and settable properties.
2017-04-12 20:09:17 -07:00
swift-ci
5ba89103a7 Merge remote-tracking branch 'origin/master' into master-next 2017-04-11 09:28:31 -07:00
Arnold Schwaighofer
b167b4475d Add SIL and IRGen support for a ConstantStringLiteral instruction
This supports a utf8 or utf16 encoding.

rdar://30545013
2017-04-11 08:43:47 -07:00
swift-ci
d7e80a5fe7 Merge remote-tracking branch 'origin/master' into master-next 2017-03-29 12:48:40 -07:00
Huon Wilson
655fa58620 [IRGen] Expose LinkEntity and ValueWitness publicly. 2017-03-23 15:58:29 -07:00
Saleem Abdulrasool
15565c116a Adjust for SVN r298393 2017-03-22 07:44:03 -07:00
Erik Eckstein
a16beaea3c Remove the now usused ConformanceCollector utility.
It was used for dead witness table elimination. But this is done now by lazy emission in IRGen.
Also update DeadFunctionElimination.
NFC.
2017-03-15 10:18:18 -07:00
Erik Eckstein
41c17a5b0c IRGen: emit type metadata and (value) witness tables lazily.
This gives big code size wins for unused types and also for types, which are never used in a generic context.
Also it reduces the amount of symbols in the symbol table.
The size wins heavily depend on the project. I have seen binary size reductions from 0 to 20% on real world projects.

rdar://problem/30119960
2017-03-10 12:50:43 -08:00
Arnold Schwaighofer
80732ead34 Non-witness implementations of init_existential_addr, deinit_existential_addr, open_existential_addr, copy_addr, destory_addr
For the boxed existential variant.
2017-03-09 17:22:35 -08:00
John McCall
d61d966451 Use ConstantInitBuilder in most kinds of metadata emission.
This is NFC in intent, but I had to restructure the code to emit more
of the lists "inline", which means I inevitably altered some IRGen
emission patterns in ways that are visible to tests:

- GenClass emits property/ivar/whatever descriptors in a somewhat
  different order.

- An ext method type list is now emitted as just an array, not a struct
  containing only that array.

- Protocol descriptors are no longer emitted as packed structs.

I was sorely tempted to stop using packed structs for all the metadata
emission, but didn't really want to update that many tests in one go.
2017-03-06 14:18:47 -05:00
John McCall
ec667cae55 Adopt ConstantInitBuilder in a few places. 2017-03-06 14:18:47 -05:00
John McCall
fe7915d09e Rework a number of SIL and IRGen witness-table abstractions
to correctly handle generalized protocol requirements.

The major missing pieces here are that the conformance search
algorithms in both the AST (type substitution) and IRGen
(witness table reference emission) need to be rewritten to
back-track requirement sources, and the AST needs to actually
represent this stuff in NormalProtocolConformances instead
of just doing ???.

The new generality isn't tested yet; I'm looking into that,
but I wanted to get the abstractions in place first.
2017-03-02 01:34:13 -05:00
Slava Pestov
18550b171d IRGen: witness_method function values no longer carry witness table
This was an unnecessary complication and didn't make a lot of
logical sense, because we can recover the witness table from
substitutions when we call a @convention(witness_method) anyway.

Also, to fix materializeForSet for generic subscripts, I want the
materializeForSet *callback* of a protocol witness to have
@convention(witness_method), which requires representing such
functions as a single function pointer in IRGen.
2017-02-25 16:42:51 -08:00
Erik Eckstein
8c99bf280a IRGen: remove an unused function 2017-02-22 09:19:10 -08:00
Arnold Schwaighofer
6c35202565 Conditionalize usage of llvm::CallingConv::Swift on SWIFT_USE_SWIFTCALL macro 2017-02-14 12:17:57 -08:00
Arnold Schwaighofer
39fa2f0228 Use the swift calling convention for swift functions
Use the generic type lowering algorithm described in
"docs/CallingConvention.rst#physical-lowering" to map from IRGen's explosion
type to the type expected by the ABI.

Change IRGen to use the swift calling convention (swiftcc) for native swift
functions.

Use the 'swiftself' attribute on self parameters and for closures contexts.

Use the 'swifterror' parameter for swift error parameters.

Change functions in the runtime that are called as native swift functions to use
the swift calling convention.

rdar://19978563
2017-02-14 12:17:57 -08:00
Doug Gregor
579af863c5 Rename ArchetypeBuilder -> GenericSignatureBuilder 2017-02-10 12:46:34 -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
Andrew Trick
1abeddcc5d [SILType] SILFunctionConventions API.
Separate formal lowered types from SIL types.
The SIL type of an argument will depend on the SIL module's conventions.
The module conventions are determined by the SIL stage and LangOpts.

Almost NFC, but specialized manglings are broken incidentally as a result of
fixes to the way passes handle book-keeping of aruments. The mangler is fixed in
the subsequent commit.

Otherwise, NFC is intended, but quite possible do to rewriting the logic in many
places.
2017-01-26 15:35:48 -08:00
Slava Pestov
7b5cf4ab7d Merge pull request #3841 from tinysun212/pr-swiftc-cygwin-2
[swiftc] Fixed for Cygwin
2017-01-19 20:17:47 -08:00
Erik Eckstein
89c9ff5ca0 SIL: ConformanceCollector utility for collecting all conformances which are used by a SIL instruction.
Also verify the correctness of ConformanceCollector in IRGen by checking if IRGen does not use a conformance which is not collected by the utility.
2017-01-19 09:41:09 -08:00
Han Sangjin
b8dd577693 [swiftc] Fixed for Cygwin
Fixed for the difference of Cygwin with other Windows variants (MSVC,
Itanium, MinGW).

- The platform name is renamed to "cygwin" from "windows" which is used
  for searching the standard libraries.

- The consideration for DLL storage class (DllExport/DllImport) is not
  required for Cygwin and MinGW. There is no problem when linking in
  these environment.

- Cygwin should use large memory model as default.(This may be changed
  if someone ports to 32bit)

- Cygwin and MinGW should use the autolink feature in the sameway of
  Linux due to the linker's limit.
2017-01-19 05:48:24 +09:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Hugh Bellamy
1aa951dfb2 Fix errors and warnings building swift/IRGen on Windows using MSVC (#5958) 2016-11-30 13:27:02 -08:00
Doug Gregor
d1066d16a2 [IRGen] Use a canonical generic environment rather than an archetype builder.
Rather than directly using the ArchetypeBuilder associated with a
canonical generic signature, use a canonical GenericEnvironment
associated with that canonical generic signature. This has a few
benefits:

* It's cleaner to not have IRGen working with archetype builders;
  GenericEnvironment is the right abstraction for mapping between
  dependent types and archetypes for a specific context.
* It helps us separate the archetype builder from a *specific*
  set of archetypes. This is an ongoing refactor that is intended to
  allow us to re-use archetype builders across different generic
  environments.

As part of this, ArchetypeBuilder::substDependentType() has gone away
in favor of GenericEnvironment::mapTypeIntoContext().
2016-11-29 09:24:27 -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
Slava Pestov
78d11de396 IRGen: Emit fixed type descriptors for structs and enums with @_alignment attributes
This attribute is used in the simd overlay. To ensure we can layout
SIMD types correctly, emit a fixed type descriptor instead of a
field type descriptor for these types.
2016-11-16 19:23:04 -08:00
Slava Pestov
7dbab3cc32 IRGen: Clean up reflection metadata emission
There was some duplication here, and also a potential
memory management issue; it appears that we were
converting a temporary std::string to a StringRef
when setting the section name of a global.
2016-09-24 02:17:45 -07:00
Slava Pestov
47d7cacb98 IRGen: Fix emission of builtin reflection descriptors in multi-threaded mode
Ensure they get emitted at the end of the job by the dispatcher, and
also use a proper mangling and shared linkage for these symbols so
that if multiple threads emit the same descriptor it gets merged.

The new tests attempt to exercise these scenarios.

Fixes <rdar://problem/27906876>.
2016-09-12 19:44:53 -07:00
David Farler
10c44e1a3a Always, no, never... forget to check your references
for weak semantics, that is!

94a9c512b9 made some changes to loading
weak references by adding some information in the lower bits with
respect to locking. These bits need to be masked out when performing a
load, such as when we want to get the metadata pointer for a class
instance. This normally works fine when going through the normal weak
loading functions in the runtime.

When the runtime function swift_ClassMirror_subscript gets the offset of
one of its stored properties, it immediately packages it into the the
ad-hoc existential container, known as just `Mirror` in the runtime.
However, the weak reference isn't aligned! It has bit 1 set.  We weren't
loading the weak reference here as we would during normal SILGen, such
as with a weak_load instruction. Simulate that here and make the
reference strong before putting it into the Mirror container, which also
clears those lower bits.

rdar://problem/27475034

There are still a couple of other cases to handle, namely the
unowned(safe) and unowned(unsafe) reference kinds. There may be other
places where an unaligned pointer is problematic in the runtime, which
we should audit for correctness.

rdar://problem/27809991
2016-08-16 11:43:58 -07:00
David Farler
fd46a60785 IRGen: Emit reflection metadata version into Swift binaries
Emit a 16-bit constant that tracks the version of the reflection
metadata emitted into binaries. This can be used to cross-check
what is supported by the SwiftRemoteMirror library with the new
version API.

rdar://problem/27251582
2016-07-08 17:21:25 -07:00
Slava Pestov
95bc009e3e Reflection: Multi-payload enum layout
The approach here is to split this into two cases:

- If all case payloads have a fixed size, spare bits may be
  potentially used to differentiate between cases, and the
  remote reflection library does not have enough information to
  compute the layout itself.

  However, the total size must be fixed, so IRGen just emits a
  builtin type descriptor (which I need to rename to 'fixed type
  descriptor' since these are also used for imported value types,
  and now, certain enums).

- If at least one case has a size that depends on a generic
  parameter or is a resilient type, IRGen does not know the size,
  but this means fancy tricks with spare bits cannot be used either.
  The remote reflection library uses the same approach as the
  runtime, basically taking the maximum of the payload size and
  alignment, and adding a tag byte.

As with single-payload enums, we produce a new kind of
RecordTypeInfo, this time with a field for every enum case.
All cases start at offset zero (but of course this might change,
if for example we put the enum tag before the address point).

Also, just as with single-payload enums, there is no remote
'project case index' operation on ReflectionContext yet.

So the the main benefit from this change is that we don't entirely
give up when doing layout of class instances containing enums;
however, tools still cannot look inside the enum values themselves,
except in the simplest cases involving optionals.

Notably, the remote reflection library finally understands all
of the standard library's collection types -- Array, Character,
Dictionary, Set, and String.
2016-07-01 01:31:25 -07:00
Joe Groff
22c4e08b96 IRGen: Fix TypeInfo for witness_method SIL values.
@convention(witness_method) values were changed to carry a pointer to their source witness table, but the type info wasn't changed to match. Fixing this fixes rdar://problem/26268544.
2016-06-14 10:22:37 -07:00
Slava Pestov
60dff01093 Reflection: Simplify associated type metadata emission
Instead of hooking into nominal type and extension emission
and walking all conformances of those declarations, let's
just directly hook into the logic for emitting conformances.

This fixes an issue where we would apparently emit duplicate
conformances, as well as unnecessary conformances that are
defined elsewhere.
2016-05-26 19:33:00 -07:00