Skip to content

Commit b24a97c

Browse files
authored
---
yaml --- r: 275453 b: refs/heads/master-next c: 68cb52a h: refs/heads/master i: 275451: 08468a6
1 parent a882806 commit b24a97c

Some content is hidden

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

48 files changed

+1327
-181
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 65b3164726f2e62dff31e90a5cb5e3fb67cc82bf
3-
refs/heads/master-next: 52054d2443f844cdbe99799b9353b9afd45ec873
3+
refs/heads/master-next: 68cb52a35161f97604577d39f6f2dc2b190c38cd
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/CHANGELOG.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66

77
| Contents |
88
| :--------------------- |
9+
| [Swift 5.1](#swift-51) |
910
| [Swift 5.0](#swift-50) |
1011
| [Swift 4.2](#swift-42) |
1112
| [Swift 4.1](#swift-41) |
@@ -29,11 +30,13 @@ Swift 5.1
2930
* Single-parameter functions accepting values of type `Any` are no
3031
longer preferred over other functions.
3132

32-
```swift
33-
func foo(_: Any) { print("Any") }
34-
func foo<T>(_: T) { print("T") }
35-
foo(0) // prints "Any" in Swift < 5.1, "T" in Swift 5.1
36-
```
33+
```swift
34+
func foo(_: Any) { print("Any") }
35+
func foo<T>(_: T) { print("T") }
36+
foo(0) // prints "Any" in Swift < 5.1, "T" in Swift 5.1
37+
```
38+
39+
**Add new entries to the top of this section, not here!**
3740

3841
Swift 5.0
3942
---------

branches/master-next/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ option(SWIFT_RUNTIME_CRASH_REPORTER_CLIENT
235235
FALSE)
236236

237237
option(SWIFT_DARWIN_ENABLE_STABLE_ABI_BIT
238-
"Enable the Swift stable ABI's class marker bit"
239-
FALSE)
238+
"Enable the Swift stable ABI's class marker bit for new deployment targets"
239+
TRUE)
240240

241241
set(SWIFT_DARWIN_XCRUN_TOOLCHAIN "XcodeDefault" CACHE STRING
242242
"The name of the toolchain to pass to 'xcrun'")

branches/master-next/cmake/modules/AddSwift.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,15 @@ function(_add_swift_library_single target name)
12091209
"${SWIFTLIB_SINGLE_FORCE_BUILD_OPTIMIZED_keyword}"
12101210
RESULT_VAR_NAME c_compile_flags
12111211
)
1212+
1213+
if(SWIFTLIB_IS_STDLIB)
1214+
# We don't ever want to link against the ABI-breakage checking symbols
1215+
# in the standard library, runtime, or overlays because they only rely
1216+
# on the header parts of LLVM's ADT.
1217+
list(APPEND c_compile_flags
1218+
"-DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1")
1219+
endif()
1220+
12121221
if(SWIFTLIB_SINGLE_SDK STREQUAL WINDOWS)
12131222
if(libkind STREQUAL SHARED)
12141223
list(APPEND c_compile_flags -D_WINDLL)

branches/master-next/include/swift/ABI/Metadata.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,31 @@ struct TargetClassMetadata : public TargetAnyClassMetadata<Runtime> {
11921192
return bounds;
11931193
}
11941194

1195+
/// Given a statically-emitted metadata template, this sets the correct
1196+
/// "is Swift" bit for the current runtime. Depending on the deployment
1197+
/// target a binary was compiled for, statically emitted metadata templates
1198+
/// may have a different bit set from the one that this runtime canonically
1199+
/// considers the "is Swift" bit.
1200+
void setAsTypeMetadata() {
1201+
// If the wrong "is Swift" bit is set, set the correct one.
1202+
//
1203+
// Note that the only time we should see the "new" bit set while
1204+
// expecting the "old" one is when running a binary built for a
1205+
// new OS on an old OS, which is not supported, however we do
1206+
// have tests that exercise this scenario.
1207+
auto otherSwiftBit = (3ULL - SWIFT_CLASS_IS_SWIFT_MASK);
1208+
assert(otherSwiftBit == 1ULL || otherSwiftBit == 2ULL);
1209+
1210+
if ((this->Data & 3) == otherSwiftBit) {
1211+
this->Data ^= 3;
1212+
}
1213+
1214+
// Otherwise there should be nothing to do, since only the old "is
1215+
// Swift" bit is used for backward-deployed runtimes.
1216+
1217+
assert(isTypeMetadata());
1218+
}
1219+
11951220
static bool classof(const TargetMetadata<Runtime> *metadata) {
11961221
return metadata->getKind() == MetadataKind::Class;
11971222
}

branches/master-next/include/swift/Basic/Mangler.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ class Mangler {
7878
}
7979
};
8080

81+
void addSubstWordsInIdent(const WordReplacement &repl) {
82+
SubstWordsInIdent.push_back(repl);
83+
}
84+
85+
void addWord(const SubstitutionWord &word) {
86+
Words.push_back(word);
87+
}
88+
8189
/// Returns the buffer as a StringRef, needed by mangleIdentifier().
8290
StringRef getBufferStr() const {
8391
return StringRef(Storage.data(), Storage.size());

branches/master-next/include/swift/Demangling/Demangle.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -490,23 +490,23 @@ void mangleIdentifier(const char *data, size_t length,
490490
bool usePunycode = true);
491491

492492
/// Remangle a demangled parse tree.
493-
///
494-
/// If \p BorrowFrom is specified, the initial bump pointer memory is
495-
/// borrowed from the free memory of BorrowFrom.
496-
std::string mangleNode(NodePointer root,
497-
NodeFactory *BorrowFrom = nullptr);
493+
std::string mangleNode(NodePointer root);
498494

499495
using SymbolicResolver =
500496
llvm::function_ref<Demangle::NodePointer (SymbolicReferenceKind,
501497
const void *)>;
502498

499+
/// Remangle a demangled parse tree, using a callback to resolve
500+
/// symbolic references.
501+
std::string mangleNode(NodePointer root, SymbolicResolver resolver);
502+
503503
/// Remangle a demangled parse tree, using a callback to resolve
504504
/// symbolic references.
505505
///
506-
/// If \p BorrowFrom is specified, the initial bump pointer memory is
507-
/// borrowed from the free memory of BorrowFrom.
508-
std::string mangleNode(NodePointer root, SymbolicResolver resolver,
509-
NodeFactory *BorrowFrom = nullptr);
506+
/// The returned string is owned by \p Factory. This means \p Factory must stay
507+
/// alive as long as the returned string is used.
508+
llvm::StringRef mangleNode(NodePointer root, SymbolicResolver resolver,
509+
NodeFactory &Factory);
510510

511511
/// Remangle in the old mangling scheme.
512512
///

branches/master-next/include/swift/Demangling/Demangler.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,11 @@ template<typename T> class Vector {
279279
Capacity = 0;
280280
Elems = 0;
281281
}
282-
282+
283+
void clear() {
284+
NumElems = 0;
285+
}
286+
283287
iterator begin() { return Elems; }
284288
iterator end() { return Elems + NumElems; }
285289

@@ -299,6 +303,11 @@ template<typename T> class Vector {
299303

300304
T &back() { return (*this)[NumElems - 1]; }
301305

306+
void resetSize(size_t toPos) {
307+
assert(toPos <= NumElems);
308+
NumElems = toPos;
309+
}
310+
302311
void push_back(const T &NewElem, NodeFactory &Factory) {
303312
if (NumElems >= Capacity)
304313
Factory.Reallocate(Elems, Capacity, /*Growth*/ 1);
@@ -327,6 +336,9 @@ class CharVector : public Vector<char> {
327336
// Append an integer as readable number.
328337
void append(int Number, NodeFactory &Factory);
329338

339+
// Append an unsigned 64 bit integer as readable number.
340+
void append(unsigned long long Number, NodeFactory &Factory);
341+
330342
StringRef str() const {
331343
return StringRef(Elems, NumElems);
332344
}

branches/master-next/include/swift/Demangling/ManglingUtils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,13 @@ void mangleIdentifier(Mangler &M, StringRef ident) {
160160
if (WordIdx >= 0) {
161161
// We found a word substitution!
162162
assert(WordIdx < 26);
163-
M.SubstWordsInIdent.push_back({wordStartPos, WordIdx});
163+
M.addSubstWordsInIdent({wordStartPos, WordIdx});
164164
} else if (wordLen >= 2 && M.Words.size() < M.MaxNumWords) {
165165
// It's a new word: remember it.
166166
// Note: at this time the word's start position is relative to the
167167
// begin of the identifier. We must update it afterwards so that it is
168168
// relative to the begin of the whole mangled Buffer.
169-
M.Words.push_back({wordStartPos, wordLen});
169+
M.addWord({wordStartPos, wordLen});
170170
}
171171
wordStartPos = NotInsideWord;
172172
}
@@ -181,7 +181,7 @@ void mangleIdentifier(Mangler &M, StringRef ident) {
181181

182182
size_t Pos = 0;
183183
// Add a dummy-word at the end of the list.
184-
M.SubstWordsInIdent.push_back({ident.size(), -1});
184+
M.addSubstWordsInIdent({ident.size(), -1});
185185

186186
// Mangle a sequence of word substitutions and sub-strings.
187187
for (size_t Idx = 0, End = M.SubstWordsInIdent.size(); Idx < End; ++Idx) {

branches/master-next/include/swift/Demangling/TypeDecoder.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ class TypeDecoder {
315315
if (Node->getNumChildren() < 2)
316316
return BuiltType();
317317

318-
std::vector<BuiltType> args;
318+
SmallVector<BuiltType, 8> args;
319319

320320
const auto &genericArgs = Node->getChild(1);
321321
assert(genericArgs->getKind() == NodeKind::TypeList);
@@ -427,7 +427,7 @@ class TypeDecoder {
427427
return BuiltType();
428428

429429
// Find the protocol list.
430-
std::vector<BuiltProtocolDecl> Protocols;
430+
SmallVector<BuiltProtocolDecl, 8> Protocols;
431431
auto TypeList = Node->getChild(0);
432432
if (TypeList->getKind() == NodeKind::ProtocolList &&
433433
TypeList->getNumChildren() >= 1) {
@@ -514,7 +514,7 @@ class TypeDecoder {
514514
return BuiltType();
515515

516516
bool hasParamFlags = false;
517-
std::vector<FunctionParam<BuiltType>> parameters;
517+
SmallVector<FunctionParam<BuiltType>, 8> parameters;
518518
if (!decodeMangledFunctionInputType(Node->getChild(isThrow ? 1 : 0),
519519
parameters, hasParamFlags))
520520
return BuiltType();
@@ -531,9 +531,9 @@ class TypeDecoder {
531531
}
532532
case NodeKind::ImplFunctionType: {
533533
auto calleeConvention = ImplParameterConvention::Direct_Unowned;
534-
std::vector<ImplFunctionParam<BuiltType>> parameters;
535-
std::vector<ImplFunctionResult<BuiltType>> results;
536-
std::vector<ImplFunctionResult<BuiltType>> errorResults;
534+
SmallVector<ImplFunctionParam<BuiltType>, 8> parameters;
535+
SmallVector<ImplFunctionResult<BuiltType>, 8> results;
536+
SmallVector<ImplFunctionResult<BuiltType>, 8> errorResults;
537537
ImplFunctionTypeFlags flags;
538538

539539
for (unsigned i = 0; i < Node->getNumChildren(); i++) {
@@ -611,7 +611,7 @@ class TypeDecoder {
611611
return decodeMangledType(Node->getChild(0));
612612

613613
case NodeKind::Tuple: {
614-
std::vector<BuiltType> elements;
614+
SmallVector<BuiltType, 8> elements;
615615
std::string labels;
616616
bool variadic = false;
617617
for (auto &element : *Node) {
@@ -785,7 +785,7 @@ class TypeDecoder {
785785
private:
786786
template <typename T>
787787
bool decodeImplFunctionPart(Demangle::NodePointer node,
788-
std::vector<T> &results) {
788+
SmallVectorImpl<T> &results) {
789789
if (node->getNumChildren() != 2)
790790
return true;
791791

@@ -871,7 +871,7 @@ class TypeDecoder {
871871

872872
bool decodeMangledFunctionInputType(
873873
Demangle::NodePointer node,
874-
std::vector<FunctionParam<BuiltType>> &params,
874+
SmallVectorImpl<FunctionParam<BuiltType>> &params,
875875
bool &hasParamFlags) {
876876
// Look through a couple of sugar nodes.
877877
if (node->getKind() == NodeKind::Type ||

branches/master-next/include/swift/Reflection/TypeRefBuilder.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,12 @@ class TypeRefBuilder {
210210

211211
Optional<std::string>
212212
createTypeDecl(Node *node, bool &typeAlias) {
213-
return Demangle::mangleNode(node, &Dem);
213+
return Demangle::mangleNode(node);
214214
}
215215

216216
BuiltProtocolDecl
217217
createProtocolDecl(Node *node) {
218-
return std::make_pair(Demangle::mangleNode(node, &Dem), false);
218+
return std::make_pair(Demangle::mangleNode(node), false);
219219
}
220220

221221
BuiltProtocolDecl
@@ -274,21 +274,21 @@ class TypeRefBuilder {
274274

275275
const BoundGenericTypeRef *
276276
createBoundGenericType(const Optional<std::string> &mangledName,
277-
const std::vector<const TypeRef *> &args,
277+
ArrayRef<const TypeRef *> args,
278278
const TypeRef *parent) {
279279
return BoundGenericTypeRef::create(*this, *mangledName, args, parent);
280280
}
281281

282282
const TupleTypeRef *
283-
createTupleType(const std::vector<const TypeRef *> &elements,
283+
createTupleType(ArrayRef<const TypeRef *> elements,
284284
std::string &&labels, bool isVariadic) {
285285
// FIXME: Add uniqueness checks in TupleTypeRef::Profile and
286286
// unittests/Reflection/TypeRef.cpp if using labels for identity.
287287
return TupleTypeRef::create(*this, elements, isVariadic);
288288
}
289289

290290
const FunctionTypeRef *createFunctionType(
291-
const std::vector<remote::FunctionParam<const TypeRef *>> &params,
291+
ArrayRef<remote::FunctionParam<const TypeRef *>> params,
292292
const TypeRef *result, FunctionTypeFlags flags) {
293293
return FunctionTypeRef::create(*this, params, result, flags);
294294
}
@@ -406,7 +406,7 @@ class TypeRefBuilder {
406406

407407
const ObjCClassTypeRef *
408408
createBoundGenericObjCClassType(const std::string &name,
409-
std::vector<const TypeRef *> &args) {
409+
ArrayRef<const TypeRef *> args) {
410410
// Remote reflection just ignores generic arguments for Objective-C
411411
// lightweight generic types, since they don't affect layout.
412412
return createObjCClassType(name);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//===--- BackDeployment.h - Support for running on older OS versions. -----===//
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+
#ifndef SWIFT_STDLIB_BACKDEPLOYMENT_H
14+
#define SWIFT_STDLIB_BACKDEPLOYMENT_H
15+
16+
#if defined(__APPLE__) && defined(__MACH__)
17+
18+
#include "swift/Runtime/Config.h"
19+
#include "../../../stdlib/public/SwiftShims/Visibility.h"
20+
21+
#ifdef __cplusplus
22+
namespace swift { extern "C" {
23+
#endif
24+
25+
#if SWIFT_CLASS_IS_SWIFT_MASK_GLOBAL_VARIABLE
26+
# ifndef __cplusplus
27+
// This file gets included from some C/ObjC files and
28+
// SWIFT_RUNTIME_STDLIB_SPI doesn't imply extern in C.
29+
extern
30+
# endif
31+
SWIFT_RUNTIME_STDLIB_SPI unsigned long long _swift_classIsSwiftMask;
32+
#endif
33+
34+
/// Returns true if the current OS version, at runtime, is a back-deployment
35+
/// version.
36+
SWIFT_RUNTIME_STDLIB_INTERNAL
37+
int _swift_isBackDeploying();
38+
39+
#ifdef __cplusplus
40+
}} // extern "C", namespace swift
41+
#endif
42+
43+
#endif // defined(__APPLE__) && defined(__MACH__)
44+
45+
#endif // SWIFT_STDLIB_BACKDEPLOYMENT_H

branches/master-next/include/swift/Runtime/CMakeConfig.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55
#define SWIFT_RUNTIME_CMAKECONFIG_H
66

77
#cmakedefine01 SWIFT_DARWIN_ENABLE_STABLE_ABI_BIT
8+
#cmakedefine01 SWIFT_BNI_OS_BUILD
9+
#cmakedefine01 SWIFT_BNI_XCODE_BUILD
810

911
#endif
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
1+
# Detect B&I builds.
2+
set(SWIFT_BNI_OS_BUILD FALSE)
3+
set(SWIFT_BNI_XCODE_BUILD FALSE)
4+
if(DEFINED ENV{RC_XBS})
5+
if(NOT DEFINED ENV{RC_XCODE} OR NOT "$ENV{RC_XCODE}")
6+
set(SWIFT_BNI_OS_BUILD TRUE)
7+
else()
8+
set(SWIFT_BNI_XCODE_BUILD TRUE)
9+
endif()
10+
endif()
11+
112
configure_file(CMakeConfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/CMakeConfig.h
213
ESCAPE_QUOTES @ONLY)

0 commit comments

Comments
 (0)