Commit Graph

4421 Commits

Author SHA1 Message Date
Andrew Trick
7565a65235 Introduce unchecked_bitwise_cast SIL instruction.
We need a SIL level unsafe cast that supports arbitrary usage of
UnsafePointer, generalizes Builtin.reinterpretCast, and has the same
semantics on generic vs. nongeneric code. In other words, we need to
be able to promote the cast of an address type to the cast of an
object type without changing semantics, and that cast needs to support
types that are not layout identical.

This patch introduces an unchecked_bitwise_cast instruction for that
purpose. It is different from unsafe_addr_cast, which has been our
fall-back "unknown" cast in the past. With unchecked_bitwise_cast we
cannot assume layout or RC identity. The cast implies a store and
reload of the value to obtain the low order bytes. I know that
bit_cast is just an abbreviation for bitwise_cast, but we use
"bitcast" throught to imply copying a same sized value. No one could
come up with a better name for copying an objects low bytes via:

  @addr = alloca $wideTy
    store @addr, $wideTy
      load  @addr, $narrowTy

Followup patches will optimize unchecked_bitwise_cast into more
semantically useful unchecked casts when enough type information is
present. This way, the optimizer will rarely need to be taught about
the bitwise case.

Swift SVN r29510
2015-06-19 16:29:35 +00:00
Arnold Schwaighofer
d64d9d11e6 Docs: Fix typos in ARCOptimization.rst
Swift SVN r29398
2015-06-16 14:51:59 +00:00
Erik Eckstein
bbd503545c Add a document which contains some tips and tricks on how to debug the swift compiler.
This could be useful for people who start working with the swift compiler.

Please feel free to correct/enhance/extend etc.



Swift SVN r29383
2015-06-15 11:26:17 +00:00
Joe Groff
7388b56035 Mangler: Include the error result of SILFunctionTypes in their mangling.
Fixes a mangling collision when e.g. reabstraction thunks for T -> U and T throws -> U are needed in the same module.

Swift SVN r29362
2015-06-10 20:27:24 +00:00
Dmitri Hrybenko
23d474cab3 Fix documentation build
Swift SVN r28710
2015-05-18 18:16:40 +00:00
Slava Pestov
b06c45b9b3 Attempt to document checked_cast_addr_br and unconditional_checked_cast_addr
Swift SVN r28693
2015-05-18 00:26:21 +00:00
Dmitri Hrybenko
9b67c6bf7f stdilb: Document the new policy about complexity and properties vs. methods
Swift SVN r28498
2015-05-12 23:37:54 +00:00
David Farler
b29220a27e Add a Requires field to doc comments
rdar://problem/20902140

Swift SVN r28446
2015-05-11 22:52:34 +00:00
Dmitri Hrybenko
2c68b35d3e StdlibRationales: document one more reason against map() returning Self
Swift SVN r28414
2015-05-11 08:40:54 +00:00
Joe Groff
22e34ab4e1 AST: Interface type mangling for protocol conformances.
Mangle the generic signature and interface type of the conforming type signature. Fix the demangler to reset the generic context between mangling a witness's conformance and requirement; they have independent generic contexts, and the bookkeeping for generic signatures notes the discrepancy.

Swift SVN r28377
2015-05-09 22:20:40 +00:00
Dmitri Hrybenko
f46f16ae82 stdlib: implement new print() API
rdar://20775683

Swift SVN r28309
2015-05-08 01:37:59 +00:00
Joe Groff
9f8fd4e43c AST: Compress the mangling for generic signatures a bit.
Single generic parameters are common, as are a lack of requirements, so tweak things so that generic parameter counts are mangled as (count - 1), with a special mangling for zero, and give a single generic parameter at depth zero the empty-string mangling. Most requirements are protocol constraints, so use a better mangling for them that doesn't require the 'P..._' wrapping of the general type mangling. On the other hand, dependent member types ought to mangle in the protocol of the associated type, which adds some length, but isn't too bad since the protocol will almost definitely have a substitution introduced by a preceding protocol constraint.

Swift SVN r28296
2015-05-07 22:26:34 +00:00
Chris Lattner
6f7caf8335 fix a past-o in the dox.
Swift SVN r28149
2015-05-05 04:26:19 +00:00
Slava Pestov
58f0b46335 Implement @nonobjc attribute
The following declaration kinds can be marked with this attribute:
- method
- property
- property accessor
- subscript
- constructor

Use cases include resolving circularity for bridging methods in an @objc
class, and allowing overloading methods and constructors in an @objc class
by signature by marking some of them @nonobjc.

It is an error to override an @objc method with a @nonobjc method. The
converse, where we override a @nonobjc method with a @objc method, is
explicitly supported.

It is also an error to put a @nonobjc attribute on a method which is
inferred as @objc due to being part of an @objc protocol conformance.

Fixes <rdar://problem/16763754>.

Swift SVN r28126
2015-05-04 19:26:23 +00:00
Erik Eckstein
40c1160713 Revert r28111 "rework the peephole for optional-to-optional casts to be more specific"
and r28105: "implement <rdar://problem/17013042> T! <-> T? conversions should not produce a diamond"

r28111 broke the stdlib build. I also reverted r28105, because r28111 fixes regressions introduced in r2805.



Swift SVN r28114
2015-05-04 07:24:13 +00:00
Chris Lattner
add4909d35 implement <rdar://problem/17013042> T! <-> T? conversions should not produce a diamond
Two pieces to this:
 - Peephole InjectOptionalExpr(BindOptionalExpr(X)) to bitcast x to the result type.
 - Enhance OptionalEvaluationExpr to delete the failure block if not needed.



Swift SVN r28105
2015-05-04 01:12:23 +00:00
Ted Kremenek
2f2b9363e9 Change Printable/DebugPrintable to CustomStringConvertible/CustomDebugStringConvertible in docs.
Swift SVN r28000
2015-04-30 22:07:03 +00:00
Erik Eckstein
3ad2b6710b stdlib: add @_semantics("availability.osversion") to _stdlib_isOSVersionAtLeast
Needed by GlobalOpt (rdar://problem/20708979)



Swift SVN r27963
2015-04-30 11:05:31 +00:00
Dmitri Hrybenko
fe0a335a49 docs: add a rationale for use of BooleanType in the standard library
Swift SVN r27956
2015-04-30 02:17:27 +00:00
Dmitri Hrybenko
eaef05c99d docs: add a rationale for lazy functions on sequences and collections
Swift SVN r27955
2015-04-30 02:00:00 +00:00
David Farler
5b2de9ff9e Add document on Swift Markup Doc Comments
Swift SVN r27952
2015-04-30 00:34:41 +00:00
Andrew Trick
41cf8608cb Add is_unique documentation.
I also added a placeholder for ARC optimization docs. I wanted anyone
reading about swift ARC optimization to run across my discussion on
correctness w.r.t. COW.

Swift SVN r27890
2015-04-28 22:54:26 +00:00
Dmitri Hrybenko
c999f87c7c StdlibRationales: add Dave's writeup about high-order functions
Swift SVN r27823
2015-04-27 22:50:26 +00:00
Chris Willmore
c7c7388cf2 Change do-while to repeat-while.
Change all uses of "do { ... } while <cond>" to use "repeat" instead.
Rename DoWhileStmt to RepeatWhileStmt. Add diagnostic suggesting change
of 'do' to 'repeat' if a condition is found afterwards.

<rdar://problem/20336424> rename do/while loops to repeat/while & introduce "repeat <count> {}" loops

Swift SVN r27650
2015-04-23 22:48:31 +00:00
John McCall
ab66ffabf7 Another grammar bug.
Swift SVN r27649
2015-04-23 22:41:16 +00:00
John McCall
21b35b5e43 Spell out that initializers are imported as throwing instead
of failable if they have an error parameter.

Swift SVN r27648
2015-04-23 22:40:14 +00:00
John McCall
b8405acbc2 Mispelign.
Swift SVN r27647
2015-04-23 21:54:18 +00:00
John McCall
d00d6b8b3e Rationalize "throws" as a syntactic choice.
Swift SVN r27646
2015-04-23 21:15:09 +00:00
John McCall
bfa2038e60 Describe the order in which multiple defer actions are executed.
Swift SVN r27645
2015-04-23 21:15:06 +00:00
John McCall
aa0a8670e0 Editorial changes; credit to Quinn Taylor and Mark Lacey.
Swift SVN r27630
2015-04-23 07:07:17 +00:00
Chris Lattner
08f9269cc3 unbreak the dox build. I at least don't have a rust pygments lexer and this
is breaking my full build.


Swift SVN r27625
2015-04-23 04:18:24 +00:00
John McCall
b40e297ff2 Describe the implicit binding of 'error' within a catch clause.
Swift SVN r27624
2015-04-23 02:40:44 +00:00
John McCall
229df4d230 Add the error-handling proposal to the repository.
Swift SVN r27619
2015-04-23 00:56:48 +00:00
Joe Groff
8293f3f444 Update SIL.rst to discuss @convention instead of the old attributes.
Swift SVN r27611
2015-04-22 22:51:20 +00:00
Joe Groff
fd138326ba SIL: Reject '@cc', '@thin', and '@objc_block' in SIL.
Since it's an internal interface, there's no need for migration in SIL.

Swift SVN r27610
2015-04-22 22:40:08 +00:00
Slava Pestov
49bab4c38f Fix typos in docs
Swift SVN r27581
2015-04-22 17:18:41 +00:00
Joe Groff
3f38d75006 SILGen: Currying of 'super.method' calls.
Keep track of a second set of "direct method reference" curry thunks that don't end in a dynamic dispatch in order to properly implement a partial application such as 'let foo = super.foo'. Fixes rdar://problem/20598526.

Swift SVN r27538
2015-04-21 22:56:03 +00:00
Nadav Rotem
32211041d2 Rename @semantics -> @_semantics.
Swift SVN r27533
2015-04-21 17:10:06 +00:00
Chris Lattner
5df6b054db fix the dox build
Swift SVN r27527
2015-04-21 06:18:13 +00:00
Chris Lattner
42b4a966b0 Introduce a new null_class SIL instruction for forming a null pointer
reference to something of class type.  This is required to model
RebindSelfInConstructorExpr correctly to DI, since in the class case, 
self.init and super.init *take* a value out of class box so that it 
can pass the +1 value without performing an extra retain.  Nothing
else in the compiler uninitializes a DI-controlled memory object
like this, so nothing else needs this.  DI really doesn't like something
going from initialized to uninitialized.

Yes, I feel super-gross about this and am really unhappy about it.  I
may end up reverting this if I can find an alternate solution to this
problem.



Swift SVN r27525
2015-04-21 05:56:55 +00:00
Nadav Rotem
0f63546369 Rename the semantics tag name from never to sil.never. NFC.
Swift SVN r27486
2015-04-20 17:27:32 +00:00
Nadav Rotem
926042ff81 Add @semantics("optimize.never") to disable optimizations of a specific function.
This commit adds a flag to disable optimizations on a specific functions. The
primary motivation of this patch is to allow the optimizer developers to reduce
testcasese by disabling optimizations of parts of the code without having to
recompile the compiler or inspect SIL. The annotations  "inline(never)"
and "optimize.none" can go a long way.

The second motivation for this patch is to allow our internal adopters to work
around compiler bugs.

rar://19745484

Usage:

@semantics("optimize.never")
public func miscompile() { ... }

Swift SVN r27475
2015-04-20 05:06:55 +00:00
Dave Abrahams
cdb5808a95 StdlibAPIGuidelines: final clarification
Swift SVN r27151
2015-04-09 00:47:04 +00:00
Dave Abrahams
6832f493c1 StdlibAPIGuidelines: editorial review w/Dmitri
Swift SVN r27150
2015-04-09 00:43:55 +00:00
Dave Abrahams
4cf634ec7f StdlibAPIGuidelines: add a note.
Swift SVN r27149
2015-04-09 00:43:54 +00:00
Dave Abrahams
f3579767e9 Fix a ReST error
Swift SVN r27145
2015-04-08 23:43:40 +00:00
Dave Abrahams
d734fe7e07 [stdlib] Document our current design conventions
The API review list has requested this document.

Swift SVN r27144
2015-04-08 23:41:44 +00:00
Michael Gottesman
11e8cfa06f State in the uncurry level examples which reference is the "natural uncurry level" explicitly.
Swift SVN r27143
2015-04-08 23:30:52 +00:00
Joe Groff
655b2d3e93 Inplace: let -> var
Swift SVN r26800
2015-04-01 03:58:10 +00:00
Joe Groff
4b6c2803de Inplace proposal: Clarify the section on classes.
Try to make it more plain that assignment method syntax is still allowed with class methods; only explicit implementation of the assignment form is not allowed.

Swift SVN r26799
2015-04-01 03:54:30 +00:00