Skip to content

[Distributed] Improve getting return type metadata for distributed invocations #79381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions stdlib/public/runtime/MetadataLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2945,8 +2945,12 @@ swift_func_getReturnTypeInfo(const char *typeNameStart, size_t typeNameLength,

SubstGenericParametersFromMetadata substFn(genericEnv, genericArguments);

DecodedMetadataBuilder builder(
demangler,
auto request = MetadataRequest(MetadataState::Complete);

NodePointer nodePointer = resultType->getFirstChild();
auto typeInfoOrErr = swift_getTypeByMangledNode(
request, demangler, nodePointer,
/*arguments=*/genericArguments,
/*substGenericParam=*/
[&substFn](unsigned depth, unsigned index) {
return substFn.getMetadata(depth, index).Ptr;
Expand All @@ -2956,9 +2960,12 @@ swift_func_getReturnTypeInfo(const char *typeNameStart, size_t typeNameLength,
return substFn.getWitnessTable(type, index);
});

TypeDecoder<DecodedMetadataBuilder> decoder(builder);
if (typeInfoOrErr.isError()) {
return nullptr;
}

return decodeType(decoder, resultType->getFirstChild());
auto typeInfo = typeInfoOrErr.getType();
return typeInfo.getMetadata();
}

SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_SPI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ public final class FakeInvocationDecoder: DistributedTargetInvocationDecoder {

var argumentIndex: Int = 0

fileprivate init(
public init(
args: [Any],
substitutions: [Any.Type] = [],
returnType: Any.Type? = nil,
Expand Down
Loading