Skip to content

Commit 76f2c74

Browse files
Merge pull request #4443 from swiftwasm/main
[pull] swiftwasm from main
2 parents b1ac3d9 + f0f8911 commit 76f2c74

File tree

382 files changed

+6802
-1488
lines changed

Some content is hidden

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

382 files changed

+6802
-1488
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ option(SWIFT_BUILD_PERF_TESTSUITE
137137
"Create in-tree targets for building swift performance benchmarks."
138138
FALSE)
139139

140+
option(SWIFT_BUILD_REGEX_PARSER_IN_COMPILER
141+
"Build the Swift regex parser as part of the compiler."
142+
TRUE)
143+
140144
option(SWIFT_INCLUDE_TESTS "Create targets for building/running tests." TRUE)
141145

142146
option(SWIFT_INCLUDE_TEST_BINARIES

SwiftCompilerSources/Sources/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
add_subdirectory(Basic)
1212
add_subdirectory(AST)
13-
if(SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING)
13+
if(SWIFT_BUILD_REGEX_PARSER_IN_COMPILER)
1414
add_subdirectory(_RegexParser)
1515
endif()
1616
add_subdirectory(SIL)

SwiftCompilerSources/Sources/Optimizer/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
set(dependencies)
1010
list(APPEND dependencies Basic SIL)
11-
if(SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING)
11+
if(SWIFT_BUILD_REGEX_PARSER_IN_COMPILER)
1212
list(APPEND dependencies _CompilerRegexParser)
1313
endif()
1414

benchmark/scripts/Benchmark_DTrace.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
# ===--- Benchmark_DTrace.in ---------------------------------------------===//
44
#

benchmark/scripts/Benchmark_Driver

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

44
# ===--- Benchmark_Driver ------------------------------------------------===//

benchmark/scripts/Benchmark_GuardMalloc.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
# ===--- Benchmark_GuardMalloc.in ----------------------------------------===//
44
#

benchmark/scripts/Benchmark_QuickCheck.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
# ===--- Benchmark_QuickCheck.in -----------------------------------------===//
44
#

benchmark/scripts/Benchmark_RuntimeLeaksRunner.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
# ===--- Benchmark_RuntimeLeaksRunner.in ---------------------------------===//
44
#

benchmark/scripts/build_linux.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
import argparse
44
import os

benchmark/scripts/build_script_helper.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#!/usr/bin/env python
2-
3-
from __future__ import print_function
1+
#!/usr/bin/env python3
42

53
import argparse
64
import os

benchmark/scripts/compare_perf_tests.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

44
# ===--- compare_perf_tests.py -------------------------------------------===//
@@ -27,8 +27,6 @@ class `ReportFormatter` creates the test comparison report in specified format.
2727
2828
"""
2929

30-
from __future__ import print_function
31-
3230
import argparse
3331
import functools
3432
import re

benchmark/scripts/create_benchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
import argparse
44
import os

benchmark/scripts/generate_harness/generate_harness.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
# ===--- generate_harness.py ---------------------------------------------===//
44
#
@@ -14,8 +14,6 @@
1414

1515
# Generate boilerplate, CMakeLists.txt and utils/main.swift from templates.
1616

17-
from __future__ import print_function
18-
1917
import argparse
2018
import os
2119
import subprocess

benchmark/scripts/perf_test_driver/perf_test_driver.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
# ===--- perf_test_driver.py ---------------------------------------------===//
44
#
@@ -12,8 +12,6 @@
1212
#
1313
# ===---------------------------------------------------------------------===//
1414

15-
from __future__ import print_function
16-
1715
import functools
1816
import glob
1917
import multiprocessing

benchmark/scripts/run_smoke_bench

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

44
# ===--- run_smoke_bench -------------------------------------------------===//
@@ -21,8 +21,6 @@
2121
#
2222
# ===---------------------------------------------------------------------===//
2323

24-
from __future__ import print_function
25-
2624
import argparse
2725
import glob
2826
import os

benchmark/scripts/test_Benchmark_Driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

44
# ===--- test_Benchmark_Driver.py ----------------------------------------===//

benchmark/scripts/test_compare_perf_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

44
# ===--- test_compare_perf_tests.py --------------------------------------===//

benchmark/scripts/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

44
# ===--- test_utils.py ---------------------------------------------------===//

benchmark/utils/convertToJSON.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
# ===--- convertToJSON.py ------------------------------------------------===//
44
#
@@ -57,8 +57,6 @@
5757
# ]
5858
# }
5959

60-
from __future__ import print_function
61-
6260
import json
6361
import re
6462
import sys

docs/ABI/Mangling.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ Globals
189189
global ::= global 'MN' // noncanonical specialized generic type metadata for global
190190
global ::= global 'Mz' // canonical specialized generic type metadata caching token
191191

192+
global ::= global 'Mq' // global with a uniquing prefix
193+
192194
#if SWIFT_RUNTIME_VERSION >= 5.4
193195
global ::= context (decl-name '_')+ 'WZ' // global variable one-time initialization function
194196
global ::= context (decl-name '_')+ 'Wz' // global variable one-time initialization token
@@ -914,6 +916,23 @@ than the module of the conforming type or the conformed-to protocol), it is
914916
mangled with its offset into the set of conformance requirements, the
915917
root protocol conformance, and the suffix 'g'.
916918

919+
::
920+
921+
// No generalization signature, no type expression.
922+
extended-existential-shape ::= generic-signature 'Xg' extended-existential-value-storage
923+
924+
// Generalization signature (the second one), no type expression.
925+
extended-existential-shape ::= generic-signature generic-signature 'XG' extended-existential-value-storage
926+
927+
// No generalization signature, type expression.
928+
extended-existential-shape ::= generic-signature type 'Xh' extended-existential-value-storage
929+
930+
// Generalization signature (the second one), type expression.
931+
extended-existential-shape ::= generic-signature generic-signature type 'Xh' extended-existential-value-storage
932+
933+
extended-existential-value-storage ::= 'o' // opaque
934+
extended-existential-value-storage ::= 'c' // class
935+
extended-existential-value-storage ::= 'm' // metatype
917936

918937
Identifiers
919938
~~~~~~~~~~~

docs/HowToGuides/GettingStarted.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ Double-check that running `pwd` prints a path ending with `swift`.
157157
1. The latest Linux dependencies are listed in the respective Dockerfiles:
158158
* [Ubuntu 20.04](https://github.com/apple/swift-docker/blob/main/swift-ci/master/ubuntu/20.04/Dockerfile)
159159
* [CentOS 7](https://github.com/apple/swift-docker/blob/main/swift-ci/master/centos/7/Dockerfile)
160-
* [CentOS 8](https://github.com/apple/swift-docker/blob/main/swift-ci/master/centos/8/Dockerfile)
161160
* [Amazon Linux 2](https://github.com/apple/swift-docker/blob/main/swift-ci/master/amazon-linux/2/Dockerfile)
162161
163162
2. To install sccache (optional):

docs/scripts/ns-html2rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#!/usr/bin/env python
2-
from __future__ import print_function
3-
1+
#!/usr/bin/env python3
42
import re
53
import subprocess
64
import sys

include/swift/ABI/MetadataValues.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ class ExtendedExistentialTypeShapeFlags {
865865
(Data & ~SpecialKindMask) | (int_type(kind) << SpecialKindShift));
866866
}
867867
constexpr ExtendedExistentialTypeShapeFlags
868-
withHasTypeExpresssion(bool hasTypeExpression) const {
868+
withHasTypeExpression(bool hasTypeExpression) const {
869869
return ExtendedExistentialTypeShapeFlags(
870870
hasTypeExpression ? (Data | HasTypeExpression)
871871
: (Data & ~HasTypeExpression));
@@ -1424,6 +1424,9 @@ namespace SpecialPointerAuthDiscriminators {
14241424

14251425
/// Dispatch integration.
14261426
const uint16_t DispatchInvokeFunction = 0xf493; // = 62611
1427+
1428+
/// Functions accessible at runtime (i.e. distributed method accessors).
1429+
const uint16_t AccessibleFunctionRecord = 0x438c; // = 17292
14271430
}
14281431

14291432
/// The number of arguments that will be passed directly to a generic

include/swift/AST/DiagnosticEngine.h

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,7 @@ namespace swift {
848848
friend class DiagnosticTransaction;
849849
friend class CompoundDiagnosticTransaction;
850850
friend class DiagnosticStateRAII;
851+
friend class DiagnosticQueue;
851852

852853
public:
853854
explicit DiagnosticEngine(SourceManager &SourceMgr)
@@ -1137,10 +1138,20 @@ namespace swift {
11371138
/// Send \c diag to all diagnostic consumers.
11381139
void emitDiagnostic(const Diagnostic &diag);
11391140

1141+
/// Handle a new diagnostic, which will either be emitted, or added to an
1142+
/// active transaction.
1143+
void handleDiagnostic(Diagnostic &&diag);
1144+
1145+
/// Clear any tentative diagnostics.
1146+
void clearTentativeDiagnostics();
1147+
11401148
/// Send all tentative diagnostics to all diagnostic consumers and
11411149
/// delete them.
11421150
void emitTentativeDiagnostics();
11431151

1152+
/// Forward all tentative diagnostics to a different diagnostic engine.
1153+
void forwardTentativeDiagnosticsTo(DiagnosticEngine &targetEngine);
1154+
11441155
public:
11451156
DiagnosticKind declaredDiagnosticKindFor(const DiagID id);
11461157

@@ -1333,6 +1344,78 @@ namespace swift {
13331344
}
13341345
};
13351346

1347+
/// Represents a queue of diagnostics that have their emission delayed until
1348+
/// the queue is destroyed. This is similar to DiagnosticTransaction, but
1349+
/// with a few key differences:
1350+
///
1351+
/// - The queue maintains its own diagnostic engine (which may be accessed
1352+
/// through `getDiags()`), and diagnostics must be specifically emitted
1353+
/// using that engine to be enqueued.
1354+
/// - It allows for non-LIFO transactions, as each queue operates
1355+
/// independently.
1356+
/// - A queue can be drained multiple times without having to be recreated
1357+
/// (unlike DiagnosticTransaction, it has no concept of "closing").
1358+
///
1359+
/// Note you may add DiagnosticTransactions to the queue's diagnostic engine,
1360+
/// but they must be closed before attempting to clear or emit the diagnostics
1361+
/// in the queue.
1362+
///
1363+
class DiagnosticQueue final {
1364+
/// The underlying diagnostic engine that the diagnostics will be emitted
1365+
/// by.
1366+
DiagnosticEngine &UnderlyingEngine;
1367+
1368+
/// A temporary engine used to queue diagnostics.
1369+
DiagnosticEngine QueueEngine;
1370+
1371+
/// Whether the queued diagnostics should be emitted on the destruction of
1372+
/// the queue, or whether they should be cleared.
1373+
bool EmitOnDestruction;
1374+
1375+
public:
1376+
DiagnosticQueue(const DiagnosticQueue &) = delete;
1377+
DiagnosticQueue &operator=(const DiagnosticQueue &) = delete;
1378+
1379+
/// Create a new diagnostic queue with a given engine to forward the
1380+
/// diagnostics to.
1381+
explicit DiagnosticQueue(DiagnosticEngine &engine, bool emitOnDestruction)
1382+
: UnderlyingEngine(engine), QueueEngine(engine.SourceMgr),
1383+
EmitOnDestruction(emitOnDestruction) {
1384+
// Open a transaction to avoid emitting any diagnostics for the temporary
1385+
// engine.
1386+
QueueEngine.TransactionCount++;
1387+
}
1388+
1389+
/// Retrieve the engine which may be used to enqueue diagnostics.
1390+
DiagnosticEngine &getDiags() { return QueueEngine; }
1391+
1392+
/// Retrieve the underlying engine which will receive the diagnostics.
1393+
DiagnosticEngine &getUnderlyingDiags() { return UnderlyingEngine; }
1394+
1395+
/// Clear this queue and erase all diagnostics recorded.
1396+
void clear() {
1397+
assert(QueueEngine.TransactionCount == 1 &&
1398+
"Must close outstanding DiagnosticTransactions before draining");
1399+
QueueEngine.clearTentativeDiagnostics();
1400+
}
1401+
1402+
/// Emit all the diagnostics recorded by this queue.
1403+
void emit() {
1404+
assert(QueueEngine.TransactionCount == 1 &&
1405+
"Must close outstanding DiagnosticTransactions before draining");
1406+
QueueEngine.forwardTentativeDiagnosticsTo(UnderlyingEngine);
1407+
}
1408+
1409+
~DiagnosticQueue() {
1410+
if (EmitOnDestruction) {
1411+
emit();
1412+
} else {
1413+
clear();
1414+
}
1415+
QueueEngine.TransactionCount--;
1416+
}
1417+
};
1418+
13361419
inline void
13371420
DiagnosticEngine::diagnoseWithNotes(InFlightDiagnostic parentDiag,
13381421
llvm::function_ref<void(void)> builder) {

include/swift/AST/DiagnosticsParse.def

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ ERROR(forbidden_extended_escaping_string,none,
9494
ERROR(regex_literal_parsing_error,none,
9595
"%0", (StringRef))
9696

97+
ERROR(prefix_slash_not_allowed,none,
98+
"prefix operator may not contain '/'", ())
99+
97100
//------------------------------------------------------------------------------
98101
// MARK: Lexer diagnostics
99102
//------------------------------------------------------------------------------
@@ -140,7 +143,10 @@ ERROR(lex_invalid_escape_delimiter,none,
140143
ERROR(lex_invalid_closing_delimiter,none,
141144
"too many '#' characters in closing delimiter", ())
142145

143-
ERROR(lex_unterminated_regex,none,
146+
ERROR(lex_regex_literal_invalid_starting_char,none,
147+
"regex literal may not start with %0; add backslash to escape",
148+
(StringRef))
149+
ERROR(lex_regex_literal_unterminated,none,
144150
"unterminated regex literal", ())
145151

146152
ERROR(lex_invalid_unicode_scalar,none,

include/swift/AST/DiagnosticsSema.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4538,6 +4538,10 @@ NOTE(note_distributed_actor_system_can_be_defined_using_defaultdistributedactors
45384538
ERROR(distributed_actor_protocol_illegal_inheritance,none,
45394539
"non-distributed actor type %0 cannot conform to the 'DistributedActor' protocol",
45404540
(DeclName))
4541+
ERROR(actor_cannot_inherit_distributed_actor_protocol,none,
4542+
"actor type %0 cannot conform to the 'DistributedActor' protocol. "
4543+
"Isolation rules of these actor types are not interchangeable.",
4544+
(DeclName))
45414545
ERROR(broken_distributed_actor_requirement,none,
45424546
"DistributedActor protocol is broken: unexpected requirement", ())
45434547
ERROR(distributed_actor_system_conformance_missing_adhoc_requirement,none,

0 commit comments

Comments
 (0)