Skip to content

Commit 407bfb9

Browse files
authored
---
yaml --- r: 245759 b: refs/heads/marcrasi-static-assert c: eac1524 h: refs/heads/master i: 245757: 5bda214 245755: 0595368 245751: 2ce295a 245743: 9b5a5fd 245727: 2e9a202 245695: 1a03880 245631: 024075c 245503: 94d0b18 245247: 5d17d4d 244735: f43bb5c 243711: 6072ae5 241663: 2827929 237567: 994e00e 229375: 9ccee7d
1 parent 9b81631 commit 407bfb9

File tree

133 files changed

+60098
-10659
lines changed

Some content is hidden

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

133 files changed

+60098
-10659
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-09-20-a: 37a08a7edae5cf9ebde7866dbc974
10711071
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-09-21-a: a47bb052988de099ac2562a50cd1ee60a411e182
10721072
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-09-22-a: 141f61f3c887a81aa5d7a66e843f5e5e9a31ca02
10731073
refs/heads/anotherdayanothercommit: 983c399b25b26d80728c0bf11b12afac852768f6
1074-
refs/heads/marcrasi-static-assert: dd8edef2d5644c9228e8b3f5381d97f5b772dc87
1074+
refs/heads/marcrasi-static-assert: eac1524277364fc04a5e60d6eaf739b93251afcc
10751075
refs/heads/revert-19500-updateValue-but-not-the-key: b4e27b110af0d7e3002b4f734a347f752d42b9a8
10761076
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-09-25-a: 2ed7952ddd7ef765b60efd13e169ea900ebb5e80
10771077
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-09-26-a: b7cbce34ef0921069091a65e5918640bb382a419

branches/marcrasi-static-assert/benchmark/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ set(SWIFT_BENCH_MODULES
8888
single-source/Hash
8989
single-source/HashQuadratic
9090
single-source/Histogram
91+
single-source/InsertCharacter
9192
single-source/Integrate
9293
single-source/IterateData
9394
single-source/Join
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
//===--- InsertCharacter.swift ------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2018 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+
public let InsertCharacter = [
16+
BenchmarkInfo(name: "InsertCharacterEndIndex", runFunction: run_InsertCharacterEndIndex, tags: [.validation, .api], setUpFunction: buildWorkload),
17+
BenchmarkInfo(name: "InsertCharacterTowardsEndIndex", runFunction: run_InsertCharacterTowardsEndIndex, tags: [.validation, .api], setUpFunction: buildWorkload),
18+
BenchmarkInfo(name: "InsertCharacterStartIndex", runFunction: run_InsertCharacterStartIndex, tags: [.validation, .api], setUpFunction: buildWorkload),
19+
BenchmarkInfo(name: "InsertCharacterEndIndexNonASCII", runFunction: run_InsertCharacterEndIndexNonASCII, tags: [.validation, .api], setUpFunction: buildWorkload),
20+
BenchmarkInfo(name: "InsertCharacterTowardsEndIndexNonASCII", runFunction: run_InsertCharacterTowardsEndIndexNonASCII, tags: [.validation, .api], setUpFunction: buildWorkload),
21+
BenchmarkInfo(name: "InsertCharacterStartIndexNonASCII", runFunction: run_InsertCharacterStartIndexNonASCII, tags: [.validation, .api], setUpFunction: buildWorkload)
22+
]
23+
24+
let str = String(repeating: "A very long ASCII string.", count: 200)
25+
26+
func buildWorkload() {
27+
blackHole(str)
28+
}
29+
30+
// Insert towards end index
31+
32+
@inline(__always)
33+
func insertTowardsEndIndex(_ c: Character, in string: String, count: Int) {
34+
var workload = string
35+
var index = workload.endIndex
36+
for i in 0..<count {
37+
workload.insert(identity(c), at: index)
38+
if i % 1000 == 0 {
39+
index = workload.endIndex
40+
}
41+
}
42+
blackHole(workload)
43+
}
44+
45+
@inline(never)
46+
func run_InsertCharacterTowardsEndIndex(_ N: Int) {
47+
insertTowardsEndIndex("s", in: str, count: N * 3000)
48+
}
49+
50+
@inline(never)
51+
func run_InsertCharacterTowardsEndIndexNonASCII(_ N: Int) {
52+
insertTowardsEndIndex("👩🏼‍💻", in: str, count: N * 1000)
53+
}
54+
55+
// Insert at end index
56+
57+
@inline(__always)
58+
func insertAtEndIndex(_ c: Character, in string: String, count: Int) {
59+
var workload = string
60+
for _ in 0..<count {
61+
workload.insert(identity(c), at: workload.endIndex)
62+
}
63+
blackHole(workload)
64+
}
65+
66+
@inline(never)
67+
func run_InsertCharacterEndIndex(_ N: Int) {
68+
insertAtEndIndex("s", in: str, count: N * 3000)
69+
}
70+
71+
@inline(never)
72+
func run_InsertCharacterEndIndexNonASCII(_ N: Int) {
73+
insertAtEndIndex("👩🏾‍🏫", in: str, count: N * 1000)
74+
}
75+
76+
// Insert at start index
77+
78+
@inline(__always)
79+
func insertAtStartIndex(_ c: Character, in string: String, count: Int, insertions: Int) {
80+
var workload = str
81+
for _ in 0..<count {
82+
for _ in 0..<insertions {
83+
workload.insert(identity(c), at: workload.startIndex)
84+
}
85+
workload = str
86+
}
87+
blackHole(workload)
88+
}
89+
90+
@inline(never)
91+
func run_InsertCharacterStartIndex(_ N: Int) {
92+
insertAtStartIndex("w", in: str, count: N * 75, insertions: 50)
93+
}
94+
95+
@inline(never)
96+
func run_InsertCharacterStartIndexNonASCII(_ N: Int) {
97+
insertAtStartIndex("👩🏾‍🏫", in: str, count: N * 75, insertions: 25)
98+
}

branches/marcrasi-static-assert/benchmark/utils/main.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ import Hanoi
7676
import Hash
7777
import HashQuadratic
7878
import Histogram
79+
import InsertCharacter
7980
import Integrate
8081
import IterateData
8182
import Join
@@ -241,6 +242,7 @@ registerBenchmark(Hanoi)
241242
registerBenchmark(HashTest)
242243
registerBenchmark(HashQuadratic)
243244
registerBenchmark(Histogram)
245+
registerBenchmark(InsertCharacter)
244246
registerBenchmark(IntegrateTest)
245247
registerBenchmark(IterateData)
246248
registerBenchmark(Join)

branches/marcrasi-static-assert/docs/ABI/Mangling.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Globals
128128

129129
global ::= protocol-conformance 'Mc' // protocol conformance descriptor
130130
global ::= protocol-conformance 'WP' // protocol witness table
131-
global ::= protocol-conformance 'Wa' // protocol witness table accessor
131+
global ::= protocol-conformance 'Wa' // protocol witness table accessor (HISTORICAL)
132132

133133
global ::= protocol-conformance 'WG' // generic protocol witness table (HISTORICAL)
134134
global ::= protocol-conformance 'Wp' // protocol witness table pattern

branches/marcrasi-static-assert/docs/GenericsManifesto.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public struct ZipIterator<... Iterators : IteratorProtocol> : Iterator { // zer
346346
public mutating func next() -> Element? {
347347
if reachedEnd { return nil }
348348

349-
guard let values = (iterators.next()...) { // call "next" on each of the iterators, put the results into a tuple named "values"
349+
guard let values = (iterators.next()...) else { // call "next" on each of the iterators, put the results into a tuple named "values"
350350
reachedEnd = true
351351
return nil
352352
}

branches/marcrasi-static-assert/include/swift/ABI/Metadata.h

Lines changed: 20 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,13 +2013,10 @@ struct TargetGenericWitnessTable {
20132013
/// to require instantiation.
20142014
uint16_t WitnessTablePrivateSizeInWordsAndRequiresInstantiation;
20152015

2016-
/// The pattern.
2017-
RelativeDirectPointer<const TargetWitnessTable<Runtime>> Pattern;
2018-
20192016
/// The instantiation function, which is called after the template is copied.
20202017
RelativeDirectPointer<void(TargetWitnessTable<Runtime> *instantiatedTable,
20212018
const TargetMetadata<Runtime> *type,
2022-
void ** const *instantiationArgs),
2019+
const void * const *instantiationArgs),
20232020
/*nullable*/ true> Instantiator;
20242021

20252022
using PrivateDataType = void *[swift::NumGenericMetadataPrivateDataWords];
@@ -2036,18 +2033,6 @@ struct TargetGenericWitnessTable {
20362033
uint16_t requiresInstantiation() const {
20372034
return WitnessTablePrivateSizeInWordsAndRequiresInstantiation & 0x01;
20382035
}
2039-
2040-
/// Retrieve the protocol conformance descriptor.
2041-
ConstTargetPointer<Runtime, TargetProtocolConformanceDescriptor<Runtime>>
2042-
getConformance() const {
2043-
return Pattern->Description;
2044-
}
2045-
2046-
/// Retrieve the protocol.
2047-
ConstTargetPointer<Runtime, TargetProtocolDescriptor<Runtime>>
2048-
getProtocol() const {
2049-
return Pattern->Description->getProtocol();
2050-
}
20512036
};
20522037
using GenericWitnessTable = TargetGenericWitnessTable<InProcess>;
20532038

@@ -2279,15 +2264,8 @@ struct TargetProtocolConformanceDescriptor final
22792264
// Some description of the type that conforms to the protocol.
22802265
TargetTypeReference<Runtime> TypeRef;
22812266

2282-
// The conformance, or a generator function for the conformance.
2283-
union {
2284-
/// A direct reference to the witness table for the conformance.
2285-
RelativeDirectPointer<const TargetWitnessTable<Runtime>> WitnessTable;
2286-
2287-
/// A function that produces the witness table given an instance of the
2288-
/// type.
2289-
RelativeDirectPointer<WitnessTableAccessorFn> WitnessTableAccessor;
2290-
};
2267+
/// The witness table pattern, which may also serve as the witness table.
2268+
RelativeDirectPointer<const TargetWitnessTable<Runtime>> WitnessTablePattern;
22912269

22922270
/// Various flags, including the kind of conformance.
22932271
ConformanceFlags Flags;
@@ -2302,10 +2280,6 @@ struct TargetProtocolConformanceDescriptor final
23022280
return Flags.getTypeReferenceKind();
23032281
}
23042282

2305-
typename ConformanceFlags::ConformanceKind getConformanceKind() const {
2306-
return Flags.getConformanceKind();
2307-
}
2308-
23092283
const char *getDirectObjCClassName() const {
23102284
return TypeRef.getDirectObjCClassName(getTypeKind());
23112285
}
@@ -2325,6 +2299,18 @@ struct TargetProtocolConformanceDescriptor final
23252299
return this->template getTrailingObjects<RelativeContextPointer<Runtime>>();
23262300
}
23272301

2302+
/// Whether this conformance is non-unique because it has been synthesized
2303+
/// for a foreign type.
2304+
bool isSynthesizedNonUnique() const {
2305+
return Flags.isSynthesizedNonUnique();
2306+
}
2307+
2308+
/// Whether this conformance has any conditional requirements that need to
2309+
/// be evaluated.
2310+
bool hasConditionalRequirements() const {
2311+
return Flags.getNumConditionalRequirements() > 0;
2312+
}
2313+
23282314
/// Retrieve the conditional requirements that must also be
23292315
/// satisfied
23302316
llvm::ArrayRef<GenericRequirementDescriptor>
@@ -2333,31 +2319,12 @@ struct TargetProtocolConformanceDescriptor final
23332319
Flags.getNumConditionalRequirements()};
23342320
}
23352321

2336-
/// Get the directly-referenced static witness table.
2337-
const swift::TargetWitnessTable<Runtime> *getStaticWitnessTable() const {
2338-
switch (getConformanceKind()) {
2339-
case ConformanceFlags::ConformanceKind::WitnessTable:
2340-
break;
2341-
2342-
case ConformanceFlags::ConformanceKind::WitnessTableAccessor:
2343-
case ConformanceFlags::ConformanceKind::ConditionalWitnessTableAccessor:
2344-
assert(false && "not witness table");
2345-
}
2346-
return WitnessTable;
2322+
/// Get the directly-referenced witness table pattern, which may also
2323+
/// serve as the witness table.
2324+
const swift::TargetWitnessTable<Runtime> *getWitnessTablePattern() const {
2325+
return WitnessTablePattern;
23472326
}
2348-
2349-
WitnessTableAccessorFn *getWitnessTableAccessor() const {
2350-
switch (getConformanceKind()) {
2351-
case ConformanceFlags::ConformanceKind::WitnessTableAccessor:
2352-
case ConformanceFlags::ConformanceKind::ConditionalWitnessTableAccessor:
2353-
break;
2354-
2355-
case ConformanceFlags::ConformanceKind::WitnessTable:
2356-
assert(false && "not witness table accessor");
2357-
}
2358-
return WitnessTableAccessor;
2359-
}
2360-
2327+
23612328
/// Get the canonical metadata for the type referenced by this record, or
23622329
/// return null if the record references a generic or universal type.
23632330
const TargetMetadata<Runtime> *getCanonicalTypeMetadata() const;

branches/marcrasi-static-assert/include/swift/ABI/MetadataValues.h

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -600,24 +600,9 @@ class ConformanceFlags {
600600
public:
601601
typedef uint32_t int_type;
602602

603-
enum class ConformanceKind {
604-
/// A direct reference to a protocol witness table.
605-
WitnessTable,
606-
/// A function pointer that can be called to access the protocol witness
607-
/// table.
608-
WitnessTableAccessor,
609-
/// A function pointer that can be called to access the protocol witness
610-
/// table whose conformance is conditional on additional requirements that
611-
/// must first be evaluated and then provided to the accessor function.
612-
ConditionalWitnessTableAccessor,
613-
614-
First_Kind = WitnessTable,
615-
Last_Kind = ConditionalWitnessTableAccessor,
616-
};
617-
618603
private:
619604
enum : int_type {
620-
ConformanceKindMask = 0x07, // 8 conformance kinds
605+
UnusedLowBits = 0x07, // historical conformance kind
621606

622607
TypeMetadataKindMask = 0x7 << 3, // 8 type reference kinds
623608
TypeMetadataKindShift = 3,
@@ -637,10 +622,6 @@ class ConformanceFlags {
637622
public:
638623
ConformanceFlags(int_type value = 0) : Value(value) {}
639624

640-
ConformanceFlags withConformanceKind(ConformanceKind kind) const {
641-
return ConformanceFlags((Value & ~ConformanceKindMask) | int_type(kind));
642-
}
643-
644625
ConformanceFlags withTypeReferenceKind(TypeReferenceKind kind) const {
645626
return ConformanceFlags((Value & ~TypeMetadataKindMask)
646627
| (int_type(kind) << TypeMetadataKindShift));
@@ -677,11 +658,6 @@ class ConformanceFlags {
677658
: 0));
678659
}
679660

680-
/// Retrieve the conformance kind.
681-
ConformanceKind getConformanceKind() const {
682-
return ConformanceKind(Value & ConformanceKindMask);
683-
}
684-
685661
/// Retrieve the type reference kind kind.
686662
TypeReferenceKind getTypeReferenceKind() const {
687663
return TypeReferenceKind(
@@ -880,7 +856,11 @@ using FunctionTypeFlags = TargetFunctionTypeFlags<size_t>;
880856

881857
template <typename int_type>
882858
class TargetParameterTypeFlags {
883-
enum : int_type { ValueOwnershipMask = 0x7F, VariadicMask = 0x80 };
859+
enum : int_type {
860+
ValueOwnershipMask = 0x7F,
861+
VariadicMask = 0x80,
862+
AutoClosureMask = 0x100,
863+
};
884864
int_type Data;
885865

886866
constexpr TargetParameterTypeFlags(int_type Data) : Data(Data) {}
@@ -900,8 +880,15 @@ class TargetParameterTypeFlags {
900880
(isVariadic ? VariadicMask : 0));
901881
}
902882

883+
constexpr TargetParameterTypeFlags<int_type>
884+
withAutoClosure(bool isAutoClosure) const {
885+
return TargetParameterTypeFlags<int_type>(
886+
(Data & ~AutoClosureMask) | (isAutoClosure ? AutoClosureMask : 0));
887+
}
888+
903889
bool isNone() const { return Data == 0; }
904890
bool isVariadic() const { return Data & VariadicMask; }
891+
bool isAutoClosure() const { return Data & AutoClosureMask; }
905892

906893
ValueOwnership getValueOwnership() const {
907894
return (ValueOwnership)(Data & ValueOwnershipMask);

branches/marcrasi-static-assert/include/swift/AST/Decl.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,8 @@ class alignas(1 << DeclAlignInBits) Decl {
463463
HasStubImplementation : 1
464464
);
465465

466-
SWIFT_INLINE_BITFIELD_EMPTY(AbstractTypeParamDecl, ValueDecl);
466+
SWIFT_INLINE_BITFIELD_EMPTY(TypeDecl, ValueDecl);
467+
SWIFT_INLINE_BITFIELD_EMPTY(AbstractTypeParamDecl, TypeDecl);
467468

468469
SWIFT_INLINE_BITFIELD_FULL(GenericTypeParamDecl, AbstractTypeParamDecl, 16+16,
469470
: NumPadBits,
@@ -472,7 +473,7 @@ class alignas(1 << DeclAlignInBits) Decl {
472473
Index : 16
473474
);
474475

475-
SWIFT_INLINE_BITFIELD_EMPTY(GenericTypeDecl, ValueDecl);
476+
SWIFT_INLINE_BITFIELD_EMPTY(GenericTypeDecl, TypeDecl);
476477

477478
SWIFT_INLINE_BITFIELD(TypeAliasDecl, GenericTypeDecl, 1+1,
478479
/// Whether the typealias forwards perfectly to its underlying type.
@@ -572,6 +573,22 @@ class alignas(1 << DeclAlignInBits) Decl {
572573
HasAnyUnavailableValues : 1
573574
);
574575

576+
SWIFT_INLINE_BITFIELD(ModuleDecl, TypeDecl, 1+1+1+1,
577+
/// If the module was or is being compiled with `-enable-testing`.
578+
TestingEnabled : 1,
579+
580+
/// If the module failed to load
581+
FailedToLoad : 1,
582+
583+
/// Whether the module is resilient.
584+
///
585+
/// \sa ResilienceStrategy
586+
RawResilienceStrategy : 1,
587+
588+
/// Whether all imports have been resolved. Used to detect circular imports.
589+
HasResolvedImports : 1
590+
);
591+
575592
SWIFT_INLINE_BITFIELD(PrecedenceGroupDecl, Decl, 1+2,
576593
/// Is this an assignment operator?
577594
IsAssignment : 1,

0 commit comments

Comments
 (0)