Skip to content

Commit 564a451

Browse files
committed
Merge remote-tracking branch 'apple/master'
2 parents cc48d84 + c4a6a09 commit 564a451

File tree

609 files changed

+10973
-5395
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

609 files changed

+10973
-5395
lines changed

CMakeLists.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ endfunction()
354354
# Print out path and version of any installed commands.
355355
# We migth be using the wrong version of a command, so record them all.
356356
function(print_versions)
357-
find_version("cmake" "--version" TRUE)
357+
find_version("${CMAKE_COMMAND}" "--version" TRUE)
358358

359359
message(STATUS "Finding version for: ${CMAKE_COMMAND}")
360360
message(STATUS "Found version: ${CMAKE_VERSION}")
@@ -726,7 +726,7 @@ elseif("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*)")
726726
COMMAND "xcodebuild" "-version"
727727
OUTPUT_VARIABLE xcode_version
728728
OUTPUT_STRIP_TRAILING_WHITESPACE)
729-
string(REPLACE "\n" ", " xcode_version ${xcode_version})
729+
string(REPLACE "\n" ", " xcode_version "${xcode_version}")
730730
message(STATUS "${xcode_version}")
731731
message(STATUS "")
732732

@@ -866,11 +866,13 @@ endfunction()
866866
# package lookup. Otherwise, rely on the paths specified by the user. These
867867
# need to be defined when cross-compiling.
868868
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
869-
swift_icu_variables_set("${SWIFT_HOST_VARIANT_SDK_default}"
870-
"${SWIFT_HOST_VARIANT_ARCH_default}"
871-
ICU_CONFIGURED)
872-
if("${SWIFT_PATH_TO_LIBICU_BUILD}" STREQUAL "" AND NOT ${ICU_CONFIGURED})
873-
find_package(ICU REQUIRED COMPONENTS uc i18n)
869+
if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
870+
swift_icu_variables_set("${SWIFT_HOST_VARIANT_SDK_default}"
871+
"${SWIFT_HOST_VARIANT_ARCH_default}"
872+
ICU_CONFIGURED)
873+
if("${SWIFT_PATH_TO_LIBICU_BUILD}" STREQUAL "" AND NOT ${ICU_CONFIGURED})
874+
find_package(ICU REQUIRED COMPONENTS uc i18n)
875+
endif()
874876
endif()
875877
endif()
876878

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
| **macOS** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-osx/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-osx)|[![Build Status](https://ci.swift.org/job/oss-swift-package-osx/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-osx)|
99
| **Ubuntu 14.04** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-14_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-14_04)|[![Build Status](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-14_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-14_04)|
1010
| **Ubuntu 16.04** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_04)|[![Build Status](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-16_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-16_04)|
11-
| **Ubuntu 16.10** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_10/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_10)|[![Build Status](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-16_10/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-16_10)|
1211
| **Ubuntu 18.04** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-18_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-18_04)|[![Build Status](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-18_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-18_04)|
1312

1413
**Swift Community-Hosted CI Platforms**

benchmark/single-source/BinaryFloatingPointConversionFromBinaryInteger.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ extension MockBinaryInteger : BinaryInteger {
110110
var trailingZeroBitCount: Int {
111111
return _value.trailingZeroBitCount
112112
}
113+
114+
func isMultiple(of other: MockBinaryInteger<T>) -> Bool {
115+
return _value.isMultiple(of: other._value)
116+
}
113117

114118
static func + (
115119
lhs: MockBinaryInteger<T>, rhs: MockBinaryInteger<T>

cmake/modules/AddSwift.cmake

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ function(_add_variant_c_compile_flags)
246246
list(APPEND result "-DLLVM_ON_WIN32")
247247
list(APPEND result "-D_CRT_SECURE_NO_WARNINGS")
248248
list(APPEND result "-D_CRT_NONSTDC_NO_WARNINGS")
249-
list(APPEND result "-D_CRT_USE_BUILTIN_OFFSETOF")
249+
if(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
250+
list(APPEND result "-D_CRT_USE_BUILTIN_OFFSETOF")
251+
endif()
250252
# TODO(compnerd) permit building for different families
251253
list(APPEND result "-D_CRT_USE_WINAPI_FAMILY_DESKTOP_APP")
252254
if("${CFLAGS_ARCH}" MATCHES arm)
@@ -800,11 +802,13 @@ function(_add_swift_library_single target name)
800802

801803
if("${SWIFTLIB_SINGLE_SDK}" STREQUAL "WINDOWS")
802804
swift_windows_include_for_arch(${SWIFTLIB_SINGLE_ARCHITECTURE} SWIFTLIB_INCLUDE)
803-
swift_windows_generate_sdk_vfs_overlay(SWIFTLIB_SINGLE_VFS_OVERLAY_FLAGS)
804-
foreach(flag ${SWIFTLIB_SINGLE_VFS_OVERLAY_FLAGS})
805-
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS -Xcc;${flag})
806-
list(APPEND SWIFTLIB_SINGLE_C_COMPILE_FLAGS ${flag})
807-
endforeach()
805+
if(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
806+
swift_windows_generate_sdk_vfs_overlay(SWIFTLIB_SINGLE_VFS_OVERLAY_FLAGS)
807+
foreach(flag ${SWIFTLIB_SINGLE_VFS_OVERLAY_FLAGS})
808+
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS -Xcc;${flag})
809+
list(APPEND SWIFTLIB_SINGLE_C_COMPILE_FLAGS ${flag})
810+
endforeach()
811+
endif()
808812
foreach(directory ${SWIFTLIB_INCLUDE})
809813
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS -Xfrontend;-I${directory})
810814
endforeach()
@@ -1572,6 +1576,13 @@ function(add_swift_library name)
15721576
endif()
15731577

15741578
if(SWIFTLIB_TARGET_LIBRARY)
1579+
# In the standard library and overlays, warn about implicit overrides
1580+
# as a reminder to consider when inherited protocols need different
1581+
# behavior for their requirements.
1582+
if (SWIFTLIB_IS_STDLIB)
1583+
list(APPEND SWIFTLIB_SWIFT_COMPILE_FLAGS "-warn-implicit-overrides")
1584+
endif()
1585+
15751586
if(NOT SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER AND NOT BUILD_STANDALONE)
15761587
list(APPEND SWIFTLIB_DEPENDS clang)
15771588
endif()

cmake/modules/SwiftSharedCMakeConfig.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ macro(swift_common_standalone_build_config_llvm product is_cross_compiling)
2424
# Then we import LLVMConfig. This is going to override whatever cached value
2525
# we have for LLVM_ENABLE_ASSERTIONS.
2626
find_package(LLVM REQUIRED CONFIG
27-
HINTS "${PATH_TO_LLVM_BUILD}" NO_DEFAULT_PATH)
27+
HINTS "${PATH_TO_LLVM_BUILD}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
2828

2929
# If we did not have a cached value for LLVM_ENABLE_ASSERTIONS, set
3030
# LLVM_ENABLE_ASSERTIONS_saved to be the ENABLE_ASSERTIONS value from LLVM so
@@ -69,7 +69,7 @@ macro(swift_common_standalone_build_config_llvm product is_cross_compiling)
6969
endif()
7070

7171
find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" "${${product}_NATIVE_LLVM_TOOLS_PATH}"
72-
NO_DEFAULT_PATH)
72+
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
7373
if ("${LLVM_TABLEGEN_EXE}" STREQUAL "LLVM_TABLEGEN_EXE-NOTFOUND")
7474
message(FATAL_ERROR "Failed to find tablegen in ${${product}_NATIVE_LLVM_TOOLS_PATH}")
7575
endif()
@@ -149,7 +149,7 @@ macro(swift_common_standalone_build_config_clang product is_cross_compiling)
149149

150150
# Then include Clang.
151151
find_package(Clang REQUIRED CONFIG
152-
HINTS "${PATH_TO_CLANG_BUILD}" NO_DEFAULT_PATH)
152+
HINTS "${PATH_TO_CLANG_BUILD}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
153153

154154
if(NOT EXISTS "${PATH_TO_CLANG_SOURCE}/include/clang/AST/Decl.h")
155155
message(FATAL_ERROR "Please set ${product}_PATH_TO_CLANG_SOURCE to the root directory of Clang's source code.")

docs/ABI/Mangling.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Globals
5959
global ::= nominal-type 'Ml' // in-place type initialization cache
6060
global ::= nominal-type 'Mm' // class metaclass
6161
global ::= nominal-type 'Mn' // nominal type descriptor
62+
global ::= nominal-type 'Mu' // class method lookup function
6263
global ::= module 'MXM' // module descriptor
6364
global ::= context 'MXE' // extension descriptor
6465
global ::= context 'MXX' // anonymous context descriptor

docs/Lexicon.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ source code, tests, and commit messages. See also the `LLVM lexicon`_.
2626
struct Foo<T> {
2727
var value: T
2828
// Foo.value has abstraction pattern <T> T
29-
29+
}
3030
struct Bar<T, U> {
3131
var value: (T) -> U
3232
// Bar.value has abstraction pattern <T, U> (T) -> U

docs/RequestEvaluator.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ The request-evaluator is relatively new to the Swift compiler, having been intro
6161
* Add API to the evaluator to add a specific (request, result) pair to the cache, and make it "stick" even if the cache is cleared. This API should be usable from places in the compiler that inject specific known state, such as when the Clang importer synthesizes ASTs.
6262
* Explore how best to cache data structures in the evaluator. For example, caching `std::vector<T>` or `std::string` implies that we'll make copies of the underlying data structure each time we access the data. Could we automatically intern the data into an allocation arena owned by the evaluator, and vend `ArrayRef<T>` and `StringRef` to clients instead?
6363
* Sometimes the compiler crashes or otherwise fails due to a cycle detected by the evaluator but (currently) not diagnosed. Add some logic to record cycles encountered during compilation, and if the compiler crashes (or otherwise fails), dump the cycles at the end of execution to help with debugging.
64-
* Automatically create appropriate [`FrontendStatsTracer`](https://github.com/apple/swift/blob/master/include/swift/Basic/Statistic.h) instances when evaluating requests that embed AST references to anything the stats-tracing logic can handle (`Decl*`, `ProtocolConformance*`, etc.). Try to do this automatically for `SimpleRequest` so specific requests don't need to opt in for it to work.
6564
* Cycle diagnostics are far too complicated and produce very poor results. Consider replacing the current `diagnoseCycle`/`noteCycleStep` scheme with a single method that produces summary information (e.g., a short summary string + source location information) and provides richer diagnostics from that string.
6665
* The `isCached()` check to determine whether a specific instance of a request is worth caching may be at the wrong level, because one generally has to duplicate effort (or worse, code!) to make the decision in `isCached()`. Consider whether the `evaluator()` function could return something special to say "produce this value without caching" vs. the normal "produce this value with caching".
6766
* Try to eliminate more boilerplate from subclasses of [`SimpleRequest`](https://github.com/apple/swift/blob/master/include/swift/AST/SimpleRequest.h). We are going to have a *lot* of requests.

include/swift/ABI/Metadata.h

Lines changed: 86 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -770,17 +770,25 @@ struct TargetHeapMetadata : TargetMetadata<Runtime> {
770770
};
771771
using HeapMetadata = TargetHeapMetadata<InProcess>;
772772

773+
/// An opaque descriptor describing a class or protocol method. References to
774+
/// these descriptors appear in the method override table of a class context
775+
/// descriptor, or a resilient witness table pattern, respectively.
776+
///
777+
/// Clients should not assume anything about the contents of this descriptor
778+
/// other than it having 4 byte alignment.
773779
template <typename Runtime>
774780
struct TargetMethodDescriptor {
775-
/// The method implementation.
776-
TargetRelativeDirectPointer<Runtime, void> Impl;
777-
778781
/// Flags describing the method.
779782
MethodDescriptorFlags Flags;
780783

784+
/// The method implementation.
785+
TargetRelativeDirectPointer<Runtime, void> Impl;
786+
781787
// TODO: add method types or anything else needed for reflection.
782788
};
783789

790+
using MethodDescriptor = TargetMethodDescriptor<InProcess>;
791+
784792
/// Header for a class vtable descriptor. This is a variable-sized
785793
/// structure that describes how to find and parse a vtable
786794
/// within the type metadata for a class.
@@ -804,14 +812,41 @@ struct TargetVTableDescriptorHeader {
804812
/// entries occupy in instantiated class metadata.
805813
uint32_t VTableSize;
806814

807-
uint32_t getVTableOffset(const TargetClassMetadata<Runtime> *metadata) const {
808-
const auto *description = metadata->getDescription();
809-
if (description->hasResilientSuperclass())
810-
return metadata->Superclass->getSizeInWords() + VTableOffset;
815+
uint32_t getVTableOffset(const TargetClassDescriptor<Runtime> *description) const {
816+
if (description->hasResilientSuperclass()) {
817+
auto bounds = description->getMetadataBounds();
818+
return (bounds.ImmediateMembersOffset / sizeof(StoredPointer)
819+
+ VTableOffset);
820+
}
821+
811822
return VTableOffset;
812823
}
813824
};
814825

826+
/// An entry in the method override table, referencing a method from one of our
827+
/// ancestor classes, together with an implementation.
828+
template <typename Runtime>
829+
struct TargetMethodOverrideDescriptor {
830+
/// The class containing the base method.
831+
TargetRelativeIndirectablePointer<Runtime, TargetClassDescriptor<Runtime>> Class;
832+
833+
/// The base method.
834+
TargetRelativeIndirectablePointer<Runtime, TargetMethodDescriptor<Runtime>> Method;
835+
836+
/// The implementation of the override.
837+
TargetRelativeDirectPointer<Runtime, void, /*Nullable=*/true> Impl;
838+
};
839+
840+
/// Header for a class vtable override descriptor. This is a variable-sized
841+
/// structure that provides implementations for overrides of methods defined
842+
/// in superclasses.
843+
template <typename Runtime>
844+
struct TargetOverrideTableHeader {
845+
/// The number of MethodOverrideDescriptor records following the vtable
846+
/// override header in the class's nominal type descriptor.
847+
uint32_t NumEntries;
848+
};
849+
815850
/// The bounds of a class metadata object.
816851
///
817852
/// This type is a currency type and is not part of the ABI.
@@ -1107,7 +1142,7 @@ struct TargetClassMetadata : public TargetAnyClassMetadata<Runtime> {
11071142
/// Get a pointer to the field offset vector, if present, or null.
11081143
const StoredPointer *getFieldOffsets() const {
11091144
assert(isTypeMetadata());
1110-
auto offset = getDescription()->getFieldOffsetVectorOffset(this);
1145+
auto offset = getDescription()->getFieldOffsetVectorOffset();
11111146
if (offset == 0)
11121147
return nullptr;
11131148
auto asWords = reinterpret_cast<const void * const*>(this);
@@ -3580,15 +3615,19 @@ class TargetClassDescriptor final
35803615
TargetForeignMetadataInitialization<Runtime>,
35813616
TargetSingletonMetadataInitialization<Runtime>,
35823617
TargetVTableDescriptorHeader<Runtime>,
3583-
TargetMethodDescriptor<Runtime>> {
3618+
TargetMethodDescriptor<Runtime>,
3619+
TargetOverrideTableHeader<Runtime>,
3620+
TargetMethodOverrideDescriptor<Runtime>> {
35843621
private:
35853622
using TrailingGenericContextObjects =
35863623
TrailingGenericContextObjects<TargetClassDescriptor<Runtime>,
35873624
TargetTypeGenericContextDescriptorHeader,
35883625
TargetForeignMetadataInitialization<Runtime>,
35893626
TargetSingletonMetadataInitialization<Runtime>,
35903627
TargetVTableDescriptorHeader<Runtime>,
3591-
TargetMethodDescriptor<Runtime>>;
3628+
TargetMethodDescriptor<Runtime>,
3629+
TargetOverrideTableHeader<Runtime>,
3630+
TargetMethodOverrideDescriptor<Runtime>>;
35923631

35933632
using TrailingObjects =
35943633
typename TrailingGenericContextObjects::TrailingObjects;
@@ -3597,6 +3636,8 @@ class TargetClassDescriptor final
35973636
public:
35983637
using MethodDescriptor = TargetMethodDescriptor<Runtime>;
35993638
using VTableDescriptorHeader = TargetVTableDescriptorHeader<Runtime>;
3639+
using OverrideTableHeader = TargetOverrideTableHeader<Runtime>;
3640+
using MethodOverrideDescriptor = TargetMethodOverrideDescriptor<Runtime>;
36003641
using ForeignMetadataInitialization =
36013642
TargetForeignMetadataInitialization<Runtime>;
36023643
using SingletonMetadataInitialization =
@@ -3707,6 +3748,17 @@ class TargetClassDescriptor final
37073748
return getVTableDescriptor()->VTableSize;
37083749
}
37093750

3751+
size_t numTrailingObjects(OverloadToken<OverrideTableHeader>) const {
3752+
return hasOverrideTable() ? 1 : 0;
3753+
}
3754+
3755+
size_t numTrailingObjects(OverloadToken<MethodOverrideDescriptor>) const {
3756+
if (!hasOverrideTable())
3757+
return 0;
3758+
3759+
return getOverrideTable()->NumEntries;
3760+
}
3761+
37103762
public:
37113763
const ForeignMetadataInitialization &getForeignMetadataInitialization() const{
37123764
assert(this->hasForeignMetadataInitialization());
@@ -3722,11 +3774,12 @@ class TargetClassDescriptor final
37223774
/// its stored properties.
37233775
bool hasFieldOffsetVector() const { return FieldOffsetVectorOffset != 0; }
37243776

3725-
unsigned getFieldOffsetVectorOffset(const ClassMetadata *metadata) const {
3726-
const auto *description = metadata->getDescription();
3727-
3728-
if (description->hasResilientSuperclass())
3729-
return metadata->Superclass->getSizeInWords() + FieldOffsetVectorOffset;
3777+
unsigned getFieldOffsetVectorOffset() const {
3778+
if (hasResilientSuperclass()) {
3779+
auto bounds = getMetadataBounds();
3780+
return (bounds.ImmediateMembersOffset / sizeof(StoredPointer)
3781+
+ FieldOffsetVectorOffset);
3782+
}
37303783

37313784
return FieldOffsetVectorOffset;
37323785
}
@@ -3735,6 +3788,10 @@ class TargetClassDescriptor final
37353788
return this->getTypeContextDescriptorFlags().class_hasVTable();
37363789
}
37373790

3791+
bool hasOverrideTable() const {
3792+
return this->getTypeContextDescriptorFlags().class_hasOverrideTable();
3793+
}
3794+
37383795
bool hasResilientSuperclass() const {
37393796
return this->getTypeContextDescriptorFlags().class_hasResilientSuperclass();
37403797
}
@@ -3744,14 +3801,27 @@ class TargetClassDescriptor final
37443801
return nullptr;
37453802
return this->template getTrailingObjects<VTableDescriptorHeader>();
37463803
}
3747-
3804+
37483805
llvm::ArrayRef<MethodDescriptor> getMethodDescriptors() const {
37493806
if (!hasVTable())
37503807
return {};
37513808
return {this->template getTrailingObjects<MethodDescriptor>(),
37523809
numTrailingObjects(OverloadToken<MethodDescriptor>{})};
37533810
}
37543811

3812+
const OverrideTableHeader *getOverrideTable() const {
3813+
if (!hasOverrideTable())
3814+
return nullptr;
3815+
return this->template getTrailingObjects<OverrideTableHeader>();
3816+
}
3817+
3818+
llvm::ArrayRef<MethodOverrideDescriptor> getMethodOverrideDescriptors() const {
3819+
if (!hasOverrideTable())
3820+
return {};
3821+
return {this->template getTrailingObjects<MethodOverrideDescriptor>(),
3822+
numTrailingObjects(OverloadToken<MethodOverrideDescriptor>{})};
3823+
}
3824+
37553825
/// Return the bounds of this class's metadata.
37563826
TargetClassMetadataBounds<Runtime> getMetadataBounds() const {
37573827
if (!hasResilientSuperclass())

0 commit comments

Comments
 (0)