Skip to content

Commit 410e2f7

Browse files
committed
Update from upstream
2 parents e4719f8 + d6bbf81 commit 410e2f7

File tree

827 files changed

+15826
-10391
lines changed

Some content is hidden

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

827 files changed

+15826
-10391
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ option(SWIFT_RUNTIME_CRASH_REPORTER_CLIENT
207207
"Whether to enable CrashReporter integration"
208208
FALSE)
209209

210+
option(SWIFT_DARWIN_ENABLE_STABLE_ABI_BIT
211+
"Enable the Swift stable ABI's class marker bit"
212+
FALSE)
213+
210214
set(SWIFT_DARWIN_XCRUN_TOOLCHAIN "XcodeDefault" CACHE STRING
211215
"The name of the toolchain to pass to 'xcrun'")
212216

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ options such as building a Swift-compatible LLDB, building the Swift Package
114114
Manager, building for various platforms, running tests after builds, and more.
115115

116116
There are two primary build systems to use: Xcode and Ninja. The Xcode build
117-
system allows you to work in Xcode.app, but Ninja is a bit faster and supports
117+
system allows you to work in Xcode, but Ninja is a bit faster and supports
118118
more environments.
119119

120120
To build using Ninja, run:
@@ -143,7 +143,7 @@ information, see the inline help:
143143
#### Xcode
144144

145145
To build using Xcode, specify the `--xcode` argument on any of the above commands.
146-
Xcode.app can be used to edit the Swift source code, but it is not currently
146+
Xcode can be used to edit the Swift source code, but it is not currently
147147
fully supported as a build environment for SDKs other than macOS. The generated
148148
Xcode project does not integrate with the test runner, but the tests can be run
149149
with the 'check-swift' target.
@@ -159,7 +159,7 @@ helps to save this directory as an environment variable for future use.
159159

160160
#### Ninja
161161

162-
Once the first build has completed, ninja can perform fast incremental builds of
162+
Once the first build has completed, Ninja can perform fast incremental builds of
163163
various products. These incremental builds are a big timesaver when developing
164164
and debugging.
165165

benchmark/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,20 @@ option(SWIFT_BENCHMARK_GENERATE_OPT_VIEW
217217
"Produce optimization view for benchmarks"
218218
FALSE)
219219

220+
set(SWIFT_BENCHMARK_OPT_VIEWER "" CACHE FILEPATH
221+
"Path to opt-viewer")
222+
223+
if(SWIFT_BENCHMARK_OPT_VIEWER)
224+
# If the path to the opt-viewer was specified manually and we have no access
225+
# to the LLVM tree, assume we have the modules for the opt-viewer installed.
226+
if(SWIFT_BENCHMARK_BUILT_STANDALONE)
227+
set(LLVM_HAVE_OPT_VIEWER_MODULES 1)
228+
endif()
229+
else()
230+
set (SWIFT_BENCHMARK_OPT_VIEWER
231+
"${LLVM_BUILD_MAIN_SRC_DIR}/tools/opt-viewer/opt-viewer.py")
232+
endif()
233+
220234
# Options for other configurations
221235
set(BENCHOPTS_MULTITHREADED
222236
"-whole-module-optimization" "-num-threads" "4")

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,10 @@ endfunction()
9999
function(add_opt_view opt_view_main_dir, module_name, opt_view_dir_out)
100100
set(opt_view_dir "${opt_view_main_dir}/${module_name}")
101101
set(opt_record "${objdir}/${module_name}.opt.yaml")
102-
set(opt_viewer "${LLVM_BUILD_MAIN_SRC_DIR}/tools/opt-viewer/opt-viewer.py")
103102
add_custom_command(
104103
OUTPUT ${opt_view_dir}
105104
DEPENDS "${objfile}"
106-
COMMAND ${opt_viewer} ${opt_record} "-o" ${opt_view_dir})
105+
COMMAND ${SWIFT_BENCHMARK_OPT_VIEWER} ${opt_record} "-o" ${opt_view_dir})
107106
set(${opt_view_dir_out} ${opt_view_dir} PARENT_SCOPE)
108107
endfunction()
109108

@@ -214,9 +213,6 @@ function (swift_benchmark_compile_archopts)
214213

215214
set(opt_view_main_dir)
216215
if(SWIFT_BENCHMARK_GENERATE_OPT_VIEW AND LLVM_HAVE_OPT_VIEWER_MODULES)
217-
precondition(SWIFT_BENCHMARK_BUILT_STANDALONE NEGATE
218-
"Opt-viewer is not supported when running the benchmarks outside the Swift tree")
219-
220216
if(NOT ${optflag} STREQUAL "Onone" AND "${bench_flags}" MATCHES "-whole-module.*")
221217
list(APPEND common_options "-save-optimization-record")
222218
set(opt_view_main_dir "${objdir}/opt-view")

benchmark/single-source/ArraySetElement.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import TestsUtils
1818
public var ArraySetElement = BenchmarkInfo(
1919
name: "ArraySetElement",
2020
runFunction: run_ArraySetElement,
21-
tags: [.runtime, .cpubench]
21+
tags: [.runtime, .cpubench, .unstable]
2222
)
2323

2424
// This is an effort to defeat isUniquelyReferenced optimization. Ideally

benchmark/single-source/Exclusivity.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public let Exclusivity = [
3535
BenchmarkInfo(
3636
name: "ExclusivityInMatSet",
3737
runFunction: run_accessInMatSet,
38-
tags: [.runtime, .cpubench]
38+
tags: [.runtime, .cpubench, .unstable]
3939
),
4040
// At -Onone
4141
// 25% swift_release

cmake/modules/AddSwift.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,9 @@ function(_add_swift_library_single target name)
856856
if("${SWIFTLIB_SINGLE_SDK}" STREQUAL "WINDOWS")
857857
swift_windows_include_for_arch(${SWIFTLIB_SINGLE_ARCHITECTURE} SWIFTLIB_INCLUDE)
858858
target_include_directories("${target}" SYSTEM PRIVATE ${SWIFTLIB_INCLUDE})
859+
set_target_properties(${target}
860+
PROPERTIES
861+
CXX_STANDARD 14)
859862
endif()
860863

861864
if("${SWIFTLIB_SINGLE_SDK}" STREQUAL "WINDOWS" AND NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")

docs/ABI/Mangling.rst

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,13 @@ Entities
175175
static ::= 'Z'
176176
curry-thunk ::= 'Tc'
177177

178+
label-list ::= empty-list // represents complete absence of parameter labels
179+
label-list ::= ('_' | identifier)* // '_' is inserted as placeholder for empty label,
180+
// since the number of labels should match the number of parameters
181+
178182
// The leading type is the function type
179-
entity-spec ::= type file-discriminator? 'fC' // allocating constructor
180-
entity-spec ::= type file-discriminator? 'fc' // non-allocating constructor
183+
entity-spec ::= label-list type file-discriminator? 'fC' // allocating constructor
184+
entity-spec ::= label-list type file-discriminator? 'fc' // non-allocating constructor
181185
entity-spec ::= type 'fU' INDEX // explicit anonymous closure expression
182186
entity-spec ::= type 'fu' INDEX // implicit anonymous closure
183187
entity-spec ::= 'fA' INDEX // default argument N+1 generator
@@ -189,11 +193,11 @@ Entities
189193
entity-spec ::= 'Tv' NATURAL // outlined global variable (from context function)
190194
entity-spec ::= 'Te' bridge-spec // outlined objective c method call
191195

192-
entity-spec ::= decl-name function-signature generic-signature? 'F' // function
193-
entity-spec ::= type file-discriminator? 'i' ACCESSOR // subscript
194-
entity-spec ::= decl-name type 'v' ACCESSOR // variable
195-
entity-spec ::= decl-name type 'fp' // generic type parameter
196-
entity-spec ::= decl-name type 'fo' // enum element (currently not used)
196+
entity-spec ::= decl-name label-list function-signature generic-signature? 'F' // function
197+
entity-spec ::= label-list type file-discriminator? 'i' ACCESSOR // subscript
198+
entity-spec ::= decl-name label-list? type 'v' ACCESSOR // variable
199+
entity-spec ::= decl-name type 'fp' // generic type parameter
200+
entity-spec ::= decl-name type 'fo' // enum element (currently not used)
197201

198202
ACCESSOR ::= 'm' // materializeForSet
199203
ACCESSOR ::= 's' // setter
@@ -351,7 +355,8 @@ Types
351355
function-signature ::= params-type params-type throws? // results and parameters
352356

353357
params-type := type 'z'? 'h'? // tuple in case of multiple parameters or a single parameter with a single tuple type
354-
// with optional inout convention, shared convention
358+
// with optional inout convention, shared convention. parameters don't have labels,
359+
// they are mangled separately as part of the entity.
355360
params-type := empty-list // shortcut for no parameters
356361

357362
throws ::= 'K' // 'throws' annotation on function types

docs/ErrorHandlingRationale.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -577,9 +577,9 @@ be able to recognize specific classes of error, but libraries
577577
generally want to reserve flexibility about the exact kind of error
578578
they produce, and so many errors just end up falling into broad
579579
buckets. Different libraries end up with their own library-specific
580-
general error classes, and exceptions list end up just restating the
580+
general error classes, and exception lists end up just restating the
581581
library's own dependencies or wrapping the underlying errors in ways
582-
that loses critical information.
582+
that lose critical information.
583583
584584
585585
Tradeoffs of typed propagation
@@ -799,7 +799,7 @@ significantly for the common case of frames that just need to run some
799799
clean-ups before propagating the error further. It may even
800800
completely eliminate the need for a landing pad.
801801
802-
The ObjC/C++ exceptions system on iOS/ARM32 is kindof like that
802+
The ObjC/C++ exceptions system on iOS/ARM32 is kind of like that
803803
hybrid. Propagation and clean-up code is explicit in the function,
804804
but the registered context includes the "personality" information from
805805
the unwinding tables, which makes the decision whether to land at the
@@ -1096,7 +1096,7 @@ exceptions.
10961096
10971097
Objective-C exceptions are *mostly* only used for unrecoverable
10981098
conditions, akin to what I called "failures" above. There are a few
1099-
major exceptions to this rule, where APIs that do use exceptions to
1099+
major exceptions to this rule, where APIs do use exceptions to
11001100
report errors.
11011101
11021102
Instead, Objective-C mostly relies on manual propagation,
@@ -1134,7 +1134,7 @@ failures in our scheme; essentially, Java attempts to promote a fully
11341134
statically-enforced model where truly catastrophic problems can still
11351135
be handled when necessary. Unfortunately, these motivations don't
11361136
seem to have been communicated very well to developers, and the result
1137-
is kindof a mess.
1137+
is kind of a mess.
11381138
11391139
Java allows methods to be very specific about the kinds of exception
11401140
they throw. In my experience, exceptions tend to fall into two
@@ -1420,9 +1420,9 @@ It is valuable to be able to overload higher-order functions based on
14201420
whether an argument function throws; it is easy to imagine algorithms
14211421
that can be implemented more efficiently if they do not need to worry
14221422
about exceptions. (We do not, however, particularly want to encourage
1423-
a pattern of duplicating This is straightforward if the primary
1423+
a pattern of duplicating. This is straightforward if the primary
14241424
type-checking pass is able to reliably decide whether a function value
1425-
can throw.
1425+
can throw.)
14261426
14271427
Typed propagation checking can generally be performed in a secondary
14281428
pass over a type-checked function body: if a function is not permitted
@@ -1509,7 +1509,7 @@ code using the protocol to deal with probably-spurious errors, or
15091509
aggressively forbid them, and thus forbid conformances by types whose
15101510
operations naturally throw.
15111511
1512-
There are several different ways we could approach this problem, but
1512+
There are several different ways we could approach this problem, and
15131513
after some investigation I feel confident that they're workable.
15141514
Unfortunately, they are clearly out-of-scope for the first release.
15151515
For now, the standard library should provide protocols that cannot

docs/Runtime.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,9 @@ runtime.
314314
000000000001e620 T _swift_allocateGenericValueMetadata
315315
0000000000022be0 T _swift_initClassMetadata_UniversalStrategy
316316
000000000001c100 T _swift_initEnumMetadataMultiPayload
317-
000000000001bd60 T _swift_initEnumValueWitnessTableSinglePayload
318-
0000000000022a20 T _swift_initStructMetadata_UniversalStrategy
317+
000000000001bd60 T _swift_initEnumMetadataSingleCase
318+
000000000001bd60 T _swift_initEnumMetadataSinglePayload
319+
0000000000022a20 T _swift_initStructMetadata
319320
0000000000024230 T _swift_initializeSuperclass
320321
0000000000028b60 T _swift_instantiateObjCClass
321322
```

include/swift/ABI/MetadataValues.h

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,16 @@ inline DynamicCastFlags &operator|=(DynamicCastFlags &a, DynamicCastFlags b) {
8686
}
8787

8888
/// Swift class flags.
89+
/// These flags are valid only when isTypeMetadata().
90+
/// When !isTypeMetadata() these flags will collide with other Swift ABIs.
8991
enum class ClassFlags : uint32_t {
90-
/// Is this a Swift 1 class?
91-
IsSwift1 = 0x1,
92+
/// Is this a Swift class from the Darwin pre-stable ABI?
93+
/// This bit is clear in stable ABI Swift classes.
94+
/// The Objective-C runtime also reads this bit.
95+
IsSwiftPreStableABI = 0x1,
9296

93-
/// Does this class use Swift 1.0 refcounting?
94-
UsesSwift1Refcounting = 0x2,
97+
/// Does this class use Swift refcounting?
98+
UsesSwiftRefcounting = 0x2,
9599

96100
/// Has this class a custom name, specified with the @objc attribute?
97101
HasCustomObjCName = 0x4
@@ -747,6 +751,62 @@ static inline bool isWarningOnly(ExclusivityFlags flags) {
747751
return uintptr_t(flags) & uintptr_t(ExclusivityFlags::WarningOnly);
748752
}
749753

754+
/// Flags for struct layout.
755+
enum class StructLayoutFlags : uintptr_t {
756+
/// Reserve space for 256 layout algorithms.
757+
AlgorithmMask = 0xff,
758+
759+
/// The ABI baseline algorithm, i.e. the algorithm implemented in Swift 5.
760+
Swift5Algorithm = 0x00,
761+
762+
/// Is the value-witness table mutable in place, or does layout need to
763+
/// clone it?
764+
IsVWTMutable = 0x100,
765+
};
766+
static inline StructLayoutFlags operator|(StructLayoutFlags lhs,
767+
StructLayoutFlags rhs) {
768+
return StructLayoutFlags(uintptr_t(lhs) | uintptr_t(rhs));
769+
}
770+
static inline StructLayoutFlags &operator|=(StructLayoutFlags &lhs,
771+
StructLayoutFlags rhs) {
772+
return (lhs = (lhs | rhs));
773+
}
774+
static inline StructLayoutFlags getLayoutAlgorithm(StructLayoutFlags flags) {
775+
return StructLayoutFlags(uintptr_t(flags)
776+
& uintptr_t(StructLayoutFlags::AlgorithmMask));
777+
}
778+
static inline bool isValueWitnessTableMutable(StructLayoutFlags flags) {
779+
return uintptr_t(flags) & uintptr_t(StructLayoutFlags::IsVWTMutable);
780+
}
781+
782+
/// Flags for enum layout.
783+
enum class EnumLayoutFlags : uintptr_t {
784+
/// Reserve space for 256 layout algorithms.
785+
AlgorithmMask = 0xff,
786+
787+
/// The ABI baseline algorithm, i.e. the algorithm implemented in Swift 5.
788+
Swift5Algorithm = 0x00,
789+
790+
/// Is the value-witness table mutable in place, or does layout need to
791+
/// clone it?
792+
IsVWTMutable = 0x100,
793+
};
794+
static inline EnumLayoutFlags operator|(EnumLayoutFlags lhs,
795+
EnumLayoutFlags rhs) {
796+
return EnumLayoutFlags(uintptr_t(lhs) | uintptr_t(rhs));
797+
}
798+
static inline EnumLayoutFlags &operator|=(EnumLayoutFlags &lhs,
799+
EnumLayoutFlags rhs) {
800+
return (lhs = (lhs | rhs));
801+
}
802+
static inline EnumLayoutFlags getLayoutAlgorithm(EnumLayoutFlags flags) {
803+
return EnumLayoutFlags(uintptr_t(flags)
804+
& uintptr_t(EnumLayoutFlags::AlgorithmMask));
805+
}
806+
static inline bool isValueWitnessTableMutable(EnumLayoutFlags flags) {
807+
return uintptr_t(flags) & uintptr_t(EnumLayoutFlags::IsVWTMutable);
808+
}
809+
750810
} // end namespace swift
751811

752812
#endif /* SWIFT_ABI_METADATAVALUES_H */

include/swift/AST/ASTContext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,8 @@ class ASTContext {
482482
FuncDecl *getEqualIntDecl() const;
483483

484484
/// Retrieve the declaration of
485-
/// Swift._mixForSynthesizedHashValue (Int, Int) -> Int.
486-
FuncDecl *getMixForSynthesizedHashValueDecl() const;
485+
/// Swift._combineHashValues(Int, Int) -> Int.
486+
FuncDecl *getCombineHashValuesDecl() const;
487487

488488
/// Retrieve the declaration of Swift._mixInt(Int) -> Int.
489489
FuncDecl *getMixIntDecl() const;

include/swift/AST/ASTMangler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ class ASTMangler : public Mangler {
187187

188188
void appendAnyGenericType(const GenericTypeDecl *decl);
189189

190+
void appendFunction(AnyFunctionType *fn, bool isFunctionMangling = false);
190191
void appendFunctionType(AnyFunctionType *fn);
191192

192193
void appendFunctionSignature(AnyFunctionType *fn);

include/swift/AST/Builtins.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ ValueDecl *getBuiltinValueDecl(ASTContext &Context, Identifier Name);
9999
StringRef getBuiltinName(BuiltinValueKind ID);
100100

101101
/// \brief The information identifying the builtin - its kind and types.
102-
struct BuiltinInfo {
102+
class BuiltinInfo {
103+
public:
103104
BuiltinValueKind ID;
104105
SmallVector<Type, 4> Types;
105106
bool isReadNone() const;

0 commit comments

Comments
 (0)