Commit Graph

56 Commits

Author SHA1 Message Date
Erik Eckstein
14af3a57e8 Enable elimination of dead methods which are in classes of higher visibility.
The underlying problem is that e.g. even if a method is private but its class is public, the method can be referenced from another module - from the vtable of a derived class.
So far we handled this by setting the SILLinkage of such methods according to the visibility of the class. But this prevented dead method elimination.
Now I set the SILLinkage according to the visibility of the method. This enables dead method elimination, but it requires the following:
1) Still set the linkage in llvm so that it can be referenced from outside.
2) If the method is dead and eliminated, create a stub for it (which calls swift_reportMissingMethod).



Swift SVN r23889
2014-12-12 17:35:40 +00:00
Joe Groff
b60a30c84b stdlib: Make isUniquelyReferenced shims properly return bool.
rdar://problem/18573806 is fixed.

Swift SVN r23547
2014-11-22 05:36:38 +00:00
Dave Abrahams
2794fe3a13 [stdlib] Restore a combination of 11 commits
...but remove all new uses of closures, to make things easier on the
optimizer.

Swift SVN r23183
2014-11-08 20:04:29 +00:00
Dave Abrahams
c77d7e353c Revert a combination of 11 commits
These commits are suspected of causing performance regressions:

r22995, "[stdlib] Array nil state elimination, part trois"
r22994, "[stdlib] Array nil-state elimination II"
r22993, "[stdlib] Array nil-state elimination I"
r22992, "[stdlib] Still more nil buffer elimination"
r22991, "[stdlib] Nix an unneeded typealias"
r22988, "[stdlib] Nix _ContiguousArrayBuffer._base, part deux"
r22986, "[stdlib] Kill _ContiguousArrayBuffer._base, part I"
r22985, "[stdlib] destroy redundant property"
r22975, "[stdlib] More array nil-state destruction"
r22974, "[stdlib] Construct HeapBuffer without AnyObject"
r22959, "[stdlib] non-nil ContiguousArray"

Swift SVN r23001
2014-10-29 02:57:45 +00:00
Dave Abrahams
e7fb0ea3dd [stdlib] Array nil-state elimination II
Had to XFAIL one test: <rdar://problem/18800316>
SILPasses/array_mutable.swift test is fragile

Swift SVN r22994
2014-10-28 19:53:32 +00:00
Graham Batty
eaf22e9661 Make malloc_size a platform stub called swift_malloc_size.
Swift SVN r22971
2014-10-27 17:16:24 +00:00
Dave Abrahams
6daf5cf8dc [stdlib] Don't use AnyObject.self as ClassMetadata
Works around <rdar://problem/18777102>, and is smaller code to boot.

Swift SVN r22958
2014-10-27 04:45:46 +00:00
Dave Abrahams
4d2dff1501 [stdlib] HeapBuffer: no lying to the type system
Swift SVN r22833
2014-10-20 03:20:45 +00:00
Dave Abrahams
00e1b67279 Revert "[stdlib] HeapBuffer: no lying to the type system"
This reverts commit r22825, which I suspect of causing the
closure_multivalue failure at

Swift SVN r22832
2014-10-20 01:05:12 +00:00
Dave Abrahams
8119458acf [stdlib] HeapBuffer: no lying to the type system
Swift SVN r22825
2014-10-18 04:49:02 +00:00
Dave Abrahams
56c4cb2d42 [stdlib] Kill off _isUniquelyReferenced
It was doing an unsafeBitCast and possibly not managing lifetimes;
replace it with more-typesafe and memory-safe calls where possible.

Swift SVN r22779
2014-10-15 22:25:12 +00:00
Dave Abrahams
2d850421bc [stdlib] Internalize HeapBuffer[Storage], OnHeap
They were never really useful to users, because their APIs were
insufficiently public.  They have been replaced with a single class,
ManagedBuffer<Value,Element>, which is really designed for user
consumption.

Swift SVN r22636
2014-10-09 21:45:44 +00:00
Dave Abrahams
587c818c5b [stdlib] Use addressors in HeapBuffer
Swift SVN r22620
2014-10-09 13:30:02 +00:00
Dave Abrahams
74e27aaab1 [stdlib] uniqueness checking for users
Make unique reference checking available to users, making ManagedBuffer
a complete facility for building COW value types.  Also rationalize the
way we name and organize the runtime primitives we ultimately call.

Swift SVN r22594
2014-10-08 04:48:52 +00:00
Dave Abrahams
cc9bc0c274 [stdlib] Kill _swift_isUniquelyReferenced @asmname
Swift SVN r22576
2014-10-07 21:40:48 +00:00
Dave Abrahams
d1b6dfa48f [stdlib] pick off more public non-protocol docs
137 undocumented public non-operator APIs remain in core

Swift SVN r22253
2014-09-24 03:58:14 +00:00
Dave Abrahams
27809a507a [stdlib] Don't @asmname POSIX APIs
For reasons not entirely clear yet, this can cause problems in the
compiler when some modules bring in the same names via the Darwin
module (see <rdar://problem/18184795>).  Use SwiftShims instead.

Swift SVN r21646
2014-09-02 17:26:03 +00:00
Dave Abrahams
a45cb59747 [stdlib] Eliminate some gratuitous @objc labels
Swift SVN r21511
2014-08-28 02:03:31 +00:00
Dave Abrahams
18dac28aea [stdlib] Eliminate HeapBufferStorageBase
It's just needless complexity

Swift SVN r21508
2014-08-28 01:41:43 +00:00
Dave Abrahams
ea73121217 [stdlib] Make a method final
Swift SVN r21441
2014-08-25 16:50:29 +00:00
Dave Abrahams
6c07fb4ad1 [stdlib] Revert UnsafePointer casting change
The syntax being reverted added busywork and noise to the common case
where you want to say "I have the right address, but the wrong type,"
without adding any real safety.

Also it eliminated the ability to write UnsafePointer<T>(otherPointer),
without adding ".self" to T.  Overall, it was not a win.

This reverts commits r21324 and r21342

Swift SVN r21424
2014-08-22 21:53:12 +00:00
Dave Abrahams
1fb0f889d7 [stdlib] Make UnsafePointer conversions explicit
Previously, it was possible to write Unsafe[Mutable]Pointer(x) and have
Swift deduce the pointee type based on context.  Since reinterpreting
memory is a fundamentally type-unsafe operation, it's better to be
explicit about conversions from Unsafe[Mutable]Pointer<T> to
Unsafe[Mutable]Pointer<U>.  This change is consistent with the move from
reinterpretCast(x) to unsafeBitCast(x, T.self).

Also, we've encoded the operations of explicitly adding or removing
mutability as properties, so that adding mutability can be separated
from wild reinterpretCast'ing, a much more severe form of unsafety.

Swift SVN r21324
2014-08-20 23:15:56 +00:00
Joe Pamer
94dac129d4 Remove the BooleanType conformance from optional types (rdar://problem/17110911)
To limit user confusion when using conditional expressions of type Bool?, we've decided to remove the BooleanType (aka "LogicValue") conformance from optional types. (If users would like to use an expression of type Bool? as a conditional, they'll need to check against nil.)

Note: This change effectively regresses the "case is" pattern over types, since it currently demands a BooleanType conformance. I've filed rdar://problem/17791533 to track reinstating it if necessary.

Swift SVN r20637
2014-07-28 19:20:39 +00:00
Dave Abrahams
d00e888d95 [stdlib] Rename reinterpretCast => unsafeBitCast
Also give unsafeBitCast an explicit type parameter.  So

  let x: T = reinterpretCast(y)

becomes

  let x = unsafeBitCast(y, T.self)

Swift SVN r20487
2014-07-24 13:17:36 +00:00
Dave Abrahams
00f9ca5eda [stdlib] Rename [_]elementStorage=>[_]baseAddress
Swift SVN r20342
2014-07-22 22:29:03 +00:00
Dave Abrahams
21669b3aee [stdlib] Add "Mutable" to [Autoreleasing]UnsafePointer
UnsafePointer becomes UnsafeMutablePointer
AutoreleasingUnsafePointer becomes AutoreleasingUnsafeMutablePointer

Swift SVN r20316
2014-07-22 16:56:23 +00:00
Dmitri Hrybenko
d14f17beef Change 'getLogicValue()' into a property 'boolValue'; change
'getArrayBoundValue()' into a property 'arrayBoundValue'.

rdar://17156123


Swift SVN r20304
2014-07-22 12:08:10 +00:00
Dave Abrahams
3731a0d1d2 [stdlib] Deal with various zero-division scenarios
Primarily, this means becoming resilient to Builtin.strideof(x) == 0.
Pretty much the only way to get pointers and arrays to make sense is to
treat zero-sized elements as having a stride of 1, so we do that in our
wrapper for Builtin.strideof.  Other points include precondition checks
for radixes in number formatting.

Fixes <rdar://problem/17097768>

Swift SVN r20242
2014-07-21 05:21:22 +00:00
Dave Abrahams
0412b0cfc1 [stdlib] BooleanType is just for Bools
For now, it still applies to Optionals and Pointers, but this commit
removes it from everything else.

Swift SVN r19888
2014-07-13 01:19:39 +00:00
Dave Abrahams
cbcf9aba21 s/LogicValueType/BooleanType/
We're moving toward using that protocol for straight-up Bool types

Swift SVN r19884
2014-07-12 18:58:18 +00:00
Dave Abrahams
6d1095f44e Protocol names end in "Type," "ible," or "able"
Mechanically add "Type" to the end of any protocol names that don't end
in "Type," "ible," or "able."  Also, drop "Type" from the end of any
associated type names, except for those of the *LiteralConvertible
protocols.

There are obvious improvements to make in some of these names, which can
be handled with separate commits.

Fixes <rdar://problem/17165920> Protocols `Integer` etc should get
uglier names.

Swift SVN r19883
2014-07-12 17:29:57 +00:00
Nadav Rotem
f4a470979b Use unsafe arithmetic for basic sizeof and alignof calculations.
Swift SVN r19838
2014-07-11 00:03:57 +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
Jordan Rose
da29f099f0 Update stdlib for accessibility modifiers becoming context-sensitive keywords.
Swift SVN r19672
2014-07-08 02:17:46 +00:00
Doug Gregor
2bddbc7711 Replace OnHeap<T>'s implicit conversion with a computed property.
No user-visible change.

Swift SVN r19623
2014-07-07 18:57:35 +00:00
Doug Gregor
d62d98de18 Replace an implicit conversion with a computed property (library implementation detail).
Swift SVN r19622
2014-07-07 18:57:35 +00:00
Jordan Rose
2836c474ec [Accessibility] Public enum cases cannot have private payloads.
...because you can't match them properly in switches.

In the future, we could consider allowing private enum cases in a
resilient public enum, which essentially forces the user to consider the
default case.

Swift SVN r19620
2014-07-07 18:39:35 +00:00
Dmitri Hrybenko
1911aaed9f stdlib: hide isUniquelyReferenced
Swift SVN r19598
2014-07-07 10:01:48 +00:00
Dmitri Hrybenko
735bf5e785 stdlib: hide swift_bufferAllocate
Swift SVN r19593
2014-07-07 09:45:59 +00:00
Dmitri Hrybenko
7f351643d9 stdlib: hide roundUpToAlignment
rdar://17315534


Swift SVN r19566
2014-07-04 15:57:47 +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
Dmitri Hrybenko
b304e651c8 stdlib/HeapBuffer: add a message to a runtime trap
Swift SVN r19458
2014-07-02 14:14:55 +00:00
Jordan Rose
748efed913 [Accessibility] Protocol witnesses must be as accessible as the protocol.
...unless the type has less accessibility than the protocol, in which case
they must be as accessible as the type.

This restriction applies even with access control checking disabled, but
shouldn't affect any decls not already marked with access control modifiers.

Swift SVN r19382
2014-06-30 23:38:35 +00:00
Jordan Rose
5e59d30c6f Update stdlib for memberwise access control.
As before, there may be more things marked @public than we actually want
public. Judicious use of the frontend option -disable-access-control may
help reduce the public surface area of the stdlib.

Swift SVN r19353
2014-06-30 18:50:50 +00:00
Jordan Rose
cca27d02a0 Tag everything in the standard library with accessibility attributes.
Keep calm: remember that the standard library has many more public exports
than the average target, and that this contains ALL of them at once.
I also deliberately tried to tag nearly every top-level decl, even if that
was just to explicitly mark things @internal, to make sure I didn't miss
something.

This does export more than we might want to, mostly for protocol conformance
reasons, along with our simple-but-limiting typealias rule. I tried to also
mark things private where possible, but it's really going to be up to the
standard library owners to get this right. This is also only validated
against top-level access control; I haven't fully tested against member-level
access control yet, and none of our semantic restrictions are in place.

Along the way I also noticed bits of stdlib cruft; to keep this patch
understandable, I didn't change any of them.

Swift SVN r19145
2014-06-24 21:32:18 +00:00
Jordan Rose
7d649e0a16 Use "_" instead of "c_" for primitive functions accessed through asmname.
No functionality change.

Swift SVN r19119
2014-06-24 01:23:04 +00:00
Michael Gottesman
8de060ff3f Revert "[stdlib] mask unused bits in uniqueness checks"
Revert "[stdlib] Use an enum for ArrayBuffer storage"

This reverts commit r18996.
This reverts commit r18954.

The optimizer is not ready yet to handle this change especially given
the time until Beta 3. After speaking with DaveA, we agreed to revert
this and take such large changes onto private branches until we are sure
that the optimizer is ready to handle them rather than risking
performance regressions due to hitting the "optimization cliff".

Swift SVN r19026
2014-06-20 01:41:04 +00:00
Dave Abrahams
2b82e8988f [stdlib] mask unused bits in uniqueness checks
Also update ArrayBuffer to take advantage of it.

This change allows us to pass a word-sized enum with a native object
reference payload directly to the runtime, without switching on the enum
to unwrap the contents.  Even though that unwrapping was semantically
equivalent to bit masking, it was causing fits in the optimizer.

Swift SVN r18996
2014-06-19 02:32:07 +00:00
John McCall
329abe543d Pass an alignment mask during heap array allocation,
not an alignment value.

Assert that various entrypoints get an alignment mask.

Get everything uniformly passing an assertion about
dealloating an object with the correct allocation
size; don't actually enable the assertion yet, though.

rdar://16989632

Swift SVN r18550
2014-05-22 01:58:05 +00:00
John McCall
5ddee671b6 Provide a hacky hook for specifying a class's instance size
and alignment for the purposes of deallocation.

If a class contains a method named __getInstanceSizeAndAlignMask,
and it takes no arguments and returns a pair of words, call
that method directly in order to get the size and alignment
mask instead of trusting the class's formal size and alignment.

This is not a replacement for a proper language solution for
custom allocation, but it'll suffice to fix some immediate
problems with HeapBufferStorage.

If we decide we like this approach, we should really raise
the deallocating destructor up to SIL.

rdar://16979846

Swift SVN r18485
2014-05-21 07:22:39 +00:00