Skip to content

Commit

Permalink
Merge pull request #2108 from swiftwasm/katei/merge-main-2020-10-27
Browse files Browse the repository at this point in the history
Merge main 2020-10-27
  • Loading branch information
kateinoigakukun authored Nov 5, 2020
2 parents ae9ccac + 1becb8e commit 01d3115
Show file tree
Hide file tree
Showing 159 changed files with 3,965 additions and 544 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
sudo apt clean
docker rmi $(docker image ls -aq)
df -h
- uses: actions/checkout@v2
- uses: actions/checkout@v1
with:
path: swift
- name: Prepare sccache timestamp
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
sudo apt clean
docker rmi $(docker image ls -aq)
df -h
- uses: actions/checkout@v2
- uses: actions/checkout@v1
with:
path: swift
- name: Prepare sccache timestamp
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
runs-on: macos-10.15

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v1
with:
path: swift
- name: Prepare sccache timestamp
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/manual-distribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
manual-distribution:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v1
- name: Setup keychain
run: |
security create-keychain -p "$KEYCHAIN_PASSWORD" swiftwasm-ci
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly-distribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
nightly-distribution:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v1
- name: Setup keychain
run: |
security create-keychain -p "$KEYCHAIN_PASSWORD" swiftwasm-ci
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ if(POLICY CMP0076)
cmake_policy(SET CMP0076 NEW)
endif()

# Don't clobber existing variable values when evaluating `option()` declarations.
if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()

# Add path for custom CMake modules.
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
Expand Down
39 changes: 24 additions & 15 deletions include/swift/ABI/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -2295,37 +2295,28 @@ struct TargetTypeMetadataRecord {
union {
/// A direct reference to a nominal type descriptor.
RelativeDirectPointerIntPair<TargetContextDescriptor<Runtime>,
TypeReferenceKind>
TypeMetadataRecordKind>
DirectNominalTypeDescriptor;

/// An indirect reference to a nominal type descriptor.
RelativeDirectPointerIntPair<TargetSignedPointer<Runtime, TargetContextDescriptor<Runtime> * __ptrauth_swift_type_descriptor>,
TypeReferenceKind>
TypeMetadataRecordKind>
IndirectNominalTypeDescriptor;

// We only allow a subset of the TypeReferenceKinds here.
// Should we just acknowledge that this is a different enum?
};

public:
TypeReferenceKind getTypeKind() const {
TypeMetadataRecordKind getTypeKind() const {
return DirectNominalTypeDescriptor.getInt();
}

const TargetContextDescriptor<Runtime> *
getContextDescriptor() const {
switch (getTypeKind()) {
case TypeReferenceKind::DirectTypeDescriptor:
case TypeMetadataRecordKind::DirectTypeDescriptor:
return DirectNominalTypeDescriptor.getPointer();

case TypeReferenceKind::IndirectTypeDescriptor:
case TypeMetadataRecordKind::IndirectTypeDescriptor:
return *IndirectNominalTypeDescriptor.getPointer();

// These types (and any others we might add to TypeReferenceKind
// in the future) are just never used in these lists.
case TypeReferenceKind::DirectObjCClassName:
case TypeReferenceKind::IndirectObjCClass:
return nullptr;
}

return nullptr;
Expand Down Expand Up @@ -2415,6 +2406,9 @@ struct TargetTypeReference {
/// A direct reference to an Objective-C class name.
RelativeDirectPointer<const char>
DirectObjCClassName;

/// A "reference" to some metadata kind, e.g. tuple.
MetadataKind MetadataKind;
};

const TargetContextDescriptor<Runtime> *
Expand All @@ -2428,12 +2422,18 @@ struct TargetTypeReference {

case TypeReferenceKind::DirectObjCClassName:
case TypeReferenceKind::IndirectObjCClass:
case TypeReferenceKind::MetadataKind:
return nullptr;
}

return nullptr;
}

enum MetadataKind getMetadataKind(TypeReferenceKind kind) const {
assert(kind == TypeReferenceKind::MetadataKind);
return MetadataKind;
}

#if SWIFT_OBJC_INTEROP
/// If this type reference is one of the kinds that supports ObjC
/// references,
Expand Down Expand Up @@ -2519,6 +2519,10 @@ struct TargetProtocolConformanceDescriptor final
return Flags.getTypeReferenceKind();
}

enum MetadataKind getMetadataKind() const {
return TypeRef.getMetadataKind(getTypeKind());
}

const char *getDirectObjCClassName() const {
return TypeRef.getDirectObjCClassName(getTypeKind());
}
Expand Down Expand Up @@ -2546,6 +2550,11 @@ struct TargetProtocolConformanceDescriptor final
TargetRelativeContextPointer<Runtime>>();
}

/// Whether this conformance is builtin by the compiler + runtime.
bool isBuiltin() const {
return getTypeKind() == TypeReferenceKind::MetadataKind;
}

/// Whether this conformance is non-unique because it has been synthesized
/// for a foreign type.
bool isSynthesizedNonUnique() const {
Expand Down
22 changes: 19 additions & 3 deletions include/swift/ABI/MetadataValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -361,7 +361,19 @@ enum : unsigned {
NumGenericMetadataPrivateDataWords = 16,
};

/// Kinds of type metadata/protocol conformance records.
/// Kinds of type metadata reocrds.
enum class TypeMetadataRecordKind : unsigned {
/// A direct reference to a nominal type descriptor.
DirectTypeDescriptor = 0x00,

/// An indirect reference to a nominal type descriptor.
IndirectTypeDescriptor = 0x01,

First_Kind = DirectTypeDescriptor,
Last_Kind = IndirectTypeDescriptor,
};

/// Kinds of references to type metadata.
enum class TypeReferenceKind : unsigned {
/// The conformance is for a nominal type referenced directly;
/// getTypeDescriptor() points to the type context descriptor.
Expand All @@ -384,10 +396,14 @@ enum class TypeReferenceKind : unsigned {
/// unused.
IndirectObjCClass = 0x03,

/// The conformance is for a non-nominal type whose metadata kind we recorded;
/// getMetadataKind() returns the kind.
MetadataKind = 0x04,

// We only reserve three bits for this in the various places we store it.

First_Kind = DirectTypeDescriptor,
Last_Kind = IndirectObjCClass,
Last_Kind = MetadataKind,
};

/// Flag that indicates whether an existential type is class-constrained or not.
Expand Down
6 changes: 6 additions & 0 deletions include/swift/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ namespace swift {
class InheritedProtocolConformance;
class SelfProtocolConformance;
class SpecializedProtocolConformance;
class BuiltinProtocolConformance;
enum class ProtocolConformanceState;
class Pattern;
enum PointerTypeKind : unsigned;
Expand Down Expand Up @@ -948,6 +949,11 @@ class ASTContext final {
SelfProtocolConformance *
getSelfConformance(ProtocolDecl *protocol);

/// Produce the builtin conformance for some structural type to some protocol.
BuiltinProtocolConformance *
getBuiltinConformance(Type type, ProtocolDecl *protocol,
ArrayRef<ProtocolConformanceRef> conformances);

/// A callback used to produce a diagnostic for an ill-formed protocol
/// conformance that was type-checked before we're actually walking the
/// conformance itself, along with a bit indicating whether this diagnostic
Expand Down
32 changes: 3 additions & 29 deletions include/swift/AST/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,7 @@ class ModuleDecl : public DeclContext, public TypeDecl {
Default = 1 << 1,
/// Include imports declared with `@_implementationOnly`.
ImplementationOnly = 1 << 2,
/// Include imports of SPIs declared with `@_spi`. Non-SPI imports are
/// included whether or not this flag is specified.
/// Include imports of SPIs declared with `@_spi`
SPIAccessControl = 1 << 3,
/// Include imports shadowed by a cross-import overlay. Unshadowed imports
/// are included whether or not this flag is specified.
Expand All @@ -605,33 +604,8 @@ class ModuleDecl : public DeclContext, public TypeDecl {

/// Looks up which modules are imported by this module.
///
/// \p filter controls which imports are included in the list.
///
/// There are three axes for categorizing imports:
/// 1. Privacy: Exported/Private/ImplementationOnly (mutually exclusive).
/// 2. SPI/non-SPI: An import of any privacy level may be @_spi("SPIName").
/// 3. Shadowed/Non-shadowed: An import of any privacy level may be shadowed
/// by a cross-import overlay.
///
/// It is also possible for SPI imports to be shadowed by a cross-import
/// overlay.
///
/// If \p filter contains multiple privacy levels, modules at all the privacy
/// levels are included.
///
/// If \p filter contains \c ImportFilterKind::SPIAccessControl, then both
/// SPI and non-SPI imports are included. Otherwise, only non-SPI imports are
/// included.
///
/// If \p filter contains \c ImportFilterKind::ShadowedByCrossImportOverlay,
/// both shadowed and non-shadowed imports are included. Otherwise, only
/// non-shadowed imports are included.
///
/// Clang modules have some additional complexities; see the implementation of
/// \c ClangModuleUnit::getImportedModules for details.
///
/// \pre \p filter must contain at least one privacy level, i.e. one of
/// \c Exported or \c Private or \c ImplementationOnly.
/// \p filter controls whether public, private, or any imports are included
/// in this list.
void getImportedModules(SmallVectorImpl<ImportedModule> &imports,
ImportFilter filter = ImportFilterKind::Exported) const;

Expand Down
Loading

0 comments on commit 01d3115

Please sign in to comment.