mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[6.2][Runtime] Add function_cast, switch from std::bit_cast.
Function types aren't always trivially copyable, e.g. with address-discriminated signed pointers on ARM64e. Introduce a function_cast helper and use that instead.
(cherry picked from commit 185b739cf1)
This commit is contained in:
@@ -17,9 +17,9 @@
|
||||
#include "swift/ABI/Actor.h"
|
||||
#include "swift/ABI/Metadata.h"
|
||||
#include "swift/ABI/Task.h"
|
||||
#include "swift/Basic/Casting.h"
|
||||
#include "swift/Runtime/AccessibleFunction.h"
|
||||
#include "swift/Runtime/Concurrency.h"
|
||||
#include "swift/Runtime/STLCompatibility.h"
|
||||
|
||||
using namespace swift;
|
||||
|
||||
@@ -103,7 +103,7 @@ static void swift_distributed_execute_target_resume(
|
||||
SWIFT_CONTEXT SwiftError *error) {
|
||||
auto parentCtx = context->Parent;
|
||||
auto resumeInParent =
|
||||
std::bit_cast<TargetExecutorSignature::ContinuationType *>(
|
||||
function_cast<TargetExecutorSignature::ContinuationType *>(
|
||||
parentCtx->ResumeParent);
|
||||
swift_task_dealloc(context);
|
||||
// See `swift_distributed_execute_target` - `parentCtx` in this case
|
||||
@@ -132,7 +132,7 @@ void swift_distributed_execute_target(
|
||||
SwiftError *error =
|
||||
swift_distributed_makeDistributedTargetAccessorNotFoundError();
|
||||
auto resumeInParent =
|
||||
std::bit_cast<TargetExecutorSignature::ContinuationType *>(
|
||||
function_cast<TargetExecutorSignature::ContinuationType *>(
|
||||
callerContext->ResumeParent);
|
||||
resumeInParent(callerContext, error);
|
||||
return;
|
||||
@@ -150,7 +150,7 @@ void swift_distributed_execute_target(
|
||||
swift_task_alloc(asyncFnPtr->ExpectedContextSize));
|
||||
|
||||
calleeContext->Parent = callerContext;
|
||||
calleeContext->ResumeParent = std::bit_cast<TaskContinuationFunction *>(
|
||||
calleeContext->ResumeParent = function_cast<TaskContinuationFunction *>(
|
||||
&swift_distributed_execute_target_resume);
|
||||
|
||||
accessorEntry(calleeContext, argumentDecoder, argumentTypes, resultBuffer,
|
||||
|
||||
Reference in New Issue
Block a user