Skip to content

Commit 4db569a

Browse files
authored
---
yaml --- r: 349134 b: refs/heads/master c: 0a606c3 h: refs/heads/master
1 parent 9fd6a3a commit 4db569a

File tree

109 files changed

+1011
-443
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+1011
-443
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: a29a5f1a34388e2ce131a07b6df041d995b71d9b
2+
refs/heads/master: 0a606c39d1b44f14e5caad9db48f3ecfc1dc8dae
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ endif()
1111
list(APPEND CMAKE_MODULE_PATH
1212
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
1313

14+
set(CMAKE_DISABLE_IN_SOURCE_BUILD YES)
15+
1416
if(DEFINED CMAKE_JOB_POOLS)
1517
# CMake < 3.11 doesn't support CMAKE_JOB_POOLS. Manually set the property.
1618
set_property(GLOBAL PROPERTY JOB_POOLS "${CMAKE_JOB_POOLS}")
@@ -375,6 +377,10 @@ option(SWIFT_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING
375377
"Build stdlibCore with exclusivity checking enabled"
376378
FALSE)
377379

380+
option(SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING
381+
"Enable experimental Swift differentiable programming features"
382+
FALSE)
383+
378384
#
379385
# End of user-configurable options.
380386
#

trunk/benchmark/scripts/run_smoke_bench

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ def main():
9393
argparser.add_argument(
9494
'-num-samples', type=int,
9595
help='The (minimum) number of samples to run', default=3)
96+
argparser.add_argument(
97+
'-num-reruns', type=int,
98+
help="The number of re-runs until it's assumed to be a real change",
99+
default=8)
96100
argparser.add_argument(
97101
'-platform', type=str,
98102
help='The benchmark build platform', default='macosx')
@@ -120,7 +124,7 @@ def test_opt_levels(args):
120124
if test_performance(opt_level, args.oldbuilddir[0],
121125
args.newbuilddir[0],
122126
float(args.threshold) / 100, args.num_samples,
123-
output_file):
127+
args.num_reruns, output_file):
124128
changes = True
125129

126130
# There is no point in reporting code size for Onone.
@@ -171,7 +175,7 @@ def merge(results, other_results):
171175

172176

173177
def test_performance(opt_level, old_dir, new_dir, threshold, num_samples,
174-
output_file):
178+
num_reruns, output_file):
175179
"""Detect performance changes in benchmarks.
176180
177181
Start fast with few samples per benchmark and gradually spend more time
@@ -185,7 +189,7 @@ def test_performance(opt_level, old_dir, new_dir, threshold, num_samples,
185189
tests = TestComparator(results[0], results[1], threshold)
186190
changed = tests.decreased + tests.increased
187191

188-
while len(changed) > 0 and unchanged_length_count < 10:
192+
while len(changed) > 0 and unchanged_length_count < num_reruns:
189193
i += 1
190194
if VERBOSE:
191195
log(' test again: ' + str([test.name for test in changed]))

trunk/benchmark/single-source/UTF8Decode.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ public let UTF8Decode = [
4242
name: "UTF8Decode_InitFromBytes_ascii",
4343
runFunction: run_UTF8Decode_InitFromBytes_ascii,
4444
tags: [.validation, .api, .String]),
45+
BenchmarkInfo(
46+
name: "UTF8Decode_InitFromData_ascii_as_ascii",
47+
runFunction: run_UTF8Decode_InitFromData_ascii_as_ascii,
48+
tags: [.validation, .api, .String]),
49+
BenchmarkInfo(
50+
name: "UTF8Decode_InitDecoding_ascii_as_ascii",
51+
runFunction: run_UTF8Decode_InitDecoding_ascii_as_ascii,
52+
tags: [.validation, .api, .String]),
53+
BenchmarkInfo(
54+
name: "UTF8Decode_InitFromBytes_ascii_as_ascii",
55+
runFunction: run_UTF8Decode_InitFromBytes_ascii_as_ascii,
56+
tags: [.validation, .api, .String]),
4557
]
4658

4759
// 1-byte sequences
@@ -129,4 +141,26 @@ public func run_UTF8Decode_InitFromBytes_ascii(_ N: Int) {
129141
}
130142
}
131143

144+
@inline(never)
145+
public func run_UTF8Decode_InitFromData_ascii_as_ascii(_ N: Int) {
146+
let input = asciiData
147+
for _ in 0..<1_000*N {
148+
blackHole(String(data: input, encoding: .ascii))
149+
}
150+
}
151+
@inline(never)
152+
public func run_UTF8Decode_InitDecoding_ascii_as_ascii(_ N: Int) {
153+
let input = asciiBytes
154+
for _ in 0..<1_000*N {
155+
blackHole(String(decoding: input, as: Unicode.ASCII.self))
156+
}
157+
}
158+
@inline(never)
159+
public func run_UTF8Decode_InitFromBytes_ascii_as_ascii(_ N: Int) {
160+
let input = asciiBytes
161+
for _ in 0..<1_000*N {
162+
blackHole(String(bytes: input, encoding: .ascii))
163+
}
164+
}
165+
132166

trunk/cmake/modules/AddSwift.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,10 @@ function(_add_variant_swift_compile_flags
422422
list(APPEND result "-D" "SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS")
423423
endif()
424424

425+
if(SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING)
426+
list(APPEND result "-D" "SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING")
427+
endif()
428+
425429
set("${result_var_name}" "${result}" PARENT_SCOPE)
426430
endfunction()
427431

trunk/docs/WindowsBuild.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ mklink "%VCToolsInstallDir%\include\visualc.apinotes" S:\swift\stdlib\public\Pla
9999
Warning: Creating the above links usually requires administrator privileges. The quick and easy way to do this is to open a second developer prompt by right clicking whatever shortcut you used to open the first one, choosing Run As Administrator, and pasting the above commands into the resulting window. You can then close the privileged prompt; this is the only step which requires elevation.
100100

101101
## 6. Build LLVM/Clang
102-
- This must be done from within a developer command prompt. LLVM and Clang are
103-
large projects, so building might take a few hours. Make sure that the build
102+
- This must be done from within a developer command prompt. Make sure that the build
104103
type for LLVM/Clang is compatible with the build type for Swift. That is,
105104
either build everything `Debug` or some variant of `Release` (e.g. `Release`,
106105
`RelWithDebInfo`).
@@ -126,8 +125,8 @@ ninja
126125
path S:\b\llvm\bin;%PATH%
127126
```
128127
## 7. Build CMark
129-
- This must be done from within a developer command prompt. CMark is a fairly
130-
small project and should only take a few minutes to build.
128+
- This must be done from within a developer command prompt.
129+
131130
```cmd
132131
md "S:\b\cmark"
133132
cd "S:\b\cmark"
@@ -180,8 +179,8 @@ cmake -G "Visual Studio 2017" -A x64 -T "host=x64"^ ...
180179
```
181180

182181
## 9. Build lldb
183-
- This must be done from within a developer command prompt and could take hours
184-
depending on your system.
182+
- This must be done from within a developer command prompt.
183+
185184
```cmd
186185
md "S:\b\lldb"
187186
cd "S:\b\lldb"

trunk/include/swift/AST/AnyFunctionRef.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ class AnyFunctionRef {
5252
}
5353
}
5454

55-
const CaptureInfo &getCaptureInfo() const {
55+
CaptureInfo getCaptureInfo() const {
5656
if (auto *AFD = TheFunction.dyn_cast<AbstractFunctionDecl *>())
5757
return AFD->getCaptureInfo();
5858
return TheFunction.get<AbstractClosureExpr *>()->getCaptureInfo();
5959
}
6060

61-
void setCaptureInfo(const CaptureInfo &captures) const {
61+
void setCaptureInfo(CaptureInfo captures) const {
6262
if (auto *AFD = TheFunction.dyn_cast<AbstractFunctionDecl *>()) {
6363
AFD->setCaptureInfo(captures);
6464
return;

trunk/include/swift/AST/Decl.h

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ namespace swift {
7171
class GenericTypeParamDecl;
7272
class GenericTypeParamType;
7373
class ModuleDecl;
74+
class NamedPattern;
7475
class EnumCaseDecl;
7576
class EnumElementDecl;
7677
class ParameterList;
@@ -2021,8 +2022,8 @@ class PatternBindingEntry {
20212022
/// from the source range.
20222023
SourceRange getSourceRange(bool omitAccessors = false) const;
20232024

2024-
const CaptureInfo &getCaptureInfo() const { return Captures; }
2025-
void setCaptureInfo(const CaptureInfo &captures) { Captures = captures; }
2025+
CaptureInfo getCaptureInfo() const { return Captures; }
2026+
void setCaptureInfo(CaptureInfo captures) { Captures = captures; }
20262027

20272028
private:
20282029
SourceLoc getLastAccessorEndLoc() const;
@@ -2126,11 +2127,11 @@ class PatternBindingDecl final : public Decl,
21262127
return getPatternList()[i].getInitContext();
21272128
}
21282129

2129-
const CaptureInfo &getCaptureInfo(unsigned i) const {
2130+
CaptureInfo getCaptureInfo(unsigned i) const {
21302131
return getPatternList()[i].getCaptureInfo();
21312132
}
21322133

2133-
void setCaptureInfo(unsigned i, const CaptureInfo &captures) {
2134+
void setCaptureInfo(unsigned i, CaptureInfo captures) {
21342135
getMutablePatternList()[i].setCaptureInfo(captures);
21352136
}
21362137

@@ -4773,6 +4774,8 @@ enum class PropertyWrapperSynthesizedPropertyKind {
47734774

47744775
/// VarDecl - 'var' and 'let' declarations.
47754776
class VarDecl : public AbstractStorageDecl {
4777+
NamedPattern *NamingPattern = nullptr;
4778+
47764779
public:
47774780
enum class Introducer : uint8_t {
47784781
Let = 0,
@@ -4786,10 +4789,6 @@ class VarDecl : public AbstractStorageDecl {
47864789
bool issCaptureList, SourceLoc nameLoc, Identifier name,
47874790
DeclContext *dc, StorageIsMutable_t supportsMutation);
47884791

4789-
TypeRepr *ParentRepr = nullptr;
4790-
4791-
Type typeInContext;
4792-
47934792
public:
47944793
VarDecl(bool isStatic, Introducer introducer, bool isCaptureList,
47954794
SourceLoc nameLoc, Identifier name, DeclContext *dc)
@@ -4806,26 +4805,10 @@ class VarDecl : public AbstractStorageDecl {
48064805
return hasName() ? getBaseName().getIdentifier().str() : "_";
48074806
}
48084807

4809-
/// Retrieve the TypeRepr corresponding to the parsed type of the parent
4810-
/// pattern, if it exists.
4811-
TypeRepr *getTypeRepr() const { return ParentRepr; }
4812-
void setTypeRepr(TypeRepr *repr) { ParentRepr = repr; }
4813-
4814-
bool hasType() const {
4815-
// We have a type if either the type has been computed already or if
4816-
// this is a deserialized declaration with an interface type.
4817-
return !typeInContext.isNull();
4818-
}
4819-
48204808
/// Get the type of the variable within its context. If the context is generic,
48214809
/// this will use archetypes.
48224810
Type getType() const;
48234811

4824-
/// Set the type of the variable within its context.
4825-
void setType(Type t);
4826-
4827-
void markInvalid();
4828-
48294812
/// Retrieve the source range of the variable type, or an invalid range if the
48304813
/// variable's type is not explicitly written in the source.
48314814
///
@@ -4864,6 +4847,14 @@ class VarDecl : public AbstractStorageDecl {
48644847
///
48654848
Pattern *getParentPattern() const;
48664849

4850+
/// Returns the parsed type of this variable declaration. For parameters, this
4851+
/// is the parsed type the user explicitly wrote. For variables, this is the
4852+
/// type the user wrote in the typed pattern that binds this variable.
4853+
///
4854+
/// Note that there are many cases where the user may elide types. This will
4855+
/// return null in those cases.
4856+
TypeRepr *getTypeReprOrParentPatternTypeRepr() const;
4857+
48674858
/// Return the statement that owns the pattern associated with this VarDecl,
48684859
/// if one exists.
48694860
///
@@ -4904,6 +4895,9 @@ class VarDecl : public AbstractStorageDecl {
49044895
Parent = v;
49054896
}
49064897

4898+
NamedPattern *getNamingPattern() const { return NamingPattern; }
4899+
void setNamingPattern(NamedPattern *Pat) { NamingPattern = Pat; }
4900+
49074901
/// If this is a VarDecl that does not belong to a CaseLabelItem's pattern,
49084902
/// return this. Otherwise, this VarDecl must belong to a CaseStmt's
49094903
/// CaseLabelItem. In that case, return the first case label item of the first
@@ -5158,6 +5152,8 @@ class ParamDecl : public VarDecl {
51585152
SourceLoc ArgumentNameLoc;
51595153
SourceLoc SpecifierLoc;
51605154

5155+
TypeRepr *TyRepr = nullptr;
5156+
51615157
struct StoredDefaultArgument {
51625158
PointerUnion<Expr *, VarDecl *> DefaultArg;
51635159
Initializer *InitContext = nullptr;
@@ -5203,6 +5199,10 @@ class ParamDecl : public VarDecl {
52035199

52045200
SourceLoc getSpecifierLoc() const { return SpecifierLoc; }
52055201

5202+
/// Retrieve the TypeRepr corresponding to the parsed type of the parameter, if it exists.
5203+
TypeRepr *getTypeRepr() const { return TyRepr; }
5204+
void setTypeRepr(TypeRepr *repr) { TyRepr = repr; }
5205+
52065206
DefaultArgumentKind getDefaultArgumentKind() const {
52075207
return static_cast<DefaultArgumentKind>(Bits.ParamDecl.defaultArgumentKind);
52085208
}
@@ -5237,12 +5237,12 @@ class ParamDecl : public VarDecl {
52375237

52385238
void setDefaultArgumentInitContext(Initializer *initContext);
52395239

5240-
const CaptureInfo &getDefaultArgumentCaptureInfo() const {
5240+
CaptureInfo getDefaultArgumentCaptureInfo() const {
52415241
assert(DefaultValueAndFlags.getPointer());
52425242
return DefaultValueAndFlags.getPointer()->Captures;
52435243
}
52445244

5245-
void setDefaultArgumentCaptureInfo(const CaptureInfo &captures);
5245+
void setDefaultArgumentCaptureInfo(CaptureInfo captures);
52465246

52475247
/// Extracts the text of the default argument attached to the provided
52485248
/// ParamDecl, removing all inactive #if clauses and providing only the
@@ -5814,8 +5814,8 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
58145814
/// Retrieve the source range of the function declaration name + patterns.
58155815
SourceRange getSignatureSourceRange() const;
58165816

5817-
const CaptureInfo &getCaptureInfo() const { return Captures; }
5818-
void setCaptureInfo(const CaptureInfo &captures) { Captures = captures; }
5817+
CaptureInfo getCaptureInfo() const { return Captures; }
5818+
void setCaptureInfo(CaptureInfo captures) { Captures = captures; }
58195819

58205820
/// Retrieve the Objective-C selector that names this method.
58215821
ObjCSelector getObjCSelector(DeclName preferredName = DeclName(),

trunk/include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,9 @@ ERROR(pattern_binds_no_variables,none,
15091509
"%select{property|global variable}0 declaration does not bind any "
15101510
"variables",
15111511
(unsigned))
1512+
ERROR(variable_bound_by_no_pattern,none,
1513+
"variable %0 is not bound by any pattern",
1514+
(DeclName))
15121515

15131516
WARNING(optional_ambiguous_case_ref,none,
15141517
"assuming you mean '%0.%2'; did you mean '%1.%2' instead?",

trunk/include/swift/AST/Expr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3449,7 +3449,7 @@ class AbstractClosureExpr : public DeclContext, public Expr {
34493449
Bits.AbstractClosureExpr.Discriminator = Discriminator;
34503450
}
34513451

3452-
const CaptureInfo &getCaptureInfo() const { return Captures; }
3452+
CaptureInfo getCaptureInfo() const { return Captures; }
34533453
void setCaptureInfo(CaptureInfo captures) { Captures = captures; }
34543454

34553455
/// Retrieve the parameters of this closure.

trunk/include/swift/AST/Initializer.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,6 @@ class SerializedPatternBindingInitializer : public SerializedLocalDeclContext {
150150
/// A default argument expression. The parent context is the function
151151
/// (possibly a closure) for which this is a default argument.
152152
class DefaultArgumentInitializer : public Initializer {
153-
friend class ASTContext; // calls reset on unused contexts
154-
void reset(DeclContext *parent, unsigned index) {
155-
setParent(parent);
156-
SpareBits = index;
157-
}
158-
159153
public:
160154
explicit DefaultArgumentInitializer(DeclContext *parent, unsigned index)
161155
: Initializer(InitializerKind::DefaultArgument, parent) {

trunk/include/swift/SIL/MemoryLifetime.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@
2222

2323
namespace swift {
2424

25+
void printBitsAsArray(llvm::raw_ostream &OS, const SmallBitVector &bits);
26+
27+
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
28+
const SmallBitVector &bits) {
29+
printBitsAsArray(OS, bits);
30+
return OS;
31+
}
32+
33+
void dumpBits(const SmallBitVector &bits);
34+
2535
/// The MemoryLocations utility provides functions to analyze memory locations.
2636
///
2737
/// Memory locations are limited to addresses which are guaranteed to

0 commit comments

Comments
 (0)