Skip to content

Commit 911ae5f

Browse files
authored
Merge pull request #80690 from swiftlang/revert-80601-maxd/fix-executor-impl
Revert "Concurrency: Move code between `Executor{Bridge,Impl}.cpp`"
2 parents ce680ea + ef6cf57 commit 911ae5f

File tree

3 files changed

+72
-99
lines changed

3 files changed

+72
-99
lines changed

stdlib/public/Concurrency/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,8 @@ set(SWIFT_RUNTIME_CONCURRENCY_SWIFT_SOURCES
166166
PlatformExecutorWindows.swift
167167
)
168168

169-
set(SWIFT_RUNTIME_CONCURRENCY_NONEMBEDDED_C_SOURCES
170-
ExecutorImpl.cpp
171-
)
172-
173169
set(SWIFT_RUNTIME_CONCURRENCY_EXECUTOR_SOURCES)
174170
set(SWIFT_RUNTIME_CONCURRENCY_NONEMBEDDED_SWIFT_SOURCES)
175-
176171
if("${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "dispatch")
177172
set(SWIFT_RUNTIME_CONCURRENCY_EXECUTOR_SOURCES
178173
DispatchGlobalExecutor.cpp
@@ -207,7 +202,6 @@ set(LLVM_OPTIONAL_SOURCES
207202
add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB
208203
${SWIFT_RUNTIME_CONCURRENCY_C_SOURCES}
209204
${SWIFT_RUNTIME_CONCURRENCY_EXECUTOR_SOURCES}
210-
${SWIFT_RUNTIME_CONCURRENCY_NONEMBEDDED_C_SOURCES}
211205
${SWIFT_RUNTIME_CONCURRENCY_SWIFT_SOURCES}
212206
${SWIFT_RUNTIME_CONCURRENCY_NONEMBEDDED_SWIFT_SOURCES}
213207

stdlib/public/Concurrency/ExecutorBridge.cpp

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,83 @@ SerialExecutorRef swift_getMainExecutor() {
3434
}
3535
#endif
3636

37+
extern "C" SWIFT_CC(swift)
38+
void _swift_task_checkIsolatedSwift(
39+
HeapObject *executor,
40+
const Metadata *executorType,
41+
const SerialExecutorWitnessTable *witnessTable
42+
);
43+
3744
extern "C" SWIFT_CC(swift)
3845
void _swift_task_checkIsolatedSwift(HeapObject *executor,
3946
const Metadata *executorType,
4047
const SerialExecutorWitnessTable *witnessTable);
4148

49+
extern "C" SWIFT_CC(swift)
50+
bool _swift_task_isIsolatingCurrentContextSwift(
51+
HeapObject *executor,
52+
const Metadata *executorType,
53+
const SerialExecutorWitnessTable *witnessTable
54+
);
55+
56+
extern "C" SWIFT_CC(swift)
57+
bool _swift_task_isMainExecutorSwift(
58+
HeapObject *executor,
59+
const Metadata *executorType,
60+
const SerialExecutorWitnessTable *witnessTable
61+
);
62+
63+
extern "C" SWIFT_CC(swift)
64+
void swift_task_checkIsolatedImpl(SerialExecutorRef executor) {
65+
HeapObject *identity = executor.getIdentity();
66+
67+
// We might be being called with an actor rather than a "proper"
68+
// SerialExecutor; in that case, we won't have a SerialExecutor witness
69+
// table.
70+
if (executor.hasSerialExecutorWitnessTable()) {
71+
_swift_task_checkIsolatedSwift(identity,
72+
swift_getObjectType(identity),
73+
executor.getSerialExecutorWitnessTable());
74+
} else {
75+
const Metadata *objectType = swift_getObjectType(executor.getIdentity());
76+
auto typeName = swift_getTypeName(objectType, true);
77+
78+
swift_Concurrency_fatalError(
79+
0, "Incorrect actor executor assumption; expected '%.*s' executor.\n",
80+
(int)typeName.length, typeName.data);
81+
}
82+
}
83+
84+
extern "C" SWIFT_CC(swift)
85+
bool swift_task_isIsolatingCurrentContextImpl(SerialExecutorRef executor) {
86+
HeapObject *identity = executor.getIdentity();
87+
88+
// We might be being called with an actor rather than a "proper"
89+
// SerialExecutor; in that case, we won't have a SerialExecutor witness
90+
// table.
91+
if (executor.hasSerialExecutorWitnessTable()) {
92+
return _swift_task_isIsolatingCurrentContextSwift(identity,
93+
swift_getObjectType(identity),
94+
executor.getSerialExecutorWitnessTable());
95+
} else {
96+
const Metadata *objectType = swift_getObjectType(executor.getIdentity());
97+
auto typeName = swift_getTypeName(objectType, true);
98+
99+
swift_Concurrency_fatalError(
100+
0, "Incorrect actor executor assumption; expected '%.*s' executor.\n",
101+
(int)typeName.length, typeName.data);
102+
}
103+
}
104+
105+
extern "C" SWIFT_CC(swift)
106+
bool swift_task_isMainExecutorImpl(SerialExecutorRef executor) {
107+
HeapObject *identity = executor.getIdentity();
108+
return executor.hasSerialExecutorWitnessTable()
109+
&& _swift_task_isMainExecutorSwift(identity,
110+
swift_getObjectType(identity),
111+
executor.getSerialExecutorWitnessTable());
112+
}
113+
42114
extern "C" SWIFT_CC(swift)
43115
uint8_t swift_job_getPriority(Job *job) {
44116
return (uint8_t)(job->getPriority());

stdlib/public/Concurrency/ExecutorImpl.cpp

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)