Commit Graph

2062 Commits

Author SHA1 Message Date
Michael Gottesman
800ea37c34 Revert r13036 as per Joe's request.
Swift SVN r13063
2014-01-28 21:36:06 +00:00
Joe Groff
5d58f10e48 SIL: Make ContextGenericParams a constructor parameter of SILFunction.
Edge SILFunction one step closer to independence from SILFunctionType context by taking the generic param list as a separate constructor parameter, and serializing those params alongside the function record. For now we still pass in the context params from the SILFunctionType in most cases, because the logic for finding the generic params tends to be entangled in type lowering, but this pushes the problem up a step.

Thanks Jordan for helping work out the serialization changes needed.

Swift SVN r13036
2014-01-28 02:17:46 +00:00
Manman Ren
eaad8df51a SILSerializer: handle SILWitnessTable.
We add two records in sil_block to specify a witness table record and a method
entry record. Out of the four entry types, only "Method" is handled in this
commit.

Two records are also added to sil_index_block to search for a specific witness
table given a unique identifier. The interface lookupWitnessTable is not
implemented yet.

Right now, we serialize a witness table only when sil-serialize-all is on and
deserialize all witness tables in the module when sil-link-all is on.

rdar://15722175


Swift SVN r13000
2014-01-27 19:30:43 +00:00
John McCall
f416dd81a8 Track whether a PatternBindingDecl theoretically
declares storage or not.

Swift SVN r12942
2014-01-24 22:46:22 +00:00
Jordan Rose
cc3119be51 Teach the Mach-O-based AST importer to accept bare serialized ASTs.
This necessitated adding a new function to validate a serialized AST, so
that we can get the same information that used to be extracted from the
section header.

For now, we'll continue accepting the wrapped ASTs as well, since we
haven't changed the existing debug info generator.

Swift SVN r12922
2014-01-24 18:42:07 +00:00
Jordan Rose
af700a1912 [serialization] Include the module name in the serialized AST data.
We don't currently use this for anything, but if we have the module name
available and easy to access in the bitstream, we can drop the wrapper
around the serialized AST that's put into the binary itself for use by LLDB.

Swift SVN r12921
2014-01-24 18:42:06 +00:00
Jordan Rose
f214e2f185 [serialization] Include the module name in the serialized AST data.
We don't currently use this for anything, but if we have the module name
available and easy to access in the bitstream, we can drop the wrapper
around the serialized AST that's put into the binary itself for use by LLDB.

Swift SVN r12919
2014-01-24 18:42:03 +00:00
Joe Groff
a17654a7dd Serialization: Serialize the conformances of InitExistential*Inst.
Swift SVN r12847
2014-01-23 03:58:43 +00:00
Jordan Rose
c312e51962 Add the ability to serialize modules with LLDB's wrapper info around them.
Currently when compiling with debug info, the AST gets serialized into the
.o file for use by the debugger. However, when we switch to one .o file
per .swift file, this won't really make sense any more. Instead, we should
collect all the ASTs at the end of the build and merge them together, then
write /that/ into the final binary.

This commit handles writing a serialized AST with an LLDB wrapper around it,
so that we can take a merged AST, write it out in the wrapper, and splice it
into the final binary using ld's -sectcreate option.

In the long run, we probably won't need the LLDB wrapper, but for now I'm
trying to disturb as little as possible. (It looks like the layout is
broken on 32-bit platforms, though...there was a problem with 64-bit
relocations in the existing SwiftASTStreamerPass, but nothing ever tried to
/read/ the new layout in 32 bits. I'm holding off on dealing with this
right now.)

Part of <rdar://problem/15786017>

Swift SVN r12667
2014-01-21 23:13:26 +00:00
Joe Groff
0776c4b6b8 SIL: Reorient function type lowering toward interface types.
Lower types for SILDeclRefs from the interface types of their referents, dragging the old type along for the ride so we can still offer the context to clients that haven't been weaned off of it. Make SILFunctionType's interface types and generic signature independent arguments of its  Derive the context types of SILFunctionType from the interface types, instead of the other way around. Do a bunch of annoying inseparable work in the AST and IRGen to accommodate the switchover.

Swift SVN r12536
2014-01-18 19:42:02 +00:00
Jordan Rose
11008f0ed1 Split diagnostics out into separate files.
Thanks to the way we've set up our diagnostics engine, there's not actually
a reason for /everything/ to get rebuilt when /one/ diagnostic changes.
I've split them up into five categories for now: Parse, Sema, SIL, IRGen,
and Frontend, plus a set of "Common" diagnostics that are used in multiple
areas of the compiler. We can massage this later.

No functionality change, but should speed up compile times!

Swift SVN r12438
2014-01-17 00:15:12 +00:00
Doug Gregor
caf474fb72 We already serialize the requires_stored_property_inits attribute.
Swift SVN r12245
2014-01-13 21:14:15 +00:00
Doug Gregor
a534f6978a Add a new class attribute requires_stored_property_inits.
This attribute states that all stored properties within the class must
provide initial values. This will allow us to move stored property
initialization into Objective-C's post-allocation initialization hook,
.cxx_construct.

Swift SVN r12228
2014-01-13 16:31:22 +00:00
John McCall
1bc1c669a2 Add the '@unchecked T?' syntactic sugar for UncheckedOptional<T>.
Swift SVN r12128
2014-01-10 19:13:51 +00:00
Manman Ren
ce642b89f7 Move printing of DeclAttributes from PrintAST::printAttributes to
DeclAttributes::print.

Also add printing of mutating to the print functions.
In serializer, print out the unhandled attributes.


Swift SVN r12073
2014-01-08 23:44:05 +00:00
Joe Groff
44fb729830 SIL: Use only interface types in the verifier.
Treat the interface types of SILFunctionTypes as the canonical representation in the verifier. Do a bunch of supporting and annoyingly irreducible work to enable this:

- Stop trying to uncurry generic parameter lists during type lowering and preserve the structure of AST GenericParamLists. This makes mapping dependent types into contexts easier.
- Properly walk generic parameter lists at all depths when grooming substitution vectors for use with substGenericArgs interfaces.
- Reseat the generic parameter lists created for protocol_method results so that we don't expect the outer Self archetype to be unbound; it's provided by the extra data of the result.
- Hack SILFunctionType serialization never to use a decl reference when serializing its generic param list. When this happens, we get incorrect archetypes. This is a gross hack, but when we're able to jump all the way to interface types, it can go away.

Putting these ducks in a row nicely un-XFAILs TextFormatting.swift.

Swift SVN r11989
2014-01-07 06:50:20 +00:00
Manman Ren
baf7645af8 Use SmallVector's constructor to initialize it to an array of null pointers.
Swift SVN r11947
2014-01-06 20:28:17 +00:00
Manman Ren
59c45c4da2 Serialization: for archetypes, use an array of null pointers for conformances.
For archetypes the conformance information is context dependent, the conformance
array is either empty or full of nulls and can be ignored. We uniform the two
cases by passing in an array of null pointers to writeConformances.

rdar://15693816


Swift SVN r11940
2014-01-06 19:47:02 +00:00
Manman Ren
93243ca683 SIL serialization: do not use attribute field for cast kind.
Attribute field is a fixed 2-bit field, but cast kind exceeds 4,
so using 2-bit attribute field for cast kind will cause overflow.
The fix is to add a record for the cast instruction with a 4-bit
kind field instead of a 2-bit attribute field.


Swift SVN r11938
2014-01-06 19:35:29 +00:00
Joe Groff
8bebb084e6 Rename 'RequirementKind::ValueWitnessMarker' to 'WitnessMarker'.
It's witnessing protocol requirements, not values, and "value witness" has a particular meaning in IRGen.

Swift SVN r11814
2014-01-02 17:47:40 +00:00
Chris Lattner
7f3ece324e Fix serialization of var patterns.
Swift SVN r11771
2013-12-31 07:17:16 +00:00
Chris Lattner
9ae289de46 Drive the semantic wedge harder into lvalues. Now, instead of having one LValueType
with qualifiers on it, we have two distinct types:
 - LValueType(T) aka @lvalue T, which is used for mutable values on the LHS of an
   assignment in the typechecker.
 - InOutType(T) aka @inout T, which is used for @inout arguments, and the implicit
   @inout self argument of mutable methods on value types.  This type is also used
   at the SIL level for address types.

While I detangled a number of cases that were checking for LValueType (without checking
qualifiers) and only meant @inout or @lvalue, there is more to be done here.  Notably,
getRValueType() still strips @inout, which is totally and unbearably wrong.



Swift SVN r11727
2013-12-29 22:23:11 +00:00
Doug Gregor
1482256a04 Make operator methods to module-scope name lookup.
Fixes the operator name lookup issue in <rdar://problem/15715996>.

Swift SVN r11724
2013-12-29 20:41:07 +00:00
Chris Lattner
d3c91387e9 Substantially simplify the API to LValueType now that nonsettable is gone.
Swift SVN r11703
2013-12-28 22:48:44 +00:00
Chris Lattner
d7621b5a7b Remove the concept of a "nonsettable lvalue": Now everything that is
nonsettable is represented as an rvalue.  Yay for one less concept in
the AST.


Swift SVN r11640
2013-12-25 22:20:01 +00:00
Joe Groff
63d08c786d SIL: Handle metatype abstraction differences.
Lower metatype types as @thin or @thick based on whether the type is static and whether the abstraction pattern allows for a thin metatype. Add a '@thick' attribute and require SIL metatypes to always be annotated with either '@thin' or '@thick' to distinguish them from unlowered metatypes.

Swift SVN r11525
2013-12-20 23:06:16 +00:00
Doug Gregor
be3463f32d Store a file-level DeclContext* in protocol conformances rather than a module.
We'll need to perform name lookup based on the file-level
DeclContext*, so the module no longer suffices. No functionality
change here yet.


Swift SVN r11523
2013-12-20 22:53:21 +00:00
Jordan Rose
f1ff340367 Move the "conformances" array from TypeDecl to NominalTypeDecl.
No functionality change, but a nice limiting of scope.

Swift SVN r11489
2013-12-19 23:25:07 +00:00
Jordan Rose
7a30de2efe Disallow inheritance clauses for concrete typealiases.
typealias MyInt: ForwardIndex = Int

There is no real reason to allow this; it's just a static_assert that Int
conforms to ForwardIndex, which would be better spelled some other way.

This only applies to concrete typealiases, i.e. those that simply alias an
underlying type. Associated types can still have both inheritance clauses
and a (default) underlying type.

Swift SVN r11481
2013-12-19 21:13:54 +00:00
Joe Groff
017440165e Fix the weird capitalization of MetaTypeType.
Swift SVN r11475
2013-12-19 18:43:08 +00:00
Chris Lattner
42d0fdadcf - Introduce the ability for attributes to be inverted with !.
- Switch @mutable to be a tri-state attribute that is invertable with @!mutable.
- Move the semantic form of 'mutable' to being a bit on FuncDecl instead of
  something in DeclAttrs.  The former is a binary bit, the later is a tristate
  which differentiates between "not present", "present and set" "present and inverted".
- Diagnose some invalid uses of @mutable, e.g. on class methods.
- Make setters default to mutable, and allow them to be switched with @!mutable.



Swift SVN r11439
2013-12-18 21:38:53 +00:00
Doug Gregor
ec4913b0ea Implement default definitions for associated types.
Addresses <rdar://problem/14292873>.


Swift SVN r11422
2013-12-18 06:24:53 +00:00
Chris Lattner
51862b91fd rename the inout decl attribute (not the type attribute) to @mutating.
Swift SVN r11416
2013-12-18 04:44:56 +00:00
Jordan Rose
531b240ca0 [serialization] Rework cross-references to be more general / more robust.
Previously, cross-references just carried a chain of identifiers and a
top-level module, plus a type to validate against, a generic parameter index,
or an operator fixity. However, referencing "the first generic parameter
of the prefix function ++ that takes a ForwardIndex" requires /all three/
of these filters to unambiguously select the right declaration.

Now, cross-references consist of a chain of trailing records, one for each
link in the path. There are (currently) five kinds of links:

Type: a declaration that cannot have overloads
Value: a declaration that can have overloads (filtered by type)
Extension: filter to decls within extensions on another module
Operator:
- as the first path piece, an operator declaration
- as a later path piece, a fixity filter for operator functions
Generic Param: an indexed generic parameter of the previous result

This should allow us to uniquely cross-reference any Swift declaration we
need to.

Swift SVN r11399
2013-12-17 23:03:34 +00:00
Doug Gregor
2d75ca2adf Add a LazyResolver to ProtocolConformance::getWitness().
Swift SVN r11331
2013-12-15 19:40:49 +00:00
Doug Gregor
07c0793e30 Construct the type witnesses of SpecializedProtocolConformance lazily.
A SpecializedProtocolConformance intentionally contains all of the
information we need to synthesize the type witnesses from the
underlying (generic) conformance. Do so lazily rather than eagerly,
because we won't always need all of them.

As a nice side effect, we no longer need to serialize the witnesses of
these specialized protocol conformances, so we can save some space in
the Swift module file.


Swift SVN r11303
2013-12-14 06:20:44 +00:00
Doug Gregor
1b161ff043 Eliminate ProtocolConformance::getTypeWitnesses().
Swift SVN r11301
2013-12-14 05:19:18 +00:00
Chris Lattner
281cd524b7 recommit @inout attributes, now with serialization support.
Swift SVN r11286
2013-12-14 01:17:35 +00:00
Doug Gregor
b4a739854d Stop using ProtocolConformance::getWitnesses().
It's going away, soon.


Swift SVN r11277
2013-12-13 23:44:42 +00:00
Doug Gregor
fadebe02bb Stop using ProtocolConformance::getTypeWitnesses() almost everywhere.
In doing so, make serialization more deterministic. It was depending
on DenseMap ordering for both type and value witnesses. Now, serialize
the witnesses in the declaration order of the requirements.


Swift SVN r11267
2013-12-13 21:31:57 +00:00
Jordan Rose
f29f083fcb [serialization] Stop eagerly deserializing decls with conversion functions.
There shouldn't ever be a reason to do this: if a conversion function is
ever selected by the type-checker, it's because the type the conversion
lives on was suggested by another constraint, which means we can do a
normal lookup for the conversion function.

This is actually the only thing being eagerly deserialized, so remove the
notion of eager deserialization altogether.

Swift SVN r11220
2013-12-12 23:31:16 +00:00
John McCall
0bfa86673f Introduce (but don't yet create) a new kind of DeclContext for
various kinds of expressions that appear outside of local
evaluation contexts.

Swift SVN r11176
2013-12-12 03:36:17 +00:00
Chris Lattner
698380d6d3 Introduce a new bit in VarDecl, "isLet". Teach Sema that 'isLet' properties
are not settable (like get-only ones).  Set the 'isLet' bit in various 
places, but not the particularly interesting or useful places yet.



Swift SVN r11121
2013-12-11 06:45:40 +00:00
Jordan Rose
fac5659813 [serialization] Sprinkle PrettyStackTrace throughout deserialization code.
Since we don't have soft-failure yet from deserialization, it's helpful to
at least know where to start looking when something crashes. There are some
rough edges here but it should be much better than nothing.

This also pulls the list of record nodes out into a separate file, so that
we can avoid repeating it.

Example crash:
1.	While reading from ./CTypes.swiftmodule
2.	While deserializing 'CBool' (StructDecl)
3.	While deserializing decl #26 (XREF)
4.	Cross-reference to 'LogicValue' in swift
(don't worry, this is an example where I'm tweaking things)

<rdar://problem/14838332>

Swift SVN r11057
2013-12-10 00:23:40 +00:00
Argyrios Kyrtzidis
55e2792f10 Serialize @IBLiveView attribute.
Swift SVN r10959
2013-12-07 00:41:58 +00:00
Argyrios Kyrtzidis
12161a10cf Introduce @IBLiveView attribute, only applicable to classes.
rdar://15586673

Swift SVN r10954
2013-12-07 00:14:53 +00:00
Argyrios Kyrtzidis
345564380c Rename 'ibaction/iboutlet' attributes to 'IBAction/IBOutlet'.
Swift SVN r10953
2013-12-07 00:14:51 +00:00
Anna Zaks
378a425dba Allow @transparent on computed VarDecls.
Addresses radar://15489270. This is mainly a convenience enhancement.

Swift SVN r10943
2013-12-06 22:10:44 +00:00
Joe Groff
0ff977d407 Add a 'WitnessMethod' enumerator to AbstractCC.
We'll use this to represent the slightly-different polymorphic calling convention used for passing Self into protocol witnesses.

Swift SVN r10898
2013-12-06 01:32:35 +00:00
Manman Ren
395b8f4eda SILSerializer: handle sil_global and sil_global_addr.
Always serialize global variables and deserialize a global variable lazily
when deserializing SILGlobalAddr.

rdar://15493552


Swift SVN r10884
2013-12-05 21:56:02 +00:00