Skip to content

Commit 13bb927

Browse files
committed
Merge branch 'master' into inhibit-implicit-conversions
2 parents 81e9585 + 9435633 commit 13bb927

File tree

109 files changed

+5005
-1305
lines changed

Some content is hidden

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

109 files changed

+5005
-1305
lines changed

CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ set(SWIFT_ENABLE_GOLD_LINKER FALSE CACHE BOOL
8686
"Enable using the gold linker when available")
8787

8888
set(_SWIFT_KNOWN_INSTALL_COMPONENTS
89-
"autolink-driver;compiler;clang-builtin-headers;clang-resource-dir-symlink;clang-builtin-headers-in-clang-resource-dir;stdlib;stdlib-experimental;sdk-overlay;editor-integration;tools;testsuite-tools;dev;license;sourcekit-xpc-service;sourcekit-inproc")
89+
"autolink-driver;compiler;clang-builtin-headers;clang-resource-dir-symlink;clang-builtin-headers-in-clang-resource-dir;stdlib;stdlib-experimental;sdk-overlay;editor-integration;tools;testsuite-tools;toolchain-dev-tools;dev;license;sourcekit-xpc-service;sourcekit-inproc;swift-remote-mirror-headers")
9090

9191
# Set the SWIFT_INSTALL_COMPONENTS variable to the default value if it is not passed in via -D
9292
set(SWIFT_INSTALL_COMPONENTS "${_SWIFT_KNOWN_INSTALL_COMPONENTS}" CACHE STRING
@@ -112,6 +112,7 @@ set(SWIFT_INSTALL_COMPONENTS "${_SWIFT_KNOWN_INSTALL_COMPONENTS}" CACHE STRING
112112
# * tools -- tools (other than the compiler) useful for developers writing
113113
# Swift code.
114114
# * testsuite-tools -- extra tools required to run the Swift testsuite.
115+
# * toolchain-dev-tools -- install development tools useful in a shared toolchain
115116
# * dev -- headers and libraries required to use Swift compiler as a library.
116117

117118
set(SWIFT_SDKS "" CACHE STRING
@@ -699,6 +700,13 @@ if(SWIFT_PARALLEL_LINK_JOBS)
699700
endif()
700701
endif()
701702

703+
# Set the CMAKE_OSX_* variables in a way that minimizes conflicts.
704+
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
705+
set(CMAKE_OSX_SYSROOT "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_PATH}")
706+
set(CMAKE_OSX_ARCHITECTURES "")
707+
set(CMAKE_OSX_DEPLOYMENT_TARGET "")
708+
endif()
709+
702710
message(STATUS "Building host Swift tools for ${SWIFT_HOST_VARIANT_SDK} ${SWIFT_HOST_VARIANT_ARCH}")
703711
message(STATUS " Build type: ${CMAKE_BUILD_TYPE}")
704712
message(STATUS " Assertions: ${LLVM_ENABLE_ASSERTIONS}")

docs/GenericsManifesto.md

Lines changed: 740 additions & 0 deletions
Large diffs are not rendered by default.

include/swift/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ configure_file(Config.h.in ${CMAKE_CURRENT_BINARY_DIR}/Config.h
22
ESCAPE_QUOTES @ONLY)
33

44
add_subdirectory(Option)
5+
add_subdirectory(SwiftRemoteMirror)

include/swift/Markup/AST.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,27 @@ bool isAFieldTag(StringRef Tag);
729729
void dump(const MarkupASTNode *Node, llvm::raw_ostream &OS, unsigned indent = 0);
730730
void printInlinesUnder(const MarkupASTNode *Node, llvm::raw_ostream &OS,
731731
bool PrintDecorators = false);
732+
733+
734+
template <typename ImplClass, typename RetTy = void, typename... Args>
735+
class MarkupASTVisitor {
736+
public:
737+
RetTy visit(const MarkupASTNode *Node, Args... args) {
738+
switch (Node->getKind()) {
739+
#define MARKUP_AST_NODE(Id, Parent) \
740+
case ASTNodeKind::Id: \
741+
return static_cast<ImplClass*>(this) \
742+
->visit##Id(cast<const Id>(Node), \
743+
::std::forward<Args>(args)...);
744+
#define ABSTRACT_MARKUP_AST_NODE(Id, Parent)
745+
#define MARKUP_AST_NODE_RANGE(Id, FirstId, LastId)
746+
#include "swift/Markup/ASTNodes.def"
747+
}
748+
}
749+
750+
virtual ~MarkupASTVisitor() {}
751+
};
752+
732753
} // namespace markup
733754
} // namespace swift
734755

include/swift/Option/Options.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,12 @@ def no_link_objc_runtime : Flag<["-"], "no-link-objc-runtime">,
258258
Flags<[HelpHidden, DoesNotAffectIncrementalBuild]>,
259259
HelpText<"Don't link in additions to the Objective-C runtime">;
260260

261+
def static_stdlib: Flag<["-"], "static-stdlib">,
262+
HelpText<"Statically link the Swift standard library">;
263+
def no_static_stdlib: Flag<["-"], "no-static-stdlib">,
264+
Flags<[HelpHidden]>,
265+
HelpText<"Don't statically link the Swift standard library">;
266+
261267
def use_ld : Joined<["-"], "use-ld=">,
262268
Flags<[DoesNotAffectIncrementalBuild]>,
263269
HelpText<"Specifies the linker to be used">;

include/swift/Reflection/ReflectionContext.h

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,85 @@ class ReflectionContext
119119
return getMetadataTypeInfo(MetadataAddress.second);
120120
}
121121

122+
bool
123+
projectExistential(RemoteAddress ExistentialAddress,
124+
const TypeRef *ExistentialTR,
125+
const TypeRef **OutInstanceTR,
126+
RemoteAddress *OutInstanceAddress) {
127+
if (ExistentialTR == nullptr)
128+
return false;
129+
130+
auto ExistentialTI = getTypeInfo(ExistentialTR);
131+
if (ExistentialTI == nullptr)
132+
return false;
133+
134+
auto ExistentialRecordTI = dyn_cast<const RecordTypeInfo>(ExistentialTI);
135+
if (ExistentialRecordTI == nullptr)
136+
return false;
137+
138+
switch (ExistentialRecordTI->getRecordKind()) {
139+
// Class existentials have trivial layout.
140+
// It is itself the pointer to the instance followed by the witness tables.
141+
case RecordKind::ClassExistential:
142+
*OutInstanceTR = getBuilder().getTypeConverter().getUnknownObjectTypeRef();
143+
*OutInstanceAddress = ExistentialAddress;
144+
return true;
145+
146+
// Other existentials have two cases:
147+
// If the value fits in three words, it starts at the beginning of the
148+
// container. If it doesn't, the first word is a pointer to a heap box.
149+
case RecordKind::Existential: {
150+
auto Fields = ExistentialRecordTI->getFields();
151+
auto ExistentialMetadataField = std::find_if(Fields.begin(), Fields.end(),
152+
[](const FieldInfo &FI) -> bool {
153+
return FI.Name.compare("metadata") == 0;
154+
});
155+
if (ExistentialMetadataField == Fields.end())
156+
return false;
157+
158+
// Get the metadata pointer for the contained instance type.
159+
// This is equivalent to:
160+
// auto PointerArray = reinterpret_cast<uintptr_t*>(ExistentialAddress);
161+
// uintptr_t MetadataAddress = PointerArray[Offset];
162+
auto MetadataAddressAddress
163+
= RemoteAddress(ExistentialAddress.getAddressData() +
164+
ExistentialMetadataField->Offset);
165+
166+
StoredPointer MetadataAddress = 0;
167+
if (!getReader().readInteger(MetadataAddressAddress, &MetadataAddress))
168+
return false;
169+
170+
auto InstanceTR = readTypeFromMetadata(MetadataAddress);
171+
if (!InstanceTR)
172+
return false;
173+
174+
*OutInstanceTR = InstanceTR;
175+
176+
auto InstanceTI = getTypeInfo(InstanceTR);
177+
if (!InstanceTI)
178+
return false;
179+
180+
if (InstanceTI->getSize() <= ExistentialMetadataField->Offset) {
181+
// The value fits in the existential container, so it starts at the
182+
// start of the container.
183+
*OutInstanceAddress = ExistentialAddress;
184+
} else {
185+
// Otherwise it's in a box somewhere off in the heap. The first word
186+
// of the container has the address to that box.
187+
StoredPointer BoxAddress = 0;
188+
189+
if (!getReader().readInteger(ExistentialAddress, &BoxAddress))
190+
return false;
191+
192+
*OutInstanceAddress = RemoteAddress(BoxAddress);
193+
}
194+
return true;
195+
}
196+
default:
197+
return false;
198+
}
199+
}
200+
122201
/// Return a description of the layout of a value with the given type.
123202
const TypeInfo *getTypeInfo(const TypeRef *TR) {
124203
return getBuilder().getTypeConverter().getTypeInfo(TR);

include/swift/Remote/MetadataReader.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,21 +682,28 @@ class MetadataReader {
682682
}
683683
}
684684

685+
BuiltType readTypeFromMangledName(const char *MangledTypeName,
686+
size_t Length) {
687+
auto Demangled = Demangle::demangleSymbolAsNode(MangledTypeName, Length);
688+
return decodeMangledType(Demangled);
689+
}
690+
685691
/// Read the isa pointer of a class or closure context instance and apply
686692
/// the isa mask.
687693
std::pair<bool, StoredPointer> readMetadataFromInstance(
688694
StoredPointer ObjectAddress) {
695+
StoredPointer isaMaskValue = ~0;
689696
auto isaMask = readIsaMask();
690-
if (!isaMask.first)
691-
return {false, 0};
697+
if (isaMask.first)
698+
isaMaskValue = isaMask.second;
692699

693700
StoredPointer MetadataAddress;
694701
if (!Reader->readBytes(RemoteAddress(ObjectAddress),
695702
(uint8_t*)&MetadataAddress,
696703
sizeof(StoredPointer)))
697704
return {false, 0};
698705

699-
return {true, MetadataAddress & isaMask.second};
706+
return {true, MetadataAddress & isaMaskValue};
700707
}
701708

702709
/// Given the address of a nominal type descriptor, attempt to resolve

include/swift/Runtime/Config.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
#endif
3131
#endif
3232

33+
/// Does the current Swift platform use LLVM's intrinsic "swiftcall"
34+
/// calling convention for Swift functions?
35+
#ifndef SWIFT_USE_SWIFTCALL
36+
#define SWIFT_USE_SWIFTCALL 0
37+
#endif
38+
3339
/// Does the current Swift platform allow information other than the
3440
/// class pointer to be stored in the isa field? If so, when deriving
3541
/// the class pointer of an object, we must apply a
@@ -90,6 +96,18 @@
9096
#define SWIFT_CC_preserve_all __attribute__((preserve_all))
9197
#define SWIFT_CC_c
9298

99+
#if SWIFT_USE_SWIFTCALL
100+
#define SWIFT_CC_swift __attribute__((swiftcall))
101+
#define SWIFT_CONTEXT __attribute__((swift_context))
102+
#define SWIFT_ERROR_RESULT __attribute__((swift_error_result))
103+
#define SWIFT_INDIRECT_RESULT __attribute__((swift_indirect_result))
104+
#else
105+
#define SWIFT_CC_swift
106+
#define SWIFT_CONTEXT
107+
#define SWIFT_ERROR_RESULT
108+
#define SWIFT_INDIRECT_RESULT
109+
#endif
110+
93111
// Map a logical calling convention (e.g. RegisterPreservingCC) to LLVM calling
94112
// convention.
95113
#define SWIFT_LLVM_CC(CC) SWIFT_LLVM_CC_##CC

include/swift/Runtime/HeapObject.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,9 +634,15 @@ static inline void swift_unownedTakeAssign(UnownedReference *dest,
634634

635635
/// A weak reference value object. This is ABI.
636636
struct WeakReference {
637-
HeapObject *Value;
637+
uintptr_t Value;
638638
};
639639

640+
/// Return true if this is a native weak reference
641+
///
642+
/// \param ref - never null
643+
/// \return true if ref is a native weak reference
644+
bool isNativeSwiftWeakReference(WeakReference *ref);
645+
640646
/// Initialize a weak reference.
641647
///
642648
/// \param ref - never null

include/swift/SIL/BridgedTypes.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ BRIDGING_KNOWN_TYPE(Foundation, NSSet)
4545
BRIDGING_KNOWN_TYPE(Foundation, NSError)
4646
BRIDGING_KNOWN_TYPE(Swift, String)
4747
BRIDGING_KNOWN_TYPE(ObjectiveC, ObjCBool)
48+
BRIDGING_KNOWN_TYPE(ObjectiveC, Selector)
4849
BRIDGING_KNOWN_TYPE(Darwin, DarwinBoolean)
4950
BRIDGING_KNOWN_TYPE(Swift, Bool)
5051
BRIDGING_KNOWN_TYPE(Swift, ErrorProtocol)

0 commit comments

Comments
 (0)