Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b8cbd4f
[stdlib][docs] Clarify BidirectionalCollection requirements
lorentey Apr 25, 2022
e15ca51
Update Runtime Generalized Existential Metadata
CodaFi Apr 25, 2022
a410d1a
[NFC] Consolidate Builder Result Types
CodaFi Apr 25, 2022
d710b52
Add Substitution Machinery to Builders
CodaFi Apr 25, 2022
f76f1a7
Add a Hack
CodaFi Apr 26, 2022
fe6e280
Add a Utility to Read Extended Existential Type Shapes
CodaFi Apr 26, 2022
61e5eee
Read Runtime Generic Signatures
CodaFi Apr 26, 2022
9918050
[Remote Mirrors] Support Extended Existential Type Metadata
CodaFi Apr 26, 2022
368cfa9
[RemoteMirror] Add bounds checking to BitMask operations.
mikeash Apr 28, 2022
f3bb988
[nfc] [cxx-interop] Disable `ReadAccessor` benchmark.
zoecarver Apr 29, 2022
01e0e0a
Gate Clock Runtime Test on Current Runtimes
CodaFi Apr 29, 2022
61a3524
Create sr15884-generic-signature-builder-keypath-iterable.swift
philipturner Apr 26, 2022
448dd59
Merge pull request #58533 from zoecarver/disable-benchmark
zoecarver Apr 29, 2022
4eae12a
Merge pull request #58403 from lorentey/bidirectional-docs
lorentey Apr 29, 2022
c06423d
Merge pull request #58507 from mikeash/bitmask-range-checks
mikeash Apr 29, 2022
340d0dc
Merge pull request #58536 from CodaFi/tardis-grade
CodaFi Apr 29, 2022
186afa5
Merge pull request #58412 from CodaFi/remote-work
CodaFi Apr 29, 2022
dd95257
Merge pull request #58418 from philipturner/patch-35
swift-ci Apr 30, 2022
c30333a
Remove Needless Template Dependent Access
CodaFi Apr 30, 2022
745cf50
Merge pull request #58552 from CodaFi/templatize-me-capn
compnerd Apr 30, 2022
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
5 changes: 3 additions & 2 deletions benchmark/utils/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ import RangeAssignment
import RangeIteration
import RangeOverlaps
import RangeReplaceableCollectionPlusDefault
import ReadAccessor
//import ReadAccessor
import RecursiveOwnedParameter
import ReduceInto
import RemoveWhere
Expand Down Expand Up @@ -333,7 +333,8 @@ register(RangeAssignment.benchmarks)
register(RangeIteration.benchmarks)
register(RangeOverlaps.benchmarks)
register(RangeReplaceableCollectionPlusDefault.benchmarks)
register(ReadAccessor.benchmarks)
// TODO: rdar://92120528
//register(ReadAccessor.benchmarks)
register(RecursiveOwnedParameter.benchmarks)
register(ReduceInto.benchmarks)
register(RemoveWhere.benchmarks)
Expand Down
39 changes: 31 additions & 8 deletions include/swift/ABI/GenericContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct TargetGenericContextDescriptorHeader {
/// Key arguments include generic parameters and conformance
/// requirements which are part of the identity of the context.
///
/// The key area of the argument layout considers of a sequence
/// The key area of the argument layout consists of a sequence
/// of type metadata pointers (in the same order as the parameter
/// descriptors, for those parameters which satisfy hasKeyArgument())
/// followed by a sequence of witness table pointers (in the same
Expand Down Expand Up @@ -191,25 +191,48 @@ using GenericRequirementDescriptor =
extern const GenericParamDescriptor
ImplicitGenericParamDescriptors[MaxNumImplicitGenericParamDescriptors];

inline const GenericParamDescriptor *
externalTargetImplicitGenericParamDescriptors() {
static const GenericParamDescriptor
buffer[MaxNumImplicitGenericParamDescriptors] = {
#define D GenericParamDescriptor::implicit()
D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D,
D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D,
D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D
#undef D
};
return buffer;
}

template <class Runtime>
const GenericParamDescriptor *targetImplicitGenericParamDescriptors() {
return externalTargetImplicitGenericParamDescriptors();
}
template <>
inline const GenericParamDescriptor *targetImplicitGenericParamDescriptors<InProcess>() {
return ImplicitGenericParamDescriptors;
}

/// A runtime description of a generic signature.
template<typename Runtime>
class RuntimeGenericSignature {
GenericContextDescriptorHeader Header;
TargetGenericContextDescriptorHeader<Runtime> Header;
const GenericParamDescriptor *Params;
const GenericRequirementDescriptor *Requirements;
const TargetGenericRequirementDescriptor<Runtime> *Requirements;
public:
RuntimeGenericSignature()
: Header{0, 0, 0, 0}, Params(nullptr), Requirements(nullptr) {}

RuntimeGenericSignature(const GenericContextDescriptorHeader &header,
RuntimeGenericSignature(const TargetGenericContextDescriptorHeader<Runtime> &header,
const GenericParamDescriptor *params,
const GenericRequirementDescriptor *requirements)
const TargetGenericRequirementDescriptor<Runtime> *requirements)
: Header(header), Params(params), Requirements(requirements) {}

llvm::ArrayRef<GenericParamDescriptor> getParams() const {
return llvm::makeArrayRef(Params, Header.NumParams);
}

llvm::ArrayRef<GenericRequirementDescriptor> getRequirements() const {
llvm::ArrayRef<TargetGenericRequirementDescriptor<Runtime>> getRequirements() const {
return llvm::makeArrayRef(Requirements, Header.NumRequirements);
}

Expand Down Expand Up @@ -375,8 +398,8 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
* sizeof(StoredPointer);
}

RuntimeGenericSignature getGenericSignature() const {
if (!asSelf()->isGeneric()) return RuntimeGenericSignature();
RuntimeGenericSignature<Runtime> getGenericSignature() const {
if (!asSelf()->isGeneric()) return RuntimeGenericSignature<Runtime>();
return {getGenericContextHeader(),
getGenericParams().data(),
getGenericRequirements().data()};
Expand Down
48 changes: 32 additions & 16 deletions include/swift/ABI/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,12 @@ struct TargetExistentialTypeMetadata
using ExistentialTypeMetadata
= TargetExistentialTypeMetadata<InProcess>;

template<typename Runtime>
struct TargetExistentialTypeExpression {
/// The type expression.
TargetRelativeDirectPointer<Runtime, const char, /*nullable*/ false> name;
};

/// A description of the shape of an existential type.
///
/// An existential type has the general form:
Expand Down Expand Up @@ -1791,7 +1797,7 @@ struct TargetExtendedExistentialTypeShape
// Optional generalization signature header
TargetGenericContextDescriptorHeader<Runtime>,
// Optional type subexpression
TargetRelativeDirectPointer<Runtime, const char, /*nullable*/ false>,
TargetExistentialTypeExpression<Runtime>,
// Optional suggested value witnesses
TargetRelativeIndirectablePointer<Runtime, const TargetValueWitnessTable<Runtime>,
/*nullable*/ false>,
Expand All @@ -1802,8 +1808,6 @@ struct TargetExtendedExistentialTypeShape
// for generalization signature
TargetGenericRequirementDescriptor<Runtime>> {
private:
using RelativeStringPointer =
TargetRelativeDirectPointer<Runtime, const char, /*nullable*/ false>;
using RelativeValueWitnessTablePointer =
TargetRelativeIndirectablePointer<Runtime,
const TargetValueWitnessTable<Runtime>,
Expand All @@ -1812,7 +1816,7 @@ struct TargetExtendedExistentialTypeShape
swift::ABI::TrailingObjects<
TargetExtendedExistentialTypeShape<Runtime>,
TargetGenericContextDescriptorHeader<Runtime>,
RelativeStringPointer,
TargetExistentialTypeExpression<Runtime>,
RelativeValueWitnessTablePointer,
GenericParamDescriptor,
TargetGenericRequirementDescriptor<Runtime>>;
Expand All @@ -1825,7 +1829,7 @@ struct TargetExtendedExistentialTypeShape
return Flags.hasGeneralizationSignature();
}

size_t numTrailingObjects(OverloadToken<RelativeStringPointer>) const {
size_t numTrailingObjects(OverloadToken<TargetExistentialTypeExpression<Runtime>>) const {
return Flags.hasTypeExpression();
}

Expand Down Expand Up @@ -1879,12 +1883,13 @@ struct TargetExtendedExistentialTypeShape
/// we nonetheless distinguish at compile time. Storing this also
/// allows us to far more easily produce a formal type from this
/// shape reflectively.
RelativeStringPointer ExistentialType;
TargetRelativeDirectPointer<Runtime, const char, /*nullable*/ false>
ExistentialType;

/// The header describing the requirement signature of the existential.
TargetGenericContextDescriptorHeader<Runtime> ReqSigHeader;

RuntimeGenericSignature getRequirementSignature() const {
RuntimeGenericSignature<Runtime> getRequirementSignature() const {
return {ReqSigHeader, getReqSigParams(), getReqSigRequirements()};
}

Expand All @@ -1894,8 +1899,8 @@ struct TargetExtendedExistentialTypeShape

const GenericParamDescriptor *getReqSigParams() const {
return Flags.hasImplicitReqSigParams()
? ImplicitGenericParamDescriptors
: this->template getTrailingObjects<GenericParamDescriptor>();
? swift::targetImplicitGenericParamDescriptors<Runtime>()
: this->template getTrailingObjects<GenericParamDescriptor>();
}

unsigned getNumReqSigRequirements() const {
Expand All @@ -1911,10 +1916,11 @@ struct TargetExtendedExistentialTypeShape
/// The type expression of the existential, as a symbolic mangled type
/// string. Must be null if the header is just the (single)
/// requirement type parameter.
TargetPointer<Runtime, const char> getTypeExpression() const {
const TargetExistentialTypeExpression<Runtime> *getTypeExpression() const {
return Flags.hasTypeExpression()
? this->template getTrailingObjects<RelativeStringPointer>()->get()
: nullptr;
? this->template getTrailingObjects<
TargetExistentialTypeExpression<Runtime>>()
: nullptr;
}

bool isTypeExpressionOpaque() const {
Expand Down Expand Up @@ -1961,8 +1967,8 @@ struct TargetExtendedExistentialTypeShape
return Flags.hasGeneralizationSignature();
}

RuntimeGenericSignature getGeneralizationSignature() const {
if (!hasGeneralizationSignature()) return RuntimeGenericSignature();
RuntimeGenericSignature<Runtime> getGeneralizationSignature() const {
if (!hasGeneralizationSignature()) return RuntimeGenericSignature<Runtime>();
return {*getGenSigHeader(), getGenSigParams(), getGenSigRequirements()};
}

Expand All @@ -1974,7 +1980,7 @@ struct TargetExtendedExistentialTypeShape
const GenericParamDescriptor *getGenSigParams() const {
assert(hasGeneralizationSignature());
if (Flags.hasImplicitGenSigParams())
return ImplicitGenericParamDescriptors;
return swift::targetImplicitGenericParamDescriptors<Runtime>();
auto base = this->template getTrailingObjects<GenericParamDescriptor>();
if (!Flags.hasImplicitReqSigParams())
base += getNumReqSigParams();
Expand Down Expand Up @@ -2086,6 +2092,8 @@ struct TargetExtendedExistentialTypeMetadata
swift::ABI::TrailingObjects<
TargetExtendedExistentialTypeMetadata<Runtime>,
ConstTargetPointer<Runtime, void>> {
using StoredSize = typename Runtime::StoredSize;

private:
using TrailingObjects =
swift::ABI::TrailingObjects<
Expand All @@ -2097,9 +2105,12 @@ struct TargetExtendedExistentialTypeMetadata
using OverloadToken = typename TrailingObjects::template OverloadToken<T>;

size_t numTrailingObjects(OverloadToken<ConstTargetPointer<Runtime, void>>) const {
return Shape->getGenSigLayoutSizeInWords();
return Shape->getGenSigArgumentLayoutSizeInWords();
}

public:
static constexpr StoredSize OffsetToArguments = sizeof(TargetMetadata<Runtime>);

public:
explicit constexpr
TargetExtendedExistentialTypeMetadata(const ExtendedExistentialTypeShape *shape)
Expand All @@ -2113,6 +2124,11 @@ struct TargetExtendedExistentialTypeMetadata
ConstTargetPointer<Runtime, void> const *getGeneralizationArguments() const {
return this->template getTrailingObjects<ConstTargetPointer<Runtime, void>>();
}

public:
static bool classof(const TargetMetadata<Runtime> *metadata) {
return metadata->getKind() == MetadataKind::ExtendedExistential;
}
};
using ExtendedExistentialTypeMetadata
= TargetExtendedExistentialTypeMetadata<InProcess>;
Expand Down
17 changes: 16 additions & 1 deletion include/swift/AST/ASTDemangler.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ class ASTBuilder {
using BuiltType = swift::Type;
using BuiltTypeDecl = swift::GenericTypeDecl *; // nominal or type alias
using BuiltProtocolDecl = swift::ProtocolDecl *;
using BuiltGenericSignature = swift::GenericSignature;
using BuiltGenericTypeParam = swift::GenericTypeParamType *;
using BuiltRequirement = swift::Requirement;
using BuiltSubstitutionMap = swift::SubstitutionMap;

explicit ASTBuilder(ASTContext &ctx) : Ctx(ctx) {}

ASTContext &getASTContext() { return Ctx; }
Expand Down Expand Up @@ -112,6 +117,8 @@ class ASTBuilder {
bool isClassBound,
bool forRequirement = true);

Type createProtocolTypeFromDecl(ProtocolDecl *protocol);

Type createParameterizedProtocolType(Type base, ArrayRef<Type> args);

Type createExistentialMetatypeType(Type instance,
Expand All @@ -134,7 +141,6 @@ class ASTBuilder {
Type createSILBoxType(Type base);
using BuiltSILBoxField = llvm::PointerIntPair<Type, 1>;
using BuiltSubstitution = std::pair<Type, Type>;
using BuiltRequirement = swift::Requirement;
using BuiltLayoutConstraint = swift::LayoutConstraint;
Type createSILBoxTypeWithLayout(ArrayRef<BuiltSILBoxField> Fields,
ArrayRef<BuiltSubstitution> Substitutions,
Expand Down Expand Up @@ -167,6 +173,15 @@ class ASTBuilder {

Type createParenType(Type base);

BuiltGenericSignature
createGenericSignature(ArrayRef<BuiltType> params,
ArrayRef<BuiltRequirement> requirements);

BuiltSubstitutionMap createSubstitutionMap(BuiltGenericSignature sig,
ArrayRef<BuiltType> replacements);

Type subst(Type subject, const BuiltSubstitutionMap &Subs) const;

LayoutConstraint getLayoutConstraint(LayoutConstraintKind kind);
LayoutConstraint getLayoutConstraintWithSizeAlign(LayoutConstraintKind kind,
unsigned size,
Expand Down
3 changes: 3 additions & 0 deletions include/swift/Demangling/TypeDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@ class TypeDecoder {
using BuiltSubstitution = typename BuilderType::BuiltSubstitution;
using BuiltRequirement = typename BuilderType::BuiltRequirement;
using BuiltLayoutConstraint = typename BuilderType::BuiltLayoutConstraint;
using BuiltGenericTypeParam = typename BuilderType::BuiltGenericTypeParam;
using BuiltGenericSignature = typename BuilderType::BuiltGenericSignature;
using BuiltSubstitutionMap = typename BuilderType::BuiltSubstitutionMap;
using NodeKind = Demangle::Node::Kind;

BuilderType &Builder;
Expand Down
31 changes: 31 additions & 0 deletions include/swift/Reflection/TypeRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,37 @@ class DependentMemberTypeRef final : public TypeRef {
}
};

/// A representation of a dynamically-constructed generic signature.
///
/// \note This class is not a \c TypeRef.
class GenericSignatureRef final {
std::vector<const GenericTypeParameterTypeRef *> Params;
std::vector<TypeRefRequirement> Requirements;

public:
GenericSignatureRef(
llvm::ArrayRef<const GenericTypeParameterTypeRef *> Params,
llvm::ArrayRef<TypeRefRequirement> Requirements)
: Params(Params.begin(), Params.end()),
Requirements(Requirements.begin(), Requirements.end()) {}

template <typename Allocator>
static const GenericSignatureRef *
create(Allocator &A,
llvm::ArrayRef<const GenericTypeParameterTypeRef *> Params,
llvm::ArrayRef<TypeRefRequirement> Requirements) {
return A.makeGenericSignatureRef(Params, Requirements);
}

const llvm::ArrayRef<const GenericTypeParameterTypeRef *> getParams() const {
return Params;
}

const llvm::ArrayRef<TypeRefRequirement> getRequirements() const {
return Requirements;
}
};

class ForeignClassTypeRef final : public TypeRef {
std::string Name;

Expand Down
Loading