Commit Graph

1847 Commits

Author SHA1 Message Date
Brian Gesiak 6ac8075079 [docs] Recommend using utils/build-script to test
Contributors likely won't need to invoke CMake directly in order to run the test suite. As such, the current testing documentation is a little misleading: it jumps into a detailed explanation of the `check-swift` family of targets, even though those are abstracted away via the build script. For example, I remember when I first read this document, I spent 20 minutes searching in vain for a build executable named `check-swift`.

Instead, change the wording to make it clear that `utils/build-script` is the best way to run the tests. For those interested in **how** the tests are executed, show an example of a CMake command that runs them.
2016-03-22 21:32:13 -04:00
Dmitri Gribenko ef89cb4219 Testing.rst: document what XFAIL: linux means 2016-03-22 17:14:38 -07:00
Andrew Trick 482b264afc Reapply "Merge pull request #1725 from atrick/specialize"
This was mistakenly reverted in an attempt to fix buildbots.
Unfortunately it's now smashed into one commit.

---
Introduce @_specialize(<type list>) internal attribute.

This attribute can be attached to generic functions. The attribute's
arguments must be a list of concrete types to be substituted in the
function's generic signature. Any number of specializations may be
associated with a generic function.

This attribute provides a hint to the compiler. At -O, the compiler
will generate the specified specializations and emit calls to the
specialized code in the original generic function guarded by type
checks.

The current attribute is designed to be an internal tool for
performance experimentation. It does not affect the language or
API. This work may be extended in the future to add user-visible
attributes that do provide API guarantees and/or direct dispatch to
specialized code.

This attribute works on any generic function: a freestanding function
with generic type parameters, a nongeneric method declared in a
generic class, a generic method in a nongeneric class or a generic
method in a generic class. A function's generic signature is a
concatenation of the generic context and the function's own generic
type parameters.

e.g.

struct S<T> {
var x: T
@_specialize(Int, Float)
mutating func exchangeSecond<U>(u: U, _ t: T) -> (U, T) {
x = t
return (u, x)
}
}
// Substitutes: <T, U> with <Int, Float> producing:
// S<Int>::exchangeSecond<Float>(u: Float, t: Int) -> (Float, Int)

---
[SILOptimizer] Introduce an eager-specializer pass.

This pass finds generic functions with @_specialized attributes and
generates specialized code for the attribute's concrete types. It
inserts type checks and guarded dispatch at the beginning of the
generic function for each specialization. Since we don't currently
expose this attribute as API and don't specialize vtables and witness
tables yet, the only way to reach the specialized code is by calling
the generic function which performs the guarded dispatch.

In the future, we can build on this work in several ways:
- cross module dispatch directly to specialized code
- dynamic dispatch directly to specialized code
- automated specialization based on less specific hints
- partial specialization
- and so on...

I reorganized and refactored the optimizer's generic utilities to
support direct function specialization as opposed to apply
specialization.
2016-03-21 12:43:05 -07:00
Andrew Trick 5bda28e1cb Revert "Merge pull request #1725 from atrick/specialize"
Temporarily reverting @_specialize because stdlib unit tests are
failing on an internal branch during deserialization.

This reverts commit e2c43cfe14, reversing
changes made to 9078011f93.
2016-03-18 22:31:29 -07:00
Erik Eckstein 6d654aa3e8 Debugging on SIL level.
This change follows up on an idea from Michael (thanks!).
It enables debugging and profiling on SIL level, which is useful for compiler debugging.

There is a new frontend option -gsil which lets the compiler write a SIL file and generated debug info for it.
For details see docs/DebuggingTheCompiler.rst and the comments in SILDebugInfoGenerator.cpp.
2016-03-18 14:02:06 -07:00
Andrew Trick e2c43cfe14 Merge pull request #1725 from atrick/specialize
@_specialize attribute
2016-03-18 13:24:31 -07:00
Andrew Trick 0c5002b2cf [docs] Correction to SIL unchecked_addr_cast documentation. 2016-03-18 04:00:48 -07:00
Andrew Trick 4c052274e6 Introduce @_specialize(<type list>) internal attribute.
This attribute can be attached to generic functions. The attribute's
arguments must be a list of concrete types to be substituted in the
function's generic signature. Any number of specializations may be
associated with a generic function.

This attribute provides a hint to the compiler. At -O, the compiler
will generate the specified specializations and emit calls to the
specialized code in the original generic function guarded by type
checks.

The current attribute is designed to be an internal tool for
performance experimentation. It does not affect the language or
API. This work may be extended in the future to add user-visible
attributes that do provide API guarantees and/or direct dispatch to
specialized code.

This attribute works on any generic function: a freestanding function
with generic type parameters, a nongeneric method declared in a
generic class, a generic method in a nongeneric class or a generic
method in a generic class. A function's generic signature is a
concatenation of the generic context and the function's own generic
type parameters.

e.g.

  struct S<T> {
    var x: T
    @_specialize(Int, Float)
    mutating func exchangeSecond<U>(u: U, _ t: T) -> (U, T) {
      x = t
      return (u, x)
    }
  }
  // Substitutes: <T, U> with <Int, Float> producing:
  // S<Int>::exchangeSecond<Float>(u: Float, t: Int) -> (Float, Int)
2016-03-17 18:27:10 -07:00
practicalswift 2645d03ded [gardening] Fix recently introduced typos: "releaseing" → "releasing", "typealiase" → "typealias" 2016-03-17 09:39:37 +01:00
Michael Gottesman b793bab760 [docs][arc] Add a subsection on the relationships in between ARC and "copying" pointers. 2016-03-16 19:07:06 -07:00
Michael Gottesman 621ffa1d43 [docs][arc] Elaborate a bit more in the section about reference counted overhead and structs. 2016-03-16 19:06:49 -07:00
Michael Gottesman 39248af707 [arc][docs] Add a section with information about {retain,release}_value. 2016-03-16 18:59:09 -07:00
Michael Gottesman 9f7cdff90e Add a small section on ARC optimization and enums. It should be expanded more in the future. 2016-03-16 18:43:40 -07:00
Michael Gottesman f032632046 Add section for definitions of terms that we are using. But only provide a definition from an ARC perspective. We do not need to add any non-relevant information to the ARC Optimization document. 2016-03-16 18:43:40 -07:00
Michael Gottesman bb1d82ac67 [arc][docs] Rephrasing/reformatting. NFC. 2016-03-16 17:59:04 -07:00
Michael Gottesman e1e096b0e6 [docs][arc] Add a section on conversions. 2016-03-16 17:59:04 -07:00
Michael Gottesman 82ed9625b7 [docs][arc] Fix two more admonition sections.
These should be the last two such changes.
2016-03-16 17:34:15 -07:00
Michael Gottesman 3732c8b532 [arc][docs] Make an admonition use the ..admonition to fix the formatting. 2016-03-16 17:32:31 -07:00
Michael Gottesman ff04cb528e [docs][arc] Expand the section on RC identity and change the organization to make more sense given multiple documentation sections. 2016-03-16 17:27:26 -07:00
Michael Gottesman aaa880943f [docs][arc] Small change to admonishment in the header. 2016-03-16 17:26:59 -07:00
Erik Eckstein c1bcb0b69d SIL: add new instruction set_deallocating
It will be used by the ReleaseDevirtualizer before calling the deallocator.
So far, this is NFC.
2016-03-15 12:56:54 -07:00
Erik Eckstein e1b94885a2 runtime: add a new runtime function swift_setDeallocating.
It's to be used by code produced by the ReleaseDevirtualizer.
As the function is only used for non-escaping objects, the deallocating bit is set non-atomically.
2016-03-15 12:56:54 -07:00
practicalswift 1edb62dc38 [Python] Make flake8 linting pass without errors/warning (w/ default rules) 2016-03-13 20:19:51 +01:00
Ted Kremenek 186149d475 Merge pull request #1640 from rayfix/patch-1
Fix typo of Bool type in Generics.rst
2016-03-11 08:17:14 -08:00
Ray Fix 74605b65db Update Generics.rst
Fixes capitalization of Swift Bool type.
2016-03-11 18:29:37 +09:00
practicalswift d5326bfdc4 [Python] Replace global linting excludes with local line-level excludes ("noqa")
Replace the project global linting rule excludes (as defined in .pep8) with
fine-grained "# noqa" annotations.

By using noqa annotation the excludes are made on a per line basis instead of
globally.

These annotations are used where we make deliberate deviations from the standard
linting rules.

To lint the Python code in the project:

  $ flake8

To install flake8:

  $ pip install flake8

See https://flake8.readthedocs.org/en/latest/ for details.

To enable checking of the PEP-8 naming conventions, install the optional
extension pep8-naming:

  $ pip install pep8-naming

To enable checking of blind "except:" statements, install the optional
extension flake8-blind-except:

  $ pip install flake8-blind-except

To enable checking of import statement order, install the optional
extension flake8-import-order:

  $ pip install flake8-import-order
2016-03-10 16:22:48 +01:00
practicalswift 42b7e3f8d6 Merge pull request #1598 from practicalswift/fix-80-column-violations-in-python-code
[Python] Fix 80 column violations
2016-03-10 10:35:25 +01:00
Max Moiseev 02006f20bc Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-09 16:05:03 -08:00
practicalswift 0796eaad1f [Python] Fix 80-column violations 2016-03-09 23:52:11 +01:00
Brian Gesiak c9000af795 Merge pull request #1526 from practicalswift/fix-pep8-violations-ii
[Python] Fix five classes of PEP-8 violations (E101/E111/E128/E302/W191)
2016-03-08 23:55:46 -05:00
Max Moiseev 1fae0d1325 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-08 12:48:48 -08:00
practicalswift 265835fdfc [Python] Use consistent import ordering for Python code
Ordering used:
1.) standard library imports
2.) third party imports
3.) local package imports

Each group is individually alphabetized.
2016-03-07 23:25:16 +01:00
practicalswift 183da818df [Python] Fix five classes of PEP-8 violations (E101/E111/E128/E302/W191)
* E101: indentation contains mixed spaces and tabs
* E111: indentation is not a multiple of four
* E128: continuation line under-indented for visual indent
* E302: expected 2 blank lines, found 1
* W191: indentation contains tabs
2016-03-07 22:36:23 +01:00
practicalswift f72f4a4831 Merge pull request #1551 from practicalswift/fix-comment-pep8
[Python] Improve block comment consistency
2016-03-07 21:59:28 +01:00
Max Moiseev 7fe6916bf6 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-07 12:10:47 -08:00
practicalswift 82a55c80e9 [gardening] Fix recently introduced typo: "conformace" → "conformance" 2016-03-07 09:22:29 +01:00
practicalswift 202ac537bb [gardening] Fix recently introduced typo: "becasue" → "because" 2016-03-07 08:08:45 +01:00
Dmitri Gribenko 26b51be546 StdlibRationales.rst: add explanation why sorted() is not lazy 2016-03-06 22:05:06 -08:00
Dmitri Gribenko 762dd1180d StdlibRationales.rst: add missing quotes 2016-03-06 21:59:37 -08:00
practicalswift 04afd6e640 [Python] Improve consistency: "block comment should start with '# '" (PEP-8) 2016-03-05 14:03:16 +01:00
Max Moiseev a49dab6bf8 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-29 12:08:52 -08:00
Adrian Prantl cbef660eda Fix broken indentation in SIL.rst 2016-02-26 13:38:16 -08:00
Adrian Prantl 310b0433a9 Reapply "Serialize debug scope and location info in the SIL assembler language.""
This ireapplies commit 255c52de9f.

Original commit message:

Serialize debug scope and location info in the SIL assembler language.
At the moment it is only possible to test the effects that SIL
optimization passes have on debug information by observing the
effects of a full .swift -> LLVM IR compilation. This change enable us
to write targeted testcases for single SIL optimization passes.

The new syntax is as follows:

 sil-scope-ref ::= 'scope' [0-9]+
 sil-scope ::= 'sil_scope' [0-9]+ '{'
                 sil-loc
                 'parent' scope-parent
                 ('inlined_at' sil-scope-ref )?
               '}'
 scope-parent ::= sil-function-name ':' sil-type
 scope-parent ::= sil-scope-ref
 sil-loc ::= 'loc' string-literal ':' [0-9]+ ':' [0-9]+

Each instruction may have a debug location and a SIL scope reference
at the end.  Debug locations consist of a filename, a line number, and
a column number.  If the debug location is omitted, it defaults to the
location in the SIL source file.  SIL scopes describe the position
inside the lexical scope structure that the Swift expression a SIL
instruction was generated from had originally. SIL scopes also hold
inlining information.

<rdar://problem/22706994>
2016-02-26 13:28:57 -08:00
Adrian Prantl 255c52de9f Revert "Serialize debug scope and location info in the SIL assembler language."
Temporarily reverting while updating the validation test suite.

This reverts commit c9927f66f0.
2016-02-26 11:51:57 -08:00
Adrian Prantl c9927f66f0 Serialize debug scope and location info in the SIL assembler language.
At the moment it is only possible to test the effects that SIL
optimization passes have on debug information by observing the
effects of a full .swift -> LLVM IR compilation. This change enable us
to write targeted testcases for single SIL optimization passes.

The new syntax is as follows:

 sil-scope-ref ::= 'scope' [0-9]+
 sil-scope ::= 'sil_scope' [0-9]+ '{'
                 sil-loc
                 'parent' scope-parent
                 ('inlined_at' sil-scope-ref )?
               '}'
 scope-parent ::= sil-function-name ':' sil-type
 scope-parent ::= sil-scope-ref
 sil-loc ::= 'loc' string-literal ':' [0-9]+ ':' [0-9]+

Each instruction may have a debug location and a SIL scope reference
at the end.  Debug locations consist of a filename, a line number, and
a column number.  If the debug location is omitted, it defaults to the
location in the SIL source file.  SIL scopes describe the position
inside the lexical scope structure that the Swift expression a SIL
instruction was generated from had originally. SIL scopes also hold
inlining information.

<rdar://problem/22706994>
2016-02-26 10:46:29 -08:00
Dmitri Gribenko f3389273ba stdlib: String indices: samePositionIn(_:) => samePosition(in:) 2016-02-24 16:29:27 -08:00
Dmitri Gribenko f0633ce5a9 stdlib: Sequence.iterator() => .makeIterator() 2016-02-23 13:52:30 -08:00
Dave Abrahams 158adab721 stdlib: Add 'invoke:' label to withVaList 2016-02-23 13:14:43 -08:00
Max Moiseev fcad164e18 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-22 12:59:57 -08:00
Michael Gottesman d6d30dbcb5 [gardening] Add doc stub for load_unowned/store_unowned in SIL.rst. 2016-02-21 19:04:27 -08:00