Skip to content

Commit d65906b

Browse files
committed
[Runtime] Expose accessible function lookup as stdlib SPI
`findAccessibleFunction` has to be accessible from Concurrency and Distributed modules to be able to lookup distributed accessors.
1 parent 7eee8c0 commit d65906b

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//===---- AcceesibleFunction.h - Runtime accessible functions ---*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2021 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+
// The runtime interface for functions accessible by name.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
#ifndef SWIFT_RUNTIME_ACCESSIBLE_FUNCTION_H
18+
#define SWIFT_RUNTIME_ACCESSIBLE_FUNCTION_H
19+
20+
#include "swift/ABI/Metadata.h"
21+
22+
#include <cstdint>
23+
24+
namespace swift {
25+
namespace runtime {
26+
27+
SWIFT_RUNTIME_STDLIB_SPI const AccessibleFunctionRecord *
28+
swift_findAccessibleFunction(const char *targetNameStart,
29+
size_t targetNameLength);
30+
31+
} // end namespace runtime
32+
} // end namespace swift
33+
34+
#endif

stdlib/public/runtime/AccessibleFunction.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
#include "Private.h"
1919
#include "swift/Basic/Lazy.h"
2020
#include "swift/Demangling/Demangler.h"
21+
#include "swift/Runtime/AccessibleFunction.h"
2122
#include "swift/Runtime/Concurrent.h"
2223
#include "swift/Runtime/Metadata.h"
23-
#include "Private.h"
2424

2525
#include <cstdint>
2626

@@ -127,10 +127,14 @@ _searchForFunctionRecord(AccessibleFunctionsState &S, llvm::StringRef name) {
127127
return nullptr;
128128
}
129129

130-
static const AccessibleFunctionRecord *
131-
_findAccessibleFunction(llvm::StringRef name) {
130+
SWIFT_RUNTIME_STDLIB_SPI
131+
const AccessibleFunctionRecord *
132+
swift::runtime::swift_findAccessibleFunction(const char *targetNameStart,
133+
size_t targetNameLength) {
132134
auto &S = Functions.get();
133135

136+
llvm::StringRef name{targetNameStart, targetNameLength};
137+
134138
// Look for an existing entry.
135139
{
136140
auto snapshot = S.Cache.snapshot();

0 commit comments

Comments
 (0)