Skip to content

Commit c2a89ac

Browse files
authored
---
yaml --- r: 314295 b: refs/heads/rxwei-patch-6 c: 1a92886 h: refs/heads/master i: 314293: 92ed1d3 314291: 65042bb 314287: a642b3d
1 parent 89c4a3b commit c2a89ac

27 files changed

+618
-168
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ refs/heads/remove-AlignedCharArray: a09ee8660ce66898d5a5a04e2adb4a5ecf1c4644
14221422
refs/heads/revert-25193-gsoc-2019-parser: c66a8be4eb8cea9e606bcbfce52820ad02f23413
14231423
refs/heads/revert-25911-revert-25766-reenable-test-tsan-norace-deinit: 0f330b25b83d3c83ce993f535d4a83bb626aafa3
14241424
refs/heads/revert-26183-rename-adjoint-to-pullback: b16bd9f4bc54ae8ec31f412ac542dcf6f522d9ee
1425-
refs/heads/rxwei-patch-6: 184d942ba00a230e471553ff494f9e9553e40b1f
1425+
refs/heads/rxwei-patch-6: 1a9288694dfb9c4ddf4f95c0e0c0e91d651117cb
14261426
refs/heads/shahmishal-patch-3: f3e0bc73927d564bb35354dc6473a1981f2a864e
14271427
refs/heads/shahmishal/pr-swiftsyntax-test: 64ff140a6dfa78ecea27eeb6d29582650198f3e0
14281428
refs/heads/test-libdispatch-preset-on-swift-5.1-branch: 2ab0acdec00ee31d21490154081c3001648a8b85

branches/rxwei-patch-6/benchmark/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ set(SWIFT_BENCH_MODULES
166166
single-source/StringInterpolation
167167
single-source/StringMatch
168168
single-source/StringRemoveDupes
169+
single-source/StringReplaceSubrange
169170
single-source/StringTests
170171
single-source/StringWalk
171172
single-source/Substring
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
//===--- StringReplaceSubrange.swift -------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import TestsUtils
14+
15+
let tags: [BenchmarkCategory] = [.validation, .api, .String]
16+
17+
public let StringReplaceSubrange = [
18+
BenchmarkInfo(
19+
name: "String.replaceSubrange.String.Small",
20+
runFunction: { replaceSubrange($0, smallString, with: "t") },
21+
tags: tags
22+
),
23+
BenchmarkInfo(
24+
name: "String.replaceSubrange.String",
25+
runFunction: { replaceSubrange($0, largeString, with: "t") },
26+
tags: tags
27+
),
28+
BenchmarkInfo(
29+
name: "String.replaceSubrange.Substring.Small",
30+
runFunction: { replaceSubrange($0, smallString, with: "t"[...]) },
31+
tags: tags
32+
),
33+
BenchmarkInfo(
34+
name: "String.replaceSubrange.Substring",
35+
runFunction: { replaceSubrange($0, largeString, with: "t"[...]) },
36+
tags: tags
37+
),
38+
BenchmarkInfo(
39+
name: "String.replaceSubrange.ArrChar.Small",
40+
runFunction: { replaceSubrange($0, smallString, with: arrayCharacter) },
41+
tags: tags
42+
),
43+
BenchmarkInfo(
44+
name: "String.replaceSubrange.ArrChar",
45+
runFunction: { replaceSubrange($0, largeString, with: arrayCharacter) },
46+
tags: tags
47+
),
48+
BenchmarkInfo(
49+
name: "String.replaceSubrange.RepChar.Small",
50+
runFunction: { replaceSubrange($0, smallString, with: repeatedCharacter) },
51+
tags: tags
52+
),
53+
BenchmarkInfo(
54+
name: "String.replaceSubrange.RepChar",
55+
runFunction: { replaceSubrange($0, largeString, with: repeatedCharacter) },
56+
tags: tags
57+
),
58+
]
59+
60+
let smallString = "coffee"
61+
let largeString = "coffee\u{301}coffeecoffeecoffeecoffee"
62+
63+
let arrayCharacter = Array<Character>(["t"])
64+
let repeatedCharacter = repeatElement(Character("t"), count: 1)
65+
66+
@inline(never)
67+
private func replaceSubrange<C: Collection>(
68+
_ N: Int, _ string: String, with newElements: C
69+
) where C.Element == Character {
70+
var copy = getString(string)
71+
let range = string.startIndex..<string.index(after: string.startIndex)
72+
for _ in 0 ..< 500 * N {
73+
copy.replaceSubrange(range, with: newElements)
74+
}
75+
}

branches/rxwei-patch-6/benchmark/utils/main.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ import StringEnum
161161
import StringInterpolation
162162
import StringMatch
163163
import StringRemoveDupes
164+
import StringReplaceSubrange
164165
import StringTests
165166
import StringWalk
166167
import Substring
@@ -343,6 +344,7 @@ registerBenchmark(StringInterpolationManySmallSegments)
343344
registerBenchmark(StringMatch)
344345
registerBenchmark(StringNormalization)
345346
registerBenchmark(StringRemoveDupes)
347+
registerBenchmark(StringReplaceSubrange)
346348
registerBenchmark(StringTests)
347349
registerBenchmark(StringWalk)
348350
registerBenchmark(SubstringTest)

branches/rxwei-patch-6/include/swift/AST/ASTTypeIDZone.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ SWIFT_TYPEID(TypePair)
2424
SWIFT_TYPEID(PropertyWrapperBackingPropertyInfo)
2525
SWIFT_TYPEID(PropertyWrapperTypeInfo)
2626
SWIFT_TYPEID(CtorInitializerKind)
27+
SWIFT_TYPEID(ResilienceExpansion)
2728
SWIFT_TYPEID_NAMED(Optional<PropertyWrapperMutability>, PropertyWrapperMutability)
2829
SWIFT_TYPEID_NAMED(CustomAttr *, CustomAttr)
2930
SWIFT_TYPEID_NAMED(TypeAliasDecl *, TypeAliasDecl)

branches/rxwei-patch-6/include/swift/AST/TypeCheckRequests.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,29 @@ class StructuralTypeRequest :
662662
bool isCached() const { return true; }
663663
};
664664

665+
/// Request the most optimal resilience expansion for the code in the context.
666+
class ResilienceExpansionRequest :
667+
public SimpleRequest<ResilienceExpansionRequest,
668+
ResilienceExpansion(DeclContext*),
669+
CacheKind::Cached> {
670+
public:
671+
using SimpleRequest::SimpleRequest;
672+
673+
private:
674+
friend SimpleRequest;
675+
676+
// Evaluation.
677+
llvm::Expected<ResilienceExpansion> evaluate(Evaluator &eval,
678+
DeclContext *context) const;
679+
680+
public:
681+
// Caching.
682+
bool isCached() const { return true; }
683+
};
684+
685+
void simple_display(llvm::raw_ostream &out,
686+
const ResilienceExpansion &value);
687+
665688
/// Request the custom attribute which attaches a function builder to the
666689
/// given declaration.
667690
class AttachedFunctionBuilderRequest :

branches/rxwei-patch-6/include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ SWIFT_TYPEID(RequirementSignatureRequest)
3030
SWIFT_TYPEID(DefaultDefinitionTypeRequest)
3131
SWIFT_TYPEID(USRGenerationRequest)
3232
SWIFT_TYPEID(StructuralTypeRequest)
33+
SWIFT_TYPEID(ResilienceExpansionRequest)
3334
SWIFT_TYPEID(DefaultTypeRequest)
3435
SWIFT_TYPEID(MangleLocalTypeDeclRequest)
3536
SWIFT_TYPEID(PropertyWrapperTypeInfoRequest)

branches/rxwei-patch-6/include/swift/Basic/Platform.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ namespace swift {
4646
/// Return true if the given triple represents any simulator.
4747
bool tripleIsAnySimulator(const llvm::Triple &triple);
4848

49+
/// Returns true if the given triple represents an OS that ships with
50+
/// ABI-stable swift libraries (eg. in /usr/lib/swift).
51+
bool tripleRequiresRPathForSwiftInOS(const llvm::Triple &triple);
52+
4953
/// Returns the platform name for a given target triple.
5054
///
5155
/// For example, the iOS simulator has the name "iphonesimulator", while real

branches/rxwei-patch-6/include/swift/Option/Options.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,12 @@ def static_stdlib: Flag<["-"], "static-stdlib">,
502502
def no_static_stdlib: Flag<["-"], "no-static-stdlib">,
503503
Flags<[HelpHidden,DoesNotAffectIncrementalBuild]>,
504504
HelpText<"Don't statically link the Swift standard library">;
505+
def toolchain_stdlib_rpath: Flag<["-"], "toolchain-stdlib-rpath">,
506+
Flags<[HelpHidden,DoesNotAffectIncrementalBuild]>,
507+
HelpText<"Add an rpath entry for the toolchain's standard library, rather than the OS's">;
508+
def no_stdlib_rpath: Flag<["-"], "no-stdlib-rpath">,
509+
Flags<[HelpHidden,DoesNotAffectIncrementalBuild]>,
510+
HelpText<"Don't add any rpath entries.">;
505511

506512
def static_executable : Flag<["-"], "static-executable">,
507513
HelpText<"Statically link the executable">;

branches/rxwei-patch-6/lib/AST/DeclContext.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "swift/AST/LazyResolver.h"
2121
#include "swift/AST/Module.h"
2222
#include "swift/AST/Types.h"
23+
#include "swift/AST/TypeCheckRequests.h"
2324
#include "swift/Basic/SourceManager.h"
2425
#include "swift/Basic/Statistic.h"
2526
#include "llvm/ADT/DenseMap.h"
@@ -310,7 +311,16 @@ bool DeclContext::isGenericContext() const {
310311
/// domains, this ensures that only sufficiently-conservative access patterns
311312
/// are used.
312313
ResilienceExpansion DeclContext::getResilienceExpansion() const {
313-
for (const auto *dc = getLocalContext(); dc && dc->isLocalContext();
314+
auto &context = getASTContext();
315+
return evaluateOrDefault(context.evaluator,
316+
ResilienceExpansionRequest { const_cast<DeclContext *>(this) },
317+
ResilienceExpansion::Minimal);
318+
}
319+
320+
llvm::Expected<ResilienceExpansion>
321+
swift::ResilienceExpansionRequest::evaluate(Evaluator &eval,
322+
DeclContext *context) const {
323+
for (const auto *dc = context->getLocalContext(); dc && dc->isLocalContext();
314324
dc = dc->getParent()) {
315325
// Default argument initializer contexts have their resilience expansion
316326
// set when they're type checked.

branches/rxwei-patch-6/lib/AST/TypeCheckRequests.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,11 @@ void swift::simple_display(llvm::raw_ostream &os, PropertyWrapperMutability m) {
615615
os << "getter " << names[m.Getter] << ", setter " << names[m.Setter];
616616
}
617617

618+
void swift::simple_display(llvm::raw_ostream &out,
619+
const ResilienceExpansion &value) {
620+
out << value;
621+
}
622+
618623
//----------------------------------------------------------------------------//
619624
// FunctionBuilder-related requests.
620625
//----------------------------------------------------------------------------//

branches/rxwei-patch-6/lib/Basic/Platform.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@ bool swift::tripleIsAnySimulator(const llvm::Triple &triple) {
5454
tripleIsAppleTVSimulator(triple);
5555
}
5656

57+
58+
bool swift::tripleRequiresRPathForSwiftInOS(const llvm::Triple &triple) {
59+
if (triple.isMacOSX()) {
60+
// macOS 10.14.4 contains a copy of Swift, but the linker will still use an
61+
// rpath-based install name until 10.15.
62+
return triple.isMacOSXVersionLT(10, 15);
63+
64+
} else if (triple.isiOS()) {
65+
return triple.isOSVersionLT(12, 2);
66+
67+
} else if (triple.isWatchOS()) {
68+
return triple.isOSVersionLT(5, 2);
69+
}
70+
71+
// Other platforms don't have Swift installed as part of the OS by default.
72+
return false;
73+
}
74+
5775
DarwinPlatformKind swift::getDarwinPlatformKind(const llvm::Triple &triple) {
5876
if (triple.isiOS()) {
5977
if (triple.isTvOS()) {

0 commit comments

Comments
 (0)