Commit Graph

747 Commits

Author SHA1 Message Date
Joe Groff
76114d7f8a SILGen: Use dynamic thunk as the vtable entry of dynamic overrides.
If a dynamic definition overrides a non-dynamic one, then we need to go through objc_msgSend even if we try vtable dispatch on the non-dynamic superclass definition. Also, if we have a dynamic definition that doesn't override, we don't need a vtable entry for it at all.

Swift SVN r19944
2014-07-14 20:29:47 +00:00
Joe Groff
eaf84f5f0e SILGen: Use the 'dynamic' attribute to decide whether to emit ObjC dispatches.
When -enable-dynamic is passed, only require ObjC dispatch for 'dynamic' methods and accessors instead of for all @objc entities.

Swift SVN r19839
2014-07-11 00:12:25 +00:00
Chris Lattner
5b49d59c57 Remove the @ from @final and @lazy, the last major piece of
rdar://17168115.

Also, reinstate the ARM driver change and testcase that I removed
in my last patch.


Swift SVN r19790
2014-07-10 06:23:27 +00:00
Chris Lattner
02999cac51 Reinstate the @ on the @objc attribute. This is largely a revert of r19555 with a few tweaks.
Swift SVN r19706
2014-07-08 21:50:34 +00:00
Joe Groff
9f4c417095 SIL: Forward-declare witness tables with correct linkage.
Fixes <rdar://problem/16997968>.

Swift SVN r19680
2014-07-08 05:30:35 +00:00
Chris Lattner
7a56499d61 Start making @objc not start with an @ sign:
- Change the parser to accept "objc" without an @ sign as a contextual
   keyword, including the dance to handle the general parenthesized case.
 - Update all comments to refer to "objc" instead of "@objc".
 - Update all diagnostics accordingly.
 - Update all tests that fail due to the diagnostics change.
 - Switch the stdlib to use the new syntax.

This does not switch all tests to use the new syntax, nor does it warn about
the old syntax yet.  That will be forthcoming.  Also, this needs a bit of 
refactoring, which will be coming up.



Swift SVN r19555
2014-07-04 05:57:57 +00:00
Bob Wilson
2df66cf8c4 Implement inline scopes for the performance inliner.
Mandatory-inlined (aka transparent functions) are still treated as if they
had the location and scope of the call site. <rdar://problem/14845844>
Support inline scopes once we have an optimizing SIL-based inliner

Patch by Adrian Prantl.

Swift SVN r18835
2014-06-12 19:48:43 +00:00
Sean Callanan
d4c83c8f88 This patch makes it easier for the debugger to
insert the values for variables into the SIL for
expressions correctly. 

Instead of hijacking emitLValueForDecl() in
SILGenFunction, we now hook into
emitInitializationForVarDecl.  That way we can
emit the proper value and just stick it into
VarLocs.

To support this, we also make two other changes:

- We suppress marking the variable uninitialized
  in MarkPatternUninitialized::visitNamedPattern.

- We override DeclChecker in the type checker to
  allow LLDB to construct let statements without
  initializers.


Swift SVN r18676
2014-05-30 22:13:59 +00:00
Chris Lattner
761c627b38 Rework SILGenFunction::emitInitializationForVarDecl to make sure that
weak/unowned global variables get emitted with a
ReferenceStorageInitialization.  This fixes test/DebugInfo/attributes.swift



Swift SVN r17856
2014-05-10 23:54:20 +00:00
Chris Lattner
368fdd67b5 rearrange the order in which we set up initializations, so that
'unowned let' initializations don't drop their ReferenceStorageInitialization
transformation.  This defines away another class of problems related to weak and
unowned pointers, and allows us to remove a hack added to paper over rdar://16681656.


Swift SVN r17846
2014-05-10 21:09:54 +00:00
Joe Groff
3dda4c9cf5 SILGen: Reference ObjC initializers and factories through foreign-to-native thunks.
Eliminate the duplicate half-broken bridging logic in emitClassConstructorAllocator by referencing foreign initializers through their foreign-to-native thunks, which SILGen knows how to emit already. Do the same thing for factory initializers by suppressing their normal allocating initializer codegen and just referencing the usual foreign-to-native thunk for them. This fixes <rdar://problem/16853205> because we get the ownership thunking right now.

Swift SVN r17840
2014-05-10 20:18:53 +00:00
Argyrios Kyrtzidis
19aeaf94fc Fully embrace ParamDecls instead of AnyPattern at function creation time, thus removing the need to create param decls at SILGen or Sema.
Swift SVN r17829
2014-05-10 18:23:50 +00:00
Michael Gottesman
a7bb61265c [deserialization] Tighten up deserialization of witness tables.
We now enforce via an assert that each witness table is unique and that
every protocol conformance that is referenceable from SIL must have a
witness table matched to it.

Also, I taught the linker that it should deserialize witness tables for
InitExistentialRefInst instructions, something that was missed before.

Swift SVN r17283
2014-05-02 22:28:13 +00:00
Doug Gregor
b46e6cc5b7 Suppress Swift vtable entries for getters/setters of @NSManaged properties.
This finishes up the functional behavior of
<rdar://problem/16736676>. Some QoI remains.


Swift SVN r17209
2014-05-01 23:30:04 +00:00
Doug Gregor
af1f5b7baf Don't emit @objc thunks for @NSManaged properties.
Another part of <rdar://problem/16736676>.

Swift SVN r17197
2014-05-01 22:42:55 +00:00
Doug Gregor
f2e331f6ed Don't emit @objc thunks for @NSManaged properties.
Another part of <rdar://problem/16736676>.

Swift SVN r17194
2014-05-01 22:24:32 +00:00
Doug Gregor
3d3ff6811a Add a pile of missing #includes exposed by pruning includes in top-of-tree LLVM.
Swift SVN r17157
2014-05-01 14:26:34 +00:00
Chris Lattner
371a9316f4 - Introduce a new 'nonmutating' context sensitive keyword, and use it instead of @!mutating.
- Change the parser to unconditionally reject @mutating and @!mutating with a fixit and 
  specific diagnostic to rewrite them into the [non]mutating keyword.
- Update tests.

This resolves <rdar://problem/16735619> introduce nonmutating CS keyword and remove the attribute form of mutating all together



Swift SVN r16892
2014-04-26 21:00:06 +00:00
Manman Ren
480b41c824 [SIL Vtable emission] use the least derived method in sil_vtable.
Given base class A and dervied class B, both with member functions f(),
to look for A.f in B's vtable, we should return SILFunction for B.f.

Before this commit, B's vtable will have entry for B.f, A's vtable will
have entry for A.f. When looking for A.f in B's vtable, it returns null.
And devirtualizer will look for A.f in A's vtable and resolve it to
SILFunction for A.f.

When replacing a class_method %1 : $A, #A.f!1 with a function ref to B.f,
we will have type checking issues for the apply instructions. So devirtualizer
will replace the argument of the apply instructions when necessary.

rdar://16681983


Swift SVN r16854
2014-04-25 23:42:12 +00:00
John McCall
8681963bcb A couple of long-overdue renames.
Builtin.ObjectPointer -> Builtin.NativeObject
Builtin.ObjCPointer -> Builtin.UnknownObject

Swift SVN r16634
2014-04-22 00:17:08 +00:00
Joe Groff
c73acc67f2 SIL: Add an "UnownedInnerPointer" result convention.
This will represent the return convention of imported __attribute__((objc_returns_inner_pointer)) methods. Leave it unimplemented for now until we can autorelease things sanely.

Swift SVN r16628
2014-04-21 21:57:13 +00:00
Doug Gregor
e80f99ad57 Teach SILGen to build ParamDecls, too.
Swift SVN r16594
2014-04-20 19:05:03 +00:00
Doug Gregor
09797f7f99 Introduce a new declaration node, ParamDecl, for function parameters.
Use this node to capture the argument name and its source location in
the AST. We're only building these in one place at the moment; the
rest will be updated soon.


Swift SVN r16581
2014-04-20 05:23:35 +00:00
Dmitri Hrybenko
e2e8db5f38 Migrate IB attributes to new decl attribute representation and fix a few bugs
along the way


Swift SVN r16542
2014-04-18 20:00:09 +00:00
Doug Gregor
8bc2ea4ea1 Use designated/convenience initializer terminology throughout. NFC
Introduce CtorInitializerKind to describe the kind of an enum, rather
than a bool, to make way for more initializer kinds in the future.

Swift SVN r16525
2014-04-18 15:10:13 +00:00
Joe Groff
e245f9ee89 SILGen: Thunk blocks into native Swift functions when bridging into Swift.
Emit Swift thunk functions to bridge blocks into native function values. On entry into @objc thunks, copy_block blocks to ensure they've been lifted off the stack.

Swift SVN r16177
2014-04-10 22:35:42 +00:00
Joe Groff
d149851607 SILGen: Copy blocks received as function arguments.
We want to generally treat blocks as heap objects until proven stack-able by escape analysis, like we do generally with other heap entities. The only place we should be exposed to stack blocks is when they're passed as arguments, so handle this by copy_block'ing any block arguments we get in the function prolog. Optimization can eliminate them when analysis shows the block doesn't escape or is already on the heap.

Swift SVN r16096
2014-04-09 04:35:17 +00:00
John McCall
372d6513bb Don't propagate let-binding Initializations down into
conditional-executed initializers.

Swift SVN r16033
2014-04-08 01:12:56 +00:00
John McCall
62844f58b6 Emit storage and (lazy) global initialization for static
variables in extensions of non-generic structs and enums.

rdar://16520242

Swift SVN r15957
2014-04-04 21:42:17 +00:00
Chris Lattner
e6aef8e980 enhance silgen and IRGen to not emit vtable entries for non-overriding @final members
Swift SVN r15929
2014-04-04 05:32:53 +00:00
Chris Lattner
afea47b621 rename "destroy_value" to "release_value", part of rdar://15889208.
Swift SVN r15777
2014-04-02 05:33:52 +00:00
Chris Lattner
6540423613 rename CopyValueInst -> RetainValueInst. The .sil syntax
isn't changed yet.


Swift SVN r15775
2014-04-02 05:11:31 +00:00
Joe Groff
584009d27e SIL: Remove copy_value's result.
We won't have any types where copying has an effect on the bit pattern (except for blocks, which need special handling anyway), and copy_value having a result makes optimizations more complex, so remove it.

Swift SVN r15640
2014-03-30 03:40:45 +00:00
John McCall
71381ccdca Petty optimization that I noticed while doing significant
work in this file that turned out to be unnecessary.

Swift SVN r15573
2014-03-28 05:39:24 +00:00
Joe Groff
9ab2005b43 SILGen: Verify protocol witnesses after they're emitted.
Swift SVN r15351
2014-03-21 23:47:05 +00:00
Joe Groff
03a7b98806 SILGen/IRGen: Don't emit redundant witness thunks for @objc protocol witnesses that are already @objc.
If an extension introduces an @objc protocol conformance using existing methods that are already @objc, then we shouldn't emit @objc thunks for them again, and indeed, we can't for native ObjC classes. Fixes <rdar://problem/16330856>.

Swift SVN r15087
2014-03-14 22:48:59 +00:00
Joe Groff
e0c34d9fcc SILGen: 'cast' -> 'dyn_cast' in SILGenExtension::emitObjCConformanceThunks.
Allows @objc protocol property requirements to work with existing properties of a class, fixing the immediate problem in <rdar://problem/16284654> and <rdar://problem/16284574> (though there's a still a problem adopting methods of natively ObjC classes as protocol conformances, <rdar://problem/16330856>).

Swift SVN r15078
2014-03-14 22:00:04 +00:00
Joe Groff
9645e66029 SILGen: Properly handle generic substitution when calling [super dealloc] from a generic @objc grandchild class.
Swift SVN r15077
2014-03-14 21:19:26 +00:00
Joe Groff
8b82082920 SILGen: Properly carry through generic arguments when producing ObjC thunks.
We can't assume that ObjC types aren't generic anymore because container bridging requires generic subclasses of ObjC types, so remove the assertions that ObjC entry points are never generic and properly handle interface type substitution when emitting thunks.

Swift SVN r15073
2014-03-14 20:43:22 +00:00
Chris Lattner
52379cea20 Properly compute the override set for accessors in subscripts
and properties, allowing us to set up vtables properly.  Before
this patch, we'd get new entries in the derived class vtable for
overridden property accessors, which didn't help things.

This is progress along the way towards fixing:
<rdar://problem/16310561> Property vtables not set up correctly
but isn't the full story.  Dispatch is still not going through the vtable,
so we get the wrong behavior still.


This patch also exposes a totally mystifying (to me) problem with the deserializer.
A test is temporarily disabled because of this.




Swift SVN r15051
2014-03-14 16:36:37 +00:00
Chris Lattner
4543a345c1 remove some fixme's.
Swift SVN r14993
2014-03-13 06:02:22 +00:00
Joe Groff
c5feea4697 SILGen: Emit conformances for external definitions.
Teach IRGen to honor the linkage of SILWitnessTables, and teach SILGen to emit witness tables and protocol witness thunks for external definitions with shared linkage. Fixes <rdar://problem/16264703>.

Swift SVN r14908
2014-03-11 05:08:58 +00:00
Joe Groff
945fbaf167 SIL: Add a linkage specifier to SILWitnessTables.
In the short term, we need to be able to emit shared symbols for SILWitnessTables corresponding to Clang-imported modules, and soon, the generic specializer will need to be able to reference *_external witness tables deserialized from library modules.

Swift SVN r14887
2014-03-10 23:14:16 +00:00
Joe Groff
8e2521e8c2 SILGen: Emit derived '==' operators from Clang modules with shared linkage.
In Sema, give derived '==' definitions the module's DerivedFileUnit as their decl context instead of the more general Module, and give it a backreference to the nominal type for which it was derived. 
In SILGen, visit the derived global decls associated with Clang-imported enums, and give them shared linkage. Part of fixing <rdar://problem/16264703>.

Swift SVN r14875
2014-03-10 20:33:54 +00:00
Doug Gregor
15be2159a2 Rename "abstract initializers" to "required initializers".
It's better than what we have.

Swift SVN r14620
2014-03-03 23:12:40 +00:00
Dmitri Hrybenko
ba6548b072 Track uptstream LLVM API change: llvm::tie() was removed, use std::tie() instead
Swift SVN r14573
2014-03-02 13:53:19 +00:00
Doug Gregor
aa337d4899 Start emitting vtable entries for
Swift SVN r14565
2014-03-02 05:39:15 +00:00
Joe Groff
8e6b353542 Derive conformances of Equatable and Hashable for simple enums.
If an enum has no cases with payloads, make it implicitly Equatable and Hashable, and derive default implementations of '==' and 'hashValue'. Insert the derived '==' into module context wrapped in a new DerivedFileUnit kind, and arrange for it to be codegenned with the deriving EnumDecl by adding a 'DerivedOperatorDecls' array to NominalTypeDecls that gets visited at SILGen time.

Swift SVN r14471
2014-02-27 20:28:38 +00:00
Chris Lattner
1344319677 Rename the internal compiler lexicon from val -> let.
Swift SVN r14408
2014-02-26 21:21:18 +00:00
Doug Gregor
ea16062f75 Basic SILGen support for initializer requirements.
Emit witnesses for initializer requirements. Allow the use of
initializer requirements on archetypes; existentials don't work due to
<rdar://problem/16165890>.


Swift SVN r14356
2014-02-25 23:06:33 +00:00